From fdb7badb719f368696c97b036708fbb787acb101 Mon Sep 17 00:00:00 2001 From: Serhii Chaban <> Date: Tue, 21 Apr 2026 10:29:21 +0200 Subject: [PATCH 1/2] cleanup examples --- README.md | 2 +- classic-components-example/README.md | 11 ++++++++ .../adjustable-filters/proguard-rules.pro | 21 ---------------- .../java/io/scanbot/example/FilterActivity.kt | 4 +-- .../java/io/scanbot/example/MainActivity.kt | 17 +++++++++---- .../example/ui/BarcodeScannerViewActivity.kt | 11 ++++---- .../io/scanbot/example/ui/MainActivity.kt | 23 ++++++++++++----- classic-components-example/build.gradle | 2 +- .../camera-fragment/proguard-rules.pro | 17 ------------- .../java/io/scanbot/example/MainActivity.kt | 21 ++++++++++------ .../java/io/scanbot/example/MainActivity.kt | 6 ++--- .../java/io/scanbot/example/MainActivity.kt | 18 ++++++------- .../check-scanner/proguard-rules.pro | 21 ---------------- .../AutoSnappingCheckRecognizerActivity.kt | 2 +- .../scanbot/example/CheckScannerActivity.kt | 2 +- .../example/CheckScannerResultActivity.kt | 2 +- .../java/io/scanbot/example/MainActivity.kt | 21 ++++++++++++---- .../common/build.gradle | 3 --- .../common/consumer-rules.pro | 0 .../common/proguard-rules.pro | 21 ---------------- .../creditcard-scanner/proguard-rules.pro | 21 ---------------- .../java/io/scanbot/example/MainActivity.kt | 4 +-- .../io/scanbot/example/ScannerActivity.kt | 2 +- .../proguard-rules.pro | 21 ---------------- .../java/io/scanbot/example/MainActivity.kt | 25 +++++++++++++------ .../io/scanbot/example/ScannerActivity.kt | 2 +- .../proguard-rules.pro | 21 ---------------- .../java/io/scanbot/example/MainActivity.kt | 4 +-- .../io/scanbot/example/ScannerActivity.kt | 2 +- .../proguard-rules.pro | 21 ---------------- .../java/io/scanbot/example/MainActivity.kt | 18 ++++++++----- .../scanbot/example/DocumentCameraActivity.kt | 8 +++--- .../java/io/scanbot/example/MainActivity.kt | 11 +++----- .../java/io/scanbot/example/MainActivity.kt | 6 ++--- .../manual-processing/proguard-rules.pro | 21 ---------------- .../java/io/scanbot/example/MainActivity.kt | 21 ++++++++++++---- .../mc-scanner/proguard-rules.pro | 21 ---------------- .../java/io/scanbot/example/MainActivity.kt | 22 +++++++++++----- ...ManualMedicalCertificateScannerActivity.kt | 2 +- .../MedicalCertificateRecognizerActivity.kt | 2 +- .../mrz-scanner/proguard-rules.pro | 21 ---------------- .../example/MRZLiveScanningActivity.kt | 2 +- .../example/MRZStillImageDetectionActivity.kt | 19 +++++++++++--- .../java/io/scanbot/example/MainActivity.kt | 4 +-- .../src/main/res/layout/activity_main.xml | 1 + .../ocr/proguard-rules.pro | 17 ------------- .../java/io/scanbot/example/MainActivity.kt | 6 ++--- .../ocr/src/main/res/menu/menu_main.xml | 6 +++-- .../pdf-generation/proguard-rules.pro | 17 ------------- .../java/io/scanbot/example/MainActivity.kt | 2 +- .../java/io/scanbot/example/PdfActivity.kt | 4 +-- .../io/scanbot/example/PdfWithOcrActivity.kt | 4 +-- .../text-pattern-scanner/proguard-rules.pro | 21 ---------------- .../java/io/scanbot/example/MainActivity.kt | 4 +-- .../io/scanbot/example/ScannerActivity.kt | 16 ++++++------ .../tiff-generation/proguard-rules.pro | 21 ---------------- .../java/io/scanbot/example/MainActivity.kt | 20 +++++++++------ .../vin-scanner/proguard-rules.pro | 21 ---------------- .../java/io/scanbot/example/MainActivity.kt | 4 +-- .../io/scanbot/example/ScannerActivity.kt | 2 +- .../README.md | 19 ++++++++++++++ .../app/build.gradle | 8 ++---- .../java/io/scanbot/example/Application.kt | 2 +- .../java/io/scanbot/example/util/FontSpan.kt | 14 ++++++++--- .../io/scanbot/example/util/GalleryUtils.kt | 23 ++++++++++++----- .../README.md | 6 +++++ .../app/build.gradle | 4 +-- .../app/proguard-rules.pro | 21 ---------------- .../example/scanbot/di/ExampleSingleton.kt | 8 +++--- 69 files changed, 293 insertions(+), 504 deletions(-) create mode 100644 classic-components-example/README.md delete mode 100755 classic-components-example/adjustable-filters/proguard-rules.pro delete mode 100755 classic-components-example/camera-fragment/proguard-rules.pro delete mode 100755 classic-components-example/check-scanner/proguard-rules.pro delete mode 100644 classic-components-example/common/consumer-rules.pro delete mode 100644 classic-components-example/common/proguard-rules.pro delete mode 100755 classic-components-example/creditcard-scanner/proguard-rules.pro delete mode 100755 classic-components-example/document-data-extractor-autosnapping/proguard-rules.pro delete mode 100755 classic-components-example/document-data-extractor-livedetection/proguard-rules.pro delete mode 100755 classic-components-example/document-quality-analyzer/proguard-rules.pro delete mode 100644 classic-components-example/manual-processing/proguard-rules.pro delete mode 100755 classic-components-example/mc-scanner/proguard-rules.pro delete mode 100755 classic-components-example/mrz-scanner/proguard-rules.pro delete mode 100755 classic-components-example/ocr/proguard-rules.pro delete mode 100755 classic-components-example/pdf-generation/proguard-rules.pro delete mode 100755 classic-components-example/text-pattern-scanner/proguard-rules.pro delete mode 100755 classic-components-example/tiff-generation/proguard-rules.pro delete mode 100755 classic-components-example/vin-scanner/proguard-rules.pro create mode 100644 data-capture-ready-to-use-ui-example/README.md delete mode 100644 document-scanner-ready-to-use-ui-example/app/proguard-rules.pro diff --git a/README.md b/README.md index 7550815f..a6d3d77e 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Make sure you have the latest stable version of [Android Studio](https://develop 2. There are 4 separate folders with standalone examples: - * **classic-components-example**: Example project for the Scanbot SDK Classic Components which allow for full customization. + * **classic-components-example**: Example project for the Scanbot SDK Classic Components which allow for full customization. * **compose-custom-ui-example**: Example project for the Scanbot SDK Compose Custom Components which allow for full customization. * **document-scanner-ready-to-use-ui-example:** Example project for the Scanbot Document Scanner SDK using our Ready-To-Use UI components. * **data-capture-ready-to-use-ui-example**: Example project showcasing the Scanbot Data Capture Modules using our Ready-to-Use UI components. diff --git a/classic-components-example/README.md b/classic-components-example/README.md new file mode 100644 index 00000000..05ee2654 --- /dev/null +++ b/classic-components-example/README.md @@ -0,0 +1,11 @@ +# Scanbot SDK Classic Components examples + +This project contains multiple standalone Android app modules demonstrating the Scanbot SDK Classic Components. Each module can be opened and run on its own. The only shared code lives in the `common` module. + +## How to run a module + +1. Open `scanbot-sdk-example-android/classic-components-example` in Android Studio. +2. Sync Gradle. +3. Choose one module in the **Run** configuration (each module is an `application`). +4. Add your Scanbot SDK license key in the module’s `ExampleApplication` or stay on demo mode. +5. Run the app on a device or emulator. diff --git a/classic-components-example/adjustable-filters/proguard-rules.pro b/classic-components-example/adjustable-filters/proguard-rules.pro deleted file mode 100755 index f1b42451..00000000 --- a/classic-components-example/adjustable-filters/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# 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 diff --git a/classic-components-example/adjustable-filters/src/main/java/io/scanbot/example/FilterActivity.kt b/classic-components-example/adjustable-filters/src/main/java/io/scanbot/example/FilterActivity.kt index facb3372..ee30d555 100644 --- a/classic-components-example/adjustable-filters/src/main/java/io/scanbot/example/FilterActivity.kt +++ b/classic-components-example/adjustable-filters/src/main/java/io/scanbot/example/FilterActivity.kt @@ -25,8 +25,8 @@ import io.scanbot.sdk.imageprocessing.ParametricFilter import kotlinx.coroutines.* /** -Ths example uses new sdk APIs presented in Scanbot SDK v.8.x.x -Please, check the official documentation for more details: +This example uses the SDK APIs introduced in Scanbot SDK v8.x.x. +Please check the official documentation for more details: Result API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/result-api/ ImageRef API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/image-ref-api/ */ diff --git a/classic-components-example/adjustable-filters/src/main/java/io/scanbot/example/MainActivity.kt b/classic-components-example/adjustable-filters/src/main/java/io/scanbot/example/MainActivity.kt index 8604397d..27519171 100755 --- a/classic-components-example/adjustable-filters/src/main/java/io/scanbot/example/MainActivity.kt +++ b/classic-components-example/adjustable-filters/src/main/java/io/scanbot/example/MainActivity.kt @@ -22,8 +22,8 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext /** - Ths example uses new sdk APIs presented in Scanbot SDK v.8.x.x - Please, check the official documentation for more details: + This example uses the SDK APIs introduced in Scanbot SDK v8.x.x. + Please check the official documentation for more details: Result API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/result-api/ ImageRef API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/image-ref-api/ */ @@ -105,9 +105,16 @@ class MainActivity : AppCompatActivity() { private suspend fun createAndScanDocumentPage(imageUri: Uri): String? { val imageRef = withContext(Dispatchers.IO) { - val inputStream = contentResolver.openInputStream(imageUri) - ?: throw Exception("Cannot open input stream from URI") - ImageRef.fromInputStream(inputStream) + contentResolver.openInputStream(imageUri)?.use { inputStream -> + ImageRef.fromInputStream(inputStream) + } + } + if (imageRef == null) { + withContext(Dispatchers.Main) { + Log.e(Const.LOG_TAG, "Cannot open input stream from URI: $imageUri") + showToast("Error opening selected image!") + } + return null } val sdk = ScanbotSDK(this) diff --git a/classic-components-example/barcode-scanner/src/main/java/io/scanbot/example/ui/BarcodeScannerViewActivity.kt b/classic-components-example/barcode-scanner/src/main/java/io/scanbot/example/ui/BarcodeScannerViewActivity.kt index 7a38a12e..7bcd04d5 100644 --- a/classic-components-example/barcode-scanner/src/main/java/io/scanbot/example/ui/BarcodeScannerViewActivity.kt +++ b/classic-components-example/barcode-scanner/src/main/java/io/scanbot/example/ui/BarcodeScannerViewActivity.kt @@ -4,17 +4,12 @@ import android.Manifest import android.content.Intent import android.content.pm.PackageManager import android.os.Bundle -import android.view.View -import android.view.ViewGroup import android.widget.ImageView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat -import androidx.core.view.ViewCompat import androidx.core.view.WindowCompat -import androidx.core.view.WindowInsetsCompat -import androidx.core.view.updateLayoutParams import io.scanbot.common.Result import io.scanbot.common.onFailure import io.scanbot.common.onSuccess @@ -88,7 +83,11 @@ class BarcodeScannerViewActivity : AppCompatActivity() { image: ImageRef, captureInfo: CaptureInfo ) { - TODO("Not yet implemented") + image.toBitmap().onSuccess { bitmap -> + resultView.post { + resultView.setImageBitmap(bitmap) + } + } } override fun onSelectionOverlayBarcodeClicked(barcodeItem: BarcodeItem) { diff --git a/classic-components-example/barcode-scanner/src/main/java/io/scanbot/example/ui/MainActivity.kt b/classic-components-example/barcode-scanner/src/main/java/io/scanbot/example/ui/MainActivity.kt index b92d96a5..ebd15f03 100644 --- a/classic-components-example/barcode-scanner/src/main/java/io/scanbot/example/ui/MainActivity.kt +++ b/classic-components-example/barcode-scanner/src/main/java/io/scanbot/example/ui/MainActivity.kt @@ -28,8 +28,8 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext /** -Ths example uses new sdk APIs presented in Scanbot SDK v.8.x.x -Please, check the official documentation for more details: +This example uses the SDK APIs introduced in Scanbot SDK v8.x.x. +Please check the official documentation for more details: Result API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/result-api/ ImageRef API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/image-ref-api/ */ @@ -101,14 +101,25 @@ class MainActivity : AppCompatActivity() { binding.progressBar.isVisible = true } - withContext(Dispatchers.Default) { - val inputStream = contentResolver.openInputStream(uri) ?: throw IllegalStateException("Cannot open input stream from URI: $uri") - val imageRef = ImageRef.fromInputStream(inputStream) + val imageRef = withContext(Dispatchers.IO) { + contentResolver.openInputStream(uri)?.use { inputStream -> + ImageRef.fromInputStream(inputStream) + } + } + if (imageRef == null) { + withContext(Dispatchers.Main) { + binding.progressBar.isVisible = false + showToast("Error opening selected image!") + Log.e(Const.LOG_TAG, "Cannot open input stream from URI: $uri") + } + return + } + withContext(Dispatchers.Default) { val scanner = scanbotSdk.createBarcodeScanner().getOrThrow() scanner.setConfiguration(scanner.copyCurrentConfiguration().copy().apply { setBarcodeFormats(barcodeFormats = BarcodeTypeRepository.selectedTypes.toList()) - } ) + }) val result = scanner.run(imageRef).getOrNull() BarcodeResultRepository.barcodeResultBundle = result?.let { BarcodeResultBundle(it, imageRef) } diff --git a/classic-components-example/build.gradle b/classic-components-example/build.gradle index d953f471..b89ab9d6 100644 --- a/classic-components-example/build.gradle +++ b/classic-components-example/build.gradle @@ -15,7 +15,7 @@ allprojects { jvmToolchainVersion = 17 - scanbotSdkVersion = "9.0.0.99-STAGING-SNAPSHOT" + scanbotSdkVersion = "9.0.0.108-STAGING-SNAPSHOT" androidCoreKtxVersion = "1.6.0" constraintLayoutVersion = "2.0.4" diff --git a/classic-components-example/camera-fragment/proguard-rules.pro b/classic-components-example/camera-fragment/proguard-rules.pro deleted file mode 100755 index a988b426..00000000 --- a/classic-components-example/camera-fragment/proguard-rules.pro +++ /dev/null @@ -1,17 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in /Users/artem.kubiria/Development/sdk/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# 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 *; -#} diff --git a/classic-components-example/camera-fragment/src/main/java/io/scanbot/example/MainActivity.kt b/classic-components-example/camera-fragment/src/main/java/io/scanbot/example/MainActivity.kt index 7d6927a6..37bf2c88 100755 --- a/classic-components-example/camera-fragment/src/main/java/io/scanbot/example/MainActivity.kt +++ b/classic-components-example/camera-fragment/src/main/java/io/scanbot/example/MainActivity.kt @@ -25,8 +25,8 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext /** -Ths example uses new sdk APIs presented in Scanbot SDK v.8.x.x -Please, check the official documentation for more details: +This example uses the SDK APIs introduced in Scanbot SDK v8.x.x. +Please check the official documentation for more details: Result API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/result-api/ ImageRef API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/image-ref-api/ */ @@ -115,12 +115,15 @@ class MainActivity : AppCompatActivity() { } val documentImage = withContext(Dispatchers.Default) { - catchWithResult { - // load the selected image: - val inputStream = contentResolver.openInputStream(imageUri) - ?: throw IllegalStateException("Cannot open input stream from URI: $imageUri") - val image = ImageRef.fromInputStream(inputStream) + val image = contentResolver.openInputStream(imageUri)?.use { inputStream -> + ImageRef.fromInputStream(inputStream) + } + if (image == null) { + Log.e(Const.LOG_TAG, "Cannot open input stream from URI: $imageUri") + return@withContext null + } + catchWithResult { // create a new Document object with given image as original image: val newDocument = scanbotSdk.documentApi.createDocument() .getOrReturn() // can be handled with .getOrNull() if needed @@ -144,6 +147,10 @@ class MainActivity : AppCompatActivity() { withContext(Dispatchers.Main) { progressBar.visibility = View.GONE + if (documentImage == null) { + this@MainActivity.showToast("Error opening selected image!") + return@withContext + } // show Page's document image: importResultImage.setImageBitmap(documentImage) importResultImage.visibility = View.VISIBLE diff --git a/classic-components-example/camera-view-aspect-ratio-finder/src/main/java/io/scanbot/example/MainActivity.kt b/classic-components-example/camera-view-aspect-ratio-finder/src/main/java/io/scanbot/example/MainActivity.kt index 4ecce016..966b646a 100755 --- a/classic-components-example/camera-view-aspect-ratio-finder/src/main/java/io/scanbot/example/MainActivity.kt +++ b/classic-components-example/camera-view-aspect-ratio-finder/src/main/java/io/scanbot/example/MainActivity.kt @@ -36,8 +36,8 @@ import io.scanbot.sdk.ui.camera.ShutterButton import io.scanbot.sdk.util.PolygonHelper /** -Ths example uses new sdk APIs presented in Scanbot SDK v.8.x.x -Please, check the official documentation for more details: +This example uses the SDK APIs introduced in Scanbot SDK v8.x.x. +Please check the official documentation for more details: Result API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/result-api/ ImageRef API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/image-ref-api/ */ @@ -64,7 +64,7 @@ class MainActivity : AppCompatActivity(), DocumentScannerFrameHandler.ResultHand askPermission() setContentView(R.layout.activity_main) - supportActionBar!!.hide() + supportActionBar?.hide() applyEdgeToEdge(this.findViewById(R.id.root_view)) cameraView = findViewById(R.id.camera) as ScanbotCameraXView diff --git a/classic-components-example/camera-view/src/main/java/io/scanbot/example/MainActivity.kt b/classic-components-example/camera-view/src/main/java/io/scanbot/example/MainActivity.kt index 0cd1654d..0df39e65 100755 --- a/classic-components-example/camera-view/src/main/java/io/scanbot/example/MainActivity.kt +++ b/classic-components-example/camera-view/src/main/java/io/scanbot/example/MainActivity.kt @@ -43,8 +43,8 @@ import io.scanbot.sdk.ui.camera.ShutterButton import io.scanbot.sdk.util.PolygonHelper /** -Ths example uses new sdk APIs presented in Scanbot SDK v.8.x.x -Please, check the official documentation for more details: +This example uses the SDK APIs introduced in Scanbot SDK v8.x.x. +Please check the official documentation for more details: Result API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/result-api/ ImageRef API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/image-ref-api/ */ @@ -63,13 +63,13 @@ class MainActivity : AppCompatActivity(), DocumentScannerFrameHandler.ResultHand private var lastUserGuidanceHintTs = 0L private var flashEnabled = false private var autoSnappingEnabled = true - private val ignoreOrientationMistmatch = true + private val ignoreOrientationMismatch = true override fun onCreate(savedInstanceState: Bundle?) { supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY) super.onCreate(savedInstanceState) askPermission() setContentView(R.layout.activity_main) - supportActionBar!!.hide() + supportActionBar?.hide() applyEdgeToEdge(this.findViewById(R.id.root_view)) cameraView = findViewById(R.id.camera) as ScanbotCameraXView @@ -83,7 +83,7 @@ class MainActivity : AppCompatActivity(), DocumentScannerFrameHandler.ResultHand // Please note: https://docs.scanbot.io/document-scanner-sdk/android/features/document-scanner/ui-components/ setConfiguration(copyCurrentConfiguration().apply { parameters.apply { - this.ignoreOrientationMismatch = ignoreOrientationMistmatch + this.ignoreOrientationMismatch = ignoreOrientationMismatch this.acceptedSizeScore = 75 this.acceptedAngleScore = 60 } @@ -150,11 +150,11 @@ class MainActivity : AppCompatActivity(), DocumentScannerFrameHandler.ResultHand ) } }.onFailure { error -> - when(error){ - is Result.InvalidLicenseError ->{ + when (error) { + is Result.InvalidLicenseError -> { Toast.makeText(this@MainActivity, "License is invalid: ${error.message}", Toast.LENGTH_LONG).show() } - else -> { + else -> { Toast.makeText(this@MainActivity, "${error.message}", Toast.LENGTH_LONG).show() } } @@ -224,7 +224,7 @@ class MainActivity : AppCompatActivity(), DocumentScannerFrameHandler.ResultHand } DocumentDetectionStatus.OK_BUT_BAD_ASPECT_RATIO -> { - if (ignoreOrientationMistmatch) { + if (ignoreOrientationMismatch) { userGuidanceHint.text = "Don't move" // change polygon color to "OK" polygonView.setFillColor(POLYGON_FILL_COLOR_OK) diff --git a/classic-components-example/check-scanner/proguard-rules.pro b/classic-components-example/check-scanner/proguard-rules.pro deleted file mode 100755 index f1b42451..00000000 --- a/classic-components-example/check-scanner/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# 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 diff --git a/classic-components-example/check-scanner/src/main/java/io/scanbot/example/AutoSnappingCheckRecognizerActivity.kt b/classic-components-example/check-scanner/src/main/java/io/scanbot/example/AutoSnappingCheckRecognizerActivity.kt index f5df0939..71d08e9e 100644 --- a/classic-components-example/check-scanner/src/main/java/io/scanbot/example/AutoSnappingCheckRecognizerActivity.kt +++ b/classic-components-example/check-scanner/src/main/java/io/scanbot/example/AutoSnappingCheckRecognizerActivity.kt @@ -39,7 +39,7 @@ class AutoSnappingCheckScannerActivity : AppCompatActivity() { supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY) super.onCreate(savedInstanceState) setContentView(R.layout.activity_autosnapping_check_scanner) - supportActionBar!!.hide() + supportActionBar?.hide() applyEdgeToEdge(this.findViewById(R.id.root_view)) cameraView = findViewById(R.id.camera).also { cameraView -> diff --git a/classic-components-example/check-scanner/src/main/java/io/scanbot/example/CheckScannerActivity.kt b/classic-components-example/check-scanner/src/main/java/io/scanbot/example/CheckScannerActivity.kt index d9cf7677..9ac8bf25 100644 --- a/classic-components-example/check-scanner/src/main/java/io/scanbot/example/CheckScannerActivity.kt +++ b/classic-components-example/check-scanner/src/main/java/io/scanbot/example/CheckScannerActivity.kt @@ -31,7 +31,7 @@ class CheckScannerActivity : AppCompatActivity() { supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY) super.onCreate(savedInstanceState) setContentView(R.layout.activity_check_scanner) - supportActionBar!!.hide() + supportActionBar?.hide() applyEdgeToEdge(this.findViewById(R.id.root_view)) cameraView = findViewById(R.id.camera).also { cameraView -> diff --git a/classic-components-example/check-scanner/src/main/java/io/scanbot/example/CheckScannerResultActivity.kt b/classic-components-example/check-scanner/src/main/java/io/scanbot/example/CheckScannerResultActivity.kt index a0fd2d03..7e6cedb1 100644 --- a/classic-components-example/check-scanner/src/main/java/io/scanbot/example/CheckScannerResultActivity.kt +++ b/classic-components-example/check-scanner/src/main/java/io/scanbot/example/CheckScannerResultActivity.kt @@ -19,7 +19,7 @@ class CheckScannerResultActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_check_result) - supportActionBar!!.hide() + supportActionBar?.hide() applyEdgeToEdge(this.findViewById(R.id.root_view)) val fieldsLayout = findViewById(R.id.check_result_fields_layout) diff --git a/classic-components-example/check-scanner/src/main/java/io/scanbot/example/MainActivity.kt b/classic-components-example/check-scanner/src/main/java/io/scanbot/example/MainActivity.kt index d42d517d..de3ed48e 100644 --- a/classic-components-example/check-scanner/src/main/java/io/scanbot/example/MainActivity.kt +++ b/classic-components-example/check-scanner/src/main/java/io/scanbot/example/MainActivity.kt @@ -25,8 +25,8 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext /** -Ths example uses new sdk APIs presented in Scanbot SDK v.8.x.x -Please, check the official documentation for more details: +This example uses the SDK APIs introduced in Scanbot SDK v8.x.x. +Please check the official documentation for more details: Result API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/result-api/ ImageRef API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/image-ref-api/ */ @@ -77,10 +77,21 @@ class MainActivity : AppCompatActivity() { private suspend fun scanCheck(uri: Uri) { withContext(Dispatchers.Main) { binding.progressBar.isVisible = true } - val result = withContext(Dispatchers.Default) { - val inputStream = contentResolver.openInputStream(uri) ?: throw IllegalStateException("Cannot open input stream from URI: $uri") - val imageRef = ImageRef.fromInputStream(inputStream) + val imageRef = withContext(Dispatchers.IO) { + contentResolver.openInputStream(uri)?.use { inputStream -> + ImageRef.fromInputStream(inputStream) + } + } + if (imageRef == null) { + withContext(Dispatchers.Main) { + binding.progressBar.isVisible = false + showToast("Error opening selected image!") + Log.e(Const.LOG_TAG, "Cannot open input stream from URI: $uri") + } + return + } + val result = withContext(Dispatchers.Default) { val scanner = scanbotSdk.createCheckScanner().getOrThrow() scanner.run(imageRef).getOrNull() } diff --git a/classic-components-example/common/build.gradle b/classic-components-example/common/build.gradle index e2a1776f..ef52fd20 100644 --- a/classic-components-example/common/build.gradle +++ b/classic-components-example/common/build.gradle @@ -9,14 +9,11 @@ android { defaultConfig { minSdk = project.ext.minSdkVersion - - proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro", "consumer-rules.pro") } buildTypes { named("release") { minifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") } } diff --git a/classic-components-example/common/consumer-rules.pro b/classic-components-example/common/consumer-rules.pro deleted file mode 100644 index e69de29b..00000000 diff --git a/classic-components-example/common/proguard-rules.pro b/classic-components-example/common/proguard-rules.pro deleted file mode 100644 index 481bb434..00000000 --- a/classic-components-example/common/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# 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/classic-components-example/creditcard-scanner/proguard-rules.pro b/classic-components-example/creditcard-scanner/proguard-rules.pro deleted file mode 100755 index f1b42451..00000000 --- a/classic-components-example/creditcard-scanner/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# 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 diff --git a/classic-components-example/creditcard-scanner/src/main/java/io/scanbot/example/MainActivity.kt b/classic-components-example/creditcard-scanner/src/main/java/io/scanbot/example/MainActivity.kt index 5bf14381..329ac035 100755 --- a/classic-components-example/creditcard-scanner/src/main/java/io/scanbot/example/MainActivity.kt +++ b/classic-components-example/creditcard-scanner/src/main/java/io/scanbot/example/MainActivity.kt @@ -13,8 +13,8 @@ import androidx.core.content.ContextCompat import io.scanbot.example.common.applyEdgeToEdge /** -Ths example uses new sdk APIs presented in Scanbot SDK v.8.x.x -Please, check the official documentation for more details: +This example uses the SDK APIs introduced in Scanbot SDK v8.x.x. +Please check the official documentation for more details: Result API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/result-api/ ImageRef API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/image-ref-api/ */ diff --git a/classic-components-example/creditcard-scanner/src/main/java/io/scanbot/example/ScannerActivity.kt b/classic-components-example/creditcard-scanner/src/main/java/io/scanbot/example/ScannerActivity.kt index 43327b2c..6bcddc17 100644 --- a/classic-components-example/creditcard-scanner/src/main/java/io/scanbot/example/ScannerActivity.kt +++ b/classic-components-example/creditcard-scanner/src/main/java/io/scanbot/example/ScannerActivity.kt @@ -28,7 +28,7 @@ class ScannerActivity : AppCompatActivity() { super.onCreate(savedInstanceState) binding = ActivityScannerBinding.inflate(layoutInflater) setContentView(binding.root) - supportActionBar!!.hide() + supportActionBar?.hide() applyEdgeToEdge(this.findViewById(R.id.root_view)) // init scanbot sdk and create credit card scanner diff --git a/classic-components-example/document-data-extractor-autosnapping/proguard-rules.pro b/classic-components-example/document-data-extractor-autosnapping/proguard-rules.pro deleted file mode 100755 index f1b42451..00000000 --- a/classic-components-example/document-data-extractor-autosnapping/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# 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 diff --git a/classic-components-example/document-data-extractor-autosnapping/src/main/java/io/scanbot/example/MainActivity.kt b/classic-components-example/document-data-extractor-autosnapping/src/main/java/io/scanbot/example/MainActivity.kt index 0f0d3c65..2038fdad 100755 --- a/classic-components-example/document-data-extractor-autosnapping/src/main/java/io/scanbot/example/MainActivity.kt +++ b/classic-components-example/document-data-extractor-autosnapping/src/main/java/io/scanbot/example/MainActivity.kt @@ -22,8 +22,8 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext /** -Ths example uses new sdk APIs presented in Scanbot SDK v.8.x.x -Please, check the official documentation for more details: +This example uses the SDK APIs introduced in Scanbot SDK v8.x.x. +Please check the official documentation for more details: Result API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/result-api/ ImageRef API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/image-ref-api/ */ @@ -51,11 +51,22 @@ class MainActivity : AppCompatActivity() { lifecycleScope.launch { val dataExtractor = scanbotSdk.createDocumentDataExtractor().getOrThrow() - val result = withContext(Dispatchers.Default) { - val inputStream = contentResolver.openInputStream(uri) ?: throw IllegalStateException("Cannot open input stream from URI: $uri") - val imageRef = ImageRef.fromInputStream(inputStream) - dataExtractor.run(imageRef).getOrNull() - } + val imageRef = withContext(Dispatchers.IO) { + contentResolver.openInputStream(uri)?.use { inputStream -> + ImageRef.fromInputStream(inputStream) + } + } + if (imageRef == null) { + withContext(Dispatchers.Main) { + showToast("Error opening selected image!") + Log.e(Const.LOG_TAG, "Cannot open input stream from URI: $uri") + } + return@launch + } + + val result = withContext(Dispatchers.Default) { + dataExtractor.run(imageRef).getOrNull() + } withContext(Dispatchers.Main) { DocumentsResultsStorage.result = result diff --git a/classic-components-example/document-data-extractor-autosnapping/src/main/java/io/scanbot/example/ScannerActivity.kt b/classic-components-example/document-data-extractor-autosnapping/src/main/java/io/scanbot/example/ScannerActivity.kt index 8d8d6399..d440f4b0 100644 --- a/classic-components-example/document-data-extractor-autosnapping/src/main/java/io/scanbot/example/ScannerActivity.kt +++ b/classic-components-example/document-data-extractor-autosnapping/src/main/java/io/scanbot/example/ScannerActivity.kt @@ -38,7 +38,7 @@ class ScannerActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_scanner) - supportActionBar!!.hide() + supportActionBar?.hide() applyEdgeToEdge(this.findViewById(R.id.root_view)) scanbotSdk = ScanbotSDK(this) diff --git a/classic-components-example/document-data-extractor-livedetection/proguard-rules.pro b/classic-components-example/document-data-extractor-livedetection/proguard-rules.pro deleted file mode 100755 index f1b42451..00000000 --- a/classic-components-example/document-data-extractor-livedetection/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# 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 diff --git a/classic-components-example/document-data-extractor-livedetection/src/main/java/io/scanbot/example/MainActivity.kt b/classic-components-example/document-data-extractor-livedetection/src/main/java/io/scanbot/example/MainActivity.kt index f792adc3..2305a525 100755 --- a/classic-components-example/document-data-extractor-livedetection/src/main/java/io/scanbot/example/MainActivity.kt +++ b/classic-components-example/document-data-extractor-livedetection/src/main/java/io/scanbot/example/MainActivity.kt @@ -10,8 +10,8 @@ import io.scanbot.example.common.showToast import io.scanbot.example.databinding.ActivityMainBinding /** -Ths example uses new sdk APIs presented in Scanbot SDK v.8.x.x -Please, check the official documentation for more details: +This example uses the SDK APIs introduced in Scanbot SDK v8.x.x. +Please check the official documentation for more details: Result API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/result-api/ ImageRef API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/image-ref-api/ */ diff --git a/classic-components-example/document-data-extractor-livedetection/src/main/java/io/scanbot/example/ScannerActivity.kt b/classic-components-example/document-data-extractor-livedetection/src/main/java/io/scanbot/example/ScannerActivity.kt index 25011a5c..1b5bc7fc 100644 --- a/classic-components-example/document-data-extractor-livedetection/src/main/java/io/scanbot/example/ScannerActivity.kt +++ b/classic-components-example/document-data-extractor-livedetection/src/main/java/io/scanbot/example/ScannerActivity.kt @@ -28,7 +28,7 @@ class ScannerActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_scanner) - supportActionBar!!.hide() + supportActionBar?.hide() applyEdgeToEdge(this.findViewById(R.id.root_view)) cameraView = findViewById(R.id.cameraView) diff --git a/classic-components-example/document-quality-analyzer/proguard-rules.pro b/classic-components-example/document-quality-analyzer/proguard-rules.pro deleted file mode 100755 index f1b42451..00000000 --- a/classic-components-example/document-quality-analyzer/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# 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 diff --git a/classic-components-example/document-quality-analyzer/src/main/java/io/scanbot/example/MainActivity.kt b/classic-components-example/document-quality-analyzer/src/main/java/io/scanbot/example/MainActivity.kt index dab4b065..33775076 100755 --- a/classic-components-example/document-quality-analyzer/src/main/java/io/scanbot/example/MainActivity.kt +++ b/classic-components-example/document-quality-analyzer/src/main/java/io/scanbot/example/MainActivity.kt @@ -19,8 +19,8 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext /** -Ths example uses new sdk APIs presented in Scanbot SDK v.8.x.x -Please, check the official documentation for more details: +This example uses the SDK APIs introduced in Scanbot SDK v8.x.x. +Please check the official documentation for more details: Result API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/result-api/ ImageRef API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/image-ref-api/ */ @@ -55,7 +55,7 @@ class MainActivity : AppCompatActivity() { supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY) super.onCreate(savedInstanceState) setContentView(binding.root) - supportActionBar!!.hide() + supportActionBar?.hide() applyEdgeToEdge(findViewById(R.id.root_view)) binding.galleryButton.setOnClickListener { @@ -72,11 +72,17 @@ class MainActivity : AppCompatActivity() { private suspend fun estimateOnStillImage(imageUri: Uri) { val image = withContext(Dispatchers.IO) { - contentResolver.openInputStream(imageUri).use { inputStream -> - inputStream?.let { ImageRef.fromInputStream(it) } + contentResolver.openInputStream(imageUri)?.use { inputStream -> + ImageRef.fromInputStream(inputStream) } } - if (image == null) return + if (image == null) { + withContext(Dispatchers.Main) { + showToast("Error opening selected image!") + Log.e(Const.LOG_TAG, "Cannot open input stream from URI: $imageUri") + } + return + } withContext(Dispatchers.Main) { binding.stillImageImageView.setImageBitmap(image?.toBitmap()?.getOrNull()) } diff --git a/classic-components-example/document-scanner/src/main/java/io/scanbot/example/DocumentCameraActivity.kt b/classic-components-example/document-scanner/src/main/java/io/scanbot/example/DocumentCameraActivity.kt index 266e13c0..6be44604 100755 --- a/classic-components-example/document-scanner/src/main/java/io/scanbot/example/DocumentCameraActivity.kt +++ b/classic-components-example/document-scanner/src/main/java/io/scanbot/example/DocumentCameraActivity.kt @@ -36,7 +36,7 @@ class DocumentCameraActivity : AppCompatActivity() { private var lastUserGuidanceHintTs = 0L private var flashEnabled = false private var autoSnappingEnabled = true - private val ignoreOrientationMistmatch = true + private val ignoreOrientationMismatch = true private lateinit var documentScannerView: DocumentScannerView @@ -52,7 +52,7 @@ class DocumentCameraActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_camera) askPermission() - supportActionBar!!.hide() + supportActionBar?.hide() applyEdgeToEdge(findViewById(R.id.root_view)) val scanbotSdk = ScanbotSDK(this) @@ -116,7 +116,7 @@ class DocumentCameraActivity : AppCompatActivity() { documentScannerView.viewController.apply { setAcceptedAngleScore(60.0) setAcceptedSizeScore(75.0) - setIgnoreOrientationMismatch(ignoreOrientationMistmatch) + setIgnoreOrientationMismatch(ignoreOrientationMismatch) // Please note: https://docs.scanbot.io/document-scanner-sdk/android/features/document-scanner/autosnapping/#sensitivity setAutoSnappingSensitivity(0.85f) @@ -196,7 +196,7 @@ class DocumentCameraActivity : AppCompatActivity() { } DocumentDetectionStatus.OK_BUT_BAD_ASPECT_RATIO -> { - if (ignoreOrientationMistmatch) { + if (ignoreOrientationMismatch) { userGuidanceHint.text = "Don't move" } else { userGuidanceHint.text = "Wrong aspect ratio.\nRotate your device." diff --git a/classic-components-example/document-scanner/src/main/java/io/scanbot/example/MainActivity.kt b/classic-components-example/document-scanner/src/main/java/io/scanbot/example/MainActivity.kt index 047a0795..3c14c76e 100644 --- a/classic-components-example/document-scanner/src/main/java/io/scanbot/example/MainActivity.kt +++ b/classic-components-example/document-scanner/src/main/java/io/scanbot/example/MainActivity.kt @@ -11,8 +11,6 @@ import androidx.activity.result.contract.ActivityResultContracts import androidx.appcompat.app.AppCompatActivity import androidx.lifecycle.lifecycleScope import io.scanbot.common.onSuccess - - import io.scanbot.example.common.Const import io.scanbot.example.common.applyEdgeToEdge import io.scanbot.example.common.showToast @@ -25,10 +23,10 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext /** -Ths example uses new sdk APIs presented in Scanbot SDK v.8.x.x -Please, check the official documentation for more details: -Result API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/result-api/ -ImageRef API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/image-ref-api/ + * This example uses the SDK APIs introduced in Scanbot SDK v8.x.x. + * Please check the official documentation for more details: + * Result API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/result-api/ + * ImageRef API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/image-ref-api/ */ class MainActivity : AppCompatActivity() { @@ -91,7 +89,6 @@ class MainActivity : AppCompatActivity() { ImageRef.fromInputStream(inputStream) } ?: throw IllegalStateException("Cannot open input stream from URI: $uri") - // create a new Page object with given image as original image: val document = scanbotSdk.documentApi.createDocument() .getOrNull() //can be handled with .getOrThrow() if needed diff --git a/classic-components-example/edit-polygon-view/src/main/java/io/scanbot/example/MainActivity.kt b/classic-components-example/edit-polygon-view/src/main/java/io/scanbot/example/MainActivity.kt index 9d46ed9c..62cc365a 100755 --- a/classic-components-example/edit-polygon-view/src/main/java/io/scanbot/example/MainActivity.kt +++ b/classic-components-example/edit-polygon-view/src/main/java/io/scanbot/example/MainActivity.kt @@ -24,8 +24,8 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext /** -Ths example uses new sdk APIs presented in Scanbot SDK v.8.x.x -Please, check the official documentation for more details: +This example uses the SDK APIs introduced in Scanbot SDK v8.x.x. +Please check the official documentation for more details: Result API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/result-api/ ImageRef API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/image-ref-api/ */ @@ -58,7 +58,7 @@ class MainActivity : AppCompatActivity() { scanner = scanbotSDK.createDocumentScanner().getOrThrow() - supportActionBar!!.hide() + supportActionBar?.hide() editPolygonView = findViewById(R.id.polygonView) magnifierView = findViewById(R.id.magnifier) diff --git a/classic-components-example/manual-processing/proguard-rules.pro b/classic-components-example/manual-processing/proguard-rules.pro deleted file mode 100644 index f1b42451..00000000 --- a/classic-components-example/manual-processing/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# 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 diff --git a/classic-components-example/manual-processing/src/main/java/io/scanbot/example/MainActivity.kt b/classic-components-example/manual-processing/src/main/java/io/scanbot/example/MainActivity.kt index 3748b32b..f7c8b384 100755 --- a/classic-components-example/manual-processing/src/main/java/io/scanbot/example/MainActivity.kt +++ b/classic-components-example/manual-processing/src/main/java/io/scanbot/example/MainActivity.kt @@ -23,8 +23,8 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext /** -Ths example uses new sdk APIs presented in Scanbot SDK v.8.x.x -Please, check the official documentation for more details: +This example uses the SDK APIs introduced in Scanbot SDK v8.x.x. +Please check the official documentation for more details: Result API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/result-api/ ImageRef API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/image-ref-api/ */ @@ -66,10 +66,21 @@ class MainActivity : AppCompatActivity() { private suspend fun processImage(imageUri: Uri) { withContext(Dispatchers.Main) { binding.progressBar.visibility = View.VISIBLE } + val image = withContext(Dispatchers.IO) { + contentResolver.openInputStream(imageUri)?.use { inputStream -> + ImageRef.fromInputStream(inputStream) + } + } + if (image == null) { + withContext(Dispatchers.Main) { + binding.progressBar.visibility = View.GONE + showToast("Error opening selected image!") + Log.e(Const.LOG_TAG, "Cannot open input stream from URI: $imageUri") + } + return + } + val page = withContext(Dispatchers.Default) { - val inputStream = contentResolver.openInputStream(imageUri) - ?: throw IllegalStateException("Cannot open input stream from URI: $imageUri") - val image = ImageRef.fromInputStream(inputStream) val scanner = scanbotSdk.createDocumentScanner().getOrThrow() val detectedPolygon = scanner.run(image).getOrNull()?.pointsNormalized ?: PolygonHelper.getFullPolygon() diff --git a/classic-components-example/mc-scanner/proguard-rules.pro b/classic-components-example/mc-scanner/proguard-rules.pro deleted file mode 100755 index f1b42451..00000000 --- a/classic-components-example/mc-scanner/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# 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 diff --git a/classic-components-example/mc-scanner/src/main/java/io/scanbot/example/MainActivity.kt b/classic-components-example/mc-scanner/src/main/java/io/scanbot/example/MainActivity.kt index 9add4cac..06eac728 100755 --- a/classic-components-example/mc-scanner/src/main/java/io/scanbot/example/MainActivity.kt +++ b/classic-components-example/mc-scanner/src/main/java/io/scanbot/example/MainActivity.kt @@ -22,8 +22,8 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext /** -Ths example uses new sdk APIs presented in Scanbot SDK v.8.x.x -Please, check the official documentation for more details: +This example uses the SDK APIs introduced in Scanbot SDK v8.x.x. +Please check the official documentation for more details: Result API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/result-api/ ImageRef API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/image-ref-api/ */ @@ -56,11 +56,21 @@ class MainActivity : AppCompatActivity() { binding.progressBar.isVisible = true } - val result = withContext(Dispatchers.Default) { - val inputStream = contentResolver.openInputStream(uri) - ?: throw IllegalStateException("Cannot open input stream from URI: $uri") - val imageRef = ImageRef.fromInputStream(inputStream) + val imageRef = withContext(Dispatchers.IO) { + contentResolver.openInputStream(uri)?.use { inputStream -> + ImageRef.fromInputStream(inputStream) + } + } + if (imageRef == null) { + withContext(Dispatchers.Main) { + binding.progressBar.isVisible = false + showToast("Error opening selected image!") + Log.e(Const.LOG_TAG, "Cannot open input stream from URI: $uri") + } + return + } + val result = withContext(Dispatchers.Default) { val scanner = scanbotSdk.createMedicalCertificateScanner().getOrThrow() scanner.run( diff --git a/classic-components-example/mc-scanner/src/main/java/io/scanbot/example/ManualMedicalCertificateScannerActivity.kt b/classic-components-example/mc-scanner/src/main/java/io/scanbot/example/ManualMedicalCertificateScannerActivity.kt index b2e75d7b..f5ff95ff 100755 --- a/classic-components-example/mc-scanner/src/main/java/io/scanbot/example/ManualMedicalCertificateScannerActivity.kt +++ b/classic-components-example/mc-scanner/src/main/java/io/scanbot/example/ManualMedicalCertificateScannerActivity.kt @@ -42,7 +42,7 @@ class ManualMedicalCertificateScannerActivity : AppCompatActivity() { supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY) super.onCreate(savedInstanceState) setContentView(R.layout.activity_manual_mc_scanner) - supportActionBar!!.hide() + supportActionBar?.hide() applyEdgeToEdge(findViewById(R.id.root_view)) askPermission() diff --git a/classic-components-example/mc-scanner/src/main/java/io/scanbot/example/MedicalCertificateRecognizerActivity.kt b/classic-components-example/mc-scanner/src/main/java/io/scanbot/example/MedicalCertificateRecognizerActivity.kt index 77346fde..62524112 100755 --- a/classic-components-example/mc-scanner/src/main/java/io/scanbot/example/MedicalCertificateRecognizerActivity.kt +++ b/classic-components-example/mc-scanner/src/main/java/io/scanbot/example/MedicalCertificateRecognizerActivity.kt @@ -44,7 +44,7 @@ class MedicalCertificateScannerActivity : AppCompatActivity() { supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY) super.onCreate(savedInstanceState) setContentView(R.layout.activity_mc_scanner) - supportActionBar!!.hide() + supportActionBar?.hide() applyEdgeToEdge(findViewById(R.id.root_view)) askPermission() resultImageView = findViewById(R.id.resultImageView) diff --git a/classic-components-example/mrz-scanner/proguard-rules.pro b/classic-components-example/mrz-scanner/proguard-rules.pro deleted file mode 100755 index f1b42451..00000000 --- a/classic-components-example/mrz-scanner/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# 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 diff --git a/classic-components-example/mrz-scanner/src/main/java/io/scanbot/example/MRZLiveScanningActivity.kt b/classic-components-example/mrz-scanner/src/main/java/io/scanbot/example/MRZLiveScanningActivity.kt index 2955a1ea..e821f204 100755 --- a/classic-components-example/mrz-scanner/src/main/java/io/scanbot/example/MRZLiveScanningActivity.kt +++ b/classic-components-example/mrz-scanner/src/main/java/io/scanbot/example/MRZLiveScanningActivity.kt @@ -36,7 +36,7 @@ class MRZLiveScanningActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_mrz_live_scanner) askPermission() - supportActionBar!!.hide() + supportActionBar?.hide() applyEdgeToEdge(findViewById(R.id.root_view)) // Configure Initial camera state diff --git a/classic-components-example/mrz-scanner/src/main/java/io/scanbot/example/MRZStillImageDetectionActivity.kt b/classic-components-example/mrz-scanner/src/main/java/io/scanbot/example/MRZStillImageDetectionActivity.kt index 74c1b4b1..5245158c 100755 --- a/classic-components-example/mrz-scanner/src/main/java/io/scanbot/example/MRZStillImageDetectionActivity.kt +++ b/classic-components-example/mrz-scanner/src/main/java/io/scanbot/example/MRZStillImageDetectionActivity.kt @@ -66,7 +66,7 @@ class MrzStillImageScanningActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(binding.root) - supportActionBar!!.hide() + supportActionBar?.hide() applyEdgeToEdge(findViewById(R.id.root_view)) docScannerResultLauncher = @@ -121,10 +121,21 @@ class MrzStillImageScanningActivity : AppCompatActivity() { } private suspend fun importImageToPage(uri: Uri) { - val page = withContext(Dispatchers.Default) { - val inputStream = contentResolver.openInputStream(uri) ?: throw IllegalStateException("Cannot open input stream from URI: $uri") - val image = ImageRef.fromInputStream(inputStream) + val image = withContext(Dispatchers.IO) { + contentResolver.openInputStream(uri)?.use { inputStream -> + ImageRef.fromInputStream(inputStream) + } + } + if (image == null) { + withContext(Dispatchers.Main) { + binding.progressBar.visibility = View.GONE + showToast("Error opening selected image!") + Log.e(Const.LOG_TAG, "Cannot open input stream from URI: $uri") + } + return + } + val page = withContext(Dispatchers.Default) { val document = scanbotSdk.documentApi.createDocument().getOrThrow() // can be handled with .getOrNull() if needed val page = document.addPage(image).getOrThrow() // can be handled with .getOrNull() if needed diff --git a/classic-components-example/mrz-scanner/src/main/java/io/scanbot/example/MainActivity.kt b/classic-components-example/mrz-scanner/src/main/java/io/scanbot/example/MainActivity.kt index 8d255df7..9aa64ea4 100755 --- a/classic-components-example/mrz-scanner/src/main/java/io/scanbot/example/MainActivity.kt +++ b/classic-components-example/mrz-scanner/src/main/java/io/scanbot/example/MainActivity.kt @@ -8,8 +8,8 @@ import io.scanbot.example.common.applyEdgeToEdge import io.scanbot.example.databinding.ActivityMainBinding /** -Ths example uses new sdk APIs presented in Scanbot SDK v.8.x.x -Please, check the official documentation for more details: +This example uses the SDK APIs introduced in Scanbot SDK v8.x.x. +Please check the official documentation for more details: Result API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/result-api/ ImageRef API https://docs.scanbot.io/android/document-scanner-sdk/detailed-setup-guide/image-ref-api/ */ diff --git a/classic-components-example/mrz-scanner/src/main/res/layout/activity_main.xml b/classic-components-example/mrz-scanner/src/main/res/layout/activity_main.xml index c82a7bb8..a0ff3b8c 100755 --- a/classic-components-example/mrz-scanner/src/main/res/layout/activity_main.xml +++ b/classic-components-example/mrz-scanner/src/main/res/layout/activity_main.xml @@ -18,6 +18,7 @@ app:layout_constraintEnd_toEndOf="parent" android:layout_marginStart="8dp" app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" app:layout_constraintHorizontal_bias="0.502" />