From a48477bbf0b9816109648746275b7ac22c8072f6 Mon Sep 17 00:00:00 2001 From: Sergey Maltsev Date: Wed, 7 Sep 2022 14:02:46 -0700 Subject: [PATCH] added v11.5.4 --- README.md | 27 +-- acuantcamera/build.gradle | 18 +- .../camera/AcuantCameraActivity.kt | 12 +- .../camera/AcuantCameraOptions.kt | 44 +++-- .../barcode/AcuantBarcodeCameraFragment.kt | 2 +- .../document/AcuantDocCameraFragment.kt | 4 +- .../camera/mrz/AcuantMrzCameraFragment.kt | 2 +- .../acuant/acuantcamera/helper/MrzParser.kt | 6 +- .../acuant/acuantcamera/helper/PointsUtils.kt | 4 +- acuantfacecapture/build.gradle | 20 +-- app/build.gradle | 34 ++-- .../java/com/acuant/sampleapp/Constants.kt | 8 - .../java/com/acuant/sampleapp/MainActivity.kt | 167 ++++++++++-------- 13 files changed, 195 insertions(+), 153 deletions(-) delete mode 100644 app/src/main/java/com/acuant/sampleapp/Constants.kt diff --git a/README.md b/README.md index d1fd530..2bf59fb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# Acuant Android SDK v11.5.3 -**June 2022** +# Acuant Android SDK v11.5.4 +**September 2022** See [https://github.com/Acuant/AndroidSDKV11/releases](https://github.com/Acuant/AndroidSDKV11/releases) for release notes. @@ -36,7 +36,7 @@ Before 11.5.0, the SDK was not compiled with AndroidX. The SDK could still be us ## Prerequisites ## -- Supports Android SDK versions 21-31 (compiled with 31) +- Supports Android SDK versions 21-32 (compiled with 32) ## Modules ## @@ -116,15 +116,15 @@ The SDK includes the following modules: - Add the following dependencies - implementation 'com.acuant:acuantcommon:11.5.3' - implementation 'com.acuant:acuantcamera:11.5.3' - implementation 'com.acuant:acuantimagepreparation:11.5.3' - implementation 'com.acuant:acuantdocumentprocessing:11.5.3' - implementation 'com.acuant:acuantechipreader:11.5.3' - implementation 'com.acuant:acuantipliveness:11.5.3' - implementation 'com.acuant:acuantfacematch:11.5.3' - implementation 'com.acuant:acuantfacecapture:11.5.3' - implementation 'com.acuant:acuantpassiveliveness:11.5.3' + implementation 'com.acuant:acuantcommon:11.5.4' + implementation 'com.acuant:acuantcamera:11.5.4' + implementation 'com.acuant:acuantimagepreparation:11.5.4' + implementation 'com.acuant:acuantdocumentprocessing:11.5.4' + implementation 'com.acuant:acuantechipreader:11.5.4' + implementation 'com.acuant:acuantipliveness:11.5.4' + implementation 'com.acuant:acuantfacematch:11.5.4' + implementation 'com.acuant:acuantfacecapture:11.5.4' + implementation 'com.acuant:acuantpassiveliveness:11.5.4' 1. Create an .xml file with the following tags. (If you plan to use bearer tokens to initialize, include only the endpoints.): @@ -773,6 +773,7 @@ Must include EchipInitializer() in initialization (See **Initializing the SDK**) fun setColorBracketHold(value: Int) : DocumentCameraOptionsBuilder fun setColorBracketCloser(value: Int) : DocumentCameraOptionsBuilder fun setColorBracketCapturing(value: Int) : DocumentCameraOptionsBuilder + fun setPreventScreenshots(value: Boolean) : DocumentCameraOptionsBuilder /** * [ZoomType.Generic] keeps the camera zoomed out to enable you to use nearly all available * capture space. This is the default setting. Use this setting to capture large @@ -798,6 +799,7 @@ Must include EchipInitializer() in initialization (See **Initializing the SDK**) fun setDefaultBracketMarginHeight(value: Int) : MrzCameraOptionsBuilder fun setColorCapturing(value: Int) : MrzCameraOptionsBuilder fun setColorBracketCapturing(value: Int) : MrzCameraOptionsBuilder + fun setPreventScreenshots(value: Boolean) : MrzCameraOptionsBuilder fun build() : AcuantCameraOptions } @@ -806,6 +808,7 @@ Must include EchipInitializer() in initialization (See **Initializing the SDK**) fun setTimeToWaitUntilTimeout(value: Int) : BarcodeCameraOptionsBuilder fun setColorCapturing(value: Int) : BarcodeCameraOptionsBuilder fun setColorAlign(value: Int) : BarcodeCameraOptionsBuilder + fun setPreventScreenshots(value: Boolean) : BarcodeCameraOptionsBuilder fun build() : AcuantCameraOptions } diff --git a/acuantcamera/build.gradle b/acuantcamera/build.gradle index 12b8585..019dafa 100644 --- a/acuantcamera/build.gradle +++ b/acuantcamera/build.gradle @@ -3,11 +3,11 @@ apply plugin: 'kotlin-android' apply plugin: 'maven-publish' android { - compileSdkVersion 31 + compileSdkVersion 32 defaultConfig { minSdkVersion 21 - targetSdkVersion 31 + targetSdkVersion 32 } buildTypes { @@ -33,16 +33,16 @@ android { } dependencies { // Kotlin lang - implementation 'androidx.core:core-ktx:1.7.0' + implementation 'androidx.core:core-ktx:1.8.0' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2' // App compat and UI things - implementation 'androidx.appcompat:appcompat:1.4.1' - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1' - implementation 'androidx.constraintlayout:constraintlayout:2.1.3' + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' // CameraX library - def camerax_version = '1.1.0-beta02' + def camerax_version = '1.1.0' implementation "androidx.camera:camera-core:$camerax_version" implementation "androidx.camera:camera-camera2:$camerax_version" implementation "androidx.camera:camera-lifecycle:$camerax_version" @@ -52,6 +52,6 @@ dependencies { implementation 'androidx.exifinterface:exifinterface:1.3.3' implementation 'com.google.mlkit:barcode-scanning:17.0.2' implementation 'com.rmtheis:tess-two:9.1.0' - implementation 'com.acuant:acuantcommon:11.5.3' - implementation 'com.acuant:acuantimagepreparation:11.5.3' + implementation 'com.acuant:acuantcommon:11.5.4' + implementation 'com.acuant:acuantimagepreparation:11.5.4' } diff --git a/acuantcamera/src/main/java/com/acuant/acuantcamera/camera/AcuantCameraActivity.kt b/acuantcamera/src/main/java/com/acuant/acuantcamera/camera/AcuantCameraActivity.kt index 2dcdebf..98372a2 100644 --- a/acuantcamera/src/main/java/com/acuant/acuantcamera/camera/AcuantCameraActivity.kt +++ b/acuantcamera/src/main/java/com/acuant/acuantcamera/camera/AcuantCameraActivity.kt @@ -2,6 +2,7 @@ package com.acuant.acuantcamera.camera import android.content.Intent import android.os.Bundle +import android.view.WindowManager import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment import com.acuant.acuantcamera.R @@ -22,8 +23,6 @@ class AcuantCameraActivity: AppCompatActivity(), ICameraActivityFinish { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = ActivityCameraBinding.inflate(layoutInflater) - setContentView(binding.root) - hideTopMenu() val unserializedOptions = intent.getSerializableExtra(ACUANT_EXTRA_CAMERA_OPTIONS) @@ -33,7 +32,14 @@ class AcuantCameraActivity: AppCompatActivity(), ICameraActivityFinish { unserializedOptions as AcuantCameraOptions } - //start the camera if this si the first time the activity is created (camera already exists otherwise) + if (options.preventScreenshots) { + window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE) + } + + setContentView(binding.root) + hideTopMenu() + + //start the camera if this is the first time the activity is created (camera already exists otherwise) if (savedInstanceState == null) { val cameraFragment: AcuantBaseCameraFragment = when (options.cameraMode) { AcuantCameraOptions.CameraMode.BarcodeOnly -> { diff --git a/acuantcamera/src/main/java/com/acuant/acuantcamera/camera/AcuantCameraOptions.kt b/acuantcamera/src/main/java/com/acuant/acuantcamera/camera/AcuantCameraOptions.kt index 5252522..7bd3b87 100644 --- a/acuantcamera/src/main/java/com/acuant/acuantcamera/camera/AcuantCameraOptions.kt +++ b/acuantcamera/src/main/java/com/acuant/acuantcamera/camera/AcuantCameraOptions.kt @@ -29,6 +29,7 @@ internal constructor( internal val colorBracketHold : Int = Color.YELLOW, internal val colorBracketCapturing : Int = Color.GREEN, internal val cardRatio : Float = 0.65f, + internal val preventScreenshots : Boolean = true, internal val cameraMode: CameraMode = CameraMode.Document, internal val zoomType: ZoomType = ZoomType.Generic ) : Serializable { @@ -59,6 +60,7 @@ internal constructor( private var colorBracketHold : Int = Color.YELLOW private var colorBracketCapturing : Int = Color.GREEN private var zoomType: ZoomType = ZoomType.Generic + private var preventScreenshots : Boolean = true private val cardRatio : Float = 0.65f fun setTimeInMsPerDigit(value: Int) : DocumentCameraOptionsBuilder { @@ -131,6 +133,11 @@ internal constructor( return this } + fun setPreventScreenshots(value: Boolean) : DocumentCameraOptionsBuilder { + preventScreenshots = value + return this + } + @Deprecated("No longer reliant on GMS, option is ignored", ReplaceWith("")) fun setUseGms(value: Boolean) : DocumentCameraOptionsBuilder { return this @@ -156,9 +163,12 @@ internal constructor( fun build() : AcuantCameraOptions { @Suppress("DEPRECATION") - return AcuantCameraOptions(timeInMsPerDigit, digitsToShow, allowBox, autoCapture, bracketLengthInHorizontal, - bracketLengthInVertical, defaultBracketMarginWidth, defaultBracketMarginHeight, colorHold, - colorCapturing, colorBracketAlign, colorBracketCloser, colorBracketHold, colorBracketCapturing, cardRatio, zoomType = zoomType, cameraMode = CameraMode.Document) + return AcuantCameraOptions(timeInMsPerDigit, digitsToShow, allowBox, autoCapture, + bracketLengthInHorizontal, bracketLengthInVertical, defaultBracketMarginWidth, + defaultBracketMarginHeight, colorHold, colorCapturing, colorBracketAlign, + colorBracketCloser, colorBracketHold, colorBracketCapturing, cardRatio, + preventScreenshots = preventScreenshots, zoomType = zoomType, + cameraMode = CameraMode.Document) } } @@ -168,6 +178,7 @@ internal constructor( private var digitsToShow : Int = DEFAULT_TIMEOUT_BARCODE private var colorCapturing : Int = Color.GREEN private var colorHold : Int = Color.WHITE + private var preventScreenshots : Boolean = true /** * Only an aesthetic difference to prevent jarring transition from the camera (default: [DEFAULT_DELAY_BARCODE]). @@ -198,11 +209,16 @@ internal constructor( return this } + fun setPreventScreenshots(value: Boolean) : BarcodeCameraOptionsBuilder { + preventScreenshots = value + return this + } + fun build() : AcuantCameraOptions { @Suppress("DEPRECATION") - return AcuantCameraOptions(timeInMsPerDigit = timeInMsPerDigit, digitsToShow = digitsToShow, - colorCapturing = colorCapturing, colorHold = colorHold, - cameraMode = CameraMode.BarcodeOnly) + return AcuantCameraOptions(timeInMsPerDigit = timeInMsPerDigit, + digitsToShow = digitsToShow, colorCapturing = colorCapturing, colorHold = colorHold, + preventScreenshots = preventScreenshots, cameraMode = CameraMode.BarcodeOnly) } } @@ -223,8 +239,9 @@ internal constructor( private var colorBracketCloser : Int = Color.RED private var colorBracketHold : Int = Color.YELLOW private var colorBracketCapturing : Int = Color.GREEN - private val cardRatio : Float = 0.65f private var isMrzMode: Boolean = true + private var preventScreenshots : Boolean = true + private val cardRatio : Float = 0.65f fun setAllowBox(value: Boolean) : MrzCameraOptionsBuilder { allowBox = value @@ -261,11 +278,18 @@ internal constructor( return this } + fun setPreventScreenshots(value: Boolean) : MrzCameraOptionsBuilder { + preventScreenshots = value + return this + } + fun build() : AcuantCameraOptions { @Suppress("DEPRECATION") - return AcuantCameraOptions(timeInMsPerDigit, digitsToShow, allowBox, autoCapture, bracketLengthInHorizontal, - bracketLengthInVertical, defaultBracketMarginWidth, defaultBracketMarginHeight, colorHold, - colorCapturing, colorBracketAlign, colorBracketCloser, colorBracketHold, colorBracketCapturing, cardRatio, cameraMode = CameraMode.Mrz) + return AcuantCameraOptions(timeInMsPerDigit, digitsToShow, allowBox, autoCapture, + bracketLengthInHorizontal, bracketLengthInVertical, defaultBracketMarginWidth, + defaultBracketMarginHeight, colorHold, colorCapturing, colorBracketAlign, + colorBracketCloser, colorBracketHold, colorBracketCapturing, cardRatio, + preventScreenshots = preventScreenshots, cameraMode = CameraMode.Mrz) } } } \ No newline at end of file diff --git a/acuantcamera/src/main/java/com/acuant/acuantcamera/camera/barcode/AcuantBarcodeCameraFragment.kt b/acuantcamera/src/main/java/com/acuant/acuantcamera/camera/barcode/AcuantBarcodeCameraFragment.kt index df6bae6..d8f6603 100644 --- a/acuantcamera/src/main/java/com/acuant/acuantcamera/camera/barcode/AcuantBarcodeCameraFragment.kt +++ b/acuantcamera/src/main/java/com/acuant/acuantcamera/camera/barcode/AcuantBarcodeCameraFragment.kt @@ -147,8 +147,8 @@ class AcuantBarcodeCameraFragment: AcuantBaseCameraFragment() { } frameAnalyzer.disableDocumentDetection() imageAnalyzer = ImageAnalysis.Builder() -// .setTargetAspectRatio(screenAspectRatio) .setTargetResolution(Size(1280, 960)) +// .setTargetAspectRatio(screenAspectRatio) .setTargetRotation(rotation) .build() .also { diff --git a/acuantcamera/src/main/java/com/acuant/acuantcamera/camera/document/AcuantDocCameraFragment.kt b/acuantcamera/src/main/java/com/acuant/acuantcamera/camera/document/AcuantDocCameraFragment.kt index ac83985..9ab63b4 100644 --- a/acuantcamera/src/main/java/com/acuant/acuantcamera/camera/document/AcuantDocCameraFragment.kt +++ b/acuantcamera/src/main/java/com/acuant/acuantcamera/camera/document/AcuantDocCameraFragment.kt @@ -5,6 +5,7 @@ import android.graphics.Point import android.graphics.Rect import android.graphics.drawable.Drawable import android.os.Bundle +import android.util.Size import android.view.LayoutInflater import android.view.View import android.widget.TextView @@ -376,7 +377,8 @@ class AcuantDocCameraFragment: AcuantBaseCameraFragment() { setTapToCapture() } imageAnalyzer = ImageAnalysis.Builder() - .setTargetAspectRatio(screenAspectRatio) + .setTargetResolution(Size(1280, 960)) +// .setTargetAspectRatio(screenAspectRatio) .setTargetRotation(rotation) .build() .also { diff --git a/acuantcamera/src/main/java/com/acuant/acuantcamera/camera/mrz/AcuantMrzCameraFragment.kt b/acuantcamera/src/main/java/com/acuant/acuantcamera/camera/mrz/AcuantMrzCameraFragment.kt index 8ee4d92..1cd6b4e 100644 --- a/acuantcamera/src/main/java/com/acuant/acuantcamera/camera/mrz/AcuantMrzCameraFragment.kt +++ b/acuantcamera/src/main/java/com/acuant/acuantcamera/camera/mrz/AcuantMrzCameraFragment.kt @@ -206,7 +206,7 @@ class AcuantMrzCameraFragment: AcuantBaseCameraFragment() { onMrzDetection(points, result, state) } imageAnalyzer = ImageAnalysis.Builder() - .setTargetResolution(Size(960, 1280)) + .setTargetResolution(Size(1280, 960)) // .setTargetAspectRatio(screenAspectRatio) .setTargetRotation(rotation) .build() diff --git a/acuantcamera/src/main/java/com/acuant/acuantcamera/helper/MrzParser.kt b/acuantcamera/src/main/java/com/acuant/acuantcamera/helper/MrzParser.kt index a5cd07a..644850c 100644 --- a/acuantcamera/src/main/java/com/acuant/acuantcamera/helper/MrzParser.kt +++ b/acuantcamera/src/main/java/com/acuant/acuantcamera/helper/MrzParser.kt @@ -207,7 +207,11 @@ class MrzParser { // one another. This list can however get expanded if we get definitive misreads happening on // specific characters private fun trySubstitutions(phrase: String, checksum: Char, onlyModifyChecksum: Boolean = false): Pair { - val subList = listOf(Pair('O', '0'), Pair('5', 'S')) + + //numbers should be second in this list as the order of substitutions will try to sub first + // for second before second for first. + val subList = listOf(Pair('O', '0'), Pair('S', '5')) + if (checkSum(phrase, checksum)) { return Pair(phrase, checksum) } diff --git a/acuantcamera/src/main/java/com/acuant/acuantcamera/helper/PointsUtils.kt b/acuantcamera/src/main/java/com/acuant/acuantcamera/helper/PointsUtils.kt index 7fd7cda..55487be 100644 --- a/acuantcamera/src/main/java/com/acuant/acuantcamera/helper/PointsUtils.kt +++ b/acuantcamera/src/main/java/com/acuant/acuantcamera/helper/PointsUtils.kt @@ -91,8 +91,8 @@ object PointsUtils { internal fun scalePoints(points: Array, camContainer: ViewGroup?, analyzerSize: Size?, previewSize: ViewGroup?, rectangleView: BaseRectangleView?) : Array { if (camContainer != null && previewSize != null && analyzerSize != null) { - val scale: Float = previewSize.height.toFloat() / analyzerSize.width.toFloat() - val yOffset: Int = ((previewSize.width.toFloat() - analyzerSize.height * scale) / 2).toInt() + val scale: Float = max(previewSize.height, previewSize.width).toFloat() / max(analyzerSize.height, analyzerSize.width).toFloat() + val yOffset: Int = ((min(previewSize.height, previewSize.width).toFloat() - min(analyzerSize.height, analyzerSize.width).toFloat() * scale) / 2).toInt() val xOffset: Int = ((camContainer.height - previewSize.height) / 2) rectangleView?.setWidth(camContainer.width.toFloat()) diff --git a/acuantfacecapture/build.gradle b/acuantfacecapture/build.gradle index caccb4b..10969e1 100644 --- a/acuantfacecapture/build.gradle +++ b/acuantfacecapture/build.gradle @@ -3,11 +3,11 @@ apply plugin: 'kotlin-android' apply plugin: 'maven-publish' android { - compileSdkVersion 31 + compileSdkVersion 32 defaultConfig { minSdkVersion 21 - targetSdkVersion 31 + targetSdkVersion 32 testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } @@ -29,16 +29,16 @@ android { } dependencies { // Kotlin lang - implementation 'androidx.core:core-ktx:1.7.0' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2' + implementation 'androidx.core:core-ktx:1.8.0' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' // App compat and UI things - implementation 'androidx.appcompat:appcompat:1.4.1' - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1' - implementation 'androidx.constraintlayout:constraintlayout:2.1.3' + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' // CameraX library - def camerax_version = '1.1.0-beta02' + def camerax_version = '1.1.0' implementation "androidx.camera:camera-core:$camerax_version" implementation "androidx.camera:camera-camera2:$camerax_version" implementation "androidx.camera:camera-lifecycle:$camerax_version" @@ -46,8 +46,8 @@ dependencies { //acuant specific stuff implementation 'com.google.mlkit:face-detection:16.1.5' - implementation 'com.acuant:acuantcommon:11.5.3' - implementation 'com.acuant:acuantimagepreparation:11.5.3' + implementation 'com.acuant:acuantcommon:11.5.4' + implementation 'com.acuant:acuantimagepreparation:11.5.4' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' diff --git a/app/build.gradle b/app/build.gradle index c8b9485..39d8404 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,13 +5,13 @@ repositories { maven { url 'https://raw.githubusercontent.com/iProov/android/master/maven/' } } dependencies { - implementation "androidx.core:core-ktx:1.7.0" - implementation 'androidx.appcompat:appcompat:1.4.0' + implementation "androidx.core:core-ktx:1.8.0" + implementation 'androidx.appcompat:appcompat:1.4.2' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.exifinterface:exifinterface:1.3.3' - implementation 'androidx.constraintlayout:constraintlayout:2.1.2' - implementation 'com.google.android.material:material:1.4.0' - implementation "androidx.activity:activity-ktx:1.4.0" + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation 'com.google.android.material:material:1.6.1' + implementation "androidx.activity:activity-ktx:1.5.1" testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' @@ -19,26 +19,26 @@ dependencies { //If you do not plan to modify the camera code you can use these two regular maven dependencies // in place of the project ones. -// implementation 'com.acuant:acuantfacecapture:11.5.3' -// implementation 'com.acuant:acuantcamera:11.5.3' +// implementation 'com.acuant:acuantfacecapture:11.5.4' +// implementation 'com.acuant:acuantcamera:11.5.4' implementation project(path: ':acuantcamera') implementation project(path: ':acuantfacecapture') - implementation 'com.acuant:acuantcommon:11.5.3' - implementation 'com.acuant:acuantimagepreparation:11.5.3' - implementation 'com.acuant:acuantdocumentprocessing:11.5.3' - implementation 'com.acuant:acuantechipreader:11.5.3' - implementation 'com.acuant:acuantfacematch:11.5.3' - implementation 'com.acuant:acuantipliveness:11.5.3' - implementation 'com.acuant:acuantpassiveliveness:11.5.3' + implementation 'com.acuant:acuantcommon:11.5.4' + implementation 'com.acuant:acuantimagepreparation:11.5.4' + implementation 'com.acuant:acuantdocumentprocessing:11.5.4' + implementation 'com.acuant:acuantechipreader:11.5.4' + implementation 'com.acuant:acuantfacematch:11.5.4' + implementation 'com.acuant:acuantipliveness:11.5.4' + implementation 'com.acuant:acuantpassiveliveness:11.5.4' } android { - compileSdkVersion 31 - buildToolsVersion '31' + compileSdkVersion 32 + buildToolsVersion '32' defaultConfig { applicationId "com.acuant.sampleapp" minSdkVersion 21 - targetSdkVersion 31 + targetSdkVersion 32 versionCode 1 versionName multiDexEnabled true diff --git a/app/src/main/java/com/acuant/sampleapp/Constants.kt b/app/src/main/java/com/acuant/sampleapp/Constants.kt deleted file mode 100644 index e210eb1..0000000 --- a/app/src/main/java/com/acuant/sampleapp/Constants.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.acuant.sampleapp - -class Constants { - companion object { - const val HG_FRAME_RATE_TARGET = "targetFrameRate" - - } -} \ No newline at end of file diff --git a/app/src/main/java/com/acuant/sampleapp/MainActivity.kt b/app/src/main/java/com/acuant/sampleapp/MainActivity.kt index 8319b6d..1f1d7ab 100644 --- a/app/src/main/java/com/acuant/sampleapp/MainActivity.kt +++ b/app/src/main/java/com/acuant/sampleapp/MainActivity.kt @@ -66,9 +66,6 @@ import com.google.android.material.switchmaterial.SwitchMaterial import java.io.* import java.net.HttpURLConnection import java.net.URL -import java.security.KeyPairGenerator -import java.security.Signature -import java.security.spec.ECGenParameterSpec import java.util.* import kotlin.collections.HashMap import kotlin.concurrent.thread @@ -615,13 +612,8 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemSelectedListener { // } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setProgress(false) - if (isKeyless) { - handleKeyless(image) - } else { - recentImage = image - - showConfirmation(!frontCaptured) - } + recentImage = image + showConfirmation(!frontCaptured) } override fun onError(error: AcuantError) { @@ -767,88 +759,107 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemSelectedListener { if (isConfirmed) { if (isFront) { capturedFrontImage = recentImage - if (isHealthCard) { - frontCaptured = true - showAcuDialog(R.string.scan_back_side_health_insurance_card, "Message", - { dialog, _ -> - dialog.dismiss() - showDocumentCaptureCamera() - }, { dialog, _ -> - dialog.dismiss() - uploadHealthCard() - }) - + if (isKeyless) { + handleKeyless(recentImage) } else { - uploadIdFront() + if (isHealthCard) { + frontCaptured = true + showAcuDialog(R.string.scan_back_side_health_insurance_card, "Message", + { dialog, _ -> + dialog.dismiss() + showDocumentCaptureCamera() + }, { dialog, _ -> + dialog.dismiss() + uploadHealthCard() + }) + + } else { + uploadIdFront() + } } } else { capturedBackImage = recentImage - if (!isHealthCard) { - val alert = AlertDialog.Builder(this@MainActivity) - alert.setTitle("Message") - if (capturedBarcodeString != null && capturedBarcodeString!!.trim().isNotEmpty()) { - if (livenessSelected != 0) { - alert.setMessage("Following barcode is captured.\n\n" - + "Barcode String :\n\n" - + capturedBarcodeString!!.subSequence(0, (capturedBarcodeString!!.length * 0.25).toInt()) - + "...\n\n" - + "Capture Selfie Image now.") - } else { - alert.setMessage("Following barcode is captured.\n\n" - + "Barcode String :\n\n" - + capturedBarcodeString!!.subSequence(0, (capturedBarcodeString!!.length * 0.25).toInt())) - } - alert.setPositiveButton("OK") { dialog, _ -> - dialog.dismiss() - setProgress(true, "Getting Data...") - uploadIdBack() - showFaceCamera() - } - if (livenessSelected != 0) { - alert.setNegativeButton("CANCEL") { dialog, _ -> + if (isKeyless) { + handleKeyless(recentImage) + } else { + if (!isHealthCard) { + val alert = AlertDialog.Builder(this@MainActivity) + alert.setTitle("Message") + if (capturedBarcodeString != null && capturedBarcodeString!!.trim() + .isNotEmpty() + ) { + if (livenessSelected != 0) { + alert.setMessage( + "Following barcode is captured.\n\n" + + "Barcode String :\n\n" + + capturedBarcodeString!!.subSequence( + 0, + (capturedBarcodeString!!.length * 0.25).toInt() + ) + + "...\n\n" + + "Capture Selfie Image now." + ) + } else { + alert.setMessage( + "Following barcode is captured.\n\n" + + "Barcode String :\n\n" + + capturedBarcodeString!!.subSequence( + 0, + (capturedBarcodeString!!.length * 0.25).toInt() + ) + ) + } + alert.setPositiveButton("OK") { dialog, _ -> + dialog.dismiss() setProgress(true, "Getting Data...") - facialLivelinessResultString = "Facial Liveliness Failed" - capturingSelfieImage = false uploadIdBack() - dialog.dismiss() + showFaceCamera() } - } - } else if (barcodeExpected) { - alert.setMessage("A barcode was expected but was not captured. Please try capturing the barcode.") + if (livenessSelected != 0) { + alert.setNegativeButton("CANCEL") { dialog, _ -> + setProgress(true, "Getting Data...") + facialLivelinessResultString = "Facial Liveliness Failed" + capturingSelfieImage = false + uploadIdBack() + dialog.dismiss() + } + } + } else if (barcodeExpected) { + alert.setMessage("A barcode was expected but was not captured. Please try capturing the barcode.") - alert.setPositiveButton("OK") { dialog, _ -> - dialog.dismiss() - setProgress(true, "Uploading...") - uploadIdBack() - showBarcodeCaptureCamera() - } - } else { - if (livenessSelected != 0) { - alert.setMessage("Capture Selfie Image now.") + alert.setPositiveButton("OK") { dialog, _ -> + dialog.dismiss() + setProgress(true, "Uploading...") + uploadIdBack() + showBarcodeCaptureCamera() + } } else { - alert.setMessage("Continue.") - } - alert.setPositiveButton("OK") { dialog, _ -> - dialog.dismiss() - setProgress(true, "Getting Data...") - uploadIdBack() - showFaceCamera() - } - if (livenessSelected != 0) { - alert.setNegativeButton("CANCEL") { dialog, _ -> - setProgress(true, "Getting Data...") - facialLivelinessResultString = "Facial Liveliness Failed" - capturingSelfieImage = false - uploadIdFront() + if (livenessSelected != 0) { + alert.setMessage("Capture Selfie Image now.") + } else { + alert.setMessage("Continue.") + } + alert.setPositiveButton("OK") { dialog, _ -> dialog.dismiss() + setProgress(true, "Getting Data...") + uploadIdBack() + showFaceCamera() + } + if (livenessSelected != 0) { + alert.setNegativeButton("CANCEL") { dialog, _ -> + setProgress(true, "Getting Data...") + facialLivelinessResultString = "Facial Liveliness Failed" + capturingSelfieImage = false + uploadIdFront() + dialog.dismiss() + } } } + alert.show() + } else { + uploadHealthCard() } - alert.show() - } else { - uploadHealthCard() } - } } else { showDocumentCaptureCamera()