├── app
├── .gitignore
├── src
│ ├── .DS_Store
│ ├── main
│ │ ├── .DS_Store
│ │ ├── res
│ │ │ ├── .DS_Store
│ │ │ ├── drawable-nodpi
│ │ │ │ ├── logo.png
│ │ │ │ ├── .DS_Store
│ │ │ │ ├── flash_off.png
│ │ │ │ ├── flash_on.png
│ │ │ │ ├── img_geo.png
│ │ │ │ ├── img_mail.png
│ │ │ │ ├── img_sms.png
│ │ │ │ ├── img_tel.png
│ │ │ │ ├── img_url.png
│ │ │ │ ├── img_wifi.png
│ │ │ │ ├── img_wood.png
│ │ │ │ ├── img_bear_1.png
│ │ │ │ ├── img_bear_2.png
│ │ │ │ ├── img_bird_1.png
│ │ │ │ ├── img_bird_2.png
│ │ │ │ ├── img_calendar.png
│ │ │ │ ├── img_contactor.png
│ │ │ │ ├── img_elephant.png
│ │ │ │ ├── img_geo_press.png
│ │ │ │ ├── img_mail_press.png
│ │ │ │ ├── img_sms_press.png
│ │ │ │ ├── img_tel_press.png
│ │ │ │ ├── img_url_press.png
│ │ │ │ ├── img_wifi_press.png
│ │ │ │ ├── img_calendar_press.png
│ │ │ │ └── img_contactor_press.png
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── layout
│ │ │ │ ├── activity_setting.xml
│ │ │ │ ├── activity_type_generate.xml
│ │ │ │ ├── activity_scan.xml
│ │ │ │ ├── item_type.xml
│ │ │ │ ├── activity_generate.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── dialog_web.xml
│ │ │ │ ├── dialog_tel.xml
│ │ │ │ ├── dialog_mail.xml
│ │ │ │ ├── dialog_sms.xml
│ │ │ │ ├── dialog_geo.xml
│ │ │ │ ├── dialog_wifi.xml
│ │ │ │ └── activity_result.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── values
│ │ │ │ ├── styles.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── strings.xml
│ │ │ ├── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ ├── values-zh-rTW
│ │ │ │ └── strings.xml
│ │ │ └── drawable
│ │ │ │ ├── btn_style_circle_yellow.xml
│ │ │ │ ├── btn_style_result.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ ├── assets
│ │ │ └── fonts
│ │ │ │ └── font.ttf
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── showlin
│ │ │ │ └── simpleQRCode
│ │ │ │ ├── ShowApplication.kt
│ │ │ │ ├── activity
│ │ │ │ ├── BaseActivity.kt
│ │ │ │ ├── ScanActivity.kt
│ │ │ │ ├── MainActivity.kt
│ │ │ │ ├── ResultActivity.kt
│ │ │ │ ├── GenerateActivity.kt
│ │ │ │ └── TypeGenerateActivity.kt
│ │ │ │ └── Utility.kt
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── showlin
│ │ │ └── simpleQRCode
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── showlin
│ │ └── simpleQRCode
│ │ └── ExampleInstrumentedTest.kt
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .idea
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
└── misc.xml
├── README.md
├── gradle.properties
├── .gitignore
├── gradlew.bat
├── gradlew
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/.DS_Store
--------------------------------------------------------------------------------
/app/src/main/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/.DS_Store
--------------------------------------------------------------------------------
/app/src/main/res/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/.DS_Store
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/font.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/assets/fonts/font.ttf
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/.DS_Store
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/flash_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/flash_off.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/flash_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/flash_on.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_geo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_geo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_mail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_mail.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_sms.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_sms.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_tel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_tel.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_url.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_url.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_wifi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_wifi.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_wood.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_wood.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_bear_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_bear_1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_bear_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_bear_2.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_bird_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_bird_1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_bird_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_bird_2.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_calendar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_calendar.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_contactor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_contactor.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_elephant.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_elephant.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_geo_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_geo_press.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_mail_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_mail_press.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_sms_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_sms_press.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_tel_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_tel_press.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_url_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_url_press.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_wifi_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_wifi_press.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_calendar_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_calendar_press.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_contactor_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/drawable-nodpi/img_contactor_press.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinHsiu/zxing-kotlin-simple/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # zxing-kotlin-simple
2 | A simple qr code scan and generate.
3 |
4 | ### Reference
5 | Zxing https://github.com/zxing/zxing/
6 |
7 | zxing-android-embedded https://github.com/journeyapps/zxing-android-embedded#custom-layout
8 |
--------------------------------------------------------------------------------
/app/src/main/java/com/showlin/simpleQRCode/ShowApplication.kt:
--------------------------------------------------------------------------------
1 | package com.showlin.simpleQRCode
2 |
3 |
4 | import android.app.Application
5 |
6 | class ShowApplication : Application() {
7 | override fun onCreate() {
8 | super.onCreate()
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_setting.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Jan 31 11:45:18 CST 2018
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-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/showlin/simpleQRCode/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.showlin.simpleQRCode
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_type_generate.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #53C0F0
4 | #51A2D9
5 | #8A140E
6 | #E0E8F0
7 | #89E5F3
8 | #FFFFFF
9 |
10 | #94d0b4
11 | #f9ca5e
12 | #e7bb5a
13 | #f0716a
14 |
15 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_scan.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
18 |
19 |
--------------------------------------------------------------------------------
/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 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/showlin/simpleQRCode/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.showlin.simpleQRCode
2 |
3 | import android.support.test.InstrumentationRegistry
4 | import android.support.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 | assertEquals("com.showlin.zxing_kotlin_simple", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_type.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 | .idea/tasks.xml
39 | .idea/gradle.xml
40 | .idea/dictionaries
41 | .idea/libraries
42 |
43 | # Keystore files
44 | *.jks
45 |
46 | # External native build folder generated in Android Studio 2.2 and later
47 | .externalNativeBuild
48 |
49 | # Google Services (e.g. APIs or Firebase)
50 | google-services.json
51 |
52 | # Freeline
53 | freeline.py
54 | freeline/
55 | freeline_project_description.json
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/showlin/simpleQRCode/activity/BaseActivity.kt:
--------------------------------------------------------------------------------
1 | package com.showlin.simpleQRCode.activity
2 |
3 | import android.os.Build
4 | import android.os.Bundle
5 | import android.support.v4.content.ContextCompat
6 | import android.support.v7.app.AppCompatActivity
7 | import android.view.View
8 | import android.view.WindowManager
9 | import com.showlin.simpleQRCode.R
10 |
11 | open class BaseActivity : AppCompatActivity(){
12 | override fun onCreate(savedInstanceState: Bundle?) {
13 | super.onCreate(savedInstanceState)
14 | val window = this.window
15 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
16 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
17 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
18 | window.statusBarColor = ContextCompat.getColor(this, R.color.colorPrimary)
19 | }
20 | window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
21 | }
22 | }
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | apply plugin: 'kotlin-android'
4 |
5 | apply plugin: 'kotlin-android-extensions'
6 |
7 | android {
8 | compileSdkVersion 26
9 | defaultConfig {
10 | applicationId "com.showlin.zxing_kotlin_simple"
11 | minSdkVersion 19
12 | targetSdkVersion 26
13 | versionCode 1
14 | versionName "1.0"
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | implementation fileTree(include: ['*.jar'], dir: 'libs')
27 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
28 | implementation 'com.android.support:appcompat-v7:26.1.0'
29 | implementation 'com.android.support.constraint:constraint-layout:1.0.2'
30 | testImplementation 'junit:junit:4.12'
31 | androidTestImplementation 'com.android.support.test:runner:1.0.1'
32 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
33 | compile 'com.journeyapps:zxing-android-embedded:3.5.0@aar'
34 | compile 'com.google.zxing:core:3.3.0'
35 | implementation 'com.android.support:recyclerview-v7:26.1.0'
36 | }
37 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
32 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_generate.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
17 |
18 |
26 |
27 |
36 |
37 |
44 |
45 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/app/src/main/java/com/showlin/simpleQRCode/Utility.kt:
--------------------------------------------------------------------------------
1 | package com.showlin.simpleQRCode
2 |
3 | import android.app.Activity
4 | import android.content.Intent
5 | import android.graphics.Bitmap
6 | import android.graphics.Color
7 | import com.google.zxing.BarcodeFormat
8 | import com.google.zxing.EncodeHintType
9 | import com.google.zxing.MultiFormatWriter
10 | import com.google.zxing.WriterException
11 | import com.google.zxing.common.BitMatrix
12 | import com.google.zxing.common.CharacterSetECI
13 | import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel
14 | import com.showlin.simpleQRCode.activity.ScanActivity
15 | import java.util.*
16 |
17 |
18 | object Utility {
19 | const val KEY_RESULT = "KEY_RESULT"
20 | const val KEY_CONTENT = "KEY_CONTENT"
21 |
22 | const val REQUEST_CODE= 2304
23 | const val WRITE_PERMISSION = 2134
24 |
25 | fun scan(activity: Activity){
26 | val intent = Intent(activity, ScanActivity::class.java)
27 | activity.startActivityForResult(intent, REQUEST_CODE)
28 | }
29 |
30 | @Throws(WriterException::class)
31 | fun generateQR(value: String) : Bitmap? {
32 | val bitMatrix: BitMatrix
33 | try {
34 | val hints = EnumMap(EncodeHintType::class.java)
35 | hints[EncodeHintType.ERROR_CORRECTION] = ErrorCorrectionLevel.H
36 | hints[EncodeHintType.CHARACTER_SET] = CharacterSetECI.UTF8
37 |
38 | bitMatrix = MultiFormatWriter().encode(
39 | value,
40 | BarcodeFormat.QR_CODE,
41 | 500,
42 | 500,
43 | hints
44 | )
45 | }catch (Illegalargumentexception : IllegalArgumentException){
46 | return null
47 | }
48 |
49 | val bitMatrixWidth = bitMatrix.width
50 |
51 | val bitMatrixHeight = bitMatrix.height
52 |
53 | val pixels = IntArray(bitMatrixWidth * bitMatrixHeight)
54 |
55 | for (y in 0 until bitMatrixHeight) {
56 | val offset = y * bitMatrixWidth
57 |
58 | for (x in 0 until bitMatrixWidth) {
59 |
60 | pixels[offset + x] = if (bitMatrix.get(x, y))
61 | Color.BLACK
62 | else
63 | Color.WHITE
64 | }
65 | }
66 | val bitmap = Bitmap.createBitmap(bitMatrixWidth, bitMatrixHeight, Bitmap.Config.ARGB_4444)
67 | bitmap.setPixels(pixels, 0, 500, 0, 0, bitMatrixWidth, bitMatrixHeight)
68 |
69 | return bitmap
70 | }
71 | }
--------------------------------------------------------------------------------
/app/src/main/res/values-zh-rTW/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | QR code
6 | 擷取
7 | 產生
8 | QR code
9 |
10 |
11 | 結果
12 | 哈囉
13 | 好
14 | 取消
15 |
16 |
17 | WIFI
18 | 你要連結到\n%1$s嗎?
19 | 連結 WIFI
20 |
21 |
22 |
23 | 網站
24 | 前往網站
25 |
26 |
27 | 簡訊
28 | 發送 簡訊
29 |
30 |
31 | 經緯度
32 | 打開地圖
33 |
34 |
35 | 電話
36 | 撥電話
37 |
38 |
39 | 電子郵件
40 | 發送 電子郵件
41 |
42 |
43 | 文字
44 |
45 |
46 |
47 | 儲存
48 | 類別產生
49 |
50 |
51 |
52 | WIFI
53 | 網頁
54 | 簡訊
55 | 經緯度
56 | 電話
57 | 電子郵件
58 | MECARD
59 | VCARD
60 | VEVENT
61 |
62 |
63 |
64 | 緯度
65 | 精度
66 | 查詢
67 |
68 |
69 | 電子信箱
70 |
71 |
72 | 訊息
73 | 電話號碼
74 |
75 |
76 | 網址
77 |
78 |
79 | SSID
80 | 密碼
81 | 網路連結類別
82 | 無
83 | 是否隱藏?
84 |
85 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | QR code
5 | Capture
6 | Generate
7 | QR code
8 |
9 |
10 | Result
11 | Hi
12 | OK
13 | Cancel
14 |
15 |
16 | WIFI
17 | Do you want to connect to\n%1$s
18 | Connect WIFI
19 |
20 |
21 |
22 | Website
23 | Go to website
24 |
25 |
26 | SMS
27 | Send SMS
28 |
29 |
30 | Geography
31 | Open map
32 |
33 |
34 | Telephone
35 | Call
36 |
37 |
38 | E-mail
39 | Send E-mail
40 |
41 |
42 | Text
43 |
44 |
45 |
46 | Save
47 | Type Generate
48 |
49 |
50 |
51 | WIFI
52 | WEB
53 | SMS
54 | GEO
55 | TEL
56 | MAIL
57 | MECARD
58 | VCARD
59 | VEVENT
60 |
61 |
62 |
63 | Latitude
64 | Longitude
65 | Query
66 |
67 |
68 | Mail Address
69 |
70 |
71 | MESSAGE
72 | Phone Number
73 |
74 |
75 | URL
76 |
77 |
78 | SSID
79 | Password
80 | Network Type
81 | NONE
82 | Hidden?
83 |
84 |
85 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/showlin/simpleQRCode/activity/ScanActivity.kt:
--------------------------------------------------------------------------------
1 | package com.showlin.simpleQRCode.activity
2 |
3 | import android.app.Activity
4 | import android.app.Service
5 | import android.content.Intent
6 | import android.os.Build
7 | import android.os.Bundle
8 | import android.os.Vibrator
9 | import android.support.v4.content.ContextCompat
10 | import android.view.View
11 | import android.view.WindowManager
12 | import com.google.zxing.ResultPoint
13 | import com.journeyapps.barcodescanner.BarcodeCallback
14 | import com.journeyapps.barcodescanner.BarcodeResult
15 | import com.showlin.simpleQRCode.R
16 | import com.showlin.simpleQRCode.Utility.KEY_RESULT
17 | import kotlinx.android.synthetic.main.activity_scan.*
18 |
19 |
20 | class ScanActivity : Activity(){
21 | private var isTorch = false
22 |
23 | override fun onCreate(savedInstanceState: Bundle?) {
24 | super.onCreate(savedInstanceState)
25 | val window = this.window
26 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
27 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
28 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
29 | window.statusBarColor = ContextCompat.getColor(this, android.R.color.transparent)
30 | }
31 |
32 | window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
33 |
34 | setContentView(R.layout.activity_scan)
35 | barcode_view.decodeContinuous(callback)
36 |
37 | img_flash.setOnClickListener {
38 | if (isTorch){
39 | isTorch = false
40 | img_flash.setImageResource(R.drawable.flash_off)
41 | }else{
42 | isTorch = true
43 | img_flash.setImageResource(R.drawable.flash_on)
44 | }
45 | barcode_view.setTorch(isTorch)
46 | }
47 | }
48 |
49 | override fun onResume() {
50 | barcode_view.resume()
51 | super.onResume()
52 | }
53 |
54 | override fun onPause() {
55 | barcode_view.pause()
56 | super.onPause()
57 | }
58 |
59 | private val callback = object : BarcodeCallback{
60 | override fun possibleResultPoints(resultPoints: MutableList?) {
61 |
62 | }
63 |
64 | override fun barcodeResult(result: BarcodeResult?) {
65 | if (result!!.text != null){
66 | val intent = Intent()
67 | val bundle = Bundle()
68 | bundle.putString(KEY_RESULT, result.text.toString())
69 | intent.putExtras(bundle)
70 | setResult(Activity.RESULT_OK, intent)
71 | val vibrator = application.getSystemService(Service.VIBRATOR_SERVICE) as Vibrator
72 | vibrator.vibrate(100)
73 | finish()
74 | }
75 | }
76 |
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
18 |
19 |
26 |
27 |
31 |
32 |
45 |
46 |
53 |
54 |
62 |
63 |
74 |
75 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_web.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
14 |
15 |
19 |
27 |
28 |
29 |
30 |
37 |
44 |
51 |
52 |
53 |
60 |
61 |
71 |
75 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_tel.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
14 |
15 |
19 |
27 |
28 |
29 |
30 |
37 |
44 |
51 |
52 |
53 |
54 |
61 |
62 |
72 |
76 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_mail.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
14 |
15 |
19 |
27 |
28 |
29 |
30 |
37 |
44 |
51 |
52 |
53 |
54 |
61 |
62 |
72 |
76 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/btn_style_circle_yellow.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
7 |
8 |
14 |
15 |
16 |
21 |
22 |
25 |
26 |
30 |
31 |
32 |
33 | -
34 |
36 |
37 |
43 |
44 |
45 |
50 |
51 |
54 |
55 |
59 |
60 |
61 |
62 | -
63 |
65 |
66 |
72 |
73 |
74 |
79 |
80 |
83 |
84 |
88 |
89 |
90 |
91 |
92 | -
93 |
95 |
96 |
102 |
103 |
104 |
109 |
110 |
113 |
114 |
118 |
119 |
120 |
121 |
122 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/btn_style_result.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
7 |
8 |
10 |
11 |
17 |
18 |
19 |
24 |
25 |
28 |
29 |
33 |
34 |
35 |
36 | -
37 |
39 |
41 |
42 |
48 |
49 |
50 |
55 |
56 |
59 |
60 |
64 |
65 |
66 |
67 | -
68 |
70 |
72 |
73 |
79 |
80 |
81 |
86 |
87 |
90 |
91 |
95 |
96 |
97 |
98 |
99 | -
100 |
102 |
104 |
105 |
111 |
112 |
113 |
118 |
119 |
122 |
123 |
127 |
128 |
129 |
130 |
131 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_sms.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
14 |
15 |
19 |
27 |
28 |
29 |
30 |
37 |
44 |
51 |
52 |
53 |
60 |
67 |
74 |
75 |
76 |
83 |
84 |
94 |
98 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_geo.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
14 |
15 |
19 |
27 |
28 |
29 |
30 |
37 |
44 |
51 |
52 |
53 |
60 |
67 |
74 |
75 |
76 |
83 |
90 |
96 |
97 |
98 |
105 |
106 |
116 |
120 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/java/com/showlin/simpleQRCode/activity/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.showlin.simpleQRCode.activity
2 |
3 | import android.app.Activity
4 | import android.content.Intent
5 | import android.graphics.Typeface
6 | import android.os.Build
7 | import android.os.Bundle
8 | import android.support.v4.content.ContextCompat
9 | import android.support.v7.app.AppCompatActivity
10 | import android.view.View
11 | import android.view.WindowManager
12 | import android.view.animation.AccelerateInterpolator
13 | import android.view.animation.Animation
14 | import android.view.animation.RotateAnimation
15 | import android.view.animation.TranslateAnimation
16 | import com.showlin.simpleQRCode.R
17 | import com.showlin.simpleQRCode.Utility
18 | import com.showlin.simpleQRCode.Utility.REQUEST_CODE
19 | import kotlinx.android.synthetic.main.activity_main.*
20 | import android.app.ActivityManager.TaskDescription
21 | import android.content.res.Resources
22 | import android.graphics.BitmapFactory
23 | import android.graphics.Bitmap
24 |
25 |
26 |
27 |
28 | class MainActivity : BaseActivity() {
29 | var isSwitch = false
30 |
31 | override fun onCreate(savedInstanceState: Bundle?) {
32 | super.onCreate(savedInstanceState)
33 | setContentView(R.layout.activity_main)
34 |
35 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
36 | val bm = BitmapFactory.decodeResource(resources, R.drawable.logo)
37 | val taskDesc = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
38 | TaskDescription(getString(R.string.app_name), bm, ContextCompat.getColor(this, R.color.color1))
39 | } else {
40 | TODO("VERSION.SDK_INT < LOLLIPOP")
41 | }
42 | setTaskDescription(taskDesc)
43 | }
44 |
45 |
46 | btn_capture.setOnClickListener{
47 | val animation = RotateAnimation(0f, -360f, Animation.ABSOLUTE, btn_capture.pivotX, Animation.ABSOLUTE, btn_capture.pivotY + 100)
48 | animation.duration = 600
49 | animation.interpolator = object : AccelerateInterpolator(){}
50 | img_bear_white.startAnimation(animation)
51 | animation.setAnimationListener(object :Animation.AnimationListener{
52 | override fun onAnimationRepeat(animation: Animation?) {
53 | }
54 |
55 | override fun onAnimationEnd(animation: Animation?) {
56 | runOnUiThread {Utility.scan(this@MainActivity)}
57 | }
58 |
59 | override fun onAnimationStart(animation: Animation?) {
60 | }
61 |
62 | })
63 | }
64 |
65 | img_bear_white.setOnClickListener {
66 | val animation = RotateAnimation(0f, -360f, Animation.ABSOLUTE, btn_capture.pivotX, Animation.ABSOLUTE, btn_capture.pivotY + 100)
67 | animation.duration = 600
68 | animation.interpolator = object : AccelerateInterpolator(){}
69 | img_bear_white.startAnimation(animation)
70 | }
71 |
72 | btn_generate.setOnClickListener {
73 | val animation = RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f)
74 | animation.duration = 300
75 | img_bear_brown.startAnimation(animation)
76 | animation.setAnimationListener(object :Animation.AnimationListener{
77 | override fun onAnimationRepeat(animation: Animation?) {
78 | }
79 |
80 | override fun onAnimationEnd(animation: Animation?) {
81 | runOnUiThread {
82 | val intent = Intent(this@MainActivity, GenerateActivity::class.java)
83 | startActivity(intent)
84 | }
85 | }
86 |
87 | override fun onAnimationStart(animation: Animation?) {
88 | }
89 |
90 | })
91 | }
92 |
93 | img_bear_brown.setOnClickListener {
94 | val animation = RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f)
95 | animation.duration = 300
96 | img_bear_brown.startAnimation(animation)
97 | }
98 |
99 | text_title.typeface = Typeface.createFromAsset(assets, "fonts/font.ttf")
100 | text_title.setOnClickListener{
101 | isSwitch = !isSwitch
102 | val oneX = img_bird_1.x
103 | val twoX = img_bird_2.x
104 | val offset = Math.abs(oneX - twoX)
105 |
106 | val animation = TranslateAnimation(0f, offset, 0f, 0f)
107 | animation.duration = 300
108 | animation.isFillEnabled = true
109 | animation.fillAfter = true
110 | animation.setAnimationListener(object : Animation.AnimationListener{
111 | override fun onAnimationRepeat(animation: Animation?) {
112 |
113 | }
114 |
115 | override fun onAnimationEnd(animation: Animation?) {
116 | if (isSwitch){
117 | img_bird_1.setImageResource(R.drawable.img_bird_2)
118 | }else{
119 | img_bird_1.setImageResource(R.drawable.img_bird_1)
120 | }
121 | img_bird_1.clearAnimation()
122 | }
123 |
124 | override fun onAnimationStart(animation: Animation?) {
125 | }
126 |
127 | })
128 | img_bird_1.startAnimation(animation)
129 |
130 |
131 | val animation2 = TranslateAnimation(0f, -offset, 0f, 0f)
132 | animation2.duration = 300
133 | animation2.isFillEnabled = true
134 | animation2.fillAfter = true
135 | animation2.setAnimationListener(object : Animation.AnimationListener{
136 | override fun onAnimationRepeat(animation: Animation?) {
137 |
138 | }
139 |
140 | override fun onAnimationEnd(animation: Animation?) {
141 | if (isSwitch){
142 | img_bird_2.setImageResource(R.drawable.img_bird_1)
143 | }else{
144 | img_bird_2.setImageResource(R.drawable.img_bird_2)
145 | }
146 | img_bird_2.clearAnimation()
147 | }
148 |
149 | override fun onAnimationStart(animation: Animation?) {
150 |
151 | }
152 |
153 | })
154 | img_bird_2.startAnimation(animation2)
155 | }
156 | }
157 |
158 | override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
159 | if (requestCode == REQUEST_CODE){
160 | if (resultCode == Activity.RESULT_OK){
161 | val bundleResult = data!!.extras
162 | val intent = Intent(this, ResultActivity::class.java)
163 | intent.putExtras(bundleResult)
164 | startActivity(intent)
165 | }
166 | }
167 | }
168 | }
169 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_wifi.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
15 |
16 |
20 |
28 |
29 |
30 |
31 |
38 |
45 |
51 |
52 |
53 |
60 |
67 |
73 |
74 |
75 |
82 |
89 |
95 |
101 |
107 |
113 |
114 |
115 |
116 |
117 |
124 |
131 |
136 |
137 |
138 |
139 |
146 |
147 |
157 |
161 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
--------------------------------------------------------------------------------
/app/src/main/java/com/showlin/simpleQRCode/activity/ResultActivity.kt:
--------------------------------------------------------------------------------
1 | package com.showlin.simpleQRCode.activity
2 |
3 | import android.content.Context
4 | import android.content.Intent
5 | import android.net.Uri
6 | import android.net.wifi.WifiConfiguration
7 | import android.net.wifi.WifiManager
8 | import android.os.Bundle
9 | import android.support.v7.app.AlertDialog
10 | import android.util.ArrayMap
11 | import android.view.MenuItem
12 | import android.view.View
13 | import com.showlin.simpleQRCode.R
14 | import com.showlin.simpleQRCode.Utility.KEY_RESULT
15 | import kotlinx.android.synthetic.main.activity_result.*
16 |
17 |
18 | class ResultActivity : BaseActivity() {
19 |
20 | override fun onCreate(savedInstanceState: Bundle?) {
21 | super.onCreate(savedInstanceState)
22 | setContentView(R.layout.activity_result)
23 |
24 | val bundle = intent.extras
25 |
26 | supportActionBar!!.title = getString(R.string.result)
27 | supportActionBar!!.setDisplayHomeAsUpEnabled(true)
28 |
29 | pareInfo(bundle.getString(KEY_RESULT))
30 | }
31 |
32 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
33 | if (item.itemId == android.R.id.home) {
34 | finish()
35 | return true
36 | }
37 | return super.onOptionsItemSelected(item)
38 | }
39 |
40 | private fun pareInfo(resultString: String){
41 | when {
42 | resultString.indexOf("WIFI:") == 0 -> // WIFI
43 | getWIFI(resultString)
44 | resultString.indexOf("http") == 0 -> // Website
45 | getWebsite(resultString)
46 | resultString.indexOf("smsto:") == 0 -> //SMS
47 | getSMS(resultString)
48 | resultString.indexOf("geo:") == 0 -> //GEO
49 | getGEO(resultString)
50 | resultString.indexOf("tel:") == 0 -> //TEL
51 | getTEL(resultString)
52 | resultString.indexOf("mailto:") == 0 -> //MAIL
53 | getMail(resultString)
54 | // resultString.indexOf("MECARD:") == 0 -> {
55 | // //MECARD
56 | // }
57 | // resultString.indexOf("BEGIN:VCARD") == 0 -> //VCARD
58 | // getVcard()
59 | // resultString.indexOf("BEGIN:VEVENT") == 0 -> {
60 | // //VEVENT
61 | // }
62 | else -> //TEXT
63 | getTextType(resultString)
64 | }
65 | }
66 |
67 | private fun getWIFI(stringResult : String){
68 | ll_wifi.visibility = View.VISIBLE
69 | text_wifi_string.text = stringResult
70 |
71 | val subString = stringResult.substring(5)
72 | val strings = subString.split(";".toRegex()).dropLastWhile({ it.isEmpty() }).toTypedArray()
73 | val map = ArrayMap()
74 | strings.indices
75 | .map { i -> strings[i].split(":".toRegex()).dropLastWhile({ it.isEmpty() }).toTypedArray() }
76 | .forEach { map[it[0]] = it[1] }
77 | btn_wifi.setOnClickListener {
78 | val alertDialog = AlertDialog.Builder(this)
79 | .setTitle(getString(R.string.hi))
80 | .setMessage(String.format(getString(R.string.wifi_connect), map["S"]))
81 | .setNeutralButton(getString(R.string.ok), { dialog, _ ->
82 | val wifiManager = applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
83 | val configuration = WifiConfiguration()
84 | configuration.SSID = "\"" + map["S"] + "\""
85 | configuration.status = WifiConfiguration.Status.ENABLED
86 |
87 | if (map.containsKey("T")) {
88 | if (map["T"].equals("WPA")) {
89 | configuration.preSharedKey = "\"" + map["P"] + "\""
90 | configuration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK)
91 | configuration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP)
92 | configuration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP)
93 | configuration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP)
94 | configuration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP)
95 | configuration.allowedProtocols.set(WifiConfiguration.Protocol.RSN)
96 | configuration.allowedProtocols.set(WifiConfiguration.Protocol.WPA)
97 | } else if (map["T"].equals("WEP")) {
98 | configuration.wepKeys[0] = "\"" + map["P"] + "\""
99 | configuration.wepTxKeyIndex = 0
100 | configuration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE)
101 | configuration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40)
102 | }
103 | } else {
104 | configuration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE)
105 | }
106 |
107 | val netID = wifiManager.addNetwork(configuration)
108 | wifiManager.enableNetwork(netID, true)
109 | wifiManager.reconnect()
110 |
111 | dialog.dismiss()
112 | })
113 | .setPositiveButton(getString(R.string.cancel), { dialog, _ -> dialog.dismiss() })
114 | .create()
115 | alertDialog.show()
116 | }
117 | }
118 |
119 | private fun getWebsite(resultString: String) {
120 | ll_url.visibility = View.VISIBLE
121 | text_url_string.text = resultString
122 | btn_url.setOnClickListener {
123 | val intent = Intent()
124 | intent.action = Intent.ACTION_VIEW
125 | intent.data = Uri.parse(resultString)
126 | startActivity(intent)
127 | }
128 | }
129 |
130 | private fun getSMS(resultString: String) {
131 | ll_sms.visibility = View.VISIBLE
132 | text_sms_string.text = resultString
133 | val strResult = resultString.split(":".toRegex()).dropLastWhile({ it.isEmpty() }).toTypedArray()
134 |
135 | btn_sms.setOnClickListener {
136 | val uri = Uri.fromParts("sms", strResult[1], null)
137 | val intent = Intent(Intent.ACTION_SENDTO, uri)
138 | intent.putExtra("sms_body", strResult[2])
139 | startActivity(intent)
140 | }
141 | }
142 |
143 | private fun getGEO(resultString: String) {
144 | ll_geo.visibility = View.VISIBLE
145 | text_geo_string.text = resultString
146 | btn_geo.setOnClickListener {
147 | val uri = Uri.parse(resultString)
148 | val intent = Intent(Intent.ACTION_VIEW, uri)
149 | startActivity(intent)
150 | }
151 | }
152 |
153 | private fun getTEL(resultString: String) {
154 | ll_tel.visibility = View.VISIBLE
155 | text_tel_string.text = resultString
156 | btn_tel.setOnClickListener {
157 | val uri = Uri.parse(resultString)
158 | val intent = Intent(Intent.ACTION_DIAL)
159 | intent.data = uri
160 | startActivity(intent)
161 | }
162 | }
163 |
164 | private fun getMail(resultString: String) {
165 | ll_email.visibility = View.VISIBLE
166 | text_email_string.text = resultString
167 |
168 | btn_email.setOnClickListener {
169 | val intent = Intent(Intent.ACTION_SENDTO)
170 | intent.data = Uri.parse(resultString)
171 | startActivity(intent)
172 | }
173 | }
174 |
175 | private fun getTextType(resultString: String) {
176 | ll_text.visibility = View.VISIBLE
177 | text_text_string.text = resultString
178 | }
179 |
180 | private fun getVcard() {
181 | // var contentProviderOperation = ContentProviderOperation.newInsert(Content)
182 | }
183 |
184 |
185 |
186 | }
187 |
--------------------------------------------------------------------------------
/app/src/main/java/com/showlin/simpleQRCode/activity/GenerateActivity.kt:
--------------------------------------------------------------------------------
1 | package com.showlin.simpleQRCode.activity
2 |
3 | import android.content.ContentResolver
4 | import android.content.ContentUris
5 | import android.content.ContentValues
6 | import android.content.Intent
7 | import android.content.pm.PackageManager
8 | import android.graphics.Bitmap
9 | import android.graphics.Matrix
10 | import android.net.Uri
11 | import android.os.Build
12 | import android.os.Bundle
13 | import android.provider.MediaStore
14 | import android.support.annotation.RequiresApi
15 | import android.view.MenuItem
16 | import android.view.View
17 | import com.showlin.simpleQRCode.R
18 | import com.showlin.simpleQRCode.Utility
19 | import com.showlin.simpleQRCode.Utility.KEY_CONTENT
20 | import com.showlin.simpleQRCode.Utility.REQUEST_CODE
21 | import kotlinx.android.synthetic.main.activity_generate.*
22 | import java.io.IOException
23 | import java.util.*
24 |
25 |
26 | class GenerateActivity : BaseActivity(){
27 | private var mTextInput : String? = null
28 | private var mQRBitmap : Bitmap? = null
29 |
30 | override fun onCreate(savedInstanceState: Bundle?) {
31 | super.onCreate(savedInstanceState)
32 | setContentView(R.layout.activity_generate)
33 |
34 | supportActionBar!!.title = getString(R.string.generate)
35 | supportActionBar!!.setDisplayHomeAsUpEnabled(true)
36 |
37 | btn_go_generate.setOnClickListener {
38 | mQRBitmap = Utility.generateQR(edit_input.text.toString())
39 | if (mQRBitmap != null){
40 | mTextInput = edit_input.text.toString()
41 | img_qr_code.setImageBitmap(mQRBitmap)
42 | btn_save.visibility = View.VISIBLE
43 | }else{
44 | btn_save.visibility = View.INVISIBLE
45 | img_qr_code.setImageBitmap(null)
46 | mQRBitmap = null
47 | }
48 | }
49 |
50 | btn_save.setOnClickListener {
51 |
52 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
53 | if (checkSelfPermission("android.permission.WRITE_EXTERNAL_STORAGE") != PackageManager.PERMISSION_GRANTED){
54 | val strings = Array(1) { "android.permission.WRITE_EXTERNAL_STORAGE" }
55 | requestPermissions(strings, Utility.WRITE_PERMISSION)
56 | return@setOnClickListener
57 | }
58 | }
59 |
60 | CapturePhotoUtils.insertImage(contentResolver, mQRBitmap, Date().time.toString(), this.mTextInput!!)
61 | }
62 |
63 | btn_type_generate.setOnClickListener {
64 | val intent = Intent(this@GenerateActivity, TypeGenerateActivity::class.java)
65 | startActivityForResult(intent, REQUEST_CODE)
66 | }
67 | }
68 |
69 | override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
70 | super.onActivityResult(requestCode, resultCode, data)
71 | if (requestCode == REQUEST_CODE){
72 | if (data != null){
73 | val strContent = data!!.getStringExtra(KEY_CONTENT)
74 | edit_input.setText(strContent)
75 | mQRBitmap = Utility.generateQR(edit_input.text.toString())
76 | if (mQRBitmap != null){
77 | mTextInput = edit_input.text.toString()
78 | img_qr_code.setImageBitmap(mQRBitmap)
79 | btn_save.visibility = View.VISIBLE
80 | }else{
81 | btn_save.visibility = View.INVISIBLE
82 | img_qr_code.setImageBitmap(null)
83 | mQRBitmap = null
84 | }
85 | }
86 |
87 | }
88 | }
89 |
90 | @RequiresApi(Build.VERSION_CODES.M)
91 | override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) {
92 | super.onRequestPermissionsResult(requestCode, permissions, grantResults)
93 | if(requestCode == Utility.WRITE_PERMISSION){
94 | for (i in permissions.indices ){
95 | if (grantResults.get(i) != PackageManager.PERMISSION_GRANTED){
96 | val strings = Array(1) { "android.permission.WRITE_EXTERNAL_STORAGE" }
97 | requestPermissions(strings, Utility.WRITE_PERMISSION)
98 | }
99 | }
100 | }
101 | }
102 |
103 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
104 | if (item.itemId == android.R.id.home) {
105 | finish()
106 | return true
107 | }
108 | return super.onOptionsItemSelected(item)
109 | }
110 | }
111 |
112 |
113 | object CapturePhotoUtils {
114 |
115 | fun insertImage(cr: ContentResolver,
116 | source: Bitmap?,
117 | title: String,
118 | description: String): String? {
119 |
120 | val values = ContentValues()
121 | values.put(MediaStore.Images.Media.TITLE, title)
122 | values.put(MediaStore.Images.Media.DISPLAY_NAME, title)
123 | values.put(MediaStore.Images.Media.DESCRIPTION, description)
124 | values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg")
125 | // Add the date meta data to ensure the image is added at the front of the gallery
126 | values.put(MediaStore.Images.Media.DATE_ADDED, System.currentTimeMillis())
127 | values.put(MediaStore.Images.Media.DATE_TAKEN, System.currentTimeMillis())
128 |
129 | var url: Uri? = null
130 | var stringUrl: String? = null /* value to be returned */
131 |
132 | try {
133 | url = cr.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values)
134 |
135 | if (source != null) {
136 | assert(url != null)
137 | val imageOut = cr.openOutputStream(url!!)
138 | try {
139 | source.compress(Bitmap.CompressFormat.JPEG, 50, imageOut)
140 | } finally {
141 | assert(imageOut != null)
142 | imageOut!!.close()
143 | }
144 |
145 | val id = ContentUris.parseId(url)
146 | // Wait until MINI_KIND thumbnail is generated.
147 | val miniThumb = MediaStore.Images.Thumbnails.getThumbnail(cr, id, MediaStore.Images.Thumbnails.MINI_KIND, null)
148 | // This is for backward compatibility.
149 | storeThumbnail(cr, miniThumb, id, MediaStore.Images.Thumbnails.MICRO_KIND)
150 | } else {
151 | assert(url != null)
152 | cr.delete(url!!, null, null)
153 | url = null
154 | }
155 | } catch (e: Exception) {
156 | if (url != null) {
157 | cr.delete(url, null, null)
158 | url = null
159 | }
160 | }
161 |
162 | if (url != null) {
163 | stringUrl = url.toString()
164 | }
165 |
166 | return stringUrl
167 | }
168 |
169 | private fun storeThumbnail(
170 | cr: ContentResolver,
171 | source: Bitmap,
172 | id: Long,
173 | kind: Int) {
174 |
175 | val matrix = Matrix()
176 |
177 | val scaleX = 50f / source.width
178 | val scaleY = 50f / source.height
179 |
180 | matrix.setScale(scaleX, scaleY)
181 |
182 | val thumb = Bitmap.createBitmap(source, 0, 0,
183 | source.width,
184 | source.height, matrix,
185 | true
186 | )
187 |
188 | val values = ContentValues(4)
189 | values.put(MediaStore.Images.Thumbnails.KIND, kind)
190 | values.put(MediaStore.Images.Thumbnails.IMAGE_ID, id.toInt())
191 | values.put(MediaStore.Images.Thumbnails.HEIGHT, thumb.height)
192 | values.put(MediaStore.Images.Thumbnails.WIDTH, thumb.width)
193 |
194 | val url = cr.insert(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, values)
195 |
196 | try {
197 | assert(url != null)
198 | val thumbOut = cr.openOutputStream(url!!)
199 | thumb.compress(Bitmap.CompressFormat.JPEG, 100, thumbOut)
200 | assert(thumbOut != null)
201 | thumbOut!!.close()
202 | } catch (ignored: IOException) {
203 | }
204 |
205 | }
206 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_result.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
41 |
42 |
50 |
51 |
52 |
53 |
59 |
60 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
86 |
87 |
95 |
96 |
97 |
98 |
99 |
105 |
106 |
114 |
115 |
122 |
123 |
132 |
133 |
140 |
141 |
142 |
143 |
144 |
150 |
151 |
159 |
160 |
167 |
168 |
177 |
178 |
185 |
186 |
187 |
188 |
189 |
195 |
196 |
204 |
205 |
212 |
213 |
222 |
223 |
230 |
231 |
232 |
233 |
234 |
240 |
241 |
249 |
250 |
257 |
258 |
267 |
268 |
275 |
276 |
277 |
278 |
284 |
285 |
293 |
294 |
301 |
302 |
311 |
312 |
313 |
314 |
315 |
--------------------------------------------------------------------------------
/app/src/main/java/com/showlin/simpleQRCode/activity/TypeGenerateActivity.kt:
--------------------------------------------------------------------------------
1 | package com.showlin.simpleQRCode.activity
2 |
3 | import android.app.Dialog
4 | import android.content.Context
5 | import android.content.Intent
6 | import android.content.res.ColorStateList
7 | import android.graphics.drawable.StateListDrawable
8 | import android.os.Bundle
9 | import android.support.v4.content.ContextCompat
10 | import android.support.v7.widget.GridLayoutManager
11 | import android.support.v7.widget.RecyclerView
12 | import android.view.LayoutInflater
13 | import android.view.MenuItem
14 | import android.view.View
15 | import android.view.ViewGroup
16 | import android.widget.ImageView
17 | import android.widget.LinearLayout
18 | import android.widget.TextView
19 | import com.showlin.simpleQRCode.R
20 | import com.showlin.simpleQRCode.Utility.KEY_CONTENT
21 | import com.showlin.simpleQRCode.Utility.REQUEST_CODE
22 | import kotlinx.android.synthetic.main.activity_type_generate.*
23 | import kotlinx.android.synthetic.main.dialog_geo.*
24 | import kotlinx.android.synthetic.main.dialog_mail.*
25 | import kotlinx.android.synthetic.main.dialog_sms.*
26 | import kotlinx.android.synthetic.main.dialog_tel.*
27 | import kotlinx.android.synthetic.main.dialog_web.*
28 | import kotlinx.android.synthetic.main.dialog_wifi.*
29 |
30 |
31 | class TypeGenerateActivity : BaseActivity() {
32 | override fun onCreate(savedInstanceState: Bundle?) {
33 | super.onCreate(savedInstanceState)
34 | setContentView(R.layout.activity_type_generate)
35 |
36 | supportActionBar!!.title = getString(R.string.type_generate)
37 | supportActionBar!!.setDisplayHomeAsUpEnabled(true)
38 |
39 | recycle_view.setHasFixedSize(true)
40 | recycle_view.layoutManager = GridLayoutManager(this, 3)
41 | recycle_view.adapter = TypeAdapter(this)
42 | }
43 |
44 |
45 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
46 | if (item.itemId == android.R.id.home) {
47 | finish()
48 | return true
49 | }
50 | return super.onOptionsItemSelected(item)
51 | }
52 |
53 |
54 | fun sendResult(strResult : String){
55 | val intent = Intent()
56 | intent.putExtra(KEY_CONTENT, strResult)
57 | setResult(REQUEST_CODE, intent)
58 | }
59 | }
60 |
61 | class TypeAdapter(private val activity: TypeGenerateActivity) : RecyclerView.Adapter() {
62 |
63 | private val mTypeNameArray = intArrayOf(R.string.wifi, R.string.website, R.string.sms, R.string.geo, R.string.tel, R.string.mail, R.string.mecard, R.string.vcard, R.string.vevent)
64 | private val mTypeArray = intArrayOf(R.drawable.img_wifi, R.drawable.img_url, R.drawable.img_sms, R.drawable.img_geo, R.drawable.img_tel, R.drawable.img_mail, R.drawable.img_contactor, R.drawable.img_contactor, R.drawable.img_calendar)
65 | private val mTypePressArray = intArrayOf(R.drawable.img_wifi_press, R.drawable.img_url_press, R.drawable.img_sms_press, R.drawable.img_geo_press, R.drawable.img_tel_press, R.drawable.img_mail_press, R.drawable.img_contactor_press, R.drawable.img_contactor_press, R.drawable.img_calendar_press)
66 |
67 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TypeHolder {
68 | val view = LayoutInflater.from(parent.context).inflate(R.layout.item_type, parent, false)
69 |
70 | return TypeHolder(view)
71 | }
72 |
73 | override fun onBindViewHolder(holder: TypeHolder, position: Int) {
74 | setClickStatusImg(activity, mTypeArray[position], mTypePressArray[position], holder.imgLogo)
75 | setClickStatusTxt(activity, R.color.colorWhite, R.color.color2, holder.textTypeName)
76 | holder.textTypeName.setText(mTypeNameArray[position])
77 |
78 |
79 | holder.llGroup.setOnClickListener {
80 | when (position) {
81 | TYPE_WIFI -> {
82 | val dialog = Dialog(activity)
83 | dialog.setContentView(R.layout.dialog_wifi)
84 | dialog.setCancelable(false)
85 | dialog.group_radio.check(dialog.type_none.id)
86 | dialog.show()
87 | dialog.text_dialog_generate.setOnClickListener {
88 | val strWifi = generateWifiString(dialog.edit_ssid.text.toString(), dialog.edit_password.text.toString(), dialog.group_radio.checkedRadioButtonId, dialog.check_box.isChecked, dialog)
89 | activity.sendResult(strWifi)
90 | activity.finish()
91 | dialog.dismiss()
92 | }
93 | dialog.text_dialog_cancel.setOnClickListener {
94 | dialog.dismiss()
95 | }
96 | }
97 | TYPE_WEBSITE -> {
98 | val dialog = Dialog(activity)
99 | dialog.setCancelable(false)
100 | dialog.setContentView(R.layout.dialog_web)
101 | dialog.show()
102 | dialog.text_dialog_generate_url.setOnClickListener {
103 | val strURL = generateURLString(dialog.edit_url.text.toString())
104 | activity.sendResult(strURL)
105 | activity.finish()
106 | dialog.dismiss()
107 | }
108 | dialog.text_dialog_cancel_url.setOnClickListener {
109 | dialog.dismiss()
110 | }
111 | }
112 | TYPE_SMS -> {
113 | val dialog = Dialog(activity)
114 | dialog.setCancelable(false)
115 | dialog.setContentView(R.layout.dialog_sms)
116 | dialog.show()
117 | dialog.text_dialog_generate_sms.setOnClickListener {
118 | val strURL = generateSMSString(dialog.edit_sms_tel.text.toString(), dialog.edit_sms_message.text.toString())
119 | activity.sendResult(strURL)
120 | activity.finish()
121 | dialog.dismiss()
122 | }
123 | dialog.text_dialog_cancel_sms.setOnClickListener {
124 | dialog.dismiss()
125 | }
126 | }
127 | TYPE_GEO -> {
128 | val dialog = Dialog(activity)
129 | dialog.setCancelable(false)
130 | dialog.setContentView(R.layout.dialog_geo)
131 | dialog.show()
132 | dialog.text_dialog_generate_geo.setOnClickListener {
133 | val strURL = generateGEOString(dialog.edit_geo_latitude.text.toString(), dialog.edit_geo_longitude.text.toString(), dialog.edit_geo_query.text.toString())
134 | activity.sendResult(strURL)
135 | activity.finish()
136 | dialog.dismiss()
137 | }
138 | dialog.text_dialog_cancel_geo.setOnClickListener {
139 | dialog.dismiss()
140 | }
141 | }
142 | TYPE_TEL -> {
143 | val dialog = Dialog(activity)
144 | dialog.setCancelable(false)
145 | dialog.setContentView(R.layout.dialog_tel)
146 | dialog.show()
147 | dialog.text_dialog_generate_tel.setOnClickListener {
148 | val strURL = generateTELString(dialog.edit_tel_number.text.toString())
149 | activity.sendResult(strURL)
150 | activity.finish()
151 | dialog.dismiss()
152 | }
153 | dialog.text_dialog_cancel_tel.setOnClickListener {
154 | dialog.dismiss()
155 | }
156 | }
157 | TYPE_MAIL -> {
158 | val dialog = Dialog(activity)
159 | dialog.setCancelable(false)
160 | dialog.setContentView(R.layout.dialog_mail)
161 | dialog.show()
162 | dialog.text_dialog_generate_mail.setOnClickListener {
163 | val strURL = generateMAILString(dialog.edit_mail_address.text.toString())
164 | activity.sendResult(strURL)
165 | activity.finish()
166 | dialog.dismiss()
167 | }
168 | dialog.text_dialog_cancel_mail.setOnClickListener {
169 | dialog.dismiss()
170 | }
171 | }
172 | TYPE_MECARD -> {
173 | }
174 | TYPE_VCARD -> {
175 | }
176 | TYPE_VEVENT -> {
177 | }
178 | }
179 | }
180 |
181 | holder.textTypeName.setOnClickListener { }
182 | }
183 |
184 | private fun generateMAILString(mail: String): String {
185 | var strResult = "mailto:"
186 | strResult += mail
187 | return strResult
188 | }
189 |
190 | private fun generateTELString(tel: String): String {
191 | var strResult = "tel:"
192 | strResult += tel
193 | return strResult
194 | }
195 |
196 | private fun generateGEOString(latitude: String, longitude: String, query: String): String {
197 | var strResult = "geo:"
198 | strResult += latitude + "," + longitude + "q=" + query
199 | return strResult
200 | }
201 |
202 | private fun generateSMSString(tel: String, message: String): String {
203 | var strResult = "smsto:"
204 | if (tel == ""){
205 | return ""
206 | }
207 | strResult += tel
208 | strResult += ":" + message
209 | return strResult
210 | }
211 |
212 | private fun generateURLString(url: String): String {
213 | var strResult = url
214 | if (url.indexOf("http") != 0){
215 | strResult = "http://" + url
216 | }
217 | return strResult
218 | }
219 |
220 | private fun generateWifiString(ssid: String, password: String, type: Int, hidden: Boolean, dialog: Dialog): String {
221 | if (ssid == ""){
222 | return ""
223 | }
224 | var strResult = "WIFI:"
225 | strResult += "S:$ssid;"
226 | if (password != ""){
227 | strResult += "P:$password;"
228 | }
229 | when(type){
230 | dialog.type_wep.id->{
231 | strResult += "T:WEP;"
232 | }
233 | dialog.type_wpa.id->{
234 | strResult += "T:WPA;"
235 | }
236 | dialog.type_none.id->{}
237 | }
238 |
239 | if (hidden){
240 | strResult += "H:true;"
241 | }
242 | strResult += ";"
243 | return strResult
244 | }
245 |
246 |
247 |
248 | override fun getItemCount(): Int {
249 | return mTypeNameArray.size - 3
250 | }
251 |
252 | private fun setClickStatusImg(context: Context, nNormal: Int, nPressed: Int, imgview: ImageView) {
253 | val states = StateListDrawable()
254 | states.addState(intArrayOf(android.R.attr.state_pressed), ContextCompat.getDrawable(context, nPressed))
255 | states.addState(intArrayOf(android.R.attr.state_focused), ContextCompat.getDrawable(context, nPressed))
256 | states.addState(intArrayOf(), ContextCompat.getDrawable(context, nNormal))
257 | imgview.setImageDrawable(states)
258 | }
259 |
260 | private fun setClickStatusTxt(context: Context, nNormal: Int, nPressed: Int, textView: TextView) {
261 | val colorStateList = ColorStateList(
262 | arrayOf(intArrayOf(android.R.attr.state_pressed), intArrayOf(android.R.attr.state_selected), intArrayOf(-android.R.attr.state_selected)),
263 | intArrayOf(ContextCompat.getColor(context, nPressed), ContextCompat.getColor(context, nPressed), ContextCompat.getColor(context, nNormal)))
264 | textView.setTextColor(colorStateList)
265 | }
266 |
267 | companion object {
268 | const val TYPE_WIFI = 0
269 | const val TYPE_WEBSITE = 1
270 | const val TYPE_SMS = 2
271 | const val TYPE_GEO = 3
272 | const val TYPE_TEL = 4
273 | const val TYPE_MAIL = 5
274 | const val TYPE_MECARD = 6
275 | const val TYPE_VCARD = 7
276 | const val TYPE_VEVENT = 8
277 | }
278 | }
279 |
280 | class TypeHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
281 | var llGroup: LinearLayout = itemView.findViewById(R.id.ll_group)
282 | var imgLogo: ImageView = itemView.findViewById(R.id.img_logo)
283 | var textTypeName: TextView = itemView.findViewById(R.id.text_type_name)
284 |
285 | }
286 |
287 |
--------------------------------------------------------------------------------