├── .gitignore ├── .idea ├── .gitignore ├── .name ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── compiler.xml ├── gradle.xml ├── jarRepositories.xml └── misc.xml ├── QR code Reaeder.zip ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── codingwithme │ │ └── qrcodereaeder │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── codingwithme │ │ │ └── qrcodereaeder │ │ │ └── MainActivity.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── ic_launcher_background.xml │ │ └── ic_qr_code.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── 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 │ │ ├── values-night │ │ └── themes.xml │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── themes.xml │ └── test │ └── java │ └── com │ └── codingwithme │ └── qrcodereaeder │ └── ExampleUnitTest.kt ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | QR code Reaeder -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 119 | 120 | 122 | 123 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /QR code Reaeder.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-with-me/QR_Code_Reader/712e6d9052511a041641406eafd680286cc62d9c/QR code Reaeder.zip -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'kotlin-android' 4 | } 5 | 6 | android { 7 | compileSdkVersion 30 8 | buildToolsVersion "30.0.1" 9 | 10 | defaultConfig { 11 | applicationId "com.codingwithme.qrcodereaeder" 12 | minSdkVersion 21 13 | targetSdkVersion 30 14 | versionCode 1 15 | versionName "1.0" 16 | 17 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' 18 | } 19 | 20 | buildTypes { 21 | release { 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 24 | } 25 | } 26 | compileOptions { 27 | sourceCompatibility JavaVersion.VERSION_1_8 28 | targetCompatibility JavaVersion.VERSION_1_8 29 | } 30 | kotlinOptions { 31 | jvmTarget = '1.8' 32 | } 33 | } 34 | 35 | dependencies { 36 | 37 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 38 | implementation 'androidx.appcompat:appcompat:1.0.0' 39 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 40 | testImplementation 'junit:junit:4.+' 41 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 42 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' 43 | implementation "androidx.cardview:cardview:1.0.0" 44 | implementation 'pub.devrel:easypermissions:3.0.0' 45 | implementation 'com.journeyapps:zxing-android-embedded:3.0.1@aar' 46 | implementation 'com.google.zxing:core:3.3.0' 47 | } -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /app/src/androidTest/java/com/codingwithme/qrcodereaeder/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.codingwithme.qrcodereaeder 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.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.getInstrumentation().targetContext 22 | assertEquals("com.codingwithme.qrcodereaeder", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/codingwithme/qrcodereaeder/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.codingwithme.qrcodereaeder 2 | 3 | import android.content.Intent 4 | import android.graphics.drawable.Animatable 5 | import androidx.appcompat.app.AppCompatActivity 6 | import android.os.Bundle 7 | import android.view.View 8 | import android.view.animation.Animation 9 | import android.view.animation.AnimationUtils 10 | import android.widget.Button 11 | import android.widget.EditText 12 | import android.widget.TextView 13 | import android.widget.Toast 14 | import androidx.cardview.widget.CardView 15 | import com.google.zxing.integration.android.IntentIntegrator 16 | import com.journeyapps.barcodescanner.CaptureActivity 17 | import org.json.JSONException 18 | import org.w3c.dom.Text 19 | import pub.devrel.easypermissions.AppSettingsDialog 20 | import pub.devrel.easypermissions.EasyPermissions 21 | import java.util.jar.Manifest 22 | 23 | class MainActivity : AppCompatActivity(), EasyPermissions.PermissionCallbacks, 24 | EasyPermissions.RationaleCallbacks { 25 | var cardView1: CardView? = null 26 | var cardView2: CardView? = null 27 | var btnScan: Button? = null 28 | var btnEnterCode: Button? = null 29 | var btnEnter: Button? = null 30 | var edtCode: EditText? = null 31 | var tvText: TextView? = null 32 | var hide: Animation? = null 33 | var reveal: Animation? = null 34 | override fun onCreate(savedInstanceState: Bundle?) { 35 | super.onCreate(savedInstanceState) 36 | setContentView(R.layout.activity_main) 37 | 38 | cardView1 = findViewById(R.id.cardView1) 39 | cardView2 = findViewById(R.id.cardView2) 40 | btnScan = findViewById(R.id.btnScan) 41 | btnEnterCode = findViewById(R.id.btnEnterCode) 42 | btnEnter = findViewById(R.id.btnEnter) 43 | edtCode = findViewById(R.id.edtCode) 44 | tvText = findViewById(R.id.tvText) 45 | 46 | hide = AnimationUtils.loadAnimation(this, android.R.anim.fade_out) 47 | reveal = AnimationUtils.loadAnimation(this, android.R.anim.fade_in) 48 | 49 | tvText!!.startAnimation(reveal) 50 | cardView2!!.startAnimation(reveal) 51 | tvText!!.setText("Scan QR Code Here") 52 | cardView2!!.visibility = View.VISIBLE 53 | 54 | btnScan!!.setOnClickListener { 55 | tvText!!.startAnimation(reveal) 56 | cardView1!!.startAnimation(hide) 57 | cardView2!!.startAnimation(reveal) 58 | 59 | cardView2!!.visibility = View.VISIBLE 60 | cardView1!!.visibility = View.GONE 61 | tvText!!.setText("Scan QR Code Here") 62 | 63 | 64 | 65 | } 66 | 67 | cardView2!!.setOnClickListener { 68 | cameraTask() 69 | } 70 | 71 | btnEnter!!.setOnClickListener { 72 | 73 | if (edtCode!!.text.toString().isNullOrEmpty()) { 74 | Toast.makeText(this, "Please enter code", Toast.LENGTH_SHORT).show() 75 | } else { 76 | var value = edtCode!!.text.toString() 77 | 78 | Toast.makeText(this, value, Toast.LENGTH_SHORT).show() 79 | 80 | } 81 | } 82 | btnEnterCode!!.setOnClickListener { 83 | tvText!!.startAnimation(reveal) 84 | cardView1!!.startAnimation(reveal) 85 | cardView2!!.startAnimation(hide) 86 | 87 | cardView2!!.visibility = View.GONE 88 | cardView1!!.visibility = View.VISIBLE 89 | tvText!!.setText("Enter QR Code Here") 90 | } 91 | 92 | } 93 | 94 | private fun hasCameraAccess(): Boolean { 95 | return EasyPermissions.hasPermissions(this, android.Manifest.permission.CAMERA) 96 | } 97 | 98 | private fun cameraTask() { 99 | 100 | if (hasCameraAccess()) { 101 | 102 | var qrScanner = IntentIntegrator(this) 103 | qrScanner.setPrompt("scan a QR code") 104 | qrScanner.setCameraId(0) 105 | qrScanner.setOrientationLocked(true) 106 | qrScanner.setBeepEnabled(true) 107 | qrScanner.captureActivity = CaptureActivity::class.java 108 | qrScanner.initiateScan() 109 | } else { 110 | EasyPermissions.requestPermissions( 111 | this, 112 | "This app needs access to your camera so you can take pictures.", 113 | 123, 114 | android.Manifest.permission.CAMERA 115 | ) 116 | } 117 | } 118 | 119 | override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { 120 | 121 | 122 | var result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data) 123 | if (result != null) { 124 | if (result.contents == null) { 125 | Toast.makeText(this, "Result Not Found", Toast.LENGTH_SHORT).show() 126 | edtCode!!.setText("") 127 | } else { 128 | try { 129 | 130 | cardView1!!.startAnimation(reveal) 131 | cardView2!!.startAnimation(hide) 132 | cardView1!!.visibility = View.VISIBLE 133 | cardView2!!.visibility = View.GONE 134 | edtCode!!.setText(result.contents.toString()) 135 | } catch (exception: JSONException) { 136 | Toast.makeText(this, exception.localizedMessage, Toast.LENGTH_SHORT).show() 137 | edtCode!!.setText("") 138 | } 139 | } 140 | } else { 141 | super.onActivityResult(requestCode, resultCode, data) 142 | } 143 | 144 | if (requestCode == AppSettingsDialog.DEFAULT_SETTINGS_REQ_CODE) { 145 | Toast.makeText(this, "Permission Granted", Toast.LENGTH_SHORT).show() 146 | } 147 | } 148 | 149 | override fun onRequestPermissionsResult( 150 | requestCode: Int, 151 | permissions: Array, 152 | grantResults: IntArray 153 | ) { 154 | super.onRequestPermissionsResult(requestCode, permissions, grantResults) 155 | EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this) 156 | } 157 | 158 | override fun onPermissionsDenied(requestCode: Int, perms: MutableList) { 159 | if (EasyPermissions.somePermissionPermanentlyDenied(this, perms)) { 160 | AppSettingsDialog.Builder(this).build().show() 161 | } 162 | } 163 | 164 | override fun onPermissionsGranted(requestCode: Int, perms: MutableList) { 165 | } 166 | 167 | override fun onRationaleDenied(requestCode: Int) { 168 | } 169 | 170 | override fun onRationaleAccepted(requestCode: Int) { 171 | } 172 | 173 | 174 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /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/res/drawable/ic_qr_code.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 15 | 18 | 21 | 24 | 27 | 30 | 33 | 36 | 39 | 42 | 43 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 22 | 23 | 36 | 37 | 38 | 44 | 45 | 56 | 57 | 58 | 59 |