[SB-20828] cleanup examples#424
Conversation
There was a problem hiding this comment.
Pull request overview
This PR cleans up multiple Android example apps by removing unused ProGuard placeholders, improving code safety/robustness in a few image-import paths, updating Scanbot SDK snapshot versions, and adding clearer run instructions in READMEs.
Changes:
- Remove placeholder ProGuard/R8 rule files and corresponding Gradle references across examples.
- Improve example robustness (e.g., null-safe ActionBar usage; safer URI/InputStream handling in several flows).
- Update Scanbot SDK snapshot versions and add/extend READMEs with “How to run” guidance.
Reviewed changes
Copilot reviewed 67 out of 69 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| document-scanner-ready-to-use-ui-example/app/src/main/java/com/example/scanbot/di/ExampleSingleton.kt | Fix/standardize header KDoc wording/formatting. |
| document-scanner-ready-to-use-ui-example/app/proguard-rules.pro | Remove placeholder ProGuard rules file. |
| document-scanner-ready-to-use-ui-example/app/build.gradle | Remove ProGuard file references; bump Scanbot SDK snapshot version. |
| document-scanner-ready-to-use-ui-example/README.md | Add “How to run” instructions. |
| data-capture-ready-to-use-ui-example/app/src/main/java/io/scanbot/example/util/GalleryUtils.kt | Make URI-to-bitmap conversion more defensive (null stream / decode failures). |
| data-capture-ready-to-use-ui-example/app/src/main/java/io/scanbot/example/util/FontSpan.kt | Normalize style handling when creating typefaces. |
| data-capture-ready-to-use-ui-example/app/src/main/java/io/scanbot/example/Application.kt | Update trial license URL in comment. |
| data-capture-ready-to-use-ui-example/app/build.gradle | Disable release minification; remove kapt stubs; bump Scanbot SDK version. |
| data-capture-ready-to-use-ui-example/README.md | Add new README with requirements/run/obfuscation notes. |
| classic-components-example/vin-scanner/src/main/java/io/scanbot/example/ScannerActivity.kt | Avoid potential NPE by using null-safe ActionBar access. |
| classic-components-example/vin-scanner/src/main/java/io/scanbot/example/MainActivity.kt | Fix header comment wording. |
| classic-components-example/vin-scanner/proguard-rules.pro | Remove placeholder ProGuard rules file. |
| classic-components-example/tiff-generation/src/main/java/io/scanbot/example/MainActivity.kt | Improve URI→file import logic (mapNotNull + early abort); null-safe ActionBar. |
| classic-components-example/tiff-generation/proguard-rules.pro | Remove placeholder ProGuard rules file. |
| classic-components-example/text-pattern-scanner/src/main/java/io/scanbot/example/ScannerActivity.kt | Null-safe ActionBar; minor formatting/wording cleanups; simplify result handler lambda. |
| classic-components-example/text-pattern-scanner/src/main/java/io/scanbot/example/MainActivity.kt | Fix header comment wording. |
| classic-components-example/text-pattern-scanner/proguard-rules.pro | Remove placeholder ProGuard rules file. |
| classic-components-example/pdf-generation/src/main/java/io/scanbot/example/PdfWithOcrActivity.kt | Null-safe ActionBar; tweak comment wording. |
| classic-components-example/pdf-generation/src/main/java/io/scanbot/example/PdfActivity.kt | Null-safe ActionBar; tweak comment wording. |
| classic-components-example/pdf-generation/src/main/java/io/scanbot/example/MainActivity.kt | Null-safe ActionBar. |
| classic-components-example/pdf-generation/proguard-rules.pro | Remove placeholder ProGuard rules file. |
| classic-components-example/ocr/src/main/res/menu/menu_main.xml | Fix showAsAction namespace usage (use app:). |
| classic-components-example/ocr/src/main/java/io/scanbot/example/MainActivity.kt | Fix header comment wording; null-safe ActionBar. |
| classic-components-example/ocr/proguard-rules.pro | Remove placeholder ProGuard rules file. |
| classic-components-example/mrz-scanner/src/main/res/layout/activity_main.xml | Add missing top constraint on a view. |
| classic-components-example/mrz-scanner/src/main/java/io/scanbot/example/MainActivity.kt | Fix header comment wording. |
| classic-components-example/mrz-scanner/src/main/java/io/scanbot/example/MRZStillImageDetectionActivity.kt | Move URI stream work to IO; add user-visible error handling; null-safe ActionBar. |
| classic-components-example/mrz-scanner/src/main/java/io/scanbot/example/MRZLiveScanningActivity.kt | Null-safe ActionBar. |
| classic-components-example/mrz-scanner/proguard-rules.pro | Remove placeholder ProGuard rules file. |
| classic-components-example/mc-scanner/src/main/java/io/scanbot/example/MedicalCertificateRecognizerActivity.kt | Null-safe ActionBar. |
| classic-components-example/mc-scanner/src/main/java/io/scanbot/example/ManualMedicalCertificateScannerActivity.kt | Null-safe ActionBar. |
| classic-components-example/mc-scanner/src/main/java/io/scanbot/example/MainActivity.kt | Move URI stream work to IO; add user-visible error handling; fix header comment wording. |
| classic-components-example/mc-scanner/proguard-rules.pro | Remove placeholder ProGuard rules file. |
| classic-components-example/manual-processing/src/main/java/io/scanbot/example/MainActivity.kt | Move URI stream work to IO; add user-visible error handling; fix header comment wording. |
| classic-components-example/manual-processing/proguard-rules.pro | Remove placeholder ProGuard rules file. |
| classic-components-example/edit-polygon-view/src/main/java/io/scanbot/example/MainActivity.kt | Fix header comment wording; null-safe ActionBar. |
| classic-components-example/document-scanner/src/main/java/io/scanbot/example/MainActivity.kt | KDoc formatting cleanup; remove extra blank lines. |
| classic-components-example/document-scanner/src/main/java/io/scanbot/example/DocumentCameraActivity.kt | Fix typo in variable name; null-safe ActionBar; update usages accordingly. |
| classic-components-example/document-quality-analyzer/src/main/java/io/scanbot/example/MainActivity.kt | Add user-visible error handling for failed URI open; null-safe ActionBar; fix header comment wording. |
| classic-components-example/document-quality-analyzer/proguard-rules.pro | Remove placeholder ProGuard rules file. |
| classic-components-example/document-data-extractor-livedetection/src/main/java/io/scanbot/example/ScannerActivity.kt | Null-safe ActionBar. |
| classic-components-example/document-data-extractor-livedetection/src/main/java/io/scanbot/example/MainActivity.kt | Fix header comment wording. |
| classic-components-example/document-data-extractor-livedetection/proguard-rules.pro | Remove placeholder ProGuard rules file. |
| classic-components-example/document-data-extractor-autosnapping/src/main/java/io/scanbot/example/ScannerActivity.kt | Null-safe ActionBar. |
| classic-components-example/document-data-extractor-autosnapping/src/main/java/io/scanbot/example/MainActivity.kt | Move URI stream work to IO; add user-visible error handling; fix header comment wording. |
| classic-components-example/document-data-extractor-autosnapping/proguard-rules.pro | Remove placeholder ProGuard rules file. |
| classic-components-example/creditcard-scanner/src/main/java/io/scanbot/example/ScannerActivity.kt | Null-safe ActionBar. |
| classic-components-example/creditcard-scanner/src/main/java/io/scanbot/example/MainActivity.kt | Fix header comment wording. |
| classic-components-example/creditcard-scanner/proguard-rules.pro | Remove placeholder ProGuard rules file. |
| classic-components-example/common/proguard-rules.pro | Remove placeholder ProGuard rules file. |
| classic-components-example/common/build.gradle | Remove ProGuard file references. |
| classic-components-example/check-scanner/src/main/java/io/scanbot/example/MainActivity.kt | Move URI stream work to IO; add user-visible error handling; fix header comment wording. |
| classic-components-example/check-scanner/src/main/java/io/scanbot/example/CheckScannerResultActivity.kt | Null-safe ActionBar. |
| classic-components-example/check-scanner/src/main/java/io/scanbot/example/CheckScannerActivity.kt | Null-safe ActionBar. |
| classic-components-example/check-scanner/src/main/java/io/scanbot/example/AutoSnappingCheckRecognizerActivity.kt | Null-safe ActionBar. |
| classic-components-example/check-scanner/proguard-rules.pro | Remove placeholder ProGuard rules file. |
| classic-components-example/camera-view/src/main/java/io/scanbot/example/MainActivity.kt | Fix typo in variable name; null-safe ActionBar; formatting cleanup. |
| classic-components-example/camera-view-aspect-ratio-finder/src/main/java/io/scanbot/example/MainActivity.kt | Fix header comment wording; null-safe ActionBar. |
| classic-components-example/camera-fragment/src/main/java/io/scanbot/example/MainActivity.kt | Refactor URI import flow; add explicit “error opening selected image” UI path. |
| classic-components-example/camera-fragment/proguard-rules.pro | Remove placeholder ProGuard rules file. |
| classic-components-example/build.gradle | Bump Scanbot SDK snapshot version. |
| classic-components-example/barcode-scanner/src/main/java/io/scanbot/example/ui/MainActivity.kt | Move URI stream work to IO; add user-visible error handling; minor formatting cleanup. |
| classic-components-example/barcode-scanner/src/main/java/io/scanbot/example/ui/BarcodeScannerViewActivity.kt | Replace unimplemented callback with bitmap rendering logic. |
| classic-components-example/adjustable-filters/src/main/java/io/scanbot/example/MainActivity.kt | Move URI stream work to IO; add user-visible error handling; fix header comment wording. |
| classic-components-example/adjustable-filters/src/main/java/io/scanbot/example/FilterActivity.kt | Fix header comment wording. |
| classic-components-example/adjustable-filters/proguard-rules.pro | Remove placeholder ProGuard rules file. |
| classic-components-example/README.md | Add new README explaining how to run classic modules. |
| README.md | Minor whitespace cleanup in root README list item. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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) { |
| val file = appStorageDir.resolve( | ||
| UUID.randomUUID().toString() + ".jpg" | ||
| ) | ||
| file.createNewFile() | ||
| val inputStream = contentResolver.openInputStream(uri) |
| /** | ||
| 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. |
There was a problem hiding this comment.
I'd remove the first "SDK" mention - it is clear that the API is from Scanbot SDK because it already says that in the second part of the sentence.
This example uses the APIs introduced in Scanbot SDK v8.x.x.
| /** | ||
| 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. |
There was a problem hiding this comment.
I'd leave just one (the latter one) "SDK" abbreviation mention
There was a problem hiding this comment.
... and the same comment in all other places like this
| @@ -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. | |||
There was a problem hiding this comment.
Not sure how I feel about removing these parts of the project. I understand that it is effectively empty, but these are the bits that the IDE creates on "new project" anyway. I would keep the context and the environment as close to the default new project as possible + the relevant SDK example code. This way we ensure that non-devs will have more questions about "why your example is so much different than my code that I'm trying to make work"
I'd also consider asking @ildar-scanbot and @eddyfrank 's opinion here
|
|
||
| defaultConfig { | ||
| minSdk = project.ext.minSdkVersion | ||
|
|
There was a problem hiding this comment.
The comment here is the same as for deleted *.pro files
|
|
||
| buildTypes { | ||
| named("debug") { | ||
| // set this to `false` to allow debugging and run a "non-release" build |
There was a problem hiding this comment.
Please remove these comments too - all over the repo 🙏
| 3. Add your license key in `Application`. | ||
| 4. Run the app on a device or emulator. | ||
|
|
||
| ## Obfuscation |
There was a problem hiding this comment.
I'd say this is out of scope of the SDK examples and might confuse non tech-savvy users.
| } | ||
|
|
||
| kotlin { | ||
| jvmToolchain(project.ext.jvmToolchainVersion) |
There was a problem hiding this comment.
This block is actually not a part of android { ... } closure.
So correct usage is like this:
android {
...
}
kotlin {
jvmToolchain(project.ext.jvmToolchainVersion)
}
dependencies {
...
Also can be simplified to a one-liner:
kotlin.jvmToolchain(project.ext.jvmToolchainVersion)
|
Code like can be reduced to a one-liner: Not sure if we'd want to pursue that minification - just FYI |
No description provided.