Skip to content

Commit 699937b

Browse files
committed
feat(scanner): migrate QR scanner to CameraX + ML Kit (bundled, offline)
Replace zxing-lite (ancient CameraX 1.0.x + weaker ZXing decoder) with a modern CameraX 1.4.1 preview/ImageAnalysis pipeline feeding Google ML Kit's bundled barcode model (com.google.mlkit:barcode-scanning) — far more robust on angled/low-light/dense QR, and fully offline with no Google Play Services dependency (works on de-Googled ROMs). - Live scan: CameraX ImageAnalysis -> ML Kit (QR format only), STRATEGY_KEEP_ONLY_LATEST. - Image upload: decode bitmap -> ML Kit InputImage.fromBitmap (was ZXing CodeUtils); multi-image still supported; clear 'no QR found' message. - New ScannerOverlayView viewfinder (replaces king ViewfinderView) + Material torch FAB (hidden when no flash unit) with flash on/off icons. - Runtime CAMERA permission via ActivityResult API; torch via CameraControl. - Kept com.google.zxing:core for QR *generation* (QRCodeDialog); ML Kit can't encode. Compiles; APK +~5.7MB (bundled barcode model libbarhopper). On-device verification pending (device disconnected from ADB during testing).
1 parent b1c4fde commit 699937b

7 files changed

Lines changed: 305 additions & 138 deletions

File tree

app/build.gradle.kts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,18 @@ dependencies {
6060
implementation("com.google.android.material:material:1.12.0")
6161
implementation("com.google.code.gson:gson:2.11.0")
6262

63-
implementation("com.github.jenly1314:zxing-lite:2.1.1")
63+
// QR scanning: CameraX live preview/analysis + ML Kit bundled barcode model.
64+
// Bundled (not play-services-*) so detection works fully offline with no Google
65+
// Play Services dependency — important for de-Googled ROMs. Replaces zxing-lite,
66+
// which pulled in ancient CameraX 1.0.x and a weaker ZXing decoder.
67+
implementation("androidx.camera:camera-core:1.4.1")
68+
implementation("androidx.camera:camera-camera2:1.4.1")
69+
implementation("androidx.camera:camera-lifecycle:1.4.1")
70+
implementation("androidx.camera:camera-view:1.4.1")
71+
implementation("com.google.mlkit:barcode-scanning:17.3.0")
72+
// ZXing core (pure-Java) is kept only for QR *generation* (QRCodeDialog); ML Kit
73+
// scans but cannot encode. It was previously transitive via zxing-lite.
74+
implementation("com.google.zxing:core:3.5.3")
6475
implementation("com.blacksquircle.ui:editorkit:2.6.0")
6576
implementation("com.blacksquircle.ui:language-base:2.6.0")
6677
implementation("com.blacksquircle.ui:language-json:2.6.0")

0 commit comments

Comments
 (0)