[
  {
    "path": ".gitignore",
    "content": ".gradle\n/local.properties\n/.idea/workspace.xml\n/.idea/libraries\n.DS_Store\n/build\n/captures\n### Android template\n# Built application files\n*.apk\n*.ap_\n\n# Files for the Dalvik VM\n*.dex\n\n# Java class files\n*.class\n\n# Generated files\nbin/\ngen/\n\n# Gradle files\n.gradle/\nbuild/\n\n# Local configuration file (sdk path, etc)\nlocal.properties\n\n# Proguard folder generated by Eclipse\nproguard/\n\n# Log Files\n*.log\n\n# Android Studio Navigation editor temp files\n.navigation/\n\n"
  },
  {
    "path": ".idea/.name",
    "content": "ScanCode"
  },
  {
    "path": ".idea/compiler.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"CompilerConfiguration\">\n    <resourceExtensions />\n    <wildcardResourcePatterns>\n      <entry name=\"!?*.java\" />\n      <entry name=\"!?*.form\" />\n      <entry name=\"!?*.class\" />\n      <entry name=\"!?*.groovy\" />\n      <entry name=\"!?*.scala\" />\n      <entry name=\"!?*.flex\" />\n      <entry name=\"!?*.kt\" />\n      <entry name=\"!?*.clj\" />\n      <entry name=\"!?*.aj\" />\n    </wildcardResourcePatterns>\n    <annotationProcessing>\n      <profile default=\"true\" name=\"Default\" enabled=\"false\">\n        <processorPath useClasspath=\"true\" />\n      </profile>\n    </annotationProcessing>\n  </component>\n</project>"
  },
  {
    "path": ".idea/copyright/profiles_settings.xml",
    "content": "<component name=\"CopyrightManager\">\n  <settings default=\"\" />\n</component>"
  },
  {
    "path": ".idea/encodings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"Encoding\">\n    <file url=\"PROJECT\" charset=\"UTF-8\" />\n  </component>\n</project>"
  },
  {
    "path": ".idea/gradle.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"GradleSettings\">\n    <option name=\"linkedExternalProjectsSettings\">\n      <GradleProjectSettings>\n        <option name=\"distributionType\" value=\"LOCAL\" />\n        <option name=\"externalProjectPath\" value=\"$PROJECT_DIR$\" />\n        <option name=\"gradleHome\" value=\"C:\\android\\android-studio\\gradle\\gradle-2.4\" />\n        <option name=\"gradleJvm\" value=\"1.8\" />\n        <option name=\"modules\">\n          <set>\n            <option value=\"$PROJECT_DIR$\" />\n            <option value=\"$PROJECT_DIR$/app\" />\n          </set>\n        </option>\n      </GradleProjectSettings>\n    </option>\n  </component>\n</project>"
  },
  {
    "path": ".idea/misc.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"EntryPointsManager\">\n    <entry_points version=\"2.0\" />\n  </component>\n  <component name=\"NullableNotNullManager\">\n    <option name=\"myDefaultNullable\" value=\"android.support.annotation.Nullable\" />\n    <option name=\"myDefaultNotNull\" value=\"android.support.annotation.NonNull\" />\n    <option name=\"myNullables\">\n      <value>\n        <list size=\"4\">\n          <item index=\"0\" class=\"java.lang.String\" itemvalue=\"org.jetbrains.annotations.Nullable\" />\n          <item index=\"1\" class=\"java.lang.String\" itemvalue=\"javax.annotation.Nullable\" />\n          <item index=\"2\" class=\"java.lang.String\" itemvalue=\"edu.umd.cs.findbugs.annotations.Nullable\" />\n          <item index=\"3\" class=\"java.lang.String\" itemvalue=\"android.support.annotation.Nullable\" />\n        </list>\n      </value>\n    </option>\n    <option name=\"myNotNulls\">\n      <value>\n        <list size=\"4\">\n          <item index=\"0\" class=\"java.lang.String\" itemvalue=\"org.jetbrains.annotations.NotNull\" />\n          <item index=\"1\" class=\"java.lang.String\" itemvalue=\"javax.annotation.Nonnull\" />\n          <item index=\"2\" class=\"java.lang.String\" itemvalue=\"edu.umd.cs.findbugs.annotations.NonNull\" />\n          <item index=\"3\" class=\"java.lang.String\" itemvalue=\"android.support.annotation.NonNull\" />\n        </list>\n      </value>\n    </option>\n  </component>\n  <component name=\"ProjectLevelVcsManager\" settingsEditedManually=\"false\">\n    <OptionsSetting value=\"true\" id=\"Add\" />\n    <OptionsSetting value=\"true\" id=\"Remove\" />\n    <OptionsSetting value=\"true\" id=\"Checkout\" />\n    <OptionsSetting value=\"true\" id=\"Update\" />\n    <OptionsSetting value=\"true\" id=\"Status\" />\n    <OptionsSetting value=\"true\" id=\"Edit\" />\n    <ConfirmationsSetting value=\"0\" id=\"Add\" />\n    <ConfirmationsSetting value=\"0\" id=\"Remove\" />\n  </component>\n  <component name=\"ProjectRootManager\" version=\"2\" languageLevel=\"JDK_1_7\" default=\"true\" assert-keyword=\"true\" jdk-15=\"true\" project-jdk-name=\"1.8\" project-jdk-type=\"JavaSDK\">\n    <output url=\"file://$PROJECT_DIR$/build/classes\" />\n  </component>\n  <component name=\"ProjectType\">\n    <option name=\"id\" value=\"Android\" />\n  </component>\n</project>"
  },
  {
    "path": ".idea/modules.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"ProjectModuleManager\">\n    <modules>\n      <module fileurl=\"file://$PROJECT_DIR$/ScanCode.iml\" filepath=\"$PROJECT_DIR$/ScanCode.iml\" />\n      <module fileurl=\"file://$PROJECT_DIR$/app/app.iml\" filepath=\"$PROJECT_DIR$/app/app.iml\" />\n    </modules>\n  </component>\n</project>"
  },
  {
    "path": ".idea/runConfigurations.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"RunConfigurationProducerService\">\n    <option name=\"ignoredProducers\">\n      <set>\n        <option value=\"org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer\" />\n        <option value=\"org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer\" />\n        <option value=\"org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer\" />\n      </set>\n    </option>\n  </component>\n</project>"
  },
  {
    "path": ".idea/vcs.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"VcsDirectoryMappings\">\n    <mapping directory=\"$PROJECT_DIR$\" vcs=\"Git\" />\n  </component>\n</project>"
  },
  {
    "path": "README.md",
    "content": "# ScanCode\n使用zxing封装的android扫描全功能系列，包括二维码扫描，条形码扫描，二维码生成，条形码生成，从图片中扫描二维码或者条形码,闪光灯控制。<br/>\n优点：<br/>\n    1.该有的功能一个都不少！<br/>\n    2.扫描界面布局xml完成，可自行订制！<br/>\n    3.不乱码，不变形！<br/>\n    4.扫描后可得到扫描的截图！<br/>\n    5.支持连续扫描！<br/>\n    6.在一个项目中可多处使用，根据CommonScanActivity在多写一个自己的扫描界面就行了！<br/>\n#项目截图\n![](https://github.com/liang530/ScanCode/raw/master/images/main.png)<br/>\n\n![](https://github.com/liang530/ScanCode/raw/master/images/createCode.png)<br/>\n![](https://github.com/liang530/ScanCode/raw/master/images/scanCode.png)<br/>\n![](https://github.com/liang530/ScanCode/raw/master/images/scan2code.png)<br/>\n![](https://github.com/liang530/ScanCode/raw/master/images/scan_bar_code.png)<br/>\n![](https://github.com/liang530/ScanCode/raw/master/images/scan_photo.png)<br/>\n"
  },
  {
    "path": "ScanCode.iml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<module external.linked.project.id=\"ScanCode\" external.linked.project.path=\"$MODULE_DIR$\" external.root.project.path=\"$MODULE_DIR$\" external.system.id=\"GRADLE\" external.system.module.group=\"\" external.system.module.version=\"unspecified\" type=\"JAVA_MODULE\" version=\"4\">\n  <component name=\"FacetManager\">\n    <facet type=\"java-gradle\" name=\"Java-Gradle\">\n      <configuration>\n        <option name=\"BUILD_FOLDER_PATH\" value=\"$MODULE_DIR$/build\" />\n        <option name=\"BUILDABLE\" value=\"false\" />\n      </configuration>\n    </facet>\n  </component>\n  <component name=\"NewModuleRootManager\" LANGUAGE_LEVEL=\"JDK_1_7\" inherit-compiler-output=\"true\">\n    <exclude-output />\n    <content url=\"file://$MODULE_DIR$\">\n      <excludeFolder url=\"file://$MODULE_DIR$/.gradle\" />\n    </content>\n    <orderEntry type=\"inheritedJdk\" />\n    <orderEntry type=\"sourceFolder\" forTests=\"false\" />\n  </component>\n</module>"
  },
  {
    "path": "app/.gitignore",
    "content": "### Android template\n# Built application files\n*.apk\n*.ap_\n\n# Files for the Dalvik VM\n*.dex\n\n# Java class files\n*.class\n\n# Generated files\nbin/\ngen/\n\n# Gradle files\n.gradle/\nbuild/\n\n# Local configuration file (sdk path, etc)\nlocal.properties\n\n# Proguard folder generated by Eclipse\nproguard/\n\n# Log Files\n*.log\n\n# Android Studio Navigation editor temp files\n.navigation/\n\n/build\n"
  },
  {
    "path": "app/app.iml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<module external.linked.project.id=\":app\" external.linked.project.path=\"$MODULE_DIR$\" external.root.project.path=\"$MODULE_DIR$/..\" external.system.id=\"GRADLE\" external.system.module.group=\"ScanCode\" external.system.module.version=\"unspecified\" type=\"JAVA_MODULE\" version=\"4\">\n  <component name=\"FacetManager\">\n    <facet type=\"android-gradle\" name=\"Android-Gradle\">\n      <configuration>\n        <option name=\"GRADLE_PROJECT_PATH\" value=\":app\" />\n      </configuration>\n    </facet>\n    <facet type=\"android\" name=\"Android\">\n      <configuration>\n        <option name=\"SELECTED_BUILD_VARIANT\" value=\"debug\" />\n        <option name=\"SELECTED_TEST_ARTIFACT\" value=\"_android_test_\" />\n        <option name=\"ASSEMBLE_TASK_NAME\" value=\"assembleDebug\" />\n        <option name=\"COMPILE_JAVA_TASK_NAME\" value=\"compileDebugSources\" />\n        <option name=\"ASSEMBLE_TEST_TASK_NAME\" value=\"assembleDebugAndroidTest\" />\n        <option name=\"COMPILE_JAVA_TEST_TASK_NAME\" value=\"compileDebugAndroidTestSources\" />\n        <afterSyncTasks>\n          <task>generateDebugAndroidTestSources</task>\n          <task>generateDebugSources</task>\n        </afterSyncTasks>\n        <option name=\"ALLOW_USER_CONFIGURATION\" value=\"false\" />\n        <option name=\"MANIFEST_FILE_RELATIVE_PATH\" value=\"/src/main/AndroidManifest.xml\" />\n        <option name=\"RES_FOLDER_RELATIVE_PATH\" value=\"/src/main/res\" />\n        <option name=\"RES_FOLDERS_RELATIVE_PATH\" value=\"file://$MODULE_DIR$/src/main/res\" />\n        <option name=\"ASSETS_FOLDER_RELATIVE_PATH\" value=\"/src/main/assets\" />\n      </configuration>\n    </facet>\n  </component>\n  <component name=\"NewModuleRootManager\" LANGUAGE_LEVEL=\"JDK_1_7\" inherit-compiler-output=\"false\">\n    <output url=\"file://$MODULE_DIR$/build/intermediates/classes/debug\" />\n    <output-test url=\"file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug\" />\n    <exclude-output />\n    <content url=\"file://$MODULE_DIR$\">\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/r/debug\" isTestSource=\"false\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/aidl/debug\" isTestSource=\"false\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/buildConfig/debug\" isTestSource=\"false\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/rs/debug\" isTestSource=\"false\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/res/rs/debug\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/res/generated/debug\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/r/androidTest/debug\" isTestSource=\"true\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug\" isTestSource=\"true\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug\" isTestSource=\"true\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug\" isTestSource=\"true\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/res/generated/androidTest/debug\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/res\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/resources\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/assets\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/aidl\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/java\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/jni\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/rs\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/res\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/resources\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/assets\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/aidl\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/java\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/jni\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/rs\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/res\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/resources\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/assets\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/aidl\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/java\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/jni\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/rs\" isTestSource=\"true\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/assets\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/bundles\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/classes\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/dependency-cache\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/dex\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/dex-cache\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/incremental\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/jacoco\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/javaResources\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/libs\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/lint\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/manifests\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/ndk\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/pre-dexed\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/proguard\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/res\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/rs\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/symbols\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/outputs\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/tmp\" />\n    </content>\n    <orderEntry type=\"jdk\" jdkName=\"Android API 22 Platform\" jdkType=\"Android SDK\" />\n    <orderEntry type=\"sourceFolder\" forTests=\"false\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"butterknife-7.0.1\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"zxing\" level=\"project\" />\n  </component>\n</module>"
  },
  {
    "path": "app/build.gradle",
    "content": "apply plugin: 'com.android.application'\n\nandroid {\n    compileSdkVersion 22\n    buildToolsVersion \"22.0.1\"\n\n    defaultConfig {\n        applicationId \"com.liang.scancode\"\n        minSdkVersion 15\n        targetSdkVersion 22\n        versionCode 1\n        versionName \"1.0\"\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n}\n\ndependencies {\n    compile fileTree(include: ['*.jar'], dir: 'libs')\n}\n"
  },
  {
    "path": "app/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /home/hongliang/android/sdk/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the proguardFiles\n# directive in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class goodsid to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n"
  },
  {
    "path": "app/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.liang.scancode\">\n\n    <!-- 二维码相关权限 -->\n    <uses-permission android:name=\"android.permission.VIBRATE\" />\n    <uses-permission android:name=\"android.permission.CAMERA\" />\n\n    <uses-feature android:name=\"android.hardware.camera\" />\n    <uses-feature android:name=\"android.hardware.camera.autofocus\" />\n    <uses-feature android:name=\"android.hardware.camera.flash\" />\n\n    <uses-permission android:name=\"android.permission.FLASHLIGHT\" />\n    <uses-permission android:name=\"android.permission.READ_CONTACTS\" />\n    <uses-permission android:name=\"com.android.browser.permission.READ_HISTORY_BOOKMARKS\" />\n    <uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />\n    <uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\" />\n    <uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\" />\n    <uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\" />\n\n    <application\n        android:allowBackup=\"true\"\n        android:icon=\"@mipmap/ic_launcher\"\n        android:label=\"@string/app_name\"\n        android:theme=\"@style/AppTheme\">\n        <activity\n            android:name=\".MainActivity\"\n            android:label=\"@string/app_name\"\n            android:theme=\"@android:style/Theme.Light.NoTitleBar\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n        </activity>\n        <activity\n            android:name=\".CreateCodeActivity\"\n            android:label=\"@string/app_name\"\n            android:theme=\"@android:style/Theme.Light.NoTitleBar\"\n            android:windowSoftInputMode=\"adjustPan\" />\n        <activity\n            android:name=\".CommonScanActivity\"\n            android:label=\"@string/app_name\"\n            android:theme=\"@android:style/Theme.Light.NoTitleBar\" />\n\n    </application>\n\n</manifest>\n"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/CommonScanActivity.java",
    "content": "/*\n * Copyright (C) 2008 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.liang.scancode;\n\nimport android.app.Activity;\nimport android.content.Intent;\nimport android.database.Cursor;\nimport android.graphics.Bitmap;\nimport android.graphics.BitmapFactory;\nimport android.os.Bundle;\nimport android.provider.MediaStore;\nimport android.view.SurfaceView;\nimport android.view.View;\nimport android.view.Window;\nimport android.view.WindowManager;\nimport android.widget.Button;\nimport android.widget.ImageView;\nimport android.widget.TextView;\nimport android.widget.Toast;\n\nimport com.google.zxing.Result;\n\nimport butterknife.ButterKnife;\nimport butterknife.Bind;\nimport com.liang.scancode.utils.Constant;\nimport com.liang.scancode.zxing.ScanListener;\nimport com.liang.scancode.zxing.ScanManager;\nimport com.liang.scancode.zxing.decode.DecodeThread;\nimport com.liang.scancode.zxing.decode.Utils;\n\n\n/**\n * 二维码扫描使用\n *\n * @author 刘红亮  2015年4月29日  下午5:49:45\n */\npublic final class CommonScanActivity extends Activity implements ScanListener, View.OnClickListener {\n    static final String TAG = CommonScanActivity.class.getSimpleName();\n    SurfaceView scanPreview = null;\n    View scanContainer;\n    View scanCropView;\n    ImageView scanLine;\n    ScanManager scanManager;\n    TextView iv_light;\n    TextView qrcode_g_gallery;\n    TextView qrcode_ic_back;\n    final int PHOTOREQUESTCODE = 1111;\n\n    @Bind(R.id.service_register_rescan)\n    Button rescan;\n    @Bind(R.id.scan_image)\n    ImageView scan_image;\n    @Bind(R.id.authorize_return)\n    ImageView authorize_return;\n    private int scanMode;//扫描模型（条形，二维码，全部）\n\n    @Bind(R.id.common_title_TV_center)\n    TextView title;\n    @Bind(R.id.scan_hint)\n    TextView scan_hint;\n    @Bind(R.id.tv_scan_result)\n    TextView tv_scan_result;\n\n\n\n    @Override\n    public void onCreate(Bundle icicle) {\n        super.onCreate(icicle);\n\n        Window window = getWindow();\n        window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);\n        setContentView(R.layout.activity_scan_code);\n        ButterKnife.bind(this);\n        scanMode=getIntent().getIntExtra(Constant.REQUEST_SCAN_MODE,Constant.REQUEST_SCAN_MODE_ALL_MODE);\n        initView();\n    }\n\n    void initView() {\n        switch (scanMode){\n            case DecodeThread.BARCODE_MODE:\n                title.setText(R.string.scan_barcode_title);\n                scan_hint.setText(R.string.scan_barcode_hint);\n                break;\n            case DecodeThread.QRCODE_MODE:\n                title.setText(R.string.scan_qrcode_title);\n                scan_hint.setText(R.string.scan_qrcode_hint);\n                break;\n            case DecodeThread.ALL_MODE:\n                title.setText(R.string.scan_allcode_title);\n                scan_hint.setText(R.string.scan_allcode_hint);\n                break;\n        }\n        scanPreview = (SurfaceView) findViewById(R.id.capture_preview);\n        scanContainer = findViewById(R.id.capture_container);\n        scanCropView = findViewById(R.id.capture_crop_view);\n        scanLine = (ImageView) findViewById(R.id.capture_scan_line);\n        qrcode_g_gallery = (TextView) findViewById(R.id.qrcode_g_gallery);\n        qrcode_g_gallery.setOnClickListener(this);\n        qrcode_ic_back = (TextView) findViewById(R.id.qrcode_ic_back);\n        qrcode_ic_back.setOnClickListener(this);\n        iv_light = (TextView) findViewById(R.id.iv_light);\n        iv_light.setOnClickListener(this);\n        rescan.setOnClickListener(this);\n        authorize_return.setOnClickListener(this);\n        //构造出扫描管理器\n        scanManager = new ScanManager(this, scanPreview, scanContainer, scanCropView, scanLine, scanMode,this);\n    }\n\n    @Override\n    public void onResume() {\n        super.onResume();\n        scanManager.onResume();\n        rescan.setVisibility(View.INVISIBLE);\n        scan_image.setVisibility(View.GONE);\n    }\n\n    @Override\n    public void onPause() {\n        super.onPause();\n        scanManager.onPause();\n    }\n    /**\n     *\n     */\n    public void scanResult(Result rawResult, Bundle bundle) {\n        //扫描成功后，扫描器不会再连续扫描，如需连续扫描，调用reScan()方法。\n        //scanManager.reScan();\n//\t\tToast.makeText(that, \"result=\"+rawResult.getText(), Toast.LENGTH_LONG).show();\n\n        if (!scanManager.isScanning()) { //如果当前不是在扫描状态\n            //设置再次扫描按钮出现\n            rescan.setVisibility(View.VISIBLE);\n            scan_image.setVisibility(View.VISIBLE);\n            Bitmap barcode = null;\n            byte[] compressedBitmap = bundle.getByteArray(DecodeThread.BARCODE_BITMAP);\n            if (compressedBitmap != null) {\n                barcode = BitmapFactory.decodeByteArray(compressedBitmap, 0, compressedBitmap.length, null);\n                barcode = barcode.copy(Bitmap.Config.ARGB_8888, true);\n            }\n            scan_image.setImageBitmap(barcode);\n        }\n        rescan.setVisibility(View.VISIBLE);\n        scan_image.setVisibility(View.VISIBLE);\n        tv_scan_result.setVisibility(View.VISIBLE);\n        tv_scan_result.setText(\"结果：\"+rawResult.getText());\n    }\n\n    void startScan() {\n        if (rescan.getVisibility() == View.VISIBLE) {\n            rescan.setVisibility(View.INVISIBLE);\n            scan_image.setVisibility(View.GONE);\n            scanManager.reScan();\n        }\n    }\n\n    @Override\n    public void scanError(Exception e) {\n        Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();\n        //相机扫描出错时\n        if(e.getMessage()!=null&&e.getMessage().startsWith(\"相机\")){\n            scanPreview.setVisibility(View.INVISIBLE);\n        }\n    }\n\n    public void showPictures(int requestCode) {\n        Intent intent = new Intent(Intent.ACTION_PICK);\n        intent.setType(\"image/*\");\n        startActivityForResult(intent, requestCode);\n    }\n\n    @Override\n    public void onActivityResult(int requestCode, int resultCode, Intent data) {\n        super.onActivityResult(requestCode, resultCode, data);\n        String photo_path;\n        if (resultCode == RESULT_OK) {\n            switch (requestCode) {\n                case PHOTOREQUESTCODE:\n                    String[] proj = {MediaStore.Images.Media.DATA};\n                    Cursor cursor = this.getContentResolver().query(data.getData(), proj, null, null, null);\n                    if (cursor.moveToFirst()) {\n                        int colum_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);\n                        photo_path = cursor.getString(colum_index);\n                        if (photo_path == null) {\n                            photo_path = Utils.getPath(getApplicationContext(), data.getData());\n                        }\n                        scanManager.scanningImage(photo_path);\n                    }\n            }\n        }\n    }\n\n    @Override\n    public void onClick(View v) {\n        switch (v.getId()) {\n            case R.id.qrcode_g_gallery:\n                showPictures(PHOTOREQUESTCODE);\n                break;\n            case R.id.iv_light:\n                scanManager.switchLight();\n                break;\n            case R.id.qrcode_ic_back:\n                finish();\n                break;\n            case R.id.service_register_rescan://再次开启扫描\n                startScan();\n                break;\n            case R.id.authorize_return:\n                finish();\n                break;\n            default:\n                break;\n        }\n    }\n\n}"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/CreateCodeActivity.java",
    "content": "package com.liang.scancode;\n\nimport android.app.Activity;\nimport android.graphics.Bitmap;\nimport android.graphics.BitmapFactory;\nimport android.graphics.Canvas;\nimport android.graphics.Matrix;\nimport android.graphics.Rect;\nimport android.os.Bundle;\nimport android.text.TextUtils;\nimport android.view.View;\nimport android.widget.Button;\nimport android.widget.EditText;\nimport android.widget.ImageView;\nimport android.widget.Toast;\n\nimport com.google.zxing.WriterException;\n\nimport java.io.UnsupportedEncodingException;\n\nimport butterknife.ButterKnife;\nimport butterknife.Bind;\nimport butterknife.OnClick;\nimport com.liang.scancode.zxing.encode.EncodingHandler;\n\n/**\n * Created by 刘红亮 on 2015/9/24 14:37.\n */\npublic class CreateCodeActivity extends Activity {\n    @Bind(R.id.et_code_key)\n    EditText etCodeKey;\n    @Bind(R.id.btn_create_code)\n    Button btnCreateCode;\n    @Bind(R.id.iv_2_code)\n    ImageView iv2Code;\n    @Bind(R.id.iv_bar_code)\n    ImageView ivBarCode;\n\n    @Override\n    public void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_create_code);\n        ButterKnife.bind(this);\n    }\n    @OnClick({R.id.btn_create_code,R.id.btn_create_code_and_img})\n    public void clickListener(View view){\n        String key=etCodeKey.getText().toString();\n        switch (view.getId()){\n            case  R.id.btn_create_code: //生成码\n                if(TextUtils.isEmpty(key)){\n                    Toast.makeText(this,\"请输入内容\",Toast.LENGTH_SHORT).show();\n                }else{\n                    create2Code(key);\n                    createBarCode(key);\n                }\n                break;\n            case  R.id.btn_create_code_and_img: //生成码\n                Bitmap bitmap = create2Code(key);\n                Bitmap headBitmap = getHeadBitmap(60);\n                if(bitmap!=null&&headBitmap!=null){\n                    createQRCodeBitmapWithPortrait(bitmap,headBitmap);\n                }\n                break;\n        }\n    }\n    private Bitmap createBarCode(String key) {\n        Bitmap qrCode = null;\n        try {\n            qrCode = EncodingHandler.createBarCode(key, 600, 300);\n            ivBarCode.setImageBitmap(qrCode);\n        } catch (Exception e) {\n            Toast.makeText(this,\"输入的内容条形码不支持！\",Toast.LENGTH_SHORT).show();\n            e.printStackTrace();\n        }\n        return qrCode;\n    }\n\n    /**\n     * 生成二维码\n     * @param key\n     */\n    private Bitmap create2Code(String key) {\n        Bitmap qrCode=null;\n        try {\n            qrCode= EncodingHandler.create2Code(key, 400);\n            iv2Code.setImageBitmap(qrCode);\n        } catch (WriterException e) {\n            e.printStackTrace();\n        } catch (UnsupportedEncodingException e) {\n            e.printStackTrace();\n        }\n        return qrCode;\n    }\n    /**\n     * 初始化头像图片\n     */\n    private Bitmap getHeadBitmap(int size) {\n        try {\n            // 这里采用从asset中加载图片abc.jpg\n            Bitmap portrait = BitmapFactory.decodeResource(getResources(),R.drawable.head);\n            // 对原有图片压缩显示大小\n            Matrix mMatrix = new Matrix();\n            float width = portrait.getWidth();\n            float height = portrait.getHeight();\n            mMatrix.setScale(size / width, size / height);\n            return Bitmap.createBitmap(portrait, 0, 0, (int) width,\n                    (int) height, mMatrix, true);\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n        return null;\n    }\n    /**\n     * 在二维码上绘制头像\n     */\n    private void createQRCodeBitmapWithPortrait(Bitmap qr, Bitmap portrait) {\n        // 头像图片的大小\n        int portrait_W = portrait.getWidth();\n        int portrait_H = portrait.getHeight();\n\n        // 设置头像要显示的位置，即居中显示\n        int left = (qr.getWidth() - portrait_W) / 2;\n        int top = (qr.getHeight() - portrait_H) / 2;\n        int right = left + portrait_W;\n        int bottom = top + portrait_H;\n        Rect rect1 = new Rect(left, top, right, bottom);\n\n        // 取得qr二维码图片上的画笔，即要在二维码图片上绘制我们的头像\n        Canvas canvas = new Canvas(qr);\n\n        // 设置我们要绘制的范围大小，也就是头像的大小范围\n        Rect rect2 = new Rect(0, 0, portrait_W, portrait_H);\n        // 开始绘制\n        canvas.drawBitmap(portrait, rect2, rect1, null);\n    }\n}\n"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/MainActivity.java",
    "content": "package com.liang.scancode;\n\nimport android.app.Activity;\nimport android.content.Intent;\nimport android.os.Bundle;\nimport android.view.View;\n\nimport butterknife.ButterKnife;\nimport butterknife.OnClick;\nimport com.liang.scancode.utils.Constant;\n\n\npublic class MainActivity extends Activity {\n    @Override\n    public void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n        ButterKnife.bind(this);\n        int mode = getIntent().getIntExtra(Constant.REQUEST_SCAN_MODE, Constant.REQUEST_SCAN_MODE_ALL_MODE);\n\n\n    }\n\n    /**\n     * 按钮监听事件，这里我使用Butterknife，不喜欢的也可以直接写监听\n     * @param view\n     */\n    @OnClick({R.id.create_code,R.id.scan_2code,R.id.scan_bar_code,R.id.scan_code})\n    public void clickListener(View view){\n        Intent intent;\n        switch (view.getId()){\n            case  R.id.create_code: //生成码\n                intent=new Intent(this,CreateCodeActivity.class);\n                startActivity(intent);\n                break;\n            case  R.id.scan_2code: //扫描二维码\n                intent=new Intent(this,CommonScanActivity.class);\n                intent.putExtra(Constant.REQUEST_SCAN_MODE,Constant.REQUEST_SCAN_MODE_QRCODE_MODE);\n                startActivity(intent);\n                break;\n            case  R.id.scan_bar_code://扫描条形码\n                intent=new Intent(this,CommonScanActivity.class);\n                intent.putExtra(Constant.REQUEST_SCAN_MODE,Constant.REQUEST_SCAN_MODE_BARCODE_MODE);\n                startActivity(intent);\n                break;\n            case  R.id.scan_code://扫描条形码或者二维码\n                intent=new Intent(this,CommonScanActivity.class);\n                intent.putExtra(Constant.REQUEST_SCAN_MODE,Constant.REQUEST_SCAN_MODE_ALL_MODE);\n                startActivity(intent);\n                break;\n        }\n    }\n}\n"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/defineview/MyImageView.java",
    "content": "package com.liang.scancode.defineview;\n\nimport android.content.Context;\nimport android.graphics.Canvas;\nimport android.graphics.Color;\nimport android.graphics.Paint;\nimport android.util.AttributeSet;\nimport android.util.TypedValue;\nimport android.widget.ImageView;\n\n/**\n * 作者：王敏 on 2015/8/21 17:31\n * 类说明：画出扫描框的四个脚的脚边框，也可以直接用一张图片代替\n */\npublic class MyImageView extends ImageView{\n    private Context context;\n    public MyImageView(Context context, AttributeSet attrs) {\n        super(context, attrs);\n        this.context = context;\n    }\n    public MyImageView(Context context) {\n        super(context);\n        this.context = context;\n    }\n\n    @Override\n    protected void onDraw(Canvas canvas) {\n        super.onDraw(canvas);\n        int width = getWidth();\n        int height = getHeight();\n\n        Paint paint = new Paint();\n        paint.setColor(Color.rgb(9,187,7));\n        paint.setAntiAlias(true);\n        paint.setStrokeWidth(t(5));\n\n        canvas.drawLine(0, 0, 0, t(18), paint);\n        canvas.drawLine(0, 0, t(18), 0, paint);\n\n        canvas.drawLine(0, height - t(18), 0, height, paint);\n        canvas.drawLine(0, height, t(18),height,paint);\n\n        canvas.drawLine(width-t(18), 0, width, 0, paint);\n        canvas.drawLine(width, 0, width,t(18),paint);\n\n        canvas.drawLine(width, height-t(18), width, height, paint);\n        canvas.drawLine(width-t(18), height, width,height,paint);\n    }\n    public  int dp2px(float dpVal)\n    {\n        return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,\n                dpVal, context.getResources().getDisplayMetrics());\n    }\n\n    public int t(float dpVal){\n        return dp2px(dpVal);\n    }\n\n    @Override\n    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {\n        super.onMeasure(widthMeasureSpec,heightMeasureSpec);\n    //   setMeasuredDimension(t(248),t(248));\n    }\n}\n"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/utils/Constant.java",
    "content": "package com.liang.scancode.utils;\n\n/**\n * Created by 刘红亮 on 2015/9/24 14:08.\n */\npublic interface Constant {\n    /**\n     * 二维码请求的type\n     */\n    public static final String REQUEST_SCAN_TYPE=\"type\";\n    /**\n     * 普通类型，扫完即关闭\n     */\n    public static final int REQUEST_SCAN_TYPE_COMMON=0;\n    /**\n     * 服务商登记类型，扫描\n     */\n    public static final int REQUEST_SCAN_TYPE_REGIST=1;\n\n\n    /**\n     * 扫描类型\n     * 条形码或者二维码：REQUEST_SCAN_MODE_ALL_MODE\n     * 条形码： REQUEST_SCAN_MODE_BARCODE_MODE\n     * 二维码：REQUEST_SCAN_MODE_QRCODE_MODE\n     *\n     */\n    public static final String REQUEST_SCAN_MODE=\"ScanMode\";\n    /**\n     * 条形码： REQUEST_SCAN_MODE_BARCODE_MODE\n     */\n    public static final int REQUEST_SCAN_MODE_BARCODE_MODE = 0X100;\n    /**\n     * 二维码：REQUEST_SCAN_MODE_ALL_MODE\n     */\n    public static final int REQUEST_SCAN_MODE_QRCODE_MODE = 0X200;\n    /**\n     * 条形码或者二维码：REQUEST_SCAN_MODE_ALL_MODE\n     */\n    public static final int REQUEST_SCAN_MODE_ALL_MODE = 0X300;\n\n}\n"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/zxing/ScanListener.java",
    "content": "package com.liang.scancode.zxing;\n\nimport android.os.Bundle;\n\nimport com.google.zxing.Result;\n\n/**\n * 二维码结果监听返回\n * @author 刘红亮  2015年4月29日  下午8:08:13\n *\n */\npublic interface ScanListener {\n\t/**\n\t * 返回扫描结果\n\t * @param rawResult  结果对象\n\t * @param bundle  存放了截图，或者是空的\n\t */\n\tpublic void scanResult(Result rawResult, Bundle bundle);\n\t/**\n\t * 扫描抛出的异常\n\t * @param e\n\t */\n\tpublic void scanError(Exception e);\n\t\n}\n"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/zxing/ScanManager.java",
    "content": "package com.liang.scancode.zxing;\n\nimport android.app.Activity;\nimport android.graphics.Bitmap;\nimport android.graphics.Rect;\nimport android.os.Bundle;\nimport android.os.Handler;\nimport android.os.Message;\nimport android.text.TextUtils;\nimport android.util.Log;\nimport android.view.SurfaceHolder;\nimport android.view.SurfaceView;\nimport android.view.View;\nimport android.view.animation.Animation;\nimport android.view.animation.TranslateAnimation;\nimport android.widget.ImageView;\n\nimport com.google.zxing.BinaryBitmap;\nimport com.google.zxing.DecodeHintType;\nimport com.google.zxing.MultiFormatReader;\nimport com.google.zxing.Result;\nimport com.google.zxing.common.HybridBinarizer;\nimport com.google.zxing.qrcode.QRCodeReader;\nimport com.liang.scancode.R;\nimport com.liang.scancode.zxing.camera.CameraManager;\nimport com.liang.scancode.zxing.decode.DecodeThread;\nimport com.liang.scancode.zxing.decode.PhotoScanHandler;\nimport com.liang.scancode.zxing.decode.RGBLuminanceSource;\nimport com.liang.scancode.zxing.utils.BeepManager;\nimport com.liang.scancode.zxing.utils.BitmapUtil;\nimport com.liang.scancode.zxing.utils.CaptureActivityHandler;\nimport com.liang.scancode.zxing.utils.InactivityTimer;\n\nimport java.io.IOException;\nimport java.lang.reflect.Field;\nimport java.util.Map;\n\npublic class ScanManager implements SurfaceHolder.Callback{\n\tboolean isHasSurface = false;\n\tCameraManager cameraManager;\n\t//用于拍摄扫描的handler\n\tCaptureActivityHandler handler;\n\t//用于照片扫描的handler,不可共用，图片扫描是不需要摄像机的\n\tPhotoScanHandler photoScanHandler;\n\tRect mCropRect = null;\n\tInactivityTimer inactivityTimer;\n\tpublic BeepManager beepManager;\n\tSurfaceView scanPreview = null;\n\tView scanContainer;\n\tView scanCropView;\n\tImageView scanLine;\n\tfinal String TAG= ScanManager.class.getSimpleName();\n\tActivity activity;\n\tScanListener listener;\n\tboolean isOpenLight=false;\n\n\tprivate int scanMode;//扫描模型（条形，二维码，全部）\n\t/**\n\t * 用于启动照相机扫描二维码，在activity的onCreate里面构造出来\n\t * 在activity的生命周期中调用此类相对应的生命周期方法\n\t * @param activity   扫描的activity\n\t * @param scanPreview  预览的SurfaceView\n\t * @param scanContainer  扫描的布局，全屏布局\n\t * @param scanCropView  扫描的矩形区域\n\t * @param scanLine  扫描线\n\t * \n\t * \n\t */\n\tpublic ScanManager(Activity activity,SurfaceView scanPreview,View scanContainer,\n\t\t\tView scanCropView,ImageView scanLine,int scanMode,ScanListener listener) {\n\t\tthis.activity=activity;\n\t\tthis.scanPreview=scanPreview;\n\t\tthis.scanContainer=scanContainer;\n\t\tthis.scanCropView=scanCropView;\n\t\tthis.scanLine=scanLine;\n\t\tthis.listener=listener;\n\t\tthis.scanMode=scanMode;\n\t\t//启动动画\n\t\tTranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,\n\t\t\t\t0.9f);\n\t\tanimation.setDuration(4500);\n\t\tanimation.setRepeatCount(-1);\n\t\tanimation.setRepeatMode(Animation.RESTART);\n\t\tscanLine.startAnimation(animation);\n\t\t\n\t}\n\t/**\n\t * 用于图片扫描的构造函数\n\t * @param listener  结果的监听回调\n\t */\n\tpublic ScanManager(ScanListener listener){\n\t\tthis.listener=listener;\n\t}\n\t\n\tpublic void onResume(){\n\t\t// CameraManager must be initialized here, not in onCreate(). This is\n\t\t// necessary because we don't\n\t\t// want to open the camera driver and measure the screen size if we're\n\t\t// going to show the help on\n\t\t// first launch. That led to bugs where the scanning rectangle was the\n\t\t// wrong size and partially\n\t\t// off screen.\n\t\tinactivityTimer = new InactivityTimer(activity);\n\t\tbeepManager = new BeepManager(activity);\n\t\tcameraManager = new CameraManager(activity.getApplicationContext());\n\t\t\n\t\thandler = null;\n\t\tif (isHasSurface) {\n\t\t\t// The activity was paused but not stopped, so the surface still\n\t\t\t// exists. Therefore\n\t\t\t// surfaceCreated() won't be called, so init the camera here.\n\t\t\tinitCamera(scanPreview.getHolder());\n\t\t} else {\n\t\t\t// Install the callback and wait for surfaceCreated() to init the\n\t\t\t// camera.\n\t\t\tscanPreview.getHolder().addCallback(this);\n\t\t}\n\t\tinactivityTimer.onResume();\n\t}\n\tpublic void onPause() {\n\t\tif (handler != null) {\n\t\t\thandler.quitSynchronously();\n\t\t\thandler = null;\n\t\t}\n\t\tinactivityTimer.onPause();\n\t\tbeepManager.close();\n\t\tcameraManager.closeDriver();\n\t\tif (!isHasSurface) {\n\t\t\tscanPreview.getHolder().removeCallback(this);\n\t\t}\n\t}\n\tpublic void onDestroy() {\n\t\tinactivityTimer.shutdown();\n\t}\n\t\n\t\n\t@Override\n\tpublic void surfaceCreated(SurfaceHolder holder) {\n\t\tif (holder == null) {\n\t\t\tLog.e(TAG, \"*** WARNING *** surfaceCreated() gave us a null surface!\");\n\t\t}\n\t\tif (!isHasSurface) {\n\t\t\tisHasSurface = true;\n\t\t\tinitCamera(holder);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void surfaceChanged(SurfaceHolder holder, int format, int width,\n\t\t\tint height) {\n\t}\n\n\t@Override\n\tpublic void surfaceDestroyed(SurfaceHolder holder) {\n\t\tisHasSurface = false;\n\t}\n\tvoid initCamera(SurfaceHolder surfaceHolder) {\n\t\tif (surfaceHolder == null) {\n\t\t\tthrow new IllegalStateException(\"No SurfaceHolder provided\");\n\t\t}\n\t\tif (cameraManager.isOpen()) {\n\t\t\tLog.w(TAG, \"initCamera() while already open -- late SurfaceView callback?\");\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tcameraManager.openDriver(surfaceHolder);\n\t\t\t// Creating the handler starts the preview, which can also throw a\n\t\t\t// RuntimeException.\n\t\t\tif (handler == null) {\n\t\t\t\thandler = new CaptureActivityHandler(this, cameraManager, scanMode);\n\t\t\t\tLog.e(\"hongliang1\", \"handler new成功！:\"+handler);\n\t\t\t}\n\n\t\t\tinitCrop();\n\t\t} catch (IOException ioe) {\n\t\t\tLog.e(TAG,\"hongliang\", ioe);\n\t\t\t//弹出提示，报错\n\t\t\tioe.printStackTrace();\n\t\t\tlistener.scanError(new Exception(\"相机打开出错，请检查是否被禁止了该权限！\"));\n\t\t} catch (RuntimeException e) {\n\t\t\tLog.e(TAG, \"hongliang\", e);\n\t\t\t//弹出提示，报错\n\t\t\te.printStackTrace();\n\t\t\tlistener.scanError(new Exception(\"相机打开出错，请检查是否被禁止了该权限！\"));\n\t\t}\n\t}\n\t/**\n\t * 开关闪关灯\n\t */\n\tpublic void switchLight(){\n\t\tif(isOpenLight){\n\t\t\tcameraManager.offLight();\n\t\t}else{\n\t\t\tcameraManager.openLight();\n\t\t}\n\t\tisOpenLight=!isOpenLight;\n\t}\n\tpublic Handler getHandler() {\n\t\treturn handler;\n\t}\n\n\tpublic CameraManager getCameraManager() {\n\t\treturn cameraManager;\n\t}\n\tpublic Rect getCropRect() {\n\t\treturn mCropRect;\n\t}\n\t/**\n\t * 扫描成功的结果回调\n\t * @param rawResult\n\t * @param bundle\n\t */\n\tpublic void handleDecode(Result rawResult, Bundle bundle) {\n\t\tinactivityTimer.onActivity();\n\t\t//扫描成功播放声音滴一下，可根据需要自行确定什么时候播\n\t    beepManager.playBeepSoundAndVibrate();\n\t\tbundle.putInt(\"width\", mCropRect.width());\n\t\tbundle.putInt(\"height\", mCropRect.height());\n\t\tbundle.putString(\"result\", rawResult.getText());\n\t\tlistener.scanResult(rawResult, bundle);\n\t}\n\tpublic void handleDecodeError(Exception e){\n\t\tlistener.scanError(e);\n\t}\n\t/**\n\t * 初始化截取的矩形区域\n\t */\n\tvoid initCrop() {\n\t\tint cameraWidth = cameraManager.getCameraResolution().y;\n\t\tint cameraHeight = cameraManager.getCameraResolution().x;\n\n\t\t/** 获取布局中扫描框的位置信息 */\n\t\tint[] location = new int[2];\n\t\tscanCropView.getLocationInWindow(location);\n\n\t\tint cropLeft = location[0];\n\t\tint cropTop = location[1] - getStatusBarHeight();\n\n\t\tint cropWidth = scanCropView.getWidth();\n\t\tint cropHeight = scanCropView.getHeight();\n\n\t\t/** 获取布局容器的宽高 */\n\t\tint containerWidth = scanContainer.getWidth();\n\t\tint containerHeight = scanContainer.getHeight();\n\n\t\t/** 计算最终截取的矩形的左上角顶点x坐标 */\n\t\tint x = cropLeft * cameraWidth / containerWidth;\n\t\t/** 计算最终截取的矩形的左上角顶点y坐标 */\n\t\tint y = cropTop * cameraHeight / containerHeight;\n\n\t\t/** 计算最终截取的矩形的宽度 */\n\t\tint width = cropWidth * cameraWidth / containerWidth;\n\t\t/** 计算最终截取的矩形的高度 */\n\t\tint height = cropHeight * cameraHeight / containerHeight;\n\n\t\t/** 生成最终的截取的矩形 */\n\t\tmCropRect = new Rect(x, y, width + x, height + y);\n\t}\n\tint getStatusBarHeight() {\n\t\ttry {\n\t\t\tClass<?> c = Class.forName(\"com.android.internal.R$dimen\");\n\t\t\tObject obj = c.newInstance();\n\t\t\tField field = c.getField(\"status_bar_height\");\n\t\t\tint x = Integer.parseInt(field.get(obj).toString());\n\t\t\treturn activity.getResources().getDimensionPixelSize(x);\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn 0;\n\t}\n\t/**\n\t * 用于扫描本地图片二维码或者一维码\n\t * @param photo_path2 本地图片的所在位置\n\t * @return\n\t */\n\tpublic  void scanningImage(final String photo_path2) {\n\t\tif(TextUtils.isEmpty(photo_path2)){\n\t\t\tlistener.scanError(new Exception(\"photo url is null!\"));\n\t\t}\n\t\tphotoScanHandler=new PhotoScanHandler(this);\n\t\tnew Thread(new Runnable() {\n\t\t\t\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\t//获取初始化的设置器\n\t\t\t\tMap<DecodeHintType, Object> hints = DecodeThread.getHints();\n\t\t\t\thints.put(DecodeHintType.CHARACTER_SET, \"utf-8\");\n\n//\t\t\t\tHashtable<DecodeHintType, String> hints = new Hashtable<DecodeHintType, String>();\n\n\t\t\t\tBitmap bitmap= BitmapUtil.decodeBitmapFromPath(photo_path2,600,600);\n\t\t\t\tRGBLuminanceSource source = new RGBLuminanceSource(bitmap);\n\t\t\t\tBinaryBitmap bitmap1 = new BinaryBitmap(new HybridBinarizer(source));\n\t\t\t\tQRCodeReader reader = new QRCodeReader();\n\t\t\t\tMultiFormatReader multiFormatReader=new MultiFormatReader();\n\t\t\t\ttry {\n\t\t\t\t\tMessage msg=Message.obtain();\n\t\t\t\t\tmsg.what=PhotoScanHandler.PHOTODECODEOK;\n\t\t\t\t\tmsg.obj = multiFormatReader.decode(bitmap1, hints);\n\t\t\t\t\tphotoScanHandler.sendMessage(msg);\n\t\t\t\t} catch (Exception e) {\n\t\t\t\t\tMessage msg=Message.obtain();\n\t\t\t\t\tmsg.what=PhotoScanHandler.PHOTODECODEERROR;\n\t\t\t\t\tmsg.obj=new Exception(\"图片有误，或者图片模糊！\");\n\t\t\t\t\tphotoScanHandler.sendMessage(msg);\n\t\t\t\t}\n\t\t\t}\n\t\t}).start();\n\t}\n\t/**\n\t * 扫描一次后，如需再次扫描，请调用这个方法\n\t */\n\tpublic void reScan(){\n\t\tif(handler!=null){\n\t\t\thandler.sendEmptyMessage(R.id.restart_preview);\n\t\t}\n\t}\n\tpublic boolean isScanning(){\n\t\tif(handler!=null){\n\t\t\treturn handler.isScanning();\n\t\t}\n\t\treturn false;\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/zxing/camera/AutoFocusManager.java",
    "content": "/*\n * Copyright (C) 2012 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.liang.scancode.zxing.camera;\n\nimport android.annotation.SuppressLint;\nimport android.content.Context;\nimport android.hardware.Camera;\nimport android.os.AsyncTask;\nimport android.os.Build;\nimport android.util.Log;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.concurrent.RejectedExecutionException;\n\npublic class AutoFocusManager implements Camera.AutoFocusCallback {\n\n\tstatic final String TAG = AutoFocusManager.class.getSimpleName();\n\n\tstatic final long AUTO_FOCUS_INTERVAL_MS = 2000L;\n\tstatic final Collection<String> FOCUS_MODES_CALLING_AF;\n\n\tstatic {\n\t\tFOCUS_MODES_CALLING_AF = new ArrayList<String>(2);\n\t\tFOCUS_MODES_CALLING_AF.add(Camera.Parameters.FOCUS_MODE_AUTO);\n\t\tFOCUS_MODES_CALLING_AF.add(Camera.Parameters.FOCUS_MODE_MACRO);\n\t}\n\n\tboolean stopped;\n\tboolean focusing;\n\tfinal boolean useAutoFocus;\n\tfinal Camera camera;\n\tAsyncTask<?, ?, ?> outstandingTask;\n\n\tpublic AutoFocusManager(Context context, Camera camera) {\n\t\tthis.camera = camera;\n\t\tString currentFocusMode = camera.getParameters().getFocusMode();\n\t\tuseAutoFocus = FOCUS_MODES_CALLING_AF.contains(currentFocusMode);\n\t\tLog.i(TAG, \"Current focus mode '\" + currentFocusMode + \"'; use auto focus? \" + useAutoFocus);\n\t\tstart();\n\t}\n\n\t@Override\n\tpublic synchronized void onAutoFocus(boolean success, Camera theCamera) {\n\t\tfocusing = false;\n\t\tautoFocusAgainLater();\n\t}\n\n\t@SuppressLint(\"NewApi\")\n\tsynchronized void autoFocusAgainLater() {\n\t\tif (!stopped && outstandingTask == null) {\n\t\t\tAutoFocusTask newTask = new AutoFocusTask();\n\t\t\ttry {\n\t\t\t\tif (Build.VERSION.SDK_INT >= 11) {\n\t\t\t\t\tnewTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);\n\t\t\t\t} else {\n\t\t\t\t\tnewTask.execute();\n\t\t\t\t}\n\t\t\t\toutstandingTask = newTask;\n\t\t\t} catch (RejectedExecutionException ree) {\n\t\t\t\tLog.w(TAG, \"Could not request auto focus\", ree);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic synchronized void start() {\n\t\tif (useAutoFocus) {\n\t\t\toutstandingTask = null;\n\t\t\tif (!stopped && !focusing) {\n\t\t\t\ttry {\n\t\t\t\t\tcamera.autoFocus(this);\n\t\t\t\t\tfocusing = true;\n\t\t\t\t} catch (RuntimeException re) {\n\t\t\t\t\t// Have heard RuntimeException reported in Android 4.0.x+;\n\t\t\t\t\t// continue?\n\t\t\t\t\tLog.w(TAG, \"Unexpected exception while focusing\", re);\n\t\t\t\t\t// Try again later to keep cycle going\n\t\t\t\t\tautoFocusAgainLater();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tsynchronized void cancelOutstandingTask() {\n\t\tif (outstandingTask != null) {\n\t\t\tif (outstandingTask.getStatus() != AsyncTask.Status.FINISHED) {\n\t\t\t\toutstandingTask.cancel(true);\n\t\t\t}\n\t\t\toutstandingTask = null;\n\t\t}\n\t}\n\n\tpublic synchronized void stop() {\n\t\tstopped = true;\n\t\tif (useAutoFocus) {\n\t\t\tcancelOutstandingTask();\n\t\t\t// Doesn't hurt to call this even if not focusing\n\t\t\ttry {\n\t\t\t\tcamera.cancelAutoFocus();\n\t\t\t} catch (RuntimeException re) {\n\t\t\t\t// Have heard RuntimeException reported in Android 4.0.x+;\n\t\t\t\t// continue?\n\t\t\t\tLog.w(TAG, \"Unexpected exception while cancelling focusing\", re);\n\t\t\t}\n\t\t}\n\t}\n\n\tfinal class AutoFocusTask extends AsyncTask<Object, Object, Object> {\n\t\t@Override\n\t\tprotected Object doInBackground(Object... voids) {\n\t\t\ttry {\n\t\t\t\tThread.sleep(AUTO_FOCUS_INTERVAL_MS);\n\t\t\t} catch (InterruptedException e) {\n\t\t\t\t// continue\n\t\t\t}\n\t\t\tstart();\n\t\t\treturn null;\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/zxing/camera/CameraConfigurationManager.java",
    "content": "/*\n * Copyright (C) 2008 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.liang.scancode.zxing.camera;\n\nimport android.annotation.SuppressLint;\nimport android.content.Context;\nimport android.graphics.Point;\nimport android.hardware.Camera;\nimport android.util.Log;\nimport android.view.Display;\nimport android.view.WindowManager;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.Iterator;\nimport java.util.List;\n\n/**\n * \n * 邮箱: 1076559197@qq.com | tauchen1990@gmail.com\n * \n * 作者: 陈涛\n * \n * 日期: 2014年8月20日\n * \n * 描述: 该类主要负责设置相机的参数信息，获取最佳的预览界面\n * \n */\npublic final class CameraConfigurationManager {\n\n\tstatic final String TAG = \"CameraConfiguration\";\n\n\tstatic final int MIN_PREVIEW_PIXELS = 480 * 320;\n\tstatic final double MAX_ASPECT_DISTORTION = 0.15;\n\n\tfinal Context context;\n\n\t// 屏幕分辨率\n\tPoint screenResolution;\n\t// 相机分辨率\n\tPoint cameraResolution;\n\n\tpublic CameraConfigurationManager(Context context) {\n\t\tthis.context = context;\n\t}\n\n\tpublic void initFromCameraParameters(Camera camera) {\n\t\tCamera.Parameters parameters = camera.getParameters();\n\t\tWindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);\n\t\tDisplay display = manager.getDefaultDisplay();\n\t\tPoint theScreenResolution = new Point();\n\t\ttheScreenResolution = getDisplaySize(display);\n\n\t\tscreenResolution = theScreenResolution;\n\t\tLog.i(TAG, \"Screen resolution: \" + screenResolution);\n\n\t\t/** 因为换成了竖屏显示，所以不替换屏幕宽高得出的预览图是变形的 */\n\t\tPoint screenResolutionForCamera = new Point();\n\t\tscreenResolutionForCamera.x = screenResolution.x;\n\t\tscreenResolutionForCamera.y = screenResolution.y;\n\n\t\tif (screenResolution.x < screenResolution.y) {\n\t\t\tscreenResolutionForCamera.x = screenResolution.y;\n\t\t\tscreenResolutionForCamera.y = screenResolution.x;\n\t\t}\n\n\t\tcameraResolution = findBestPreviewSizeValue(parameters, screenResolutionForCamera);\n\t\tLog.i(TAG, \"Camera resolution x: \" + cameraResolution.x);\n\t\tLog.i(TAG, \"Camera resolution y: \" + cameraResolution.y);\n\t}\n\n\t@SuppressWarnings(\"deprecation\")\n\t@SuppressLint(\"NewApi\")\n\tPoint getDisplaySize(final Display display) {\n\t\tfinal Point point = new Point();\n\t\ttry {\n\t\t\tdisplay.getSize(point);\n\t\t} catch (NoSuchMethodError ignore) {\n\t\t\tpoint.x = display.getWidth();\n\t\t\tpoint.y = display.getHeight();\n\t\t}\n\t\treturn point;\n\t}\n\n\tpublic void setDesiredCameraParameters(Camera camera, boolean safeMode) {\n\t\tCamera.Parameters parameters = camera.getParameters();\n\n\t\tif (parameters == null) {\n\t\t\tLog.w(TAG, \"Device error: no camera parameters are available. Proceeding without configuration.\");\n\t\t\treturn;\n\t\t}\n\n\t\tLog.i(TAG, \"Initial camera parameters: \" + parameters.flatten());\n\n\t\tif (safeMode) {\n\t\t\tLog.w(TAG, \"In camera config safe mode -- most settings will not be honored\");\n\t\t}\n\n\t\tparameters.setPreviewSize(cameraResolution.x, cameraResolution.y);\n\t\tcamera.setParameters(parameters);\n\n\t\tCamera.Parameters afterParameters = camera.getParameters();\n\t\tCamera.Size afterSize = afterParameters.getPreviewSize();\n\t\tif (afterSize != null && (cameraResolution.x != afterSize.width || cameraResolution.y != afterSize.height)) {\n\t\t\tLog.w(TAG, \"Camera said it supported preview size \" + cameraResolution.x + 'x' + cameraResolution.y + \", but after setting it, preview size is \" + afterSize.width + 'x' + afterSize.height);\n\t\t\tcameraResolution.x = afterSize.width;\n\t\t\tcameraResolution.y = afterSize.height;\n\t\t}\n\n\t\t/** 设置相机预览为竖屏 */\n\t\tcamera.setDisplayOrientation(90);\n\t}\n\n\tpublic Point getCameraResolution() {\n\t\treturn cameraResolution;\n\t}\n\n\tpublic Point getScreenResolution() {\n\t\treturn screenResolution;\n\t}\n\n\t/**\n\t * 从相机支持的分辨率中计算出最适合的预览界面尺寸\n\t * \n\t * @param parameters\n\t * @param screenResolution\n\t * @return\n\t */\n\tPoint findBestPreviewSizeValue(Camera.Parameters parameters, Point screenResolution) {\n\t\tList<Camera.Size> rawSupportedSizes = parameters.getSupportedPreviewSizes();\n\t\tif (rawSupportedSizes == null) {\n\t\t\tLog.w(TAG, \"Device returned no supported preview sizes; using default\");\n\t\t\tCamera.Size defaultSize = parameters.getPreviewSize();\n\t\t\treturn new Point(defaultSize.width, defaultSize.height);\n\t\t}\n\n\t\t// Sort by size, descending\n\t\tList<Camera.Size> supportedPreviewSizes = new ArrayList<Camera.Size>(rawSupportedSizes);\n\t\tCollections.sort(supportedPreviewSizes, new Comparator<Camera.Size>() {\n\t\t\t@Override\n\t\t\tpublic int compare(Camera.Size a, Camera.Size b) {\n\t\t\t\tint aPixels = a.height * a.width;\n\t\t\t\tint bPixels = b.height * b.width;\n\t\t\t\tif (bPixels < aPixels) {\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t\tif (bPixels > aPixels) {\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t});\n\n\t\tif (Log.isLoggable(TAG, Log.INFO)) {\n\t\t\tStringBuilder previewSizesString = new StringBuilder();\n\t\t\tfor (Camera.Size supportedPreviewSize : supportedPreviewSizes) {\n\t\t\t\tpreviewSizesString.append(supportedPreviewSize.width).append('x').append(supportedPreviewSize.height).append(' ');\n\t\t\t}\n\t\t\tLog.i(TAG, \"Supported preview sizes: \" + previewSizesString);\n\t\t}\n\n\t\tdouble screenAspectRatio = (double) screenResolution.x / (double) screenResolution.y;\n\n\t\t// Remove sizes that are unsuitable\n\t\tIterator<Camera.Size> it = supportedPreviewSizes.iterator();\n\t\twhile (it.hasNext()) {\n\t\t\tCamera.Size supportedPreviewSize = it.next();\n\t\t\tint realWidth = supportedPreviewSize.width;\n\t\t\tint realHeight = supportedPreviewSize.height;\n\t\t\tif (realWidth * realHeight < MIN_PREVIEW_PIXELS) {\n\t\t\t\tit.remove();\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tboolean isCandidatePortrait = realWidth < realHeight;\n\t\t\tint maybeFlippedWidth = isCandidatePortrait ? realHeight : realWidth;\n\t\t\tint maybeFlippedHeight = isCandidatePortrait ? realWidth : realHeight;\n\n\t\t\tdouble aspectRatio = (double) maybeFlippedWidth / (double) maybeFlippedHeight;\n\t\t\tdouble distortion = Math.abs(aspectRatio - screenAspectRatio);\n\t\t\tif (distortion > MAX_ASPECT_DISTORTION) {\n\t\t\t\tit.remove();\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (maybeFlippedWidth == screenResolution.x && maybeFlippedHeight == screenResolution.y) {\n\t\t\t\tPoint exactPoint = new Point(realWidth, realHeight);\n\t\t\t\tLog.i(TAG, \"Found preview size exactly matching screen size: \" + exactPoint);\n\t\t\t\treturn exactPoint;\n\t\t\t}\n\t\t}\n\n\t\t// If no exact match, use largest preview size. This was not a great\n\t\t// idea on older devices because\n\t\t// of the additional computation needed. We're likely to get here on\n\t\t// newer Android 4+ devices, where\n\t\t// the CPU is much more powerful.\n\t\tif (!supportedPreviewSizes.isEmpty()) {\n\t\t\tCamera.Size largestPreview = supportedPreviewSizes.get(0);\n\t\t\tPoint largestSize = new Point(largestPreview.width, largestPreview.height);\n\t\t\tLog.i(TAG, \"Using largest suitable preview size: \" + largestSize);\n\t\t\treturn largestSize;\n\t\t}\n\n\t\t// If there is nothing at shouquan_ic_all suitable, return current preview size\n\t\tCamera.Size defaultPreview = parameters.getPreviewSize();\n\t\tPoint defaultSize = new Point(defaultPreview.width, defaultPreview.height);\n\t\tLog.i(TAG, \"No suitable preview sizes, using default: \" + defaultSize);\n\n\t\treturn defaultSize;\n\t}\n}\n"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/zxing/camera/CameraManager.java",
    "content": "/*\n * Copyright (C) 2008 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.liang.scancode.zxing.camera;\n\nimport android.content.Context;\nimport android.graphics.Point;\nimport android.hardware.Camera;\nimport android.hardware.Camera.Parameters;\nimport android.hardware.Camera.Size;\nimport android.os.Handler;\nimport android.util.Log;\nimport android.view.SurfaceHolder;\n\nimport java.io.IOException;\n\nimport com.liang.scancode.zxing.camera.open.OpenCameraInterface;\n\n/**\n * This object wraps the Camera service object and expects to be the only one\n * talking to it. The implementation encapsulates the steps needed to take\n * preview-sized images, which are used for both preview and decoding.\n * \n * @author dswitkin@google.com (Daniel Switkin)\n */\npublic class CameraManager {\n\n\tstatic final String TAG = CameraManager.class.getSimpleName();\n\n\tfinal Context context;\n\tfinal CameraConfigurationManager configManager;\n\tCamera camera;\n\tAutoFocusManager autoFocusManager;\n\n\tboolean initialized;\n\tboolean previewing;\n\t\n\t\n\t\n\tint requestedCameraId = -1;\n\t/**\n\t * Preview frames are delivered here, which we pass on to the registered\n\t * handler. Make sure to clear the handler so it will only receive one\n\t * message.\n\t */\n\tfinal PreviewCallback previewCallback;\n\n\tpublic CameraManager(Context context) {\n\t\tthis.context = context;\n\t\tthis.configManager = new CameraConfigurationManager(context);\n\t\tpreviewCallback = new PreviewCallback(configManager);\n\t}\n\n\t/**\n\t * Opens the camera driver and initializes the hardware parameters.\n\t * \n\t * @param holder\n\t *            The surface object which the camera will draw preview frames\n\t *            into.\n\t * @throws IOException\n\t *             Indicates the camera driver failed to open.\n\t */\n\tpublic synchronized void openDriver(SurfaceHolder holder) throws IOException {\n\t\tCamera theCamera = camera;\n\t\tif (theCamera == null) {\n\n\t\t\tif (requestedCameraId >= 0) {\n\t\t\t\ttheCamera = OpenCameraInterface.open(requestedCameraId);\n\t\t\t} else {\n\t\t\t\ttheCamera = OpenCameraInterface.open();\n\t\t\t}\n\n\t\t\tif (theCamera == null) {\n\t\t\t\tthrow new IOException();\n\t\t\t}\n\t\t\tcamera = theCamera;\n\t\t}\n\t\ttheCamera.setPreviewDisplay(holder);\n\n\t\tif (!initialized) {\n\t\t\tinitialized = true;\n\t\t\tconfigManager.initFromCameraParameters(theCamera);\n\t\t}\n\n\t\tParameters parameters = theCamera.getParameters();\n\t\tString parametersFlattened = parameters == null ? null : parameters.flatten(); // Save\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// these,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// temporarily\n\t\ttry {\n\t\t\tconfigManager.setDesiredCameraParameters(theCamera, false);\n\t\t} catch (RuntimeException re) {\n\t\t\t// Driver failed\n\t\t\tLog.w(TAG, \"Camera rejected parameters. Setting only minimal safe-mode parameters\");\n\t\t\tLog.i(TAG, \"Resetting to saved camera params: \" + parametersFlattened);\n\t\t\t// Reset:\n\t\t\tif (parametersFlattened != null) {\n\t\t\t\tparameters = theCamera.getParameters();\n\t\t\t\tparameters.unflatten(parametersFlattened);\n\t\t\t\ttry {\n\t\t\t\t\ttheCamera.setParameters(parameters);\n\t\t\t\t\tconfigManager.setDesiredCameraParameters(theCamera, true);\n\t\t\t\t} catch (RuntimeException re2) {\n\t\t\t\t\t// Well, darn. Give up\n\t\t\t\t\tLog.w(TAG, \"Camera rejected even safe-mode parameters! No configuration\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\tpublic synchronized boolean isOpen() {\n\t\treturn camera != null;\n\t}\n\n\t/**\n\t * Closes the camera driver if still in use.\n\t */\n\tpublic synchronized void closeDriver() {\n\t\tif (camera != null) {\n\t\t\tcamera.release();\n\t\t\tcamera = null;\n\t\t\t// Make sure to clear these each time we close the camera, so that\n\t\t\t// any scanning rect\n\t\t\t// requested by intent is forgotten.\n\t\t}\n\t}\n\n\t/**\n\t * Asks the camera hardware to begin drawing preview frames to the screen.\n\t */\n\tpublic synchronized void startPreview() {\n\t\tCamera theCamera = camera;\n\t\tif (theCamera != null && !previewing) {\n\t\t\ttheCamera.startPreview();\n\t\t\tpreviewing = true;\n\t\t\tautoFocusManager = new AutoFocusManager(context, camera);\n\t\t}\n\t}\n\n\t/**\n\t * Tells the camera to stop drawing preview frames.\n\t */\n\tpublic synchronized void stopPreview() {\n\t\tif (autoFocusManager != null) {\n\t\t\tautoFocusManager.stop();\n\t\t\tautoFocusManager = null;\n\t\t}\n\t\tif (camera != null && previewing) {\n\t\t\tcamera.stopPreview();\n\t\t\tpreviewCallback.setHandler(null, 0);\n\t\t\tpreviewing = false;\n\t\t}\n\t}\n\n\t/**\n\t * A single preview frame will be returned to the handler supplied. The data\n\t * will arrive as byte[] in the message.obj field, with width and height\n\t * encoded as message.arg1 and message.arg2, respectively.\n\t * \n\t * @param handler\n\t *            The handler to send the message to.\n\t * @param message\n\t *            The what field of the message to be sent.\n\t */\n\tpublic synchronized void requestPreviewFrame(Handler handler, int message) {\n\t\tCamera theCamera = camera;\n\t\tif (theCamera != null && previewing) {\n\t\t\tpreviewCallback.setHandler(handler, message);\n\t\t\ttheCamera.setOneShotPreviewCallback(previewCallback);\n\t\t}\n\t}\n\n\t/**\n\t * Allows third party apps to specify the camera ID, rather than determine\n\t * it automatically based on available cameras and their orientation.\n\t * \n\t * @param cameraId\n\t *            camera ID of the camera to use. A negative value means\n\t *            \"no preference\".\n\t */\n\tpublic synchronized void setManualCameraId(int cameraId) {\n\t\trequestedCameraId = cameraId;\n\t}\n\n\t/**\n\t * 获取相机分辨率\n\t * \n\t * @return\n\t */\n\tpublic Point getCameraResolution() {\n\t\treturn configManager.getCameraResolution();\n\t}\n\n\tpublic Size getPreviewSize() {\n\t\tif (null != camera) {\n\t\t\treturn camera.getParameters().getPreviewSize();\n\t\t}\n\t\treturn null;\n\t}\n\t\n\t/**\n\t * 打开闪光灯\n\t */\n\tpublic void openLight() {\n\t\tif (camera != null) {\n\t\t\tParameters parameter = camera.getParameters();\n\t\t\tparameter.setFlashMode(Parameters.FLASH_MODE_TORCH);\n\t\t\tcamera.setParameters(parameter);\n\t\t}\n\t}\n\t/**\n\t * 关闭闪光灯\n\t */\n\tpublic void offLight() {\n\t\tif (camera != null) {\n\t\t\tParameters parameter = camera.getParameters();\n\t\t\tparameter.setFlashMode(Parameters.FLASH_MODE_OFF);\n\t\t\tcamera.setParameters(parameter);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/zxing/camera/PreviewCallback.java",
    "content": "/*\n * Copyright (C) 2010 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.liang.scancode.zxing.camera;\n\nimport android.graphics.Point;\nimport android.hardware.Camera;\nimport android.os.Handler;\nimport android.os.Message;\nimport android.util.Log;\n\npublic class PreviewCallback implements Camera.PreviewCallback {\n\n\tstatic final String TAG = PreviewCallback.class.getSimpleName();\n\n\tfinal CameraConfigurationManager configManager;\n\tHandler previewHandler;\n\tint previewMessage;\n\n\tpublic PreviewCallback(CameraConfigurationManager configManager) {\n\t\tthis.configManager = configManager;\n\t}\n\n\tpublic void setHandler(Handler previewHandler, int previewMessage) {\n\t\tthis.previewHandler = previewHandler;\n\t\tthis.previewMessage = previewMessage;\n\t}\n\n\t@Override\n\tpublic void onPreviewFrame(byte[] data, Camera camera) {\n\t\tPoint cameraResolution = configManager.getCameraResolution();\n\t\tHandler thePreviewHandler = previewHandler;\n\t\tif (cameraResolution != null && thePreviewHandler != null) {\n\t\t\tMessage message = thePreviewHandler.obtainMessage(previewMessage, cameraResolution.x, cameraResolution.y, data);\n\t\t\tmessage.sendToTarget();\n\t\t\tpreviewHandler = null;\n\t\t} else {\n\t\t\tLog.d(TAG, \"Got preview callback, but no handler or resolution available\");\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/zxing/camera/open/OpenCameraInterface.java",
    "content": "/*\n * Copyright (C) 2012 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.liang.scancode.zxing.camera.open;\n\nimport android.hardware.Camera;\nimport android.util.Log;\n\npublic class OpenCameraInterface {\n\n\tstatic final String TAG = OpenCameraInterface.class.getName();\n\n\t/**\n\t * Opens the requested camera with {@link Camera#open(int)}, if one exists.\n\t * \n\t * @param cameraId\n\t *            camera ID of the camera to use. A negative value means\n\t *            \"no preference\"\n\t * @return handle to {@link Camera} that was opened\n\t */\n\tpublic static Camera open(int cameraId) {\n\n\t\tint numCameras = Camera.getNumberOfCameras();\n\t\tif (numCameras == 0) {\n\t\t\tLog.w(TAG, \"No cameras!\");\n\t\t\treturn null;\n\t\t}\n\n\t\tboolean explicitRequest = cameraId >= 0;\n\n\t\tif (!explicitRequest) {\n\t\t\t// Select a camera if no explicit camera requested\n\t\t\tint index = 0;\n\t\t\twhile (index < numCameras) {\n\t\t\t\tCamera.CameraInfo cameraInfo = new Camera.CameraInfo();\n\t\t\t\tCamera.getCameraInfo(index, cameraInfo);\n\t\t\t\tif (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t}\n\n\t\t\tcameraId = index;\n\t\t}\n\n\t\tCamera camera;\n\t\tif (cameraId < numCameras) {\n\t\t\tLog.i(TAG, \"Opening camera #\" + cameraId);\n\t\t\tcamera = Camera.open(cameraId);\n\t\t} else {\n\t\t\tif (explicitRequest) {\n\t\t\t\tLog.w(TAG, \"Requested camera does not exist: \" + cameraId);\n\t\t\t\tcamera = null;\n\t\t\t} else {\n\t\t\t\tLog.i(TAG, \"No camera facing back; returning camera #0\");\n\t\t\t\tcamera = Camera.open(0);\n\t\t\t}\n\t\t}\n\n\t\treturn camera;\n\t}\n\n\t/**\n\t * Opens a rear-facing camera with {@link Camera#open(int)}, if one exists,\n\t * or opens camera 0.\n\t * \n\t * @return handle to {@link Camera} that was opened\n\t */\n\tpublic static Camera open() {\n\t\treturn open(-1);\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/zxing/decode/DecodeFormatManager.java",
    "content": "/*\n * Copyright (C) 2010 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.liang.scancode.zxing.decode;\n\nimport com.google.zxing.BarcodeFormat;\n\nimport java.util.Collection;\nimport java.util.EnumSet;\nimport java.util.Set;\n\npublic class DecodeFormatManager {\n\n\t// 1D解码\n\tstatic final Set<BarcodeFormat> PRODUCT_FORMATS;\n\tstatic final Set<BarcodeFormat> INDUSTRIAL_FORMATS;\n\tstatic final Set<BarcodeFormat> ONE_D_FORMATS;\n\n\t// 二维码解码\n\tstatic final Set<BarcodeFormat> QR_CODE_FORMATS;\n\n\tstatic {\n\t\tPRODUCT_FORMATS = EnumSet.of(BarcodeFormat.UPC_A, BarcodeFormat.UPC_E, BarcodeFormat.EAN_13, BarcodeFormat.EAN_8, BarcodeFormat.RSS_14, BarcodeFormat.RSS_EXPANDED);\n\t\tINDUSTRIAL_FORMATS = EnumSet.of(BarcodeFormat.CODE_39, BarcodeFormat.CODE_93, BarcodeFormat.CODE_128, BarcodeFormat.ITF, BarcodeFormat.CODABAR);\n\t\tONE_D_FORMATS = EnumSet.copyOf(PRODUCT_FORMATS);\n\t\tONE_D_FORMATS.addAll(INDUSTRIAL_FORMATS);\n\n\t\tQR_CODE_FORMATS = EnumSet.of(BarcodeFormat.QR_CODE);\n\t}\n\n\tpublic static Collection<BarcodeFormat> getQrCodeFormats() {\n\t\treturn QR_CODE_FORMATS;\n\t}\n\n\tpublic static Collection<BarcodeFormat> getBarCodeFormats() {\n\t\treturn ONE_D_FORMATS;\n\t}\n}\n"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/zxing/decode/DecodeHandler.java",
    "content": "/*\n * Copyright (C) 2010 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.liang.scancode.zxing.decode;\n\nimport android.graphics.Bitmap;\nimport android.graphics.Rect;\nimport android.hardware.Camera.Size;\nimport android.os.Bundle;\nimport android.os.Handler;\nimport android.os.Looper;\nimport android.os.Message;\n\nimport com.google.zxing.BinaryBitmap;\nimport com.google.zxing.DecodeHintType;\nimport com.google.zxing.MultiFormatReader;\nimport com.google.zxing.PlanarYUVLuminanceSource;\nimport com.google.zxing.ReaderException;\nimport com.google.zxing.Result;\nimport com.google.zxing.common.HybridBinarizer;\nimport com.liang.scancode.R;\nimport com.liang.scancode.zxing.ScanManager;\n\nimport java.io.ByteArrayOutputStream;\nimport java.util.Map;\n\npublic class DecodeHandler extends Handler {\n\n\tfinal ScanManager scanManager;\n\tfinal MultiFormatReader multiFormatReader;\n\tboolean running = true;\n\n\tpublic DecodeHandler(ScanManager scanManager, Map<DecodeHintType, Object> hints) {\n\t\tmultiFormatReader = new MultiFormatReader();\n\t\tmultiFormatReader.setHints(hints);\n\t\tthis.scanManager = scanManager;\n\t}\n\n\t@Override\n\tpublic void handleMessage(Message message) {\n\t\tif (!running) {\n\t\t\treturn;\n\t\t}\n\t\tswitch (message.what) {\n\t\tcase R.id.decode:\n\t\t\tdecode((byte[]) message.obj, message.arg1, message.arg2);\n\t\t\tbreak;\n\t\tcase R.id.quit:\n\t\t\trunning = false;\n\t\t\tLooper.myLooper().quit();\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t/**\n\t * Decode the data within the viewfinder rectangle, and time how long it\n\t * took. For efficiency, reuse the same reader objects from one decode to\n\t * the next.\n\t * \n\t * @param data\n\t *            The YUV preview frame.\n\t * @param width\n\t *            The width of the preview frame.\n\t * @param height\n\t *            The height of the preview frame.\n\t */\n\tvoid decode(byte[] data, int width, int height) {\n\t\tSize size = scanManager.getCameraManager().getPreviewSize();\n\n\t\t// 这里需要将获取的data翻转一下，因为相机默认拿的的横屏的数据\n\t\tbyte[] rotatedData = new byte[data.length];\n\t\tfor (int y = 0; y < size.height; y++) {\n\t\t\tfor (int x = 0; x < size.width; x++)\n\t\t\t\trotatedData[x * size.height + size.height - y - 1] = data[x + y * size.width];\n\t\t}\n\n\t\t// 宽高也要调整\n\t\tint tmp = size.width;\n\t\tsize.width = size.height;\n\t\tsize.height = tmp;\n\n\t\tResult rawResult = null;\n\t\tPlanarYUVLuminanceSource source = buildLuminanceSource(rotatedData, size.width, size.height);\n\t\tif (source != null) {\n\t\t\tBinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));\n\t\t\ttry {\n\t\t\t\trawResult = multiFormatReader.decodeWithState(bitmap);\n\t\t\t} catch (ReaderException re) {\n\t\t\t\t// continue\n\t\t\t} finally {\n\t\t\t\tmultiFormatReader.reset();\n\t\t\t}\n\t\t}\n\n\t\tHandler handler = scanManager.getHandler();\n\t\tif (rawResult != null) {\n\t\t\t// Don't log the barcode contents for security.\n\t\t\tif (handler != null) {\n\t\t\t\tMessage message = Message.obtain(handler, R.id.decode_succeeded, rawResult);\n\t\t\t\tBundle bundle = new Bundle();\n\t\t\t\tbundleThumbnail(source, bundle);\n\t\t\t\tmessage.setData(bundle);\n\t\t\t\tmessage.sendToTarget();\n\t\t\t}\n\t\t} else {\n\t\t\tif (handler != null) {\n\t\t\t\tMessage message = Message.obtain(handler, R.id.decode_failed);\n\t\t\t\tmessage.sendToTarget();\n\t\t\t}\n\t\t}\n\n\t}\n\n\tstatic void bundleThumbnail(PlanarYUVLuminanceSource source, Bundle bundle) {\n\t\tint[] pixels = source.renderThumbnail();\n\t\tint width = source.getThumbnailWidth();\n\t\tint height = source.getThumbnailHeight();\n\t\tBitmap bitmap = Bitmap.createBitmap(pixels, 0, width, width, height, Bitmap.Config.ARGB_8888);\n\t\tByteArrayOutputStream out = new ByteArrayOutputStream();\n\t\tbitmap.compress(Bitmap.CompressFormat.JPEG, 50, out);\n\t\tbundle.putByteArray(DecodeThread.BARCODE_BITMAP, out.toByteArray());\n\t}\n\n\t/**\n\t * A factory method to build the appropriate LuminanceSource object based on\n\t * the format of the preview buffers, as described by Camera.Parameters.\n\t * \n\t * @param data\n\t *            A preview frame.\n\t * @param width\n\t *            The width of the image.\n\t * @param height\n\t *            The height of the image.\n\t * @return A PlanarYUVLuminanceSource instance.\n\t */\n\tpublic PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int height) {\n\t\tRect rect = scanManager.getCropRect();\n\t\tif (rect == null) {\n\t\t\treturn null;\n\t\t}\n\t\t// Go ahead and assume it's YUV rather than die.\n\t\treturn new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top, rect.width(), rect.height(), false);\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/zxing/decode/DecodeThread.java",
    "content": "/*\n * Copyright (C) 2008 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.liang.scancode.zxing.decode;\n\nimport android.os.Handler;\nimport android.os.Looper;\n\nimport com.google.zxing.BarcodeFormat;\nimport com.google.zxing.DecodeHintType;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.EnumMap;\nimport java.util.EnumSet;\nimport java.util.Map;\nimport java.util.concurrent.CountDownLatch;\n\nimport com.liang.scancode.zxing.ScanManager;\n\n/**\n * This thread does shouquan_ic_all the heavy lifting of decoding the images.\n * \n * @author dswitkin@google.com (Daniel Switkin)\n */\npublic class DecodeThread extends Thread {\n\n\tpublic static final String BARCODE_BITMAP = \"barcode_bitmap\";\n\n\tpublic static final int BARCODE_MODE = 0X100;\n\tpublic static final int QRCODE_MODE = 0X200;\n\tpublic static final int ALL_MODE = 0X300;\n\n\tfinal ScanManager scanManager;\n\tstatic  Map<DecodeHintType, Object> hints;\n\tHandler handler;\n\tfinal CountDownLatch handlerInitLatch;\n\n\tpublic DecodeThread(ScanManager scanManager, int decodeMode) {\n\n\t\tthis.scanManager = scanManager;\n\t\thandlerInitLatch = new CountDownLatch(1);\n\n\t\thints = new EnumMap<DecodeHintType, Object>(DecodeHintType.class);\n\n\t\tCollection<BarcodeFormat> decodeFormats = new ArrayList<BarcodeFormat>();\n\t\tdecodeFormats.addAll(EnumSet.of(BarcodeFormat.AZTEC));\n\t\tdecodeFormats.addAll(EnumSet.of(BarcodeFormat.PDF_417));\n\n\t\tswitch (decodeMode) {\n\t\tcase BARCODE_MODE:\n\t\t\tdecodeFormats.addAll(DecodeFormatManager.getBarCodeFormats());\n\t\t\tbreak;\n\n\t\tcase QRCODE_MODE:\n\t\t\tdecodeFormats.addAll(DecodeFormatManager.getQrCodeFormats());\n\t\t\tbreak;\n\n\t\tcase ALL_MODE:\n\t\t\tdecodeFormats.addAll(DecodeFormatManager.getBarCodeFormats());\n\t\t\tdecodeFormats.addAll(DecodeFormatManager.getQrCodeFormats());\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\n\t\thints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);\n\t}\n\n\tpublic Handler getHandler() {\n\t\ttry {\n\t\t\thandlerInitLatch.await();\n\t\t} catch (InterruptedException ie) {\n\t\t\t// continue?\n\t\t}\n\t\treturn handler;\n\t}\n\n\t@Override\n\tpublic void run() {\n\t\tLooper.prepare();\n\t\thandler = new DecodeHandler(scanManager, hints);\n\t\thandlerInitLatch.countDown();\n\t\tLooper.loop();\n\t}\n\n\tpublic static Map<DecodeHintType, Object> getHints() {\n\t\treturn hints;\n\t}\n}\n"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/zxing/decode/PhotoScanHandler.java",
    "content": "package com.liang.scancode.zxing.decode;\n\nimport android.os.Bundle;\nimport android.os.Handler;\nimport android.os.Message;\n\nimport com.google.zxing.Result;\n\nimport com.liang.scancode.zxing.ScanManager;\n\npublic class PhotoScanHandler extends Handler{\n\tpublic final static int PHOTODECODEERROR=0;\n\tpublic final static int PHOTODECODEOK=1;\n\tScanManager scanManager;\n\tpublic PhotoScanHandler(ScanManager scanManager) {\n\t\tthis.scanManager=scanManager;\n\t}\n\t@Override\n\tpublic void handleMessage(Message message) {\n\t\t\n\t\tswitch (message.what) {\n\t\tcase PHOTODECODEERROR:\n\t\t\tscanManager.handleDecodeError((Exception)message.obj);\n\t\t\tbreak;\n\t\tcase PHOTODECODEOK:\n\t\t\tBundle bundle = message.getData();\n\t\t\tscanManager.handleDecode((Result) message.obj, bundle);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}\n\t\n}\n"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/zxing/decode/RGBLuminanceSource.java",
    "content": "package com.liang.scancode.zxing.decode;\n\n/*\n * Copyright 2009 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nimport android.graphics.Bitmap;\nimport android.graphics.BitmapFactory;\n\nimport com.google.zxing.LuminanceSource;\n\nimport java.io.FileNotFoundException;\n\n/**\n * This class is used to help decode images from files which arrive as RGB data\n * from Android bitmaps. It does not support cropping or rotation.\n * \n * @author dswitkin@google.com (Daniel Switkin)\n */\npublic final class RGBLuminanceSource extends LuminanceSource {\n\tfinal byte[] luminances;\n\n\tpublic RGBLuminanceSource(String path) throws FileNotFoundException {\n\t\tthis(loadBitmap(path));\n\t}\n\n\tpublic RGBLuminanceSource(Bitmap bitmap) {\n\t\tsuper(bitmap.getWidth(), bitmap.getHeight());\n\t\tint width = bitmap.getWidth();\n\t\tint height = bitmap.getHeight();\n\t\tint[] pixels = new int[width * height];\n\t\tbitmap.getPixels(pixels, 0, width, 0, 0, width, height);\n\t\t// In order to measure pure decoding speed, we convert the entire image\n\t\t// to a greyscale array\n\t\t// up front, which is the same as the Y channel of the\n\t\t// YUVLuminanceSource in the real app.\n\t\tluminances = new byte[width * height];\n\t\tfor (int y = 0; y < height; y++) {\n\t\t\tint offset = y * width;\n\t\t\tfor (int x = 0; x < width; x++) {\n\t\t\t\tint pixel = pixels[offset + x];\n\t\t\t\tint r = (pixel >> 16) & 0xff;\n\t\t\t\tint g = (pixel >> 8) & 0xff;\n\t\t\t\tint b = pixel & 0xff;\n\t\t\t\tif (r == g && g == b) {\n\t\t\t\t\t// Image is already greyscale, so pick any channel.\n\t\t\t\t\tluminances[offset + x] = (byte) r;\n\t\t\t\t} else {\n\t\t\t\t\t// Calculate luminance cheaply, favoring green.\n\t\t\t\t\tluminances[offset + x] = (byte) ((r + g + g + b) >> 2);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic byte[] getRow(int y, byte[] row) {\n\t\tif (y < 0 || y >= getHeight()) {\n\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\"Requested row is outside the image: \" + y);\n\t\t}\n\t\tint width = getWidth();\n\t\tif (row == null || row.length < width) {\n\t\t\trow = new byte[width];\n\t\t}\n\t\tSystem.arraycopy(luminances, y * width, row, 0, width);\n\t\treturn row;\n\t}\n\n\t// Since this class does not support cropping, the underlying byte array\n\t// already contains\n\t// exactly what the caller is asking for, so give it to them without a copy.\n\t@Override\n\tpublic byte[] getMatrix() {\n\t\treturn luminances;\n\t}\n\n\tstatic Bitmap loadBitmap(String path) throws FileNotFoundException {\n\t\tBitmap bitmap = BitmapFactory.decodeFile(path);\n\t\tif (bitmap == null) {\n\t\t\tthrow new FileNotFoundException(\"Couldn't open \" + path);\n\t\t}\n\t\treturn bitmap;\n\t}\n}"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/zxing/decode/Utils.java",
    "content": "package com.liang.scancode.zxing.decode;\n\nimport android.annotation.SuppressLint;\nimport android.content.ContentUris;\nimport android.content.Context;\nimport android.database.Cursor;\nimport android.graphics.Bitmap;\nimport android.graphics.Matrix;\nimport android.media.ExifInterface;\nimport android.net.Uri;\nimport android.os.Build;\nimport android.os.Environment;\nimport android.provider.DocumentsContract;\nimport android.provider.MediaStore;\n\nimport java.io.IOException;\n\npublic class Utils {\n    @SuppressLint(\"NewApi\")\n    public static String getPath(final Context context, final Uri uri) {\n\n        final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;\n\n        // DocumentProvider  \n        if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {\n            // ExternalStorageProvider  \n            if (isExternalStorageDocument(uri)) {\n                final String docId = DocumentsContract.getDocumentId(uri);\n                final String[] split = docId.split(\":\");\n                final String type = split[0];\n\n                if (\"primary\".equalsIgnoreCase(type)) {\n                    return Environment.getExternalStorageDirectory() + \"/\"\n                            + split[1];\n                }\n                // TODO handle non-primary volumes  \n            }\n            // DownloadsProvider  \n            else if (isDownloadsDocument(uri)) {\n\n                final String id = DocumentsContract.getDocumentId(uri);\n                final Uri contentUri = ContentUris.withAppendedId(\n                        Uri.parse(\"content://downloads/public_downloads\"),\n                        Long.valueOf(id));\n\n                return getDataColumn(context, contentUri, null, null);\n            }\n            // MediaProvider  \n            else if (isMediaDocument(uri)) {\n                final String docId = DocumentsContract.getDocumentId(uri);\n                final String[] split = docId.split(\":\");\n                final String type = split[0];\n\n                Uri contentUri = null;\n                if (\"image\".equals(type)) {\n                    contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;\n                } else if (\"video\".equals(type)) {\n                    contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;\n                } else if (\"audio\".equals(type)) {\n                    contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;\n                }\n\n                final String selection = \"_id=?\";\n                final String[] selectionArgs = new String[]{split[1]};\n\n                return getDataColumn(context, contentUri, selection,\n                        selectionArgs);\n            }\n        }\n        // MediaStore (and general)  \n        else if (\"content\".equalsIgnoreCase(uri.getScheme())) {\n            return getDataColumn(context, uri, null, null);\n        }\n        // File  \n        else if (\"file\".equalsIgnoreCase(uri.getScheme())) {\n            return uri.getPath();\n        }\n\n        return null;\n    }\n\n    public static String getDataColumn(Context context, Uri uri,\n                                       String selection, String[] selectionArgs) {\n\n        Cursor cursor = null;\n        final String column = \"_data\";\n        final String[] projection = {column};\n\n        try {\n            cursor = context.getContentResolver().query(uri, projection,\n                    selection, selectionArgs, null);\n            if (cursor != null && cursor.moveToFirst()) {\n                final int column_index = cursor.getColumnIndexOrThrow(column);\n                return cursor.getString(column_index);\n            }\n        } finally {\n            if (cursor != null)\n                cursor.close();\n        }\n        return null;\n    }\n\n    public static boolean isExternalStorageDocument(Uri uri) {\n        return \"com.android.externalstorage.documents\".equals(uri\n                .getAuthority());\n    }\n\n    public static boolean isDownloadsDocument(Uri uri) {\n        return \"com.android.providers.downloads.documents\".equals(uri\n                .getAuthority());\n    }\n\n    public static boolean isMediaDocument(Uri uri) {\n        return \"com.android.providers.media.documents\".equals(uri\n                .getAuthority());\n    }\n    /**\n     * 读取图片属性：旋转的角度\n     * @param path 图片绝对路径\n     * @return degree旋转的角度\n     */\n    public static int readPictureDegree(String path) {\n        int degree  = 0;\n        try {\n            ExifInterface exifInterface = new ExifInterface(path);\n            int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);\n            switch (orientation) {\n                case ExifInterface.ORIENTATION_ROTATE_90:\n                    degree = 90;\n                    break;\n                case ExifInterface.ORIENTATION_ROTATE_180:\n                    degree = 180;\n                    break;\n                case ExifInterface.ORIENTATION_ROTATE_270:\n                    degree = 270;\n                    break;\n            }\n        } catch (IOException e) {\n            e.printStackTrace();\n        }\n        return degree;\n    }\n    /*\n     * 旋转图片\n     * @param angle\n     * @param bitmap\n     * @return Bitmap\n     */\n    public static Bitmap rotaingImageView(int angle , Bitmap bitmap) {\n        //旋转图片 动作\n        Matrix matrix = new Matrix();;\n        matrix.postRotate(angle);\n        System.out.println(\"angle2=\" + angle);\n        // 创建新的图片\n        Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0,\n                bitmap.getWidth(), bitmap.getHeight(), matrix, true);\n        return resizedBitmap;\n    }\n}\n"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/zxing/encode/EncodingHandler.java",
    "content": "package com.liang.scancode.zxing.encode;\n\nimport android.graphics.Bitmap;\nimport android.util.Log;\n\nimport com.google.zxing.BarcodeFormat;\nimport com.google.zxing.EncodeHintType;\nimport com.google.zxing.MultiFormatWriter;\nimport com.google.zxing.WriterException;\nimport com.google.zxing.common.BitMatrix;\nimport com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;\n\nimport java.io.UnsupportedEncodingException;\nimport java.util.Hashtable;\n\n/**\n * @author 刘红亮  2015年4月29日  下午3:27:08\n *         用于生成二维码\n */\npublic final class EncodingHandler {\n    static final int BLACK = 0xff000000;\n    static final int WHITE = 0xFFFFFFFF;\n    /**\n     * 生成二维码图片\n     *\n     * @param str            要往二维码中写入的内容,需要utf-8格式\n     * @param widthAndHeight 图片的宽高，正方形\n     * @return 返回一个二维码bitmap\n     * @throws WriterException\n     * @throws UnsupportedEncodingException\n     */\n    public static Bitmap create2Code(String str, int widthAndHeight) throws WriterException, UnsupportedEncodingException {\n        BitMatrix matrix = new MultiFormatWriter().encode(str, BarcodeFormat.QR_CODE, widthAndHeight, widthAndHeight, getEncodeHintMap());\n        return BitMatrixToBitmap(matrix);\n    }\n\n    /**\n     * 生成条形码图片\n     * @param str 要往二维码中写入的内容,需要utf-8格式\n     * @param width 图片的宽\n     * @param height 图片的高\n     * @return 返回一个条形bitmap\n     * @throws Exception\n     */\n    public static Bitmap createBarCode(String str, Integer width, Integer height) throws Exception{\n            BitMatrix bitMatrix = new MultiFormatWriter().encode(str, BarcodeFormat.CODE_128, width, height, getEncodeHintMap());\n            return BitMatrixToBitmap(bitMatrix);\n    }\n    /**\n     * 获得设置好的编码参数\n     * @return 编码参数\n     */\n    private static Hashtable<EncodeHintType, Object> getEncodeHintMap() {\n        Hashtable<EncodeHintType, Object> hints= new Hashtable<EncodeHintType, Object>();\n        //设置编码为utf-8\n        hints.put(EncodeHintType.CHARACTER_SET, \"utf-8\");\n        // 设置QR二维码的纠错级别——这里选择最高H级别\n        hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);\n        return hints;\n    }\n    /**\n     * BitMatrix转换成Bitmap\n     *\n     * @param matrix\n     * @return\n     */\n    private static Bitmap BitMatrixToBitmap(BitMatrix matrix) {\n        int width = matrix.getWidth();\n        int height = matrix.getHeight();\n        int[] pixels = new int[width * height];\n        for (int y = 0; y < height; y++) {\n            int offset = y * width;\n            for (int x = 0; x < width; x++) {\n                if(matrix.get(x,y)){\n                    pixels[offset + x] =BLACK; //上面图案的颜色\n                }else{\n                    pixels[offset + x] =WHITE;//底色\n                }\n            }\n        }\n        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);\n        bitmap.setPixels(pixels, 0, width, 0, 0, width, height);\n        Log.e(\"hongliang\",\"width:\"+bitmap.getWidth()+\" height:\"+bitmap.getHeight());\n        return bitmap;\n    }\n}\n"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/zxing/utils/AppliationUtil.java",
    "content": "package com.liang.scancode.zxing.utils;\n\n/**\n * Created by 刘红亮 on 2015/7/23 22:35.\n */\npublic class AppliationUtil {\n    //应用程序最大可用内存\n    public static int MAX_MEMORY = ((int) Runtime.getRuntime().maxMemory())/1024/1024;\n    //应用程序已获得内存\n    public static long TOTAL_MEMORY = ((int) Runtime.getRuntime().totalMemory())/1024/1024;\n    //应用程序已获得内存中未使用内存\n    public static long FREE_MEMORY = ((int) Runtime.getRuntime().freeMemory())/1024/1024;\n\n\n\n}"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/zxing/utils/BeepManager.java",
    "content": "/*\n * Copyright (C) 2010 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.liang.scancode.zxing.utils;\n\nimport android.app.Activity;\nimport android.content.Context;\nimport android.content.SharedPreferences;\nimport android.content.res.AssetFileDescriptor;\nimport android.media.AudioManager;\nimport android.media.MediaPlayer;\nimport android.os.Vibrator;\nimport android.preference.PreferenceManager;\nimport android.util.Log;\n\nimport com.liang.scancode.R;\n\nimport java.io.Closeable;\nimport java.io.IOException;\n\n\n\n/**\n */\npublic class BeepManager implements MediaPlayer.OnCompletionListener, MediaPlayer.OnErrorListener, Closeable {\n\n\tstatic final String TAG = BeepManager.class.getSimpleName();\n\n\tstatic final float BEEP_VOLUME = 0.10f;\n\tstatic final long VIBRATE_DURATION = 200L;\n\n\tfinal Activity activity;\n\tMediaPlayer mediaPlayer;\n\tboolean playBeep;\n\tboolean vibrate;\n\n\tpublic BeepManager(Activity activity) {\n\t\tthis.activity = activity;\n\t\tthis.mediaPlayer = null;\n\t\tupdatePrefs();\n\t}\n\n\tsynchronized void updatePrefs() {\n\t\tSharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);\n\t\tplayBeep = shouldBeep(prefs, activity);\n\t\tvibrate = true;\n\t\tif (playBeep && mediaPlayer == null) {\n\t\t\t// The volume on STREAM_SYSTEM is not adjustable, and users found it\n\t\t\t// too loud,\n\t\t\t// so we now play on the music stream.\n\t\t\tactivity.setVolumeControlStream(AudioManager.STREAM_MUSIC);\n\t\t\tmediaPlayer = buildMediaPlayer(activity);\n\t\t}\n\t}\n\n\tpublic synchronized void playBeepSoundAndVibrate() {\n\t\tif (playBeep && mediaPlayer != null) {\n\t\t\tmediaPlayer.start();\n\t\t}\n\t\tif (vibrate) {\n\t\t\tVibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);\n\t\t\tvibrator.vibrate(VIBRATE_DURATION);\n\t\t}\n\t}\n\n\tstatic boolean shouldBeep(SharedPreferences prefs, Context activity) {\n\t\tboolean shouldPlayBeep = true;\n\t\tif (shouldPlayBeep) {\n\t\t\t// See if sound settings overrides this\n\t\t\tAudioManager audioService = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE);\n\t\t\tif (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {\n\t\t\t\tshouldPlayBeep = false;\n\t\t\t}\n\t\t}\n\t\treturn shouldPlayBeep;\n\t}\n\n\tMediaPlayer buildMediaPlayer(Context activity) {\n\t\tMediaPlayer mediaPlayer = new MediaPlayer();\n\t\tmediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);\n\t\tmediaPlayer.setOnCompletionListener(this);\n\t\tmediaPlayer.setOnErrorListener(this);\n\t\ttry {\n\t\t\tAssetFileDescriptor file = activity.getResources().openRawResourceFd(R.raw.beep);\n\t\t\ttry {\n\t\t\t\tmediaPlayer.setDataSource(file.getFileDescriptor(), file.getStartOffset(), file.getLength());\n\t\t\t} finally {\n\t\t\t\tfile.close();\n\t\t\t}\n\t\t\tmediaPlayer.setVolume(BEEP_VOLUME, BEEP_VOLUME);\n\t\t\tmediaPlayer.prepare();\n\t\t\treturn mediaPlayer;\n\t\t} catch (IOException ioe) {\n\t\t\tLog.w(TAG, ioe);\n\t\t\tmediaPlayer.release();\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t@Override\n\tpublic void onCompletion(MediaPlayer mp) {\n\t\t// When the beep has finished playing, rewind to queue up another one.\n\t\tmp.seekTo(0);\n\t}\n\n\t@Override\n\tpublic synchronized boolean onError(MediaPlayer mp, int what, int extra) {\n\t\tif (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {\n\t\t\t// we are finished, so put up an appropriate error toast if required\n\t\t\t// and finish\n\t\t\tactivity.finish();\n\t\t} else {\n\t\t\t// possibly media player error, so release and recreate\n\t\t\tmp.release();\n\t\t\tmediaPlayer = null;\n\t\t\tupdatePrefs();\n\t\t}\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic synchronized void close() {\n\t\tif (mediaPlayer != null) {\n\t\t\tmediaPlayer.release();\n\t\t\tmediaPlayer = null;\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/zxing/utils/BitmapUtil.java",
    "content": "package com.liang.scancode.zxing.utils;\n\nimport android.graphics.Bitmap;\nimport android.graphics.BitmapFactory;\nimport android.util.Log;\n\n/**\n * Created by 刘红亮 on 2015/7/23 22:30.\n */\npublic class BitmapUtil {\n\n\n    /**\n     *\n     * @param options\n     * @param reqWidth\n     * @param reqHeight\n     * @return\n     */\n    public static int calculateInSampleSize(BitmapFactory.Options options,\n                                            int reqWidth, int reqHeight) {\n        // 源图片的高度和宽度\n        final int height = options.outHeight;\n        final int width = options.outWidth;\n        //压缩当前图片占用内存不超过应用可用内存的3/4\n        //ARGB_8888  一个像素占用4个字节\n        //1兆字节(mb)=1048576字节(b)\n        while(reqHeight*reqWidth*4> AppliationUtil.FREE_MEMORY*1048576/4*3){\n            reqHeight-=50;\n            reqWidth-=50;\n        }\n        int inSampleSize = 1;\n        if (height > reqHeight || width > reqWidth) {\n            // 计算出实际宽高和目标宽高的比率\n            final int heightRatio = Math.round((float) height / (float) reqHeight);\n            final int widthRatio = Math.round((float) width / (float) reqWidth);\n            // 选择宽和高中最小的比率作为inSampleSize的值，这样可以保证最终图片的宽和高\n            // 一定都会大于等于目标的宽和高。\n            inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;\n        }\n        if(inSampleSize==0) return 1;\n        Log.e(\"hongliang\",\"inSampleSize=\" + inSampleSize);\n        return inSampleSize;\n    }\n    public static Bitmap decodeBitmapFromPath(String photo_path, int reqWidth, int reqHeight) {\n        // 第一次解析将inJustDecodeBounds设置为true，来获取图片大小\n        final BitmapFactory.Options options = new BitmapFactory.Options();\n        options.inJustDecodeBounds = true;\n        Bitmap scanBitmap = BitmapFactory.decodeFile(photo_path, options);\n        // 调用上面定义的方法计算inSampleSize值\n        options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);\n        // 使用获取到的inSampleSize值再次解析图片\n        options.inJustDecodeBounds = false;\n        return BitmapFactory.decodeFile(photo_path, options);\n    }\n}"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/zxing/utils/CaptureActivityHandler.java",
    "content": "/*\n * Copyright (C) 2008 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.liang.scancode.zxing.utils;\n\nimport android.os.Bundle;\nimport android.os.Handler;\nimport android.os.Message;\n\nimport com.google.zxing.Result;\nimport com.liang.scancode.R;\nimport com.liang.scancode.zxing.ScanManager;\nimport com.liang.scancode.zxing.camera.CameraManager;\nimport com.liang.scancode.zxing.decode.DecodeThread;\n\n/**\n * This class handles shouquan_ic_all the messaging which comprises the state machine for\n * capture.\n * \n * @author dswitkin@google.com (Daniel Switkin)\n */\npublic class CaptureActivityHandler extends Handler {\n\n\tfinal ScanManager scanManager;\n\tfinal DecodeThread decodeThread;\n\tfinal CameraManager cameraManager;\n\tState state;\n\n\tenum State {\n\t\tPREVIEW, SUCCESS, DONE\n\t}\n\n\tpublic CaptureActivityHandler(ScanManager scanManager, CameraManager cameraManager, int decodeMode) {\n\t\tthis.scanManager = scanManager;\n\t\tdecodeThread = new DecodeThread(scanManager, decodeMode);\n\t\tdecodeThread.start();\n\t\tstate = State.SUCCESS;\n\n\t\t// Start ourselves capturing previews and decoding.\n\t\tthis.cameraManager = cameraManager;\n\t\tcameraManager.startPreview();\n\t\trestartPreviewAndDecode();\n\t}\n\n\t@Override\n\tpublic void handleMessage(Message message) {\n\t\tswitch (message.what) {\n\t\tcase R.id.restart_preview:\n\t\t\trestartPreviewAndDecode();\n\t\t\tbreak;\n\t\tcase R.id.decode_succeeded:\n\t\t\tstate = State.SUCCESS;\n\t\t\tBundle bundle = message.getData();\n\n\t\t\tscanManager.handleDecode((Result) message.obj, bundle);\n\t\t\tbreak;\n\t\tcase R.id.decode_failed:\n\t\t\t// We're decoding as fast as possible, so when one decode fails,\n\t\t\t// start another.\n\t\t\tstate = State.PREVIEW;\n\t\t\tcameraManager.requestPreviewFrame(decodeThread.getHandler(), R.id.decode);\n\t\t\tbreak;\n\t\tcase R.id.decode_error:\n\t\t\tscanManager.handleDecodeError((Exception)message.obj);\n\t\t\tbreak;\n\t\tcase R.id.return_scan_result:\n//\t\t\tactivity.setResult(Activity.RESULT_OK, (Intent) message.obj);\n//\t\t\tactivity.finish();\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tpublic void quitSynchronously() {\n\t\tstate = State.DONE;\n\t\tcameraManager.stopPreview();\n\t\tMessage quit = Message.obtain(decodeThread.getHandler(), R.id.quit);\n\t\tquit.sendToTarget();\n\t\ttry {\n\t\t\t// Wait at most half a shouquan_icon_second; should be enough time, and onPause()\n\t\t\t// will timeout quickly\n\t\t\tdecodeThread.join(500L);\n\t\t} catch (InterruptedException e) {\n\t\t\t// continue\n\t\t}\n\n\t\t// Be absolutely sure we don't send any queued up messages\n\t\tremoveMessages(R.id.decode_succeeded);\n\t\tremoveMessages(R.id.decode_failed);\n\t}\n\n\tvoid restartPreviewAndDecode() {\n\t\tif (state == State.SUCCESS) {\n\t\t\tstate = State.PREVIEW;\n\t\t\tcameraManager.requestPreviewFrame(decodeThread.getHandler(), R.id.decode);\n\t\t}\n\t}\n\t/**\n\t * \n\t * @return 返回当前扫描状态，是否可扫描,State.PREVIEW 是可扫描状态\n\t */\n\tpublic boolean  isScanning() {\n\t\tif(state == State.PREVIEW){\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n}\n"
  },
  {
    "path": "app/src/main/java/com/liang/scancode/zxing/utils/InactivityTimer.java",
    "content": "/*\n * Copyright (C) 2010 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.liang.scancode.zxing.utils;\n\nimport android.annotation.SuppressLint;\nimport android.app.Activity;\nimport android.content.BroadcastReceiver;\nimport android.content.Context;\nimport android.content.Intent;\nimport android.content.IntentFilter;\nimport android.os.AsyncTask;\nimport android.os.BatteryManager;\nimport android.os.Build;\nimport android.util.Log;\n\n/**\n * Finishes an activity after a period of inactivity if the device is on battery\n * power.\n */\npublic class InactivityTimer {\n\n\tstatic final String TAG = InactivityTimer.class.getSimpleName();\n\n\tstatic final long INACTIVITY_DELAY_MS = 5 * 60 * 1000L;\n\n\tActivity activity;\n\tBroadcastReceiver powerStatusReceiver;\n\tboolean registered;\n\tAsyncTask<Object, Object, Object> inactivityTask;\n\n\tpublic InactivityTimer(Activity activity) {\n\t\tthis.activity = activity;\n\t\tpowerStatusReceiver = new PowerStatusReceiver();\n\t\tregistered = false;\n\t\tonActivity();\n\t}\n\n\t@SuppressLint(\"NewApi\")\n\tpublic synchronized void onActivity() {\n\t\tcancel();\n\t\tinactivityTask = new InactivityAsyncTask();\n\t\tif (Build.VERSION.SDK_INT >= 11) {\n\t\t\tinactivityTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);\n\t\t} else {\n\t\t\tinactivityTask.execute();\n\t\t}\n\t}\n\n\tpublic synchronized void onPause() {\n\t\tcancel();\n\t\tif (registered) {\n\t\t\tactivity.unregisterReceiver(powerStatusReceiver);\n\t\t\tregistered = false;\n\t\t} else {\n\t\t\tLog.w(TAG, \"PowerStatusReceiver was never registered?\");\n\t\t}\n\t}\n\n\tpublic synchronized void onResume() {\n\t\tif (registered) {\n\t\t\tLog.w(TAG, \"PowerStatusReceiver was already registered?\");\n\t\t} else {\n\t\t\tactivity.registerReceiver(powerStatusReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));\n\t\t\tregistered = true;\n\t\t}\n\t\tonActivity();\n\t}\n\n\tsynchronized void cancel() {\n\t\tAsyncTask<?, ?, ?> task = inactivityTask;\n\t\tif (task != null) {\n\t\t\ttask.cancel(true);\n\t\t\tinactivityTask = null;\n\t\t}\n\t}\n\n\tpublic void shutdown() {\n\t\tcancel();\n\t}\n\n\tclass PowerStatusReceiver extends BroadcastReceiver {\n\t\t@Override\n\t\tpublic void onReceive(Context context, Intent intent) {\n\t\t\tif (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) {\n\t\t\t\t// 0 indicates that we're on battery\n\t\t\t\tboolean onBatteryNow = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) <= 0;\n\t\t\t\tif (onBatteryNow) {\n\t\t\t\t\tInactivityTimer.this.onActivity();\n\t\t\t\t} else {\n\t\t\t\t\tInactivityTimer.this.cancel();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tclass InactivityAsyncTask extends AsyncTask<Object, Object, Object> {\n\t\t@Override\n\t\tprotected Object doInBackground(Object... objects) {\n\t\t\ttry {\n\t\t\t\tThread.sleep(INACTIVITY_DELAY_MS);\n\t\t\t\tLog.i(TAG, \"Finishing activity due to inactivity\");\n\t\t\t\tactivity.finish();\n\t\t\t} catch (InterruptedException e) {\n\t\t\t\t// continue without killing\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "app/src/main/res/anim/popupwin_nearperson_exit.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<set xmlns:android=\"http://schemas.android.com/apk/res/android\"\n\tandroid:interpolator=\"@android:anim/accelerate_interpolator\">\n         <translate \n             android:fromYDelta=\"0\"\n             android:toYDelta=\"100%\"\n              android:duration=\"250\"\n             />\n\t</set>"
  },
  {
    "path": "app/src/main/res/anim/popupwin_nearperson_show.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<set xmlns:android=\"http://schemas.android.com/apk/res/android\"\n\tandroid:interpolator=\"@android:anim/accelerate_interpolator\">\n         <translate \n             android:fromYDelta=\"100%\"\n             android:toYDelta=\"0\"\n              android:duration=\"250\"\n             />\n\t</set>"
  },
  {
    "path": "app/src/main/res/anim/shouquan_dialog_enter.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<set xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <!-- from从始点开始动画 -->\n    <translate android:duration=\"300\" android:fromYDelta=\"100%p\" />\n</set>\n"
  },
  {
    "path": "app/src/main/res/anim/shouquan_dialog_exit.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<set xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <!-- to从终点技术动画 -->\n    <translate android:duration=\"300\" android:toYDelta=\"100%p\"/>\n</set>\n"
  },
  {
    "path": "app/src/main/res/drawable/base_bgpic.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<shape\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:shape=\"rectangle\"\n    ><!-- android:shape=\"\" 表示是圆角矩形还是椭圆等等 -->\n    <solid android:color=\"#FFFFFF\"/> <!-- 背景颜色 -->\n\n    <!-- padding 表示内部空间距离背景图片内部边距 的距离 -->\n    <!--<padding android:left=\"5dp\" android:top=\"5dp\"-->\n        <!--android:right=\"5dp\" android:bottom=\"5dp\" />-->\n\n    <stroke android:width=\"0.5dp\" android:color=\"#D9D9D9\"/> <!-- 图片边框属性 -->\n    <corners android:radius=\"5dp\" /> <!-- 圆角的程度 -->\n    <gradient android:startColor=\"#FFFFFF\" android:centerColor=\"#FFFFFF\"\n        android:endColor=\"#FFFFFF\" android:type=\"linear\" android:angle=\"90\"\n        android:centerX=\"0.5\" android:centerY=\"0.5\" />\n</shape>\n"
  },
  {
    "path": "app/src/main/res/drawable/rescan_shape_button.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<shape xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:shape=\"rectangle\" >\n   <!-- 背景颜色 -->\n       <solid android:color=\"#ff6a62\"/>\n   <!-- 圆角的程度 -->\n      <corners android:radius=\"4dp\" />\n   <!-- 矩形的边线 -->\n    <stroke\n        android:width=\"1dp\" />\n</shape>\n\n"
  },
  {
    "path": "app/src/main/res/drawable/shouquan_bg_loading_dialog_shape.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<shape xmlns:android=\"http://schemas.android.com/apk/res/android\" >\n    <corners android:radius=\"10dp\"/>\n    <solid android:color=\"@android:color/white\"/>\n</shape>\n"
  },
  {
    "path": "app/src/main/res/drawable/shouquan_loading_dialog_progressbar.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<animated-rotate xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:drawable=\"@drawable/shouquan_iloading_progress\"\n    android:pivotX=\"50%\"\n    android:pivotY=\"50%\" />"
  },
  {
    "path": "app/src/main/res/drawable/shouquan_qrcode_g_gallery.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<selector xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n    <item android:drawable=\"@drawable/scan2code_icon_xiangce\" android:state_pressed=\"true\"/>\n    <item android:drawable=\"@drawable/scan2code_icon_xiangce_sel\"/>\n\n</selector>"
  },
  {
    "path": "app/src/main/res/drawable/shouquan_qrcode_ic_back.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<selector xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n    <item android:drawable=\"@drawable/scan2code_icon_back_sel\" android:state_pressed=\"true\" />\n    <item android:drawable=\"@drawable/scan2code_icon_back_nor\"/>\n\n</selector>"
  },
  {
    "path": "app/src/main/res/drawable/shouquan_qrcode_s_flashgun.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<selector xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n    <item android:drawable=\"@drawable/scan2code_icon_light_sel\" android:state_pressed=\"true\"/>\n    <item android:drawable=\"@drawable/scan2code_icon_light_nor\"/>\n</selector>"
  },
  {
    "path": "app/src/main/res/layout/activity_create_code.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:orientation=\"vertical\" android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:layout_centerHorizontal=\"true\"\n    >\n    <EditText\n        android:id=\"@+id/et_code_key\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:hint=\"输入要生成码的内容\"\n        android:gravity=\"center\"\n        android:textSize=\"17sp\"\n        android:padding=\"10dp\"\n        android:layout_marginTop=\"40dp\"\n        />\n    <LinearLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:orientation=\"horizontal\"\n        >\n        <Button\n            android:id=\"@+id/btn_create_code\"\n            android:layout_width=\"0dp\"\n            android:layout_weight=\"1\"\n            android:layout_height=\"wrap_content\"\n            android:padding=\"10dp\"\n            android:text=\"生成码\"\n            android:gravity=\"center\"\n            android:textSize=\"17sp\"\n            />\n        <Button\n            android:id=\"@+id/btn_create_code_and_img\"\n            android:layout_width=\"0dp\"\n            android:layout_weight=\"1\"\n            android:layout_height=\"wrap_content\"\n            android:padding=\"10dp\"\n            android:text=\"加个头像\"\n            android:gravity=\"center\"\n            android:textSize=\"17sp\"\n            />\n    </LinearLayout>\n\n    <ImageView\n        android:id=\"@+id/iv_2_code\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:background=\"@android:color/holo_red_light\"\n        />\n    <ImageView\n        android:layout_marginTop=\"20dp\"\n        android:id=\"@+id/iv_bar_code\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        />\n</LinearLayout>"
  },
  {
    "path": "app/src/main/res/layout/activity_main.xml",
    "content": "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\" android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\" android:paddingLeft=\"@dimen/activity_horizontal_margin\"\n    android:paddingRight=\"@dimen/activity_horizontal_margin\"\n    android:paddingTop=\"@dimen/activity_vertical_margin\"\n    android:orientation=\"vertical\"\n    android:paddingBottom=\"@dimen/activity_vertical_margin\" tools:context=\".MainActivity\">\n    <Button\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:textSize=\"17sp\"\n        android:text=\"生成二维码/条形码\"\n        android:id=\"@+id/create_code\"\n        android:gravity=\"center\"\n        android:padding=\"10dp\"\n        android:layout_marginTop=\"50dp\"\n        />\n    <Button\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:textSize=\"17sp\"\n        android:text=\"扫描二维码\"\n        android:id=\"@+id/scan_2code\"\n        android:gravity=\"center\"\n        android:padding=\"10dp\"\n        />\n    <Button\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:textSize=\"17sp\"\n        android:text=\"扫描条形码\"\n        android:id=\"@+id/scan_bar_code\"\n        android:gravity=\"center\"\n        android:padding=\"10dp\"\n        />\n    <Button\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:textSize=\"17sp\"\n        android:text=\"扫描二维码或者条形码\"\n        android:id=\"@+id/scan_code\"\n        android:gravity=\"center\"\n        android:padding=\"10dp\"\n        />\n</LinearLayout>\n"
  },
  {
    "path": "app/src/main/res/layout/activity_scan_code.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:id=\"@+id/capture_container\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:background=\"@android:color/white\" >\n    <SurfaceView\n        android:id=\"@+id/capture_preview\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        />\n    <!-- 扫描框上面的布局 -->\n    <RelativeLayout\n        android:id=\"@+id/top_mask\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"150dp\"\n        android:layout_alignParentTop=\"true\"\n        android:background=\"@color/scan_bg\">\n        <RelativeLayout\n            android:id=\"@+id/title_bar\"\n            android:layout_width=\"fill_parent\"\n            android:layout_height=\"45dip\"\n            android:background=\"@android:color/white\" >\n\n            <ImageView\n                android:id=\"@+id/authorize_return\"\n                android:layout_width=\"wrap_content\"\n                android:layout_height=\"wrap_content\"\n                android:layout_alignParentLeft=\"true\"\n                android:layout_centerVertical=\"true\"\n                android:background=\"@null\"\n                android:paddingLeft=\"12dp\"\n                android:paddingRight=\"20dp\"\n                android:src=\"@drawable/ic_my_returns_arrow\"\n                />\n            <TextView\n                android:id=\"@+id/common_title_TV_center\"\n                android:layout_width=\"wrap_content\"\n                android:layout_height=\"wrap_content\"\n                android:layout_centerHorizontal=\"true\"\n                android:layout_centerVertical=\"true\"\n                android:ellipsize=\"middle\"\n                android:singleLine=\"true\"\n                android:text=\"二维码扫描\"\n                android:textSize=\"18sp\" />\n        </RelativeLayout>\n        <TextView\n            android:id=\"@+id/tv_scan_result\"\n            android:layout_marginTop=\"20dp\"\n            android:layout_below=\"@id/title_bar\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:text=\"哈哈\"\n            android:textSize=\"14sp\"\n            android:layout_centerInParent=\"true\"\n            android:textColor=\"@android:color/white\"\n            android:visibility=\"gone\"\n            />\n    </RelativeLayout>\n    <!-- 扫描框底部的布局 -->\n    <RelativeLayout\n        android:id=\"@+id/bottom_mask\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"200dp\"\n        android:layout_alignParentBottom=\"true\"\n        android:background=\"@color/scan_bg\"\n        android:orientation=\"vertical\"\n        android:paddingBottom=\"16dp\"\n        >\n        <TextView\n            android:id=\"@+id/scan_hint\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_centerHorizontal=\"true\"\n            android:text=\"@string/scan_allcode_hint\"\n            android:textColor=\"#b4b4b4\"\n            android:textSize=\"14sp\"\n            android:paddingTop=\"20dp\"\n            android:paddingBottom=\"20dp\"\n            />\n\n        <TextView\n            android:id=\"@+id/iv_light\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_alignParentRight=\"true\"\n            android:layout_marginRight=\"30dp\"\n            android:layout_below=\"@id/scan_hint\"\n            android:background=\"@drawable/shouquan_qrcode_s_flashgun\"\n            android:clickable=\"true\" />\n\n        <TextView\n            android:id=\"@+id/qrcode_ic_back\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_centerHorizontal=\"true\"\n            android:layout_below=\"@id/scan_hint\"\n            android:background=\"@drawable/shouquan_qrcode_ic_back\"\n            android:clickable=\"true\" />\n\n        <TextView\n            android:id=\"@+id/qrcode_g_gallery\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_alignParentLeft=\"true\"\n            android:layout_marginLeft=\"30dp\"\n            android:layout_below=\"@id/scan_hint\"\n            android:background=\"@drawable/shouquan_qrcode_g_gallery\"\n            android:clickable=\"true\"\n\n            android:textSize=\"20sp\" />\n        <Button\n            android:id=\"@+id/service_register_rescan\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center_horizontal\"\n            android:background=\"@drawable/rescan_shape_button\"\n            android:padding=\"10dp\"\n            android:text=\"再次扫描\"\n            android:textColor=\"@android:color/white\"\n            android:textSize=\"18sp\"\n            android:layout_centerHorizontal=\"true\"\n            android:layout_below=\"@id/qrcode_g_gallery\"\n            android:visibility=\"visible\"\n            android:layout_marginTop=\"20dp\"\n\n            />\n    </RelativeLayout>\n    <!-- 扫描框中间的布局 -->\n    <RelativeLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:layout_below=\"@id/top_mask\"\n        android:layout_above=\"@id/bottom_mask\"\n        >\n        <ImageView\n            android:id=\"@+id/left_mask\"\n            android:layout_width=\"34dp\"\n            android:layout_height=\"match_parent\"\n            android:layout_alignParentLeft=\"true\"\n            android:background=\"@color/scan_bg\"\n            android:contentDescription=\"@string/app_name\" />\n        <ImageView\n            android:id=\"@+id/right_mask\"\n            android:layout_width=\"34dp\"\n            android:layout_height=\"match_parent\"\n            android:layout_alignParentRight=\"true\"\n            android:background=\"@color/scan_bg\" />\n        <RelativeLayout\n            android:id=\"@+id/capture_crop_view\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"match_parent\"\n            android:layout_toLeftOf=\"@id/right_mask\"\n            android:layout_toRightOf=\"@id/left_mask\"\n            android:layout_centerHorizontal=\"true\"\n            android:background=\"@android:color/transparent\" >\n            <ImageView\n                android:id=\"@+id/capture_scan_line\"\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"wrap_content\"\n                android:layout_alignParentTop=\"true\"\n                android:layout_margin=\"5dp\"\n                android:background=\"@drawable/scanning_line\" />\n            <com.liang.scancode.defineview.MyImageView\n                android:id=\"@+id/scan_image\"\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"match_parent\"\n                />\n        </RelativeLayout>\n    </RelativeLayout>\n\n</RelativeLayout>"
  },
  {
    "path": "app/src/main/res/layout/activity_scan_result.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:orientation=\"vertical\" android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    >\n    <RelativeLayout\n        android:layout_width=\"fill_parent\"\n        android:layout_height=\"45dip\"\n        android:background=\"@android:color/white\" >\n\n        <ImageView\n            android:id=\"@+id/authorize_return\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_alignParentLeft=\"true\"\n            android:layout_centerVertical=\"true\"\n            android:background=\"@null\"\n            android:paddingLeft=\"12dp\"\n            android:paddingRight=\"20dp\"\n            android:src=\"@drawable/ic_my_returns_arrow\"\n            />\n        <TextView\n            android:id=\"@+id/common_title_TV_center\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_centerHorizontal=\"true\"\n            android:layout_centerVertical=\"true\"\n            android:ellipsize=\"middle\"\n            android:singleLine=\"true\"\n            android:text=\"扫描结果\"\n            android:textSize=\"18sp\" />\n    </RelativeLayout>\n    <TextView\n        android:id=\"@+id/tv_scan_result\"\n        android:layout_marginTop=\"20dp\"\n        android:layout_gravity=\"center\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:textSize=\"14sp\"\n        android:text=\"扫描结果：\"\n        />\n    <ImageView\n        android:id=\"@+id/iv_scan_result\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        />\n</LinearLayout>"
  },
  {
    "path": "app/src/main/res/menu/menu_jump_to.xml",
    "content": "<menu xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    tools:context=\"cn.sibu.plugin.scan2code.JumpToActivity\">\n    <item android:id=\"@+id/action_settings\" android:title=\"@string/action_settings\"\n        android:orderInCategory=\"100\" android:showAsAction=\"never\" />\n</menu>\n"
  },
  {
    "path": "app/src/main/res/menu/menu_sao_mao.xml",
    "content": "<menu xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    tools:context=\"cn.sibu.plugin.scan2code.SaoMaoActivity\">\n    <item android:id=\"@+id/action_settings\" android:title=\"@string/action_settings\"\n        android:orderInCategory=\"100\" android:showAsAction=\"never\" />\n</menu>\n"
  },
  {
    "path": "app/src/main/res/values/Qrcode_ids.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--\n Copyright (C) 2008 ZXing authors\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n      http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n-->\n<resources>\n    <item name=\"decode\" type=\"id\"/>\n    <item name=\"decode_failed\" type=\"id\"/>\n    <item name=\"decode_succeeded\" type=\"id\"/>\n    <item name=\"quit\" type=\"id\"/>\n    <item name=\"restart_preview\" type=\"id\"/>\n    <item name=\"return_scan_result\" type=\"id\"/>\n    <item name=\"decode_error\" type=\"id\"/>\n\n</resources>"
  },
  {
    "path": "app/src/main/res/values/colors.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <color name=\"scan_bg\">#7f000000</color>\n    \n</resources>"
  },
  {
    "path": "app/src/main/res/values/dimens.xml",
    "content": "<resources>\n    <!-- Default screen margins, per the Android Design guidelines. -->\n    <dimen name=\"activity_horizontal_margin\">16dp</dimen>\n    <dimen name=\"activity_vertical_margin\">16dp</dimen>\n</resources>\n"
  },
  {
    "path": "app/src/main/res/values/strings.xml",
    "content": "<resources>\n    <string name=\"app_name\">Scan2Code</string>\n\n    <string name=\"hello_world\">Hello world!</string>\n    <string name=\"scan_barcode_title\">条形码扫描</string>\n    <string name=\"scan_qrcode_title\">二维码扫描</string>\n    <string name=\"scan_allcode_title\">二维码或条形码扫描</string>\n    <string name=\"scan_barcode_hint\">将条形码对入取景框，即可自动扫描</string>\n    <string name=\"scan_qrcode_hint\">将二维码对入取景框，即可自动扫描</string>\n    <string name=\"scan_allcode_hint\">将二维码或条形码对入取景框，即可自动扫描</string>\n    <string name=\"title_activity_sao_mao\">SaoMaoActivity</string>\n    <string name=\"action_settings\">Settings</string>\n\n\n    <color name=\"line_color\">#cccccc</color>\n    <color name=\"edittext_line_color\">#000000</color>\n    <string name=\"title_activity_jump_to\">JumpToActivity</string>\n</resources>\n"
  },
  {
    "path": "app/src/main/res/values/styles.xml",
    "content": "<resources>\n\n    <!-- Base application theme. -->\n    <style name=\"AppTheme\">\n        <!-- Customize your theme here. -->\n    </style>\n\n    <style name=\"popwin_nearpenson_anim_style\">\n        <item name=\"android:windowEnterAnimation\">@anim/popupwin_nearperson_show</item>\n        <item name=\"android:windowExitAnimation\">@anim/popupwin_nearperson_exit</item>\n    </style>\n\n    <!--分割线样式-->\n    <style name=\"lineStyle\">\n        <item name=\"android:layout_width\">match_parent</item>\n        <item name=\"android:layout_height\">0.5dp</item>\n        <item name=\"android:background\">#cccccc</item>\n    </style>\n\n\n    <!-- 只有背景的对话框样式 -->\n    <style name=\"dialog_show_style\" parent=\"@android:style/Theme.Dialog\">\n        <item name=\"android:windowFrame\">@null</item>\n        <item name=\"android:windowIsFloating\">true</item>\n        <item name=\"android:windowIsTranslucent\">true</item>\n        <item name=\"android:windowNoTitle\">true</item>\n        <item name=\"android:background\">@android:color/transparent</item>\n        <item name=\"android:windowBackground\">@android:color/transparent</item>\n        <item name=\"android:backgroundDimEnabled\">true</item>\n        <!-- 设置dialog的半透明背景的灰度 -->\n        <item name=\"android:backgroundDimAmount\">0.6</item>\n    </style>\n    <style name=\"my_style\">\n        <item name=\"android:windowEnterAnimation\">@anim/shouquan_dialog_enter</item>\n        <item name=\"android:windowExitAnimation\">@anim/shouquan_dialog_exit</item>\n    </style>\n\n</resources>\n"
  },
  {
    "path": "app/src/main/res/values-w820dp/dimens.xml",
    "content": "<resources>\n    <!-- Example customization of dimensions originally defined in res/values/dimens.xml\n         (such as screen margins) for screens with more than 820dp of available width. This\n         would include 7\" and 10\" devices in landscape (~960dp and ~1280dp respectively). -->\n    <dimen name=\"activity_horizontal_margin\">64dp</dimen>\n</resources>\n"
  },
  {
    "path": "build.gradle",
    "content": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n    repositories {\n        jcenter()\n    }\n    dependencies {\n        classpath 'com.android.tools.build:gradle:1.2.3'\n\n        // NOTE: Do not place your application dependencies here; they belong\n        // in the individual module build.gradle files\n    }\n}\n\nallprojects {\n    repositories {\n        jcenter()\n    }\n}\n"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "#Wed Apr 10 15:27:10 PDT 2013\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-2.2.1-all.zip\n"
  },
  {
    "path": "gradle.properties",
    "content": "## Project-wide Gradle settings.\n#\n# For more details on how to configure your build environment visit\n# http://www.gradle.org/docs/current/userguide/build_environment.html\n#\n# Specifies the JVM arguments used for the daemon process.\n# The setting is particularly useful for tweaking memory settings.\n# Default value: -Xmx10248m -XX:MaxPermSize=256m\n# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8\n#\n# When configured, Gradle will run in incubating parallel mode.\n# This option should only be used with decoupled projects. More details, visit\n# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects\n# org.gradle.parallel=true\n#Mon Aug 17 15:58:13 CST 2015\nsystemProp.http.proxyHost=hx.gy\nsystemProp.http.proxyPort=1080\n"
  },
  {
    "path": "gradlew",
    "content": "#!/usr/bin/env bash\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS=\"\"\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n\nwarn ( ) {\n    echo \"$*\"\n}\n\ndie ( ) {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n}\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\nesac\n\n# For Cygwin, ensure paths are in UNIX format before anything is touched.\nif $cygwin ; then\n    [ -n \"$JAVA_HOME\" ] && JAVA_HOME=`cygpath --unix \"$JAVA_HOME\"`\nfi\n\n# Attempt to set APP_HOME\n# Resolve links: $0 may be a link\nPRG=\"$0\"\n# Need this for relative symlinks.\nwhile [ -h \"$PRG\" ] ; do\n    ls=`ls -ld \"$PRG\"`\n    link=`expr \"$ls\" : '.*-> \\(.*\\)$'`\n    if expr \"$link\" : '/.*' > /dev/null; then\n        PRG=\"$link\"\n    else\n        PRG=`dirname \"$PRG\"`\"/$link\"\n    fi\ndone\nSAVED=\"`pwd`\"\ncd \"`dirname \\\"$PRG\\\"`/\" >&-\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >&-\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n    else\n        JAVACMD=\"$JAVA_HOME/bin/java\"\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=\"java\"\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif [ \"$cygwin\" = \"false\" -a \"$darwin\" = \"false\" ] ; then\n    MAX_FD_LIMIT=`ulimit -H -n`\n    if [ $? -eq 0 ] ; then\n        if [ \"$MAX_FD\" = \"maximum\" -o \"$MAX_FD\" = \"max\" ] ; then\n            MAX_FD=\"$MAX_FD_LIMIT\"\n        fi\n        ulimit -n $MAX_FD\n        if [ $? -ne 0 ] ; then\n            warn \"Could not set maximum file descriptor limit: $MAX_FD\"\n        fi\n    else\n        warn \"Could not query maximum file descriptor limit: $MAX_FD_LIMIT\"\n    fi\nfi\n\n# For Darwin, add options to specify how the application appears in the dock\nif $darwin; then\n    GRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n\n# For Cygwin, switch paths to Windows format before running java\nif $cygwin ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\n\n    # We build the pattern for arguments to be converted via cygpath\n    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\n    SEP=\"\"\n    for dir in $ROOTDIRSRAW ; do\n        ROOTDIRS=\"$ROOTDIRS$SEP$dir\"\n        SEP=\"|\"\n    done\n    OURCYGPATTERN=\"(^($ROOTDIRS))\"\n    # Add a user-defined pattern to the cygpath arguments\n    if [ \"$GRADLE_CYGPATTERN\" != \"\" ] ; then\n        OURCYGPATTERN=\"$OURCYGPATTERN|($GRADLE_CYGPATTERN)\"\n    fi\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    i=0\n    for arg in \"$@\" ; do\n        CHECK=`echo \"$arg\"|egrep -c \"$OURCYGPATTERN\" -`\n        CHECK2=`echo \"$arg\"|egrep -c \"^-\"`                                 ### Determine if an option\n\n        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\n            eval `echo args$i`=`cygpath --path --ignore --mixed \"$arg\"`\n        else\n            eval `echo args$i`=\"\\\"$arg\\\"\"\n        fi\n        i=$((i+1))\n    done\n    case $i in\n        (0) set -- ;;\n        (1) set -- \"$args0\" ;;\n        (2) set -- \"$args0\" \"$args1\" ;;\n        (3) set -- \"$args0\" \"$args1\" \"$args2\" ;;\n        (4) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" ;;\n        (5) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" ;;\n        (6) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" ;;\n        (7) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" ;;\n        (8) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" ;;\n        (9) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" \"$args8\" ;;\n    esac\nfi\n\n# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules\nfunction splitJvmOpts() {\n    JVM_OPTS=(\"$@\")\n}\neval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS\nJVM_OPTS[${#JVM_OPTS[*]}]=\"-Dorg.gradle.appname=$APP_BASE_NAME\"\n\nexec \"$JAVACMD\" \"${JVM_OPTS[@]}\" -classpath \"$CLASSPATH\" org.gradle.wrapper.GradleWrapperMain \"$@\"\n"
  },
  {
    "path": "gradlew.bat",
    "content": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem  Gradle startup script for Windows\n@rem\n@rem ##########################################################################\n\n@rem Set local scope for the variables with windows NT shell\nif \"%OS%\"==\"Windows_NT\" setlocal\n\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nset DEFAULT_JVM_OPTS=\n\nset DIRNAME=%~dp0\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\nset APP_BASE_NAME=%~n0\nset APP_HOME=%DIRNAME%\n\n@rem Find java.exe\nif defined JAVA_HOME goto findJavaFromJavaHome\n\nset JAVA_EXE=java.exe\n%JAVA_EXE% -version >NUL 2>&1\nif \"%ERRORLEVEL%\" == \"0\" goto init\n\necho.\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:findJavaFromJavaHome\nset JAVA_HOME=%JAVA_HOME:\"=%\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\n\nif exist \"%JAVA_EXE%\" goto init\n\necho.\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:init\n@rem Get command-line arguments, handling Windowz variants\n\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\nif \"%@eval[2+2]\" == \"4\" goto 4NT_args\n\n:win9xME_args\n@rem Slurp the command line arguments.\nset CMD_LINE_ARGS=\nset _SKIP=2\n\n:win9xME_args_slurp\nif \"x%~1\" == \"x\" goto execute\n\nset CMD_LINE_ARGS=%*\ngoto execute\n\n:4NT_args\n@rem Get arguments from the 4NT Shell from JP Software\nset CMD_LINE_ARGS=%$\n\n:execute\n@rem Setup the command line\n\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\n\n@rem Execute Gradle\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%\n\n:end\n@rem End local scope for the variables with windows NT shell\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\n\n:fail\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\nrem the _cmd.exe /c_ return code!\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\nexit /b 1\n\n:mainEnd\nif \"%OS%\"==\"Windows_NT\" endlocal\n\n:omega\n"
  },
  {
    "path": "settings.gradle",
    "content": "include ':app'\n"
  }
]