Skip to content

Commit

Permalink
Merge pull request #306 from BlinkID/staging/v6.3.0
Browse files Browse the repository at this point in the history
Add new sample app that uses MbScan which allows settings customization
  • Loading branch information
medvedecrobertmb authored Oct 31, 2023
2 parents 2425bd9 + 708eb90 commit 02c2f65
Show file tree
Hide file tree
Showing 18 changed files with 270 additions and 7 deletions.
57 changes: 57 additions & 0 deletions BlinkIDSample/BlinkID-MinimalSampleAdvanced/build.gradle
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 BlinkIDSample/BlinkID-MinimalSampleAdvanced/proguard-rules.pro
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
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 not shown.
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)
}
}
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()
}

}
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>
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>
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>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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>
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>
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>
15 changes: 8 additions & 7 deletions BlinkIDSample/settings.gradle
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'

0 comments on commit 02c2f65

Please sign in to comment.