Skip to content

[SB-20828] cleanup examples#424

Open
SerhiiChaban-apryse wants to merge 1 commit intoandroid_ds_9.0.0from
sc/SB-20828_update_examples
Open

[SB-20828] cleanup examples#424
SerhiiChaban-apryse wants to merge 1 commit intoandroid_ds_9.0.0from
sc/SB-20828_update_examples

Conversation

@SerhiiChaban-apryse
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 117 to +121
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) {
Comment on lines 98 to +102
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.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd leave just one (the latter one) "SDK" abbreviation mention

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... 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.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say this is out of scope of the SDK examples and might confuse non tech-savvy users.

}

kotlin {
jvmToolchain(project.ext.jvmToolchainVersion)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@DenDrobiazko-Apryse
Copy link
Copy Markdown

Code like

    buildFeatures {
        viewBinding = true
    }

can be reduced to a one-liner: buildFeatures.viewBinding = true

Not sure if we'd want to pursue that minification - just FYI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants