diff --git a/BlinkIDSample/BlinkID-MinimalSampleAdvanced/build.gradle b/BlinkIDSample/BlinkID-MinimalSampleAdvanced/build.gradle new file mode 100644 index 00000000..afcb09ba --- /dev/null +++ b/BlinkIDSample/BlinkID-MinimalSampleAdvanced/build.gradle @@ -0,0 +1,57 @@ +apply plugin: 'com.android.application' +apply plugin: 'org.jetbrains.kotlin.android' +apply plugin: 'kotlin-android' + +android { + namespace 'com.microblink.blinkid' + compileSdk 34 + + defaultConfig { + applicationId "com.microblink.blinkid" + minSdk 21 + targetSdk 34 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + debuggable true + minifyEnabled true + shrinkResources true + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + splits { + abi { + enable true + reset() + include 'armeabi-v7a', 'arm64-v8a' + universalApk true + } + } + + lintOptions { + checkReleaseBuilds false + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation("com.microblink:blinkid:${rootProject.ext.blinkIdVersion}@aar") { + transitive = true + } + + implementation 'androidx.activity:activity-ktx:1.7.0-alpha02' + + // uncomment this to use custom LibBlinkID build +// implementation project(':LibBlinkID') +// implementation "androidx.appcompat:appcompat:${rootProject.ext.appCompatVersion}" +} \ No newline at end of file diff --git a/BlinkIDSample/BlinkID-MinimalSampleAdvanced/proguard-rules.pro b/BlinkIDSample/BlinkID-MinimalSampleAdvanced/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/BlinkIDSample/BlinkID-MinimalSampleAdvanced/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/AndroidManifest.xml b/BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/AndroidManifest.xml new file mode 100644 index 00000000..ed6170fd --- /dev/null +++ b/BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/AndroidManifest.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/assets/com.microblink.blinkid.mblic b/BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/assets/com.microblink.blinkid.mblic new file mode 100644 index 00000000..9a09b426 Binary files /dev/null and b/BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/assets/com.microblink.blinkid.mblic differ diff --git a/BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/java/com/microblink/blinkid/BlinkIdSampleApp.kt b/BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/java/com/microblink/blinkid/BlinkIdSampleApp.kt new file mode 100644 index 00000000..906ec8cd --- /dev/null +++ b/BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/java/com/microblink/blinkid/BlinkIdSampleApp.kt @@ -0,0 +1,17 @@ +package com.microblink.blinkid + +import android.app.Application +import com.microblink.blinkid.intent.IntentDataTransferMode + +class BlinkIdSampleApp : Application() { + + override fun onCreate() { + super.onCreate() + // obtain your licence at http://microblink.com/login or contact us at http://help.microblink.com + MicroblinkSDK.setLicenseFile("com.microblink.blinkid.mblic", this) + + // use optimised way for transferring RecognizerBundle between activities, while ensuring + // data does not get lost when Android restarts the scanning activity + MicroblinkSDK.setIntentDataTransferMode(IntentDataTransferMode.PERSISTED_OPTIMISED) + } +} \ No newline at end of file diff --git a/BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/java/com/microblink/blinkid/MainActivity.kt b/BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/java/com/microblink/blinkid/MainActivity.kt new file mode 100644 index 00000000..269112b3 --- /dev/null +++ b/BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/java/com/microblink/blinkid/MainActivity.kt @@ -0,0 +1,75 @@ +package com.microblink.blinkid + +import android.content.Intent +import android.os.Bundle +import android.widget.Toast +import androidx.appcompat.app.AppCompatActivity +import com.microblink.blinkid.activity.result.ResultStatus +import com.microblink.blinkid.activity.result.ScanResult +import com.microblink.blinkid.activity.result.contract.MbScan +import com.microblink.blinkid.entities.recognizers.RecognizerBundle +import com.microblink.blinkid.entities.recognizers.blinkid.generic.BlinkIdMultiSideRecognizer +import com.microblink.blinkid.uisettings.BlinkIdUISettings +import com.microblink.blinkid.uisettings.UISettings + +class MainActivity : AppCompatActivity() { + + private lateinit var recognizer: BlinkIdMultiSideRecognizer + private lateinit var recognizerBundle: RecognizerBundle + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + // we'll use Machine Readable Travel Document recognizer + recognizer = BlinkIdMultiSideRecognizer() + + // put our recognizer in bundle so that it can be sent via intent + recognizerBundle = RecognizerBundle(recognizer) + } + + fun onScanButtonClick() { + // use default UI for scanning documents + val uiSettings = BlinkIdUISettings(recognizerBundle) + + // start scan activity based on UI settings + blinkIdScanLauncher.launch(uiSettings) + } + + private val blinkIdScanLauncher = registerForActivityResult, ScanResult>( + MbScan() + ) { mbScanResult: ScanResult -> + when (mbScanResult.resultStatus) { + ResultStatus.FINISHED -> { + // OK result code means scan was successful + mbScanResult.result?.let { onScanSuccess(it) } + } + + ResultStatus.EXCEPTION -> { + // code after a failed scan + Toast.makeText( + this@MainActivity, + "Scan failed: ${mbScanResult.exception?.message}", + Toast.LENGTH_SHORT + ).show() + } + + else -> { + // code after a cancelled scan + onScanCanceled() + } + } + } + + private fun onScanSuccess(data: Intent) { + recognizerBundle.loadFromIntent(data) + val result: BlinkIdMultiSideRecognizer.Result = recognizer.result + val name = result.firstName?.value() + Toast.makeText(this, "Name: $name", Toast.LENGTH_LONG).show() + } + + private fun onScanCanceled() { + Toast.makeText(this, "Scan cancelled!", Toast.LENGTH_SHORT).show() + } + +} \ No newline at end of file diff --git a/BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/res/drawable/ic_launcher_foreground.xml b/BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 00000000..4c3a1252 --- /dev/null +++ b/BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,14 @@ + + + + + diff --git a/BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/res/layout/activity_main.xml b/BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/res/layout/activity_main.xml new file mode 100644 index 00000000..46e39886 --- /dev/null +++ b/BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/res/layout/activity_main.xml @@ -0,0 +1,15 @@ + + + +