-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #306 from BlinkID/staging/v6.3.0
Add new sample app that uses MbScan which allows settings customization
- Loading branch information
Showing
18 changed files
with
270 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}" | ||
} |
21 changes: 21 additions & 0 deletions
21
BlinkIDSample/BlinkID-MinimalSampleAdvanced/proguard-rules.pro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
37 changes: 37 additions & 0 deletions
37
BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.microblink.blinkid" | ||
android:versionCode="1" | ||
android:versionName="1"> | ||
|
||
<uses-permission android:name="android.permission.CAMERA" /> | ||
|
||
<uses-feature | ||
android:name="android.hardware.camera" | ||
android:required="false" /> | ||
<uses-feature | ||
android:name="android.hardware.camera.autofocus" | ||
android:required="false" /> | ||
<uses-feature | ||
android:glEsVersion="0x00020000" | ||
android:required="false" /> | ||
|
||
<application | ||
android:name="com.microblink.blinkid.BlinkIdSampleApp" | ||
android:allowBackup="false" | ||
android:extractNativeLibs="false" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:theme="@style/Theme.AppCompat" | ||
android:screenOrientation="sensor" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
</application> | ||
</manifest> |
Binary file added
BIN
+189 Bytes
BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/assets/com.microblink.blinkid.mblic
Binary file not shown.
17 changes: 17 additions & 0 deletions
17
...le/BlinkID-MinimalSampleAdvanced/src/main/java/com/microblink/blinkid/BlinkIdSampleApp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
...Sample/BlinkID-MinimalSampleAdvanced/src/main/java/com/microblink/blinkid/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<UISettings<*>, 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() | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/res/drawable/ic_launcher_foreground.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="108dp" | ||
android:height="108dp" | ||
android:viewportWidth="108" | ||
android:viewportHeight="108"> | ||
<group android:scaleX="0.09104651" | ||
android:scaleY="0.09104651" | ||
android:translateX="22.68" | ||
android:translateY="22.68"> | ||
<path | ||
android:pathData="M604.548,125.826L683.117,321.911C686.444,330.199 688.102,339.062 687.995,347.993C687.895,356.923 686.031,365.746 682.51,373.955L599.367,568.212C595.858,576.413 590.768,583.842 584.387,590.075C578.007,596.308 570.461,601.223 562.181,604.54L366.03,683.123C357.748,686.445 348.894,688.096 339.972,687.996C331.05,687.889 322.235,686.032 314.033,682.517L119.773,599.359C103.214,592.268 90.147,578.893 83.443,562.174L4.876,366.025C1.557,357.746 -0.099,348.894 0.005,339.975C0.108,331.056 1.969,322.244 5.48,314.044L88.624,119.771C95.716,103.213 109.092,90.147 125.811,83.443L321.961,4.876C330.244,1.556 339.1,-0.099 348.022,0.005C356.944,0.108 365.758,1.969 373.96,5.48L568.219,88.624C576.422,92.134 583.853,97.225 590.087,103.609C596.321,109.993 601.234,117.542 604.548,125.826ZM491.539,478.572C506.652,470.796 523.138,462.315 541.221,452.409C571.017,436.168 592.693,408.087 598.192,382.406C604.231,356.472 594.028,332.952 573.56,320.048C526.827,290.114 507.633,252.812 478.6,196.39C470.827,181.284 462.349,164.808 452.449,146.736C436.287,116.924 408.207,95.216 382.526,89.765C356.591,83.711 333.071,93.929 320.167,114.397C290.238,161.119 252.947,180.305 196.544,209.322C181.429,217.099 164.94,225.582 146.852,235.49C117.04,251.747 95.347,279.827 89.88,305.508C83.841,331.427 94.044,354.963 114.512,367.85C161.245,397.785 180.439,435.086 209.472,491.509C217.244,506.615 225.722,523.091 235.622,541.162C251.784,570.975 279.865,592.683 305.546,598.134C331.481,604.188 355.001,593.986 367.905,573.517C397.835,526.78 435.131,507.593 491.539,478.572Z" | ||
android:fillColor="#142641"/> | ||
</group> | ||
</vector> |
15 changes: 15 additions & 0 deletions
15
BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/res/layout/activity_main.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:gravity="center" | ||
android:orientation="vertical"> | ||
|
||
<Button | ||
android:id="@+id/scan" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:onClick="onScanButtonClick" | ||
android:text="@string/scan" /> | ||
|
||
</LinearLayout> |
5 changes: 5 additions & 0 deletions
5
BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<background android:drawable="@color/mb_brand_white"/> | ||
<foreground android:drawable="@drawable/ic_launcher_foreground"/> | ||
</adaptive-icon> |
Binary file added
BIN
+2.34 KB
...IDSample/BlinkID-MinimalSampleAdvanced/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.62 KB
...IDSample/BlinkID-MinimalSampleAdvanced/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.25 KB
...DSample/BlinkID-MinimalSampleAdvanced/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.03 KB
...Sample/BlinkID-MinimalSampleAdvanced/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.09 KB
...ample/BlinkID-MinimalSampleAdvanced/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions
10
BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/res/values/colors.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="purple_200">#FFBB86FC</color> | ||
<color name="purple_500">#FF6200EE</color> | ||
<color name="purple_700">#FF3700B3</color> | ||
<color name="teal_200">#FF03DAC5</color> | ||
<color name="teal_700">#FF018786</color> | ||
<color name="black">#FF000000</color> | ||
<color name="white">#FFFFFFFF</color> | ||
</resources> |
4 changes: 4 additions & 0 deletions
4
BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/res/values/strings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<resources> | ||
<string name="app_name">BlinkID Minimal Sample Advanced</string> | ||
<string name="scan">Scan</string> | ||
</resources> |
7 changes: 7 additions & 0 deletions
7
BlinkIDSample/BlinkID-MinimalSampleAdvanced/src/main/res/values/styles.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<style name="FullScreen" parent="Theme.AppCompat"> | ||
<item name="android:windowFullscreen">true</item> | ||
<item name="android:windowContentOverlay">@null</item> | ||
</style> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
include ':BlinkID_AllRecognizersSample', | ||
':BlinkID-CustomUISample', | ||
':BlinkID-DirectApiSample', | ||
':BlinkID-ImagesSample', | ||
':BlinkID-CustomCombinedSample', | ||
':BlinkID-aMinimalSample', | ||
':BlinkID-OverlaySample', | ||
':LibUtils' | ||
':BlinkID-CustomUISample', | ||
':BlinkID-DirectApiSample', | ||
':BlinkID-ImagesSample', | ||
':BlinkID-CustomCombinedSample', | ||
':BlinkID-aMinimalSample', | ||
':BlinkID-MinimalSampleAdvanced', | ||
':BlinkID-OverlaySample', | ||
':LibUtils' | ||
// uncomment this line if you have customised build of LibBLinkID | ||
//include ':LibBlinkID' |