├── demo ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ │ ├── ic_default_qr.png │ │ │ │ ├── ic_build_white_36dp.png │ │ │ │ ├── ic_clear_white_36dp.png │ │ │ │ └── ic_slideshow_white_36dp.png │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── styles.xml │ │ │ │ └── strings.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ ├── menu │ │ │ │ └── main.xml │ │ │ └── layout │ │ │ │ ├── activity_main.xml │ │ │ │ └── activity_generator.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── me │ │ │ └── ydcool │ │ │ └── qrmodule │ │ │ └── demo │ │ │ ├── MainActivity.java │ │ │ └── DemoGeneratorActivity.java │ ├── test │ │ └── java │ │ │ └── me │ │ │ └── ydcool │ │ │ └── qrmodule │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── me │ │ └── ydcool │ │ └── qrmodule │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── qrmodule ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── raw │ │ │ │ └── beep.ogg │ │ │ ├── drawable-xhdpi │ │ │ │ ├── ic_flash_on_white_36dp.png │ │ │ │ ├── ic_arrow_back_white_36dp.png │ │ │ │ └── ic_flash_off_white_36dp.png │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ └── colors.xml │ │ │ ├── values-zh-rCN │ │ │ │ └── strings.xml │ │ │ ├── menu │ │ │ │ └── capture_menu.xml │ │ │ └── layout │ │ │ │ └── activity_qr_scanner.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── me │ │ │ └── ydcool │ │ │ └── lib │ │ │ └── qrmodule │ │ │ ├── common │ │ │ └── Cons.java │ │ │ ├── view │ │ │ ├── ViewfinderResultPointCallback.java │ │ │ └── ViewfinderView.java │ │ │ ├── decoding │ │ │ ├── FinishListener.java │ │ │ ├── InactivityTimer.java │ │ │ ├── DecodeThread.java │ │ │ ├── DecodeFormatManager.java │ │ │ ├── DecodeHandler.java │ │ │ ├── CaptureActivityHandler.java │ │ │ └── Intents.java │ │ │ ├── camera │ │ │ ├── AutoFocusCallback.java │ │ │ ├── PreviewCallback.java │ │ │ ├── PlanarYUVLuminanceSource.java │ │ │ ├── FlashlightManager.java │ │ │ ├── CameraConfigurationManager.java │ │ │ └── CameraManager.java │ │ │ ├── encoding │ │ │ └── QrGenerator.java │ │ │ └── activity │ │ │ └── QrScannerActivity.java │ ├── test │ │ └── java │ │ │ └── me │ │ │ └── ydcool │ │ │ └── lib │ │ │ └── qrmodule │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── me │ │ └── ydcool │ │ └── lib │ │ └── qrmodule │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── art ├── demo_scan.gif └── demo_generate.gif ├── .gitignore ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .travis.yml ├── gradle.properties ├── gradlew.bat ├── README.md ├── gradlew └── LICENSE /demo/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /qrmodule/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':demo', ':qrmodule' 2 | -------------------------------------------------------------------------------- /art/demo_scan.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ydcool/QrModule/HEAD/art/demo_scan.gif -------------------------------------------------------------------------------- /art/demo_generate.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ydcool/QrModule/HEAD/art/demo_generate.gif -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea 5 | .DS_Store 6 | /build 7 | /captures 8 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ydcool/QrModule/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /qrmodule/src/main/res/raw/beep.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ydcool/QrModule/HEAD/qrmodule/src/main/res/raw/beep.ogg -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ydcool/QrModule/HEAD/demo/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ydcool/QrModule/HEAD/demo/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ydcool/QrModule/HEAD/demo/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ydcool/QrModule/HEAD/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ydcool/QrModule/HEAD/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable-xhdpi/ic_default_qr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ydcool/QrModule/HEAD/demo/src/main/res/drawable-xhdpi/ic_default_qr.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable-xhdpi/ic_build_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ydcool/QrModule/HEAD/demo/src/main/res/drawable-xhdpi/ic_build_white_36dp.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable-xhdpi/ic_clear_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ydcool/QrModule/HEAD/demo/src/main/res/drawable-xhdpi/ic_clear_white_36dp.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable-xhdpi/ic_slideshow_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ydcool/QrModule/HEAD/demo/src/main/res/drawable-xhdpi/ic_slideshow_white_36dp.png -------------------------------------------------------------------------------- /qrmodule/src/main/res/drawable-xhdpi/ic_flash_on_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ydcool/QrModule/HEAD/qrmodule/src/main/res/drawable-xhdpi/ic_flash_on_white_36dp.png -------------------------------------------------------------------------------- /qrmodule/src/main/res/drawable-xhdpi/ic_arrow_back_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ydcool/QrModule/HEAD/qrmodule/src/main/res/drawable-xhdpi/ic_arrow_back_white_36dp.png -------------------------------------------------------------------------------- /qrmodule/src/main/res/drawable-xhdpi/ic_flash_off_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ydcool/QrModule/HEAD/qrmodule/src/main/res/drawable-xhdpi/ic_flash_off_white_36dp.png -------------------------------------------------------------------------------- /qrmodule/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | QrModule 3 | Scan Barcode 4 | Flash Light 5 | 6 | -------------------------------------------------------------------------------- /demo/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /demo/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /qrmodule/src/main/res/values-zh-rCN/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 二维码模块 4 | 将取景框对准二维码,即可自动扫描 5 | 闪光灯 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Jan 26 09:19:12 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 7 | -------------------------------------------------------------------------------- /qrmodule/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /qrmodule/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #66ffffff 4 | #ffff0000 5 | #60000000 6 | #b0000000 7 | #c0ffff00 8 | -------------------------------------------------------------------------------- /qrmodule/src/main/res/menu/capture_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | -------------------------------------------------------------------------------- /demo/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | sudo: false 3 | jdk: oraclejdk7 4 | android: 5 | components: 6 | - tools 7 | - build-tools-23.0.2 8 | - android-23 9 | - extra-android-m2repository 10 | - extra-android-support 11 | script: 12 | - ./gradlew assembleRelease 13 | deploy: 14 | provider: releases 15 | file: app/build/outputs/apk/app-release.apk 16 | skip_cleanup: true 17 | on: 18 | tags: true 19 | -------------------------------------------------------------------------------- /demo/src/test/java/me/ydcool/qrmodule/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package me.ydcool.qrmodule; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /qrmodule/src/test/java/me/ydcool/lib/qrmodule/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package me.ydcool.lib.qrmodule; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /demo/src/androidTest/java/me/ydcool/qrmodule/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package me.ydcool.qrmodule; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /demo/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /qrmodule/src/androidTest/java/me/ydcool/lib/qrmodule/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package me.ydcool.lib.qrmodule; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /qrmodule/src/main/java/me/ydcool/lib/qrmodule/common/Cons.java: -------------------------------------------------------------------------------- 1 | package me.ydcool.lib.qrmodule.common; 2 | 3 | /** 4 | * Created by ydcool on 15/11/18. 5 | * 6 | * @author ydcool 7 | */ 8 | public class Cons { 9 | public static final int ID_AUTO_FOCUS = 100; 10 | public static final int ID_RESTART_PREVIEW = 101; 11 | public static final int ID_DECODE_SUCCEED = 102; 12 | public static final int ID_DECODE_FAILED = 103; 13 | public static final int ID_RETURN_SCAN_RESULT = 104; 14 | public static final int ID_LAUNCH_PRODUCT_QUERY = 105; 15 | public static final int ID_DECODE = 106; 16 | public static final int ID_QUIT = 107; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /demo/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/Shared/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /demo/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | applicationId "me.ydcool.qrmodule" 9 | minSdkVersion 14 10 | targetSdkVersion 22 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | testCompile 'junit:junit:4.12' 25 | compile project (':qrmodule') 26 | compile 'com.android.support:appcompat-v7:23.1.1' 27 | compile 'com.jakewharton:butterknife:6.1.0' 28 | } 29 | -------------------------------------------------------------------------------- /demo/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 21 | 22 | 29 | 30 | -------------------------------------------------------------------------------- /demo/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /qrmodule/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/Shared/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -keep class !android.support.v7.internal.view.menu.**,android.support.** {*;} 19 | 20 | -keep class android.support.v4.app.** { *; } 21 | -keep interface android.support.v4.app.** { *; } 22 | 23 | -keep class android.support.v7.app.** { *; } 24 | -keep interface android.support.v7.app.** { *; } 25 | 26 | -keep class android.support.v7.internal.** { *; } 27 | -keep interface android.support.v7.internal.** { *; } 28 | -------------------------------------------------------------------------------- /qrmodule/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | minSdkVersion 14 9 | targetSdkVersion 22 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | lintOptions { 20 | abortOnError false 21 | } 22 | } 23 | 24 | dependencies { 25 | compile fileTree(dir: 'libs', include: ['*.jar']) 26 | testCompile 'junit:junit:4.12' 27 | compile 'com.google.zxing:core:latest.integration' 28 | } 29 | 30 | buildscript { 31 | repositories { 32 | jcenter() 33 | } 34 | dependencies { 35 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2' 36 | classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1" 37 | } 38 | } 39 | 40 | //apply from: 'bintray.gradle' 41 | apply from:'https://raw.githubusercontent.com/Ydcool/EasingAndroid/master/lib/bintray.gradle' 42 | -------------------------------------------------------------------------------- /qrmodule/src/main/java/me/ydcool/lib/qrmodule/view/ViewfinderResultPointCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package me.ydcool.lib.qrmodule.view; 18 | 19 | import com.google.zxing.ResultPoint; 20 | import com.google.zxing.ResultPointCallback; 21 | 22 | public final class ViewfinderResultPointCallback implements ResultPointCallback { 23 | 24 | private final ViewfinderView viewfinderView; 25 | 26 | public ViewfinderResultPointCallback(ViewfinderView viewfinderView) { 27 | this.viewfinderView = viewfinderView; 28 | } 29 | 30 | public void foundPossibleResultPoint(ResultPoint point) { 31 | viewfinderView.addPossibleResultPoint(point); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | PROJ_GROUP=me.ydcool.lib 20 | PROJ_VERSION=1.0 21 | PROJ_NAME=QrModule 22 | PROJ_WEBSITEURL=https://github.com/Ydcool/QrModule 23 | PROJ_ISSUETRACKERURL=https://github.com/Ydcool/QrModule/issues 24 | PROJ_VCSURL=https://github.com/Ydcool/QrModule.git 25 | PROJ_DESCRIPTION=Qr Scanner and generator module for Android 26 | PROJ_ARTIFACTID=qrmodule 27 | 28 | DEVELOPER_ID=ydcool 29 | DEVELOPER_NAME=ydcool 30 | DEVELOPER_EMAIL=hi@ydcool.me 31 | 32 | # placeholders for travis 33 | BINTRAY_USER=ydcool 34 | BINTRAY_KEY=**** 35 | -------------------------------------------------------------------------------- /qrmodule/src/main/java/me/ydcool/lib/qrmodule/decoding/FinishListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package me.ydcool.lib.qrmodule.decoding; 18 | 19 | import android.app.Activity; 20 | import android.content.DialogInterface; 21 | 22 | /** 23 | * Simple listener used to exit the app in a few cases. 24 | */ 25 | public final class FinishListener 26 | implements DialogInterface.OnClickListener, DialogInterface.OnCancelListener, Runnable { 27 | 28 | private final Activity activityToFinish; 29 | 30 | public FinishListener(Activity activityToFinish) { 31 | this.activityToFinish = activityToFinish; 32 | } 33 | 34 | public void onCancel(DialogInterface dialogInterface) { 35 | run(); 36 | } 37 | 38 | public void onClick(DialogInterface dialogInterface, int i) { 39 | run(); 40 | } 41 | 42 | public void run() { 43 | activityToFinish.finish(); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /demo/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | QrModule 3 | Start Scan 4 | Scan Result Here 5 | Input Content(Required) 6 | Error Correction Level(Default:L(~7%)) 7 | Overlay:ON 8 | Overlay:OFF 9 | Overlay Xfermode 10 | Footnote(Feature Under Develop) 11 | Qr Image Size(Required) 12 | QrCode Margin(Default:2) 13 | Set Qr Code Color.Default is Black(0,0,0) 14 | R(0~255) 15 | G(0~255) 16 | B(0~255) 17 | Set Qr Code Background Color.Default is White(255,255,255) 18 | R(0~255) 19 | G(0~255) 20 | B(0~255) 21 | Generate! 22 | Over Size(Required If Overlay has Set) 23 | Overlay Alpha,Default:255(Opaque) 24 | Clear 25 | Generate 26 | 0~255 27 | Generated QrCode. 28 | 29 | 30 | -------------------------------------------------------------------------------- /demo/src/main/java/me/ydcool/qrmodule/demo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package me.ydcool.qrmodule.demo; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.widget.TextView; 7 | 8 | import butterknife.ButterKnife; 9 | import butterknife.InjectView; 10 | import butterknife.OnClick; 11 | import me.ydcool.lib.qrmodule.activity.QrScannerActivity; 12 | import me.ydcool.qrmodule.R; 13 | 14 | public class MainActivity extends AppCompatActivity { 15 | 16 | @InjectView(R.id.txt_scan_result) 17 | TextView mTxtScanResult; 18 | 19 | @Override 20 | protected void onCreate(Bundle savedInstanceState) { 21 | super.onCreate(savedInstanceState); 22 | setContentView(R.layout.activity_main); 23 | ButterKnife.inject(this); 24 | } 25 | 26 | @OnClick(R.id.Main_btn_scan) 27 | void onScanBtnClick() { 28 | startActivityForResult( 29 | new Intent(MainActivity.this, QrScannerActivity.class), 30 | QrScannerActivity.QR_REQUEST_CODE); 31 | } 32 | 33 | @OnClick(R.id.Main_btn_generate) 34 | void onGenerateBtnClick() { 35 | startActivity(new Intent(MainActivity.this, DemoGeneratorActivity.class)); 36 | } 37 | 38 | @Override 39 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 40 | super.onActivityResult(requestCode, resultCode, data); 41 | if (requestCode == QrScannerActivity.QR_REQUEST_CODE) { 42 | mTxtScanResult.setText( 43 | resultCode == RESULT_OK 44 | ? data.getExtras().getString(QrScannerActivity.QR_RESULT_STR) 45 | : "Scanned Nothing!"); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /demo/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 17 | 18 |