├── .gitignore ├── .idea ├── dictionaries │ ├── 2015_249_pc.xml │ └── Jinlin.xml ├── libraries │ ├── android_support_v4.xml │ ├── animated_vector_drawable_23_2_1.xml │ ├── appcompat_v7_23_2_1.xml │ ├── core.xml │ ├── core_3_1_1_SNAPSHOT.xml │ ├── support_annotations_23_2_1.xml │ ├── support_v4_23_2_1.xml │ ├── support_vector_drawable_23_2_1.xml │ └── zxing.xml └── runConfigurations.xml ├── BarcodeScanner-master.gif ├── QRCode.iml ├── QR_CodeScan.gif ├── README.md ├── ZXingScanQRCode.gif ├── build.gradle ├── demo.gif ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── settings.gradle ├── zxing-demo-1 ├── .classpath ├── .gitignore ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs ├── AndroidManifest.xml ├── build.gradle ├── ic_launcher-web.png ├── libs │ ├── android-support-v4.jar │ └── core-3.1.1-SNAPSHOT.jar ├── proguard-project.txt ├── project.properties ├── res │ ├── drawable-hdpi │ │ ├── ic_launcher.png │ │ ├── scan_corner_bottom_left.png │ │ ├── scan_corner_bottom_right.png │ │ ├── scan_corner_top_left.png │ │ ├── scan_corner_top_right.png │ │ ├── scan_fail.png │ │ ├── scan_flashlight_normal.png │ │ ├── scan_flashlight_pressed.png │ │ ├── scan_history_normal.png │ │ ├── scan_history_pressed.png │ │ ├── scan_laser.png │ │ ├── scan_photo_normal.png │ │ ├── scan_photo_pressed.png │ │ └── thumb_unfocus.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ ├── drawable │ │ ├── scan_flashlight.xml │ │ ├── scan_history.xml │ │ ├── scan_photo.xml │ │ ├── seekbar_bg.xml │ │ └── seekbar_style.xml │ ├── layout │ │ └── capture.xml │ ├── raw │ │ └── beep.ogg │ ├── values-v11 │ │ └── styles.xml │ ├── values-v14 │ │ └── styles.xml │ └── values │ │ ├── colors.xml │ │ ├── ids.xml │ │ ├── strings.xml │ │ └── styles.xml ├── src │ └── com │ │ ├── google │ │ └── zxing │ │ │ ├── camera │ │ │ ├── AutoFocusManager.java │ │ │ ├── CameraConfigurationManager.java │ │ │ ├── CameraManager.java │ │ │ ├── FrontLightMode.java │ │ │ ├── OpenCameraInterface.java │ │ │ └── PreviewCallback.java │ │ │ ├── common │ │ │ ├── BitmapUtils.java │ │ │ └── Runnable.java │ │ │ ├── config │ │ │ └── Config.java │ │ │ ├── decode │ │ │ ├── BitmapDecoder.java │ │ │ ├── BitmapLuminanceSource.java │ │ │ ├── CaptureActivityHandler.java │ │ │ ├── DecodeFormatManager.java │ │ │ ├── DecodeHandler.java │ │ │ ├── DecodeThread.java │ │ │ ├── FinishListener.java │ │ │ └── Intents.java │ │ │ └── view │ │ │ ├── ViewfinderResultPointCallback.java │ │ │ └── ViewfinderView.java │ │ └── jinlin │ │ └── zxing │ │ ├── AmbientLightManager.java │ │ ├── BeepManager.java │ │ ├── CaptureActivity.java │ │ ├── InactivityTimer.java │ │ └── IntentSource.java └── zxing-demo-1.iml ├── zxing-demo-2 ├── .gitignore ├── AndroidManifest.xml ├── build.gradle ├── libs │ └── core-3.1.1-SNAPSHOT.jar ├── res │ ├── drawable-hdpi │ │ ├── ic_launcher.png │ │ ├── scan_flashlight_normal.png │ │ ├── scan_flashlight_pressed.png │ │ ├── scan_photo_normal.png │ │ └── scan_photo_pressed.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ ├── ic_launcher.png │ │ ├── qr_code_bg.9.png │ │ ├── scan_flashlight_normal.png │ │ ├── scan_flashlight_pressed.png │ │ ├── scan_line.png │ │ ├── scan_mask.png │ │ ├── scan_photo_normal.png │ │ └── scan_photo_pressed.png │ ├── drawable │ │ ├── scan_flashlight.xml │ │ └── scan_photo.xml │ ├── layout │ │ ├── activity_capture.xml │ │ ├── activity_main.xml │ │ └── activity_result.xml │ ├── raw │ │ └── beep.ogg │ ├── values-v11 │ │ └── styles.xml │ ├── values-v14 │ │ └── styles.xml │ └── values │ │ ├── ids.xml │ │ ├── strings.xml │ │ └── styles.xml └── src │ └── com │ ├── google │ └── zxing │ │ ├── activity │ │ └── CaptureActivity.java │ │ ├── camera │ │ ├── AutoFocusManager.java │ │ ├── CameraConfigurationManager.java │ │ ├── CameraManager.java │ │ └── PreviewCallback.java │ │ ├── decode │ │ ├── BitmapDecoder.java │ │ ├── BitmapLuminanceSource.java │ │ ├── DecodeFormatManager.java │ │ ├── DecodeHandler.java │ │ └── DecodeThread.java │ │ ├── open │ │ └── OpenCameraInterface.java │ │ └── utils │ │ ├── BeepManager.java │ │ ├── BitmapUtils.java │ │ ├── CaptureActivityHandler.java │ │ └── InactivityTimer.java │ └── jinlin │ └── zxing │ ├── MainActivity.java │ └── ResultActivity.java ├── zxing-demo-3 ├── .gitignore ├── build.gradle ├── libs │ └── zxing.jar ├── proguard-rules.pro ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ ├── google │ │ │ └── zxing │ │ │ │ ├── activity │ │ │ │ └── CaptureActivity.java │ │ │ │ ├── camera │ │ │ │ ├── AutoFocusCallback.java │ │ │ │ ├── CameraConfigurationManager.java │ │ │ │ ├── CameraManager.java │ │ │ │ ├── FlashlightManager.java │ │ │ │ ├── PlanarYUVLuminanceSource.java │ │ │ │ └── PreviewCallback.java │ │ │ │ ├── decoding │ │ │ │ ├── CaptureActivityHandler.java │ │ │ │ ├── DecodeFormatManager.java │ │ │ │ ├── DecodeHandler.java │ │ │ │ ├── DecodeThread.java │ │ │ │ ├── FinishListener.java │ │ │ │ ├── InactivityTimer.java │ │ │ │ └── Intents.java │ │ │ │ ├── encoding │ │ │ │ └── EncodingHandler.java │ │ │ │ └── view │ │ │ │ ├── ViewfinderResultPointCallback.java │ │ │ │ └── ViewfinderView.java │ │ │ └── jinlin │ │ │ └── zxing │ │ │ ├── MainActivity.java │ │ │ └── utils │ │ │ └── DensityUtils.java │ │ └── res │ │ ├── layout │ │ ├── activity_main.xml │ │ └── camera.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ ├── btn_header_barcode.png │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── raw │ │ └── beep.ogg │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── ids.xml │ │ ├── strings.xml │ │ └── styles.xml └── zxing-demo-3.iml └── zxing-demo-4 ├── .classpath ├── .gitignore ├── .project ├── .settings ├── org.eclipse.core.resources.prefs └── org.eclipse.jdt.core.prefs ├── AndroidManifest.xml ├── build.gradle ├── ic_launcher-web.png ├── libs ├── android-support-v4.jar └── core.jar ├── proguard-project.txt ├── project.properties ├── res ├── drawable-hdpi │ ├── ic_launcher.png │ └── qrcode_scan_line.png ├── drawable-mdpi │ └── ic_launcher.png ├── drawable-xhdpi │ └── ic_launcher.png ├── layout │ ├── activity_capture.xml │ └── activity_main.xml ├── menu │ └── activity_main.xml ├── raw │ └── beep.ogg ├── values-v11 │ └── styles.xml ├── values-v14 │ └── styles.xml └── values │ ├── color.xml │ ├── ids.xml │ ├── strings.xml │ └── styles.xml └── src └── com ├── google └── zxing │ └── zxing │ ├── activity │ └── MipcaActivityCapture.java │ ├── camera │ ├── AutoFocusCallback.java │ ├── CameraConfigurationManager.java │ ├── CameraManager.java │ ├── FlashlightManager.java │ ├── PlanarYUVLuminanceSource.java │ └── PreviewCallback.java │ ├── decoding │ ├── CaptureActivityHandler.java │ ├── DecodeFormatManager.java │ ├── DecodeHandler.java │ ├── DecodeThread.java │ ├── FinishListener.java │ ├── InactivityTimer.java │ └── Intents.java │ ├── image │ └── RGBLuminanceSource.java │ └── view │ ├── ViewfinderResultPointCallback.java │ └── ViewfinderView.java └── jinlin └── zxing └── MainActivity.java /.gitignore: -------------------------------------------------------------------------------- 1 | /gradlew 2 | /gradlew.bat 3 | /.idea 4 | ### Android template 5 | # Built application files 6 | *.apk 7 | *.ap_ 8 | 9 | # Files for the Dalvik VM 10 | *.dex 11 | 12 | # Java class files 13 | *.class 14 | 15 | # Generated files 16 | bin/ 17 | gen/ 18 | 19 | # Gradle files 20 | .gradle/ 21 | build/ 22 | 23 | # Local configuration file (sdk path, etc) 24 | local.properties 25 | 26 | # Proguard folder generated by Eclipse 27 | proguard/ 28 | 29 | # Log Files 30 | *.log 31 | 32 | # Android Studio Navigation editor temp files 33 | .navigation/ 34 | 35 | # Created by .ignore support plugin (hsz.mobi) 36 | -------------------------------------------------------------------------------- /.idea/dictionaries/2015_249_pc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/dictionaries/Jinlin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/libraries/android_support_v4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/libraries/animated_vector_drawable_23_2_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/appcompat_v7_23_2_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/libraries/core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/libraries/core_3_1_1_SNAPSHOT.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/libraries/support_annotations_23_2_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/support_v4_23_2_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/libraries/support_vector_drawable_23_2_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/libraries/zxing.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /BarcodeScanner-master.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/BarcodeScanner-master.gif -------------------------------------------------------------------------------- /QR_CodeScan.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/QR_CodeScan.gif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ============ 2 | 3 | 精简ZXing项目后只保留扫描功能的代码,去除了ViewfinderView,使用XML布局 4 | ============ 5 | ![Examples list](https://github.com/5peak2me/QRCode/blob/master/demo.gif) 6 | ============ 7 | ![Examples list](https://github.com/5peak2me/QRCode/blob/master/BarcodeScanner-master.gif) 8 | ============ 9 | ![Examples list](https://github.com/5peak2me/QRCode/blob/master/QR_CodeScan.gif) 10 | ============ 11 | ![Examples list](https://github.com/5peak2me/QRCode/blob/master/ZXingScanQRCode.gif) 12 | -------------------------------------------------------------------------------- /ZXingScanQRCode.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/ZXingScanQRCode.gif -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | repositories { 4 | jcenter() 5 | } 6 | dependencies { 7 | classpath 'com.android.tools.build:gradle:2.1.2' 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/demo.gif -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Apr 26 16:55:04 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 7 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':zxing-demo-1' 2 | include ':zxing-demo-2' 3 | include ':zxing-demo-3' 4 | include ':zxing-demo-4' 5 | -------------------------------------------------------------------------------- /zxing-demo-1/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /zxing-demo-1/.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | 19 | # Local configuration file (sdk path, etc) 20 | local.properties 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | -------------------------------------------------------------------------------- /zxing-demo-1/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | BarcodeScanner 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /zxing-demo-1/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | -------------------------------------------------------------------------------- /zxing-demo-1/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 20 | 21 | 26 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /zxing-demo-1/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | dependencies { 4 | compile fileTree(dir: 'libs', include: '*.jar') 5 | } 6 | 7 | android { 8 | compileSdkVersion 23 9 | buildToolsVersion "23.0.2" 10 | 11 | sourceSets { 12 | main { 13 | manifest.srcFile 'AndroidManifest.xml' 14 | java.srcDirs = ['src'] 15 | resources.srcDirs = ['src'] 16 | aidl.srcDirs = ['src'] 17 | renderscript.srcDirs = ['src'] 18 | res.srcDirs = ['res'] 19 | assets.srcDirs = ['assets'] 20 | } 21 | 22 | // Move the tests to tests/java, tests/res, etc... 23 | instrumentTest.setRoot('tests') 24 | 25 | // Move the build types to build-types/ 26 | // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... 27 | // This moves them out of them default location under src//... which would 28 | // conflict with src/ being used by the main source set. 29 | // Adding new build types or product flavors should be accompanied 30 | // by a similar customization. 31 | debug.setRoot('build-types/debug') 32 | release.setRoot('build-types/release') 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /zxing-demo-1/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-1/ic_launcher-web.png -------------------------------------------------------------------------------- /zxing-demo-1/libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-1/libs/android-support-v4.jar -------------------------------------------------------------------------------- /zxing-demo-1/libs/core-3.1.1-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-1/libs/core-3.1.1-SNAPSHOT.jar -------------------------------------------------------------------------------- /zxing-demo-1/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /zxing-demo-1/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-19 15 | -------------------------------------------------------------------------------- /zxing-demo-1/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-1/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /zxing-demo-1/res/drawable-hdpi/scan_corner_bottom_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-1/res/drawable-hdpi/scan_corner_bottom_left.png -------------------------------------------------------------------------------- /zxing-demo-1/res/drawable-hdpi/scan_corner_bottom_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-1/res/drawable-hdpi/scan_corner_bottom_right.png -------------------------------------------------------------------------------- /zxing-demo-1/res/drawable-hdpi/scan_corner_top_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-1/res/drawable-hdpi/scan_corner_top_left.png -------------------------------------------------------------------------------- /zxing-demo-1/res/drawable-hdpi/scan_corner_top_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-1/res/drawable-hdpi/scan_corner_top_right.png -------------------------------------------------------------------------------- /zxing-demo-1/res/drawable-hdpi/scan_fail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-1/res/drawable-hdpi/scan_fail.png -------------------------------------------------------------------------------- /zxing-demo-1/res/drawable-hdpi/scan_flashlight_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-1/res/drawable-hdpi/scan_flashlight_normal.png -------------------------------------------------------------------------------- /zxing-demo-1/res/drawable-hdpi/scan_flashlight_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-1/res/drawable-hdpi/scan_flashlight_pressed.png -------------------------------------------------------------------------------- /zxing-demo-1/res/drawable-hdpi/scan_history_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-1/res/drawable-hdpi/scan_history_normal.png -------------------------------------------------------------------------------- /zxing-demo-1/res/drawable-hdpi/scan_history_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-1/res/drawable-hdpi/scan_history_pressed.png -------------------------------------------------------------------------------- /zxing-demo-1/res/drawable-hdpi/scan_laser.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-1/res/drawable-hdpi/scan_laser.png -------------------------------------------------------------------------------- /zxing-demo-1/res/drawable-hdpi/scan_photo_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-1/res/drawable-hdpi/scan_photo_normal.png -------------------------------------------------------------------------------- /zxing-demo-1/res/drawable-hdpi/scan_photo_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-1/res/drawable-hdpi/scan_photo_pressed.png -------------------------------------------------------------------------------- /zxing-demo-1/res/drawable-hdpi/thumb_unfocus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-1/res/drawable-hdpi/thumb_unfocus.png -------------------------------------------------------------------------------- /zxing-demo-1/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-1/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /zxing-demo-1/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-1/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /zxing-demo-1/res/drawable/scan_flashlight.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /zxing-demo-1/res/drawable/scan_history.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /zxing-demo-1/res/drawable/scan_photo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /zxing-demo-1/res/drawable/seekbar_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /zxing-demo-1/res/drawable/seekbar_style.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /zxing-demo-1/res/layout/capture.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 19 | 20 | 26 | 27 | 33 | 34 | 42 | 43 | 44 | 55 | 56 | 62 | 63 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /zxing-demo-1/res/raw/beep.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-1/res/raw/beep.ogg -------------------------------------------------------------------------------- /zxing-demo-1/res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /zxing-demo-1/res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /zxing-demo-1/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #ff000000 5 | #ffffffff 6 | #c0ffbd21 7 | #ffc0c0c0 8 | #c099cc00 9 | #ffffffff 10 | #b0000000 11 | #ffffffff 12 | #00000000 13 | #ffcc0000 14 | #00000000 15 | #00000000 16 | #fff6f6f6 17 | 18 | -------------------------------------------------------------------------------- /zxing-demo-1/res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /zxing-demo-1/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 二维条形码扫描 4 | placeHolder 5 | + 6 | - 7 | 生成 8 | 扫描失败 9 | 建议与镜头保持10CM距离,尽量避免逆光和阴影 10 | 将条形码或二维码置于取景框内系统会自动扫描 11 | 取消 12 | 抱歉,Android相机出现问题。您可能需要重启设备。 13 | 确定 14 | 15 | -------------------------------------------------------------------------------- /zxing-demo-1/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /zxing-demo-1/src/com/google/zxing/camera/AutoFocusManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.camera; 18 | 19 | import java.util.ArrayList; 20 | import java.util.Collection; 21 | 22 | import android.content.Context; 23 | import android.content.SharedPreferences; 24 | import android.hardware.Camera; 25 | import android.os.AsyncTask; 26 | import android.preference.PreferenceManager; 27 | import android.util.Log; 28 | import com.google.zxing.common.Runnable; 29 | import com.google.zxing.config.Config; 30 | 31 | /** 32 | * 由于对焦不是一次性完成的任务(手抖),而系统提供的对焦仅有Camera.autoFocus()方法, 33 | * 因此需要一个线程来不断调用Camera.autoFocus()直到用户满意按下快门为止 34 | */ 35 | final class AutoFocusManager implements Camera.AutoFocusCallback { 36 | 37 | private static final String TAG = AutoFocusManager.class.getSimpleName(); 38 | 39 | private static final long AUTO_FOCUS_INTERVAL_MS = 2000L; 40 | private static final Collection FOCUS_MODES_CALLING_AF; 41 | static { 42 | FOCUS_MODES_CALLING_AF = new ArrayList(2); 43 | FOCUS_MODES_CALLING_AF.add(Camera.Parameters.FOCUS_MODE_AUTO); 44 | FOCUS_MODES_CALLING_AF.add(Camera.Parameters.FOCUS_MODE_MACRO); 45 | } 46 | 47 | private boolean active; 48 | private final boolean useAutoFocus; 49 | private final Camera camera; 50 | private AsyncTask outstandingTask; 51 | 52 | AutoFocusManager(Context context, Camera camera) { 53 | this.camera = camera; 54 | SharedPreferences sharedPrefs = PreferenceManager 55 | .getDefaultSharedPreferences(context); 56 | String currentFocusMode = camera.getParameters().getFocusMode(); 57 | useAutoFocus = sharedPrefs.getBoolean(Config.KEY_AUTO_FOCUS, true) 58 | && FOCUS_MODES_CALLING_AF.contains(currentFocusMode); 59 | Log.i(TAG, "Current focus mode '" + currentFocusMode 60 | + "'; use auto focus? " + useAutoFocus); 61 | start(); 62 | } 63 | 64 | @Override 65 | public synchronized void onAutoFocus(boolean success, Camera theCamera) { 66 | if (active) { 67 | outstandingTask = new AutoFocusTask(); 68 | Runnable.execAsync(outstandingTask); 69 | } 70 | } 71 | 72 | synchronized void start() { 73 | if (useAutoFocus) { 74 | active = true; 75 | try { 76 | camera.autoFocus(this); 77 | } 78 | catch (RuntimeException re) { 79 | // Have heard RuntimeException reported in Android 4.0.x+; 80 | // continue? 81 | Log.w(TAG, "Unexpected exception while focusing", re); 82 | } 83 | } 84 | } 85 | 86 | synchronized void stop() { 87 | if (useAutoFocus) { 88 | try { 89 | camera.cancelAutoFocus(); 90 | } 91 | catch (RuntimeException re) { 92 | // Have heard RuntimeException reported in Android 4.0.x+; 93 | // continue? 94 | Log.w(TAG, "Unexpected exception while cancelling focusing", re); 95 | } 96 | } 97 | if (outstandingTask != null) { 98 | outstandingTask.cancel(true); 99 | outstandingTask = null; 100 | } 101 | active = false; 102 | } 103 | 104 | private final class AutoFocusTask extends AsyncTask { 105 | @Override 106 | protected Object doInBackground(Object... voids) { 107 | try { 108 | Thread.sleep(AUTO_FOCUS_INTERVAL_MS); 109 | } 110 | catch (InterruptedException e) { 111 | // continue 112 | } 113 | synchronized (AutoFocusManager.this) { 114 | if (active) { 115 | start(); 116 | } 117 | } 118 | return null; 119 | } 120 | } 121 | 122 | } 123 | -------------------------------------------------------------------------------- /zxing-demo-1/src/com/google/zxing/camera/FrontLightMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.camera; 18 | 19 | import android.content.SharedPreferences; 20 | import com.google.zxing.config.Config; 21 | 22 | /** 23 | * Enumerates settings of the prefernce controlling the front light. 24 | */ 25 | public enum FrontLightMode { 26 | 27 | /** Always on. */ 28 | ON, 29 | /** On only when ambient light is low. */ 30 | AUTO, 31 | /** Always off. */ 32 | OFF; 33 | 34 | private static FrontLightMode parse(String modeString) { 35 | return modeString == null ? OFF : valueOf(modeString); 36 | } 37 | 38 | public static FrontLightMode readPref(SharedPreferences sharedPrefs) { 39 | return parse(sharedPrefs.getString( 40 | Config.KEY_FRONT_LIGHT_MODE, null)); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /zxing-demo-1/src/com/google/zxing/camera/OpenCameraInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.camera; 18 | 19 | import android.hardware.Camera; 20 | import android.util.Log; 21 | 22 | /** 23 | * 该类用于检测手机上摄像头的个数,如果有两个摄像头,则取背面的摄像头 24 | */ 25 | public final class OpenCameraInterface { 26 | 27 | private static final String TAG = OpenCameraInterface.class.getName(); 28 | 29 | private OpenCameraInterface() { 30 | } 31 | 32 | /** 33 | * Opens a rear-facing camera with {@link Camera#open(int)}, if one exists, 34 | * or opens camera 0. 35 | */ 36 | public static Camera open() { 37 | 38 | int numCameras = Camera.getNumberOfCameras(); 39 | if (numCameras == 0) { 40 | Log.w(TAG, "No cameras!"); 41 | return null; 42 | } 43 | 44 | int index = 0; 45 | while (index < numCameras) { 46 | Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); 47 | Camera.getCameraInfo(index, cameraInfo); 48 | // CAMERA_FACING_BACK:手机背面的摄像头 49 | if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) { 50 | break; 51 | } 52 | index++; 53 | } 54 | 55 | Camera camera; 56 | if (index < numCameras) { 57 | Log.i(TAG, "Opening camera #" + index); 58 | camera = Camera.open(index); 59 | } else { 60 | Log.i(TAG, "No camera facing back; returning camera #0"); 61 | camera = Camera.open(0); 62 | } 63 | 64 | return camera; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /zxing-demo-1/src/com/google/zxing/camera/PreviewCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.camera; 18 | 19 | import android.graphics.Point; 20 | import android.hardware.Camera; 21 | import android.os.Handler; 22 | import android.os.Message; 23 | import android.util.Log; 24 | 25 | /** 26 | * 该类的作用是在预览界面加载好后向ui线程发消息 27 | */ 28 | final class PreviewCallback implements Camera.PreviewCallback { 29 | 30 | private static final String TAG = PreviewCallback.class.getSimpleName(); 31 | 32 | private final CameraConfigurationManager configManager; 33 | private Handler previewHandler; 34 | private int previewMessage; 35 | 36 | PreviewCallback(CameraConfigurationManager configManager) { 37 | this.configManager = configManager; 38 | } 39 | 40 | /** 41 | * 绑定handler,用于发消息到ui线程 42 | * 43 | * @param previewHandler 44 | * @param previewMessage 45 | */ 46 | void setHandler(Handler previewHandler, int previewMessage) { 47 | this.previewHandler = previewHandler; 48 | this.previewMessage = previewMessage; 49 | } 50 | 51 | @Override 52 | public void onPreviewFrame(byte[] data, Camera camera) { 53 | Point cameraResolution = configManager.getCameraResolution(); 54 | Handler thePreviewHandler = previewHandler; 55 | if (cameraResolution != null && thePreviewHandler != null) { 56 | Message message = thePreviewHandler.obtainMessage(previewMessage, cameraResolution.x, cameraResolution.y, 57 | data); 58 | message.sendToTarget(); 59 | previewHandler = null; 60 | } else { 61 | Log.d(TAG, "Got preview callback, but no handler or resolution available"); 62 | } 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /zxing-demo-1/src/com/google/zxing/common/BitmapUtils.java: -------------------------------------------------------------------------------- 1 | package com.google.zxing.common; 2 | 3 | import android.content.res.Resources; 4 | import android.graphics.Bitmap; 5 | import android.graphics.BitmapFactory; 6 | 7 | public class BitmapUtils { 8 | 9 | public static Bitmap decodeSampledBitmapFromResource(Resources res, 10 | int resId, int reqWidth, int reqHeight) { 11 | 12 | // First decode with inJustDecodeBounds=true to check dimensions 13 | final BitmapFactory.Options options = new BitmapFactory.Options(); 14 | options.inJustDecodeBounds = true; 15 | BitmapFactory.decodeResource(res, resId, options); 16 | 17 | // Calculate inSampleSize 18 | options.inSampleSize = calculateInSampleSize(options, reqWidth, 19 | reqHeight); 20 | 21 | // Decode bitmap with inSampleSize set 22 | options.inJustDecodeBounds = false; 23 | return BitmapFactory.decodeResource(res, resId, options); 24 | } 25 | 26 | public static int calculateInSampleSize(BitmapFactory.Options options, 27 | int reqWidth, int reqHeight) { 28 | // Raw height and width of image 29 | final int height = options.outHeight; 30 | final int width = options.outWidth; 31 | int inSampleSize = 1; 32 | 33 | if (height > reqHeight || width > reqWidth) { 34 | 35 | // Calculate ratios of height and width to requested height and 36 | // width 37 | final int heightRatio = Math.round((float) height 38 | / (float) reqHeight); 39 | final int widthRatio = Math.round((float) width / (float) reqWidth); 40 | 41 | // Choose the smallest ratio as inSampleSize value, this will 42 | // guarantee 43 | // a final image with both dimensions larger than or equal to the 44 | // requested height and width. 45 | inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio; 46 | } 47 | 48 | return inSampleSize; 49 | } 50 | 51 | public static Bitmap getCompressedBitmap(String path) { 52 | BitmapFactory.Options options = new BitmapFactory.Options(); 53 | options.inJustDecodeBounds = true; 54 | BitmapFactory.decodeFile(path, options); 55 | options.inSampleSize = calculateInSampleSize(options, 480, 800); 56 | options.inJustDecodeBounds = false; 57 | return BitmapFactory.decodeFile(path, options); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /zxing-demo-1/src/com/google/zxing/common/Runnable.java: -------------------------------------------------------------------------------- 1 | package com.google.zxing.common; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.os.AsyncTask; 5 | import android.os.Build; 6 | 7 | /** 8 | * 兼容低版本的子线程开启任务 9 | * 10 | * @author hugo 11 | * 12 | */ 13 | public class Runnable { 14 | 15 | @SuppressLint("NewApi") 16 | @SuppressWarnings("unchecked") 17 | public static void execAsync(AsyncTask task) { 18 | if (Build.VERSION.SDK_INT >= 11) { 19 | task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); 20 | } 21 | else { 22 | task.execute(); 23 | } 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /zxing-demo-1/src/com/google/zxing/config/Config.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.config; 18 | 19 | /** 20 | * The main settings activity. 21 | * 22 | * @author dswitkin@google.com (Daniel Switkin) 23 | * @author Sean Owen 24 | */ 25 | public final class Config { 26 | public static final String KEY_DECODE_1D = "preferences_decode_1D"; 27 | public static final String KEY_DECODE_1D_PRODUCT = "preferences_decode_1D_product"; 28 | public static final String KEY_DECODE_1D_INDUSTRIAL = "preferences_decode_1D_industrial"; 29 | public static final String KEY_DECODE_QR = "preferences_decode_QR"; 30 | public static final String KEY_DECODE_DATA_MATRIX = "preferences_decode_Data_Matrix"; 31 | public static final String KEY_DECODE_AZTEC = "preferences_decode_Aztec"; 32 | public static final String KEY_DECODE_PDF417 = "preferences_decode_PDF417"; 33 | 34 | public static final String KEY_CUSTOM_PRODUCT_SEARCH = "preferences_custom_product_search"; 35 | 36 | public static final String KEY_PLAY_BEEP = "preferences_play_beep"; 37 | public static final String KEY_VIBRATE = "preferences_vibrate"; 38 | public static final String KEY_COPY_TO_CLIPBOARD = "preferences_copy_to_clipboard"; 39 | public static final String KEY_FRONT_LIGHT_MODE = "preferences_front_light_mode"; 40 | public static final String KEY_BULK_MODE = "preferences_bulk_mode"; 41 | public static final String KEY_REMEMBER_DUPLICATES = "preferences_remember_duplicates"; 42 | public static final String KEY_SUPPLEMENTAL = "preferences_supplemental"; 43 | public static final String KEY_AUTO_FOCUS = "preferences_auto_focus"; 44 | public static final String KEY_INVERT_SCAN = "preferences_invert_scan"; 45 | public static final String KEY_SEARCH_COUNTRY = "preferences_search_country"; 46 | public static final String KEY_DISABLE_AUTO_ORIENTATION = "preferences_orientation"; 47 | 48 | public static final String KEY_DISABLE_CONTINUOUS_FOCUS = "preferences_disable_continuous_focus"; 49 | public static final String KEY_DISABLE_EXPOSURE = "preferences_disable_exposure"; 50 | public static final String KEY_DISABLE_METERING = "preferences_disable_metering"; 51 | public static final String KEY_DISABLE_BARCODE_SCENE_MODE = "preferences_disable_barcode_scene_mode"; 52 | public static final String KEY_AUTO_OPEN_WEB = "preferences_auto_open_web"; 53 | 54 | } 55 | -------------------------------------------------------------------------------- /zxing-demo-1/src/com/google/zxing/decode/BitmapDecoder.java: -------------------------------------------------------------------------------- 1 | package com.google.zxing.decode; 2 | 3 | import java.util.Hashtable; 4 | import java.util.Vector; 5 | 6 | import android.content.Context; 7 | import android.graphics.Bitmap; 8 | 9 | import com.google.zxing.BarcodeFormat; 10 | import com.google.zxing.BinaryBitmap; 11 | import com.google.zxing.DecodeHintType; 12 | import com.google.zxing.MultiFormatReader; 13 | import com.google.zxing.NotFoundException; 14 | import com.google.zxing.Result; 15 | import com.google.zxing.common.HybridBinarizer; 16 | 17 | /** 18 | * 从bitmap解码 19 | * 20 | * @author hugo 21 | * 22 | */ 23 | public class BitmapDecoder { 24 | 25 | MultiFormatReader multiFormatReader; 26 | 27 | public BitmapDecoder(Context context) { 28 | 29 | multiFormatReader = new MultiFormatReader(); 30 | 31 | // 解码的参数 32 | Hashtable hints = new Hashtable( 33 | 2); 34 | // 可以解析的编码类型 35 | Vector decodeFormats = new Vector(); 36 | if (decodeFormats == null || decodeFormats.isEmpty()) { 37 | decodeFormats = new Vector(); 38 | 39 | // 这里设置可扫描的类型,我这里选择了都支持 40 | decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS); 41 | decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS); 42 | decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS); 43 | } 44 | hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats); 45 | 46 | // 设置继续的字符编码格式为UTF8 47 | hints.put(DecodeHintType.CHARACTER_SET, "UTF8"); 48 | 49 | // 设置解析配置参数 50 | multiFormatReader.setHints(hints); 51 | 52 | } 53 | 54 | /** 55 | * 获取解码结果 56 | * 57 | * @param bitmap 58 | * @return 59 | */ 60 | public Result getRawResult(Bitmap bitmap) { 61 | if (bitmap == null) { 62 | return null; 63 | } 64 | 65 | try { 66 | return multiFormatReader.decodeWithState(new BinaryBitmap( 67 | new HybridBinarizer(new BitmapLuminanceSource(bitmap)))); 68 | } 69 | catch (NotFoundException e) { 70 | e.printStackTrace(); 71 | } 72 | 73 | return null; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /zxing-demo-1/src/com/google/zxing/decode/BitmapLuminanceSource.java: -------------------------------------------------------------------------------- 1 | package com.google.zxing.decode; 2 | 3 | import android.graphics.Bitmap; 4 | 5 | import com.google.zxing.LuminanceSource; 6 | 7 | public class BitmapLuminanceSource extends LuminanceSource { 8 | 9 | private byte bitmapPixels[]; 10 | 11 | protected BitmapLuminanceSource(Bitmap bitmap) { 12 | super(bitmap.getWidth(), bitmap.getHeight()); 13 | 14 | // 首先,要取得该图片的像素数组内容 15 | int[] data = new int[bitmap.getWidth() * bitmap.getHeight()]; 16 | this.bitmapPixels = new byte[bitmap.getWidth() * bitmap.getHeight()]; 17 | bitmap.getPixels(data, 0, getWidth(), 0, 0, getWidth(), getHeight()); 18 | 19 | // 将int数组转换为byte数组,也就是取像素值中蓝色值部分作为辨析内容 20 | for (int i = 0; i < data.length; i++) { 21 | this.bitmapPixels[i] = (byte) data[i]; 22 | } 23 | } 24 | 25 | @Override 26 | public byte[] getMatrix() { 27 | // 返回我们生成好的像素数据 28 | return bitmapPixels; 29 | } 30 | 31 | @Override 32 | public byte[] getRow(int y, byte[] row) { 33 | // 这里要得到指定行的像素数据 34 | System.arraycopy(bitmapPixels, y * getWidth(), row, 0, getWidth()); 35 | return row; 36 | } 37 | } -------------------------------------------------------------------------------- /zxing-demo-1/src/com/google/zxing/decode/DecodeFormatManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.decode; 18 | 19 | import java.util.Arrays; 20 | import java.util.Collection; 21 | import java.util.EnumSet; 22 | import java.util.List; 23 | import java.util.regex.Pattern; 24 | 25 | import android.content.Intent; 26 | import android.net.Uri; 27 | 28 | import com.google.zxing.BarcodeFormat; 29 | 30 | final class DecodeFormatManager { 31 | 32 | private static final Pattern COMMA_PATTERN = Pattern.compile(","); 33 | 34 | static final Collection PRODUCT_FORMATS; 35 | static final Collection ONE_D_FORMATS; 36 | static final Collection QR_CODE_FORMATS = EnumSet 37 | .of(BarcodeFormat.QR_CODE); 38 | static final Collection DATA_MATRIX_FORMATS = EnumSet 39 | .of(BarcodeFormat.DATA_MATRIX); 40 | static { 41 | PRODUCT_FORMATS = EnumSet.of(BarcodeFormat.UPC_A, BarcodeFormat.UPC_E, 42 | BarcodeFormat.EAN_13, BarcodeFormat.EAN_8, 43 | BarcodeFormat.RSS_14, BarcodeFormat.RSS_EXPANDED); 44 | ONE_D_FORMATS = EnumSet.of(BarcodeFormat.CODE_39, 45 | BarcodeFormat.CODE_93, BarcodeFormat.CODE_128, 46 | BarcodeFormat.ITF, BarcodeFormat.CODABAR); 47 | ONE_D_FORMATS.addAll(PRODUCT_FORMATS); 48 | } 49 | 50 | private DecodeFormatManager() { 51 | } 52 | 53 | static Collection parseDecodeFormats(Intent intent) { 54 | Iterable scanFormats = null; 55 | CharSequence scanFormatsString = intent 56 | .getStringExtra(Intents.Scan.FORMATS); 57 | if (scanFormatsString != null) { 58 | scanFormats = Arrays.asList(COMMA_PATTERN.split(scanFormatsString)); 59 | } 60 | return parseDecodeFormats(scanFormats, 61 | intent.getStringExtra(Intents.Scan.MODE)); 62 | } 63 | 64 | static Collection parseDecodeFormats(Uri inputUri) { 65 | List formats = inputUri 66 | .getQueryParameters(Intents.Scan.FORMATS); 67 | if (formats != null && formats.size() == 1 && formats.get(0) != null) { 68 | formats = Arrays.asList(COMMA_PATTERN.split(formats.get(0))); 69 | } 70 | return parseDecodeFormats(formats, 71 | inputUri.getQueryParameter(Intents.Scan.MODE)); 72 | } 73 | 74 | private static Collection parseDecodeFormats( 75 | Iterable scanFormats, String decodeMode) { 76 | if (scanFormats != null) { 77 | Collection formats = EnumSet 78 | .noneOf(BarcodeFormat.class); 79 | try { 80 | for (String format : scanFormats) { 81 | formats.add(BarcodeFormat.valueOf(format)); 82 | } 83 | return formats; 84 | } 85 | catch (IllegalArgumentException iae) { 86 | // ignore it then 87 | } 88 | } 89 | if (decodeMode != null) { 90 | if (Intents.Scan.PRODUCT_MODE.equals(decodeMode)) { 91 | return PRODUCT_FORMATS; 92 | } 93 | if (Intents.Scan.QR_CODE_MODE.equals(decodeMode)) { 94 | return QR_CODE_FORMATS; 95 | } 96 | if (Intents.Scan.DATA_MATRIX_MODE.equals(decodeMode)) { 97 | return DATA_MATRIX_FORMATS; 98 | } 99 | if (Intents.Scan.ONE_D_MODE.equals(decodeMode)) { 100 | return ONE_D_FORMATS; 101 | } 102 | } 103 | return null; 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /zxing-demo-1/src/com/google/zxing/decode/DecodeThread.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.decode; 18 | 19 | import android.content.SharedPreferences; 20 | import android.os.Handler; 21 | import android.os.Looper; 22 | import android.preference.PreferenceManager; 23 | import android.util.Log; 24 | 25 | import com.google.zxing.BarcodeFormat; 26 | import com.google.zxing.DecodeHintType; 27 | import com.google.zxing.ResultPointCallback; 28 | import com.google.zxing.config.Config; 29 | import com.jinlin.zxing.CaptureActivity; 30 | 31 | import java.util.Collection; 32 | import java.util.EnumMap; 33 | import java.util.EnumSet; 34 | import java.util.Map; 35 | import java.util.concurrent.CountDownLatch; 36 | 37 | /** 38 | * This thread does all the heavy lifting of decoding the images. 39 | * 40 | * @author dswitkin@google.com (Daniel Switkin) 41 | */ 42 | final class DecodeThread extends Thread { 43 | 44 | public static final String BARCODE_BITMAP = "barcode_bitmap"; 45 | 46 | public static final String BARCODE_SCALED_FACTOR = "barcode_scaled_factor"; 47 | 48 | private final CaptureActivity activity; 49 | 50 | private final Map hints; 51 | 52 | private Handler handler; 53 | 54 | private final CountDownLatch handlerInitLatch; 55 | 56 | DecodeThread(CaptureActivity activity, 57 | Collection decodeFormats, 58 | Map baseHints, String characterSet, 59 | ResultPointCallback resultPointCallback) { 60 | 61 | this.activity = activity; 62 | handlerInitLatch = new CountDownLatch(1); 63 | 64 | hints = new EnumMap(DecodeHintType.class); 65 | if (baseHints != null) { 66 | hints.putAll(baseHints); 67 | } 68 | 69 | // The prefs can't change while the thread is running, so pick them up 70 | // once here. 71 | if (decodeFormats == null || decodeFormats.isEmpty()) { 72 | SharedPreferences prefs = PreferenceManager 73 | .getDefaultSharedPreferences(activity); 74 | decodeFormats = EnumSet.noneOf(BarcodeFormat.class); 75 | if (prefs.getBoolean(Config.KEY_DECODE_1D, false)) { 76 | decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS); 77 | } 78 | if (prefs.getBoolean(Config.KEY_DECODE_QR, false)) { 79 | decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS); 80 | } 81 | if (prefs.getBoolean(Config.KEY_DECODE_DATA_MATRIX, 82 | false)) { 83 | decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS); 84 | } 85 | } 86 | hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats); 87 | 88 | if (characterSet != null) { 89 | hints.put(DecodeHintType.CHARACTER_SET, characterSet); 90 | } 91 | hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, 92 | resultPointCallback); 93 | Log.i("DecodeThread", "Hints: " + hints); 94 | } 95 | 96 | Handler getHandler() { 97 | try { 98 | handlerInitLatch.await(); 99 | } 100 | catch (InterruptedException ie) { 101 | // continue? 102 | } 103 | return handler; 104 | } 105 | 106 | @Override 107 | public void run() { 108 | Looper.prepare(); 109 | handler = new DecodeHandler(activity, hints); 110 | handlerInitLatch.countDown(); 111 | Looper.loop(); 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /zxing-demo-1/src/com/google/zxing/decode/FinishListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.decode; 18 | 19 | import android.app.Activity; 20 | import android.content.DialogInterface; 21 | 22 | /** 23 | * Simple listener used to exit the app in a few cases. 24 | * 25 | * @author Sean Owen 26 | */ 27 | public final class FinishListener implements DialogInterface.OnClickListener, DialogInterface.OnCancelListener { 28 | 29 | private final Activity activityToFinish; 30 | 31 | public FinishListener(Activity activityToFinish) { 32 | this.activityToFinish = activityToFinish; 33 | } 34 | 35 | @Override 36 | public void onCancel(DialogInterface dialogInterface) { 37 | run(); 38 | } 39 | 40 | @Override 41 | public void onClick(DialogInterface dialogInterface, int i) { 42 | run(); 43 | } 44 | 45 | private void run() { 46 | activityToFinish.finish(); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /zxing-demo-1/src/com/google/zxing/view/ViewfinderResultPointCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.view; 18 | 19 | import com.google.zxing.ResultPoint; 20 | import com.google.zxing.ResultPointCallback; 21 | 22 | public final class ViewfinderResultPointCallback implements ResultPointCallback { 23 | 24 | private final ViewfinderView viewfinderView; 25 | 26 | public ViewfinderResultPointCallback(ViewfinderView viewfinderView) { 27 | this.viewfinderView = viewfinderView; 28 | } 29 | 30 | @Override 31 | public void foundPossibleResultPoint(ResultPoint point) { 32 | viewfinderView.addPossibleResultPoint(point); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /zxing-demo-1/src/com/jinlin/zxing/AmbientLightManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.jinlin.zxing; 18 | 19 | import android.content.Context; 20 | import android.content.SharedPreferences; 21 | import android.hardware.Sensor; 22 | import android.hardware.SensorEvent; 23 | import android.hardware.SensorEventListener; 24 | import android.hardware.SensorManager; 25 | import android.preference.PreferenceManager; 26 | import com.google.zxing.camera.CameraManager; 27 | import com.google.zxing.camera.FrontLightMode; 28 | 29 | /** 30 | * Detects ambient light and switches on the front light when very dark, and off 31 | * again when sufficiently light. 32 | * 33 | * @author Sean Owen 34 | * @author Nikolaus Huber 35 | */ 36 | final class AmbientLightManager implements SensorEventListener { 37 | 38 | private static final float TOO_DARK_LUX = 45.0f; 39 | private static final float BRIGHT_ENOUGH_LUX = 450.0f; 40 | 41 | private final Context context; 42 | private CameraManager cameraManager; 43 | 44 | /** 45 | * 光传感器 46 | */ 47 | private Sensor lightSensor; 48 | 49 | AmbientLightManager(Context context) { 50 | this.context = context; 51 | } 52 | 53 | void start(CameraManager cameraManager) { 54 | this.cameraManager = cameraManager; 55 | SharedPreferences sharedPrefs = PreferenceManager 56 | .getDefaultSharedPreferences(context); 57 | if (FrontLightMode.readPref(sharedPrefs) == FrontLightMode.AUTO) { 58 | SensorManager sensorManager = (SensorManager) context 59 | .getSystemService(Context.SENSOR_SERVICE); 60 | lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT); 61 | if (lightSensor != null) { 62 | sensorManager.registerListener(this, lightSensor, 63 | SensorManager.SENSOR_DELAY_NORMAL); 64 | } 65 | } 66 | } 67 | 68 | void stop() { 69 | if (lightSensor != null) { 70 | SensorManager sensorManager = (SensorManager) context 71 | .getSystemService(Context.SENSOR_SERVICE); 72 | sensorManager.unregisterListener(this); 73 | cameraManager = null; 74 | lightSensor = null; 75 | } 76 | } 77 | 78 | /** 79 | * 该方法会在周围环境改变后回调,然后根据设置好的临界值决定是否打开闪光灯 80 | */ 81 | @Override 82 | public void onSensorChanged(SensorEvent sensorEvent) { 83 | float ambientLightLux = sensorEvent.values[0]; 84 | if (cameraManager != null) { 85 | if (ambientLightLux <= TOO_DARK_LUX) { 86 | cameraManager.setTorch(true); 87 | } 88 | else if (ambientLightLux >= BRIGHT_ENOUGH_LUX) { 89 | cameraManager.setTorch(false); 90 | } 91 | } 92 | } 93 | 94 | @Override 95 | public void onAccuracyChanged(Sensor sensor, int accuracy) { 96 | // do nothing 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /zxing-demo-1/src/com/jinlin/zxing/InactivityTimer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.jinlin.zxing; 18 | 19 | import android.app.Activity; 20 | import android.content.BroadcastReceiver; 21 | import android.content.Context; 22 | import android.content.Intent; 23 | import android.content.IntentFilter; 24 | import android.os.AsyncTask; 25 | import android.os.BatteryManager; 26 | import android.util.Log; 27 | import com.google.zxing.common.Runnable; 28 | 29 | /** 30 | * Finishes an activity after a period of inactivity if the device is on battery 31 | * power.
32 | *
33 | * 34 | * 该活动监控器全程监控扫描活跃状态,与CaptureActivity生命周期相同 35 | */ 36 | final class InactivityTimer { 37 | 38 | private static final String TAG = InactivityTimer.class.getSimpleName(); 39 | 40 | /** 41 | * 如果在5min内扫描器没有被使用过,则自动finish掉activity 42 | */ 43 | private static final long INACTIVITY_DELAY_MS = 5 * 60 * 1000L; 44 | 45 | /** 46 | * 在本app中,此activity即为CaptureActivity 47 | */ 48 | private final Activity activity; 49 | /** 50 | * 接受系统广播:手机是否连通电源 51 | */ 52 | private final BroadcastReceiver powerStatusReceiver; 53 | private boolean registered; 54 | private AsyncTask inactivityTask; 55 | 56 | InactivityTimer(Activity activity) { 57 | this.activity = activity; 58 | powerStatusReceiver = new PowerStatusReceiver(); 59 | registered = false; 60 | onActivity(); 61 | } 62 | 63 | /** 64 | * 首先终止之前的监控任务,然后新起一个监控任务 65 | */ 66 | synchronized void onActivity() { 67 | cancel(); 68 | inactivityTask = new InactivityAsyncTask(); 69 | Runnable.execAsync(inactivityTask); 70 | } 71 | 72 | public synchronized void onPause() { 73 | cancel(); 74 | if (registered) { 75 | activity.unregisterReceiver(powerStatusReceiver); 76 | registered = false; 77 | } 78 | else { 79 | Log.w(TAG, "PowerStatusReceiver was never registered?"); 80 | } 81 | } 82 | 83 | public synchronized void onResume() { 84 | Log.d(TAG, "here"); 85 | if (registered) { 86 | Log.w(TAG, "PowerStatusReceiver was already registered?"); 87 | } else { 88 | activity.registerReceiver(powerStatusReceiver, new IntentFilter( 89 | Intent.ACTION_BATTERY_CHANGED)); 90 | registered = true; 91 | } 92 | onActivity(); 93 | } 94 | 95 | /** 96 | * 取消监控任务 97 | */ 98 | private synchronized void cancel() { 99 | AsyncTask task = inactivityTask; 100 | if (task != null) { 101 | task.cancel(true); 102 | inactivityTask = null; 103 | } 104 | } 105 | 106 | void shutdown() { 107 | cancel(); 108 | } 109 | 110 | /** 111 | * 监听是否连通电源的系统广播。如果连通电源,则停止监控任务,否则重启监控任务 112 | */ 113 | private final class PowerStatusReceiver extends BroadcastReceiver { 114 | @Override 115 | public void onReceive(Context context, Intent intent) { 116 | if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) { 117 | // 0 indicates that we're on battery 118 | boolean onBatteryNow = intent.getIntExtra( 119 | BatteryManager.EXTRA_PLUGGED, -1) <= 0; 120 | if (onBatteryNow) { 121 | InactivityTimer.this.onActivity(); 122 | } 123 | else { 124 | InactivityTimer.this.cancel(); 125 | } 126 | } 127 | } 128 | } 129 | 130 | /** 131 | * 该任务很简单,就是在INACTIVITY_DELAY_MS时间后终结activity 132 | */ 133 | private final class InactivityAsyncTask extends 134 | AsyncTask { 135 | @Override 136 | protected Object doInBackground(Object... objects) { 137 | try { 138 | Thread.sleep(INACTIVITY_DELAY_MS); 139 | Log.i(TAG, "Finishing activity due to inactivity"); 140 | activity.finish(); 141 | } 142 | catch (InterruptedException e) { 143 | // continue without killing 144 | } 145 | return null; 146 | } 147 | } 148 | 149 | } 150 | -------------------------------------------------------------------------------- /zxing-demo-1/src/com/jinlin/zxing/IntentSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.jinlin.zxing; 18 | 19 | enum IntentSource { 20 | 21 | NATIVE_APP_INTENT, 22 | PRODUCT_SEARCH_LINK, 23 | ZXING_LINK, 24 | NONE 25 | 26 | } 27 | -------------------------------------------------------------------------------- /zxing-demo-2/.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Android template 3 | # Built application files 4 | *.apk 5 | *.ap_ 6 | 7 | # Files for the Dalvik VM 8 | *.dex 9 | 10 | # Java class files 11 | *.class 12 | 13 | # Generated files 14 | bin/ 15 | gen/ 16 | out/ 17 | 18 | # Gradle files 19 | .gradle/ 20 | build/ 21 | 22 | # Local configuration file (sdk path, etc) 23 | local.properties 24 | 25 | # Proguard folder generated by Eclipse 26 | proguard/ 27 | 28 | # Log Files 29 | *.log 30 | 31 | # Android Studio Navigation editor temp files 32 | .navigation/ 33 | 34 | # Android Studio captures folder 35 | captures/ 36 | 37 | # Intellij 38 | *.iml 39 | 40 | # Keystore files 41 | *.jks 42 | 43 | -------------------------------------------------------------------------------- /zxing-demo-2/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 9 | 10 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 32 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 44 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /zxing-demo-2/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | dependencies { 4 | compile fileTree(dir: 'libs', include: '*.jar') 5 | } 6 | 7 | android { 8 | compileSdkVersion 23 9 | buildToolsVersion "23.0.2" 10 | 11 | sourceSets { 12 | main { 13 | manifest.srcFile 'AndroidManifest.xml' 14 | java.srcDirs = ['src'] 15 | resources.srcDirs = ['src'] 16 | aidl.srcDirs = ['src'] 17 | renderscript.srcDirs = ['src'] 18 | res.srcDirs = ['res'] 19 | assets.srcDirs = ['assets'] 20 | } 21 | 22 | // Move the tests to tests/java, tests/res, etc... 23 | instrumentTest.setRoot('tests') 24 | 25 | // Move the build types to build-types/ 26 | // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... 27 | // This moves them out of them default location under src//... which would 28 | // conflict with src/ being used by the main source set. 29 | // Adding new build types or product flavors should be accompanied 30 | // by a similar customization. 31 | debug.setRoot('build-types/debug') 32 | release.setRoot('build-types/release') 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /zxing-demo-2/libs/core-3.1.1-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-2/libs/core-3.1.1-SNAPSHOT.jar -------------------------------------------------------------------------------- /zxing-demo-2/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-2/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /zxing-demo-2/res/drawable-hdpi/scan_flashlight_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-2/res/drawable-hdpi/scan_flashlight_normal.png -------------------------------------------------------------------------------- /zxing-demo-2/res/drawable-hdpi/scan_flashlight_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-2/res/drawable-hdpi/scan_flashlight_pressed.png -------------------------------------------------------------------------------- /zxing-demo-2/res/drawable-hdpi/scan_photo_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-2/res/drawable-hdpi/scan_photo_normal.png -------------------------------------------------------------------------------- /zxing-demo-2/res/drawable-hdpi/scan_photo_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-2/res/drawable-hdpi/scan_photo_pressed.png -------------------------------------------------------------------------------- /zxing-demo-2/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-2/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /zxing-demo-2/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-2/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /zxing-demo-2/res/drawable-xhdpi/qr_code_bg.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-2/res/drawable-xhdpi/qr_code_bg.9.png -------------------------------------------------------------------------------- /zxing-demo-2/res/drawable-xhdpi/scan_flashlight_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-2/res/drawable-xhdpi/scan_flashlight_normal.png -------------------------------------------------------------------------------- /zxing-demo-2/res/drawable-xhdpi/scan_flashlight_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-2/res/drawable-xhdpi/scan_flashlight_pressed.png -------------------------------------------------------------------------------- /zxing-demo-2/res/drawable-xhdpi/scan_line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-2/res/drawable-xhdpi/scan_line.png -------------------------------------------------------------------------------- /zxing-demo-2/res/drawable-xhdpi/scan_mask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-2/res/drawable-xhdpi/scan_mask.png -------------------------------------------------------------------------------- /zxing-demo-2/res/drawable-xhdpi/scan_photo_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-2/res/drawable-xhdpi/scan_photo_normal.png -------------------------------------------------------------------------------- /zxing-demo-2/res/drawable-xhdpi/scan_photo_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/QRCode/bdcf5984cde598c52299ca7f3801ccdc1191deed/zxing-demo-2/res/drawable-xhdpi/scan_photo_pressed.png -------------------------------------------------------------------------------- /zxing-demo-2/res/drawable/scan_flashlight.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /zxing-demo-2/res/drawable/scan_photo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /zxing-demo-2/res/layout/activity_capture.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 15 | 16 | 22 | 23 | 30 | 31 | 39 | 40 | 41 | 48 | 49 | 58 | 59 | 68 | 69 | 78 | 79 | 80 | 88 | 89 | 101 | 102 |