diff --git a/README.md b/README.md index 810bf1e7..819c1c59 100644 --- a/README.md +++ b/README.md @@ -13,17 +13,18 @@ ## Download [![Maven Central](https://img.shields.io/maven-central/v/io.github.g00fy2.quickie/quickie-unbundled)](https://search.maven.org/search?q=g:io.github.g00fy2.quickie) There are two different flavors available on `mavenCentral()`: -| Bundled | Unbundled | -| ----------------------------------- | ------------------------------------------------- | -| ML Kit model is bundled inside app (independent of Google Services) | ML Kit model will be automatically downloaded via Play Services (once while installing/updating the app) | -| About 2.5 MB app size increase per ABI (you should use App Bundle or ABI splitting) | About 550 KB app size increase | -| V3 model is used (faster, more accurate) | Currently V1 model will be downloaded +| Bundled | Unbundled | +|-------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------| +| ML Kit model is bundled inside app (independent of Google Services) | ML Kit model will be automatically downloaded via Play Services (once while installing/updating the app) | +| About 2.5 MB app size increase per ABI (you should use App Bundle or ABI splitting) | About 550 KB app size increase | +| V3 model is used (faster, more accurate) | Currently V1 model will be downloaded | + ```kotlin // bundled: -implementation("io.github.g00fy2.quickie:quickie-bundled:1.5.1") +implementation("io.github.g00fy2.quickie:quickie-bundled:1.5.2") // unbundled: -implementation("io.github.g00fy2.quickie:quickie-unbundled:1.5.1") +implementation("io.github.g00fy2.quickie:quickie-unbundled:1.5.2") ``` ## Quick Start @@ -125,7 +126,7 @@ override fun onCreate(savedInstanceState: Bundle?) { fun handleResult(result: QRResult) { … ``` -:bulb: You can optionally [pass in an ActivityOptionsCompat object](https://developer.android.com/reference/androidx/activity/result/ActivityResultLauncher#launch(I,%20androidx.core.app.ActivityOptionsCompat)) when launching the ActivityResultLauncher to control the scanner launch animation. +> **Note**: You can optionally [pass in an ActivityOptionsCompat object](https://developer.android.com/reference/androidx/activity/result/ActivityResultLauncher#launch(I,%20androidx.core.app.ActivityOptionsCompat)) when launching the ActivityResultLauncher to control the scanner launch animation. ## Screenshots / Sample App You can find the sample app APKs inside the [release](https://github.com/G00fY2/quickie/releases) assets. diff --git a/build.gradle.kts b/build.gradle.kts index da5243c9..34ebccfc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,5 @@ import com.android.build.gradle.BaseExtension +import com.android.build.gradle.BasePlugin import io.gitlab.arturbosch.detekt.Detekt import io.gitlab.arturbosch.detekt.extensions.DetektExtension import org.jetbrains.kotlin.gradle.tasks.KotlinCompile @@ -6,7 +7,9 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile @Suppress("DSL_SCOPE_VIOLATION") plugins { alias(libs.plugins.android.application) apply false - alias(libs.plugins.kotlin.androidGradle) apply false + alias(libs.plugins.android.library) apply false + alias(libs.plugins.kotlin.android) apply false + alias(libs.plugins.kotlin.parcelize) apply false alias(libs.plugins.kotlin.dokka) apply false alias(libs.plugins.misc.detekt) apply false alias(libs.plugins.misc.gradleVersions) @@ -33,10 +36,10 @@ subprojects { "-progressive", "-Xexplicit-api=strict".takeIf { (this@subprojects.name != "sample") }, ) - jvmTarget = "11" + jvmTarget = JavaVersion.VERSION_11.toString() } } - afterEvaluate { + plugins.withType().configureEach { extensions.configure { compileSdkVersion(libs.versions.androidconfig.compileSdk.get().toInt()) buildToolsVersion(libs.versions.androidconfig.buildTools.get()) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f50bd279..ea514289 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,28 +1,28 @@ [versions] -quickie = "1.5.1" +quickie = "1.5.2" androidconfig-minSdk = "21" androidconfig-compileSdk = "32" androidconfig-targetSdk = "32" androidconfig-buildTools = "32.0.0" -androidGradle = "7.2.2" -kotlin = "1.7.10" +androidGradle = "7.3.1" +kotlin = "1.7.20" -appcompat = "1.5.0" +appcompat = "1.5.1" cameraX = "1.1.0" barcodeScanning = "17.0.2" -barcodeScanningGms = "18.0.0" +barcodeScanningGms = "18.1.0" -materialDesign = "1.6.1" +materialDesign = "1.7.0" detekt = "1.21.0" -gradleVersions = "0.42.0" -dokka = "1.7.10" +gradleVersions = "0.43.0" +dokka = "1.7.20" -junit = "5.9.0" +junit = "5.9.1" [libraries] androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" } @@ -44,9 +44,8 @@ misc-detektFormatting = { module = "io.gitlab.arturbosch.detekt:detekt-formattin android-application = { id = "com.android.application", version.ref = "androidGradle" } android-library = { id = "com.android.library", version.ref = "androidGradle" } -kotlin-androidGradle = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } -kotlin-android = { id = "kotlin-android", version.ref = "kotlin" } -kotlin-parcelize = { id = "kotlin-parcelize", version.ref = "kotlin" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" } kotlin-dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } misc-detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" } diff --git a/quickie/build.gradle.kts b/quickie/build.gradle.kts index 6be6a705..938c3980 100644 --- a/quickie/build.gradle.kts +++ b/quickie/build.gradle.kts @@ -1,14 +1,15 @@ @Suppress("DSL_SCOPE_VIOLATION") plugins { - id(libs.plugins.android.library.get().pluginId) - id(libs.plugins.kotlin.android.get().pluginId) - id(libs.plugins.kotlin.parcelize.get().pluginId) + alias(libs.plugins.android.library) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlin.parcelize) alias(libs.plugins.kotlin.dokka) `maven-publish` signing } android { + namespace = "io.github.g00fy2.quickie" resourcePrefix = "quickie" buildFeatures { viewBinding = true diff --git a/quickie/src/main/AndroidManifest.xml b/quickie/src/main/AndroidManifest.xml index 9a068c24..db4b4096 100644 --- a/quickie/src/main/AndroidManifest.xml +++ b/quickie/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + + + \ No newline at end of file diff --git a/quickie/src/main/kotlin/io/github/g00fy2/quickie/QRCodeAnalyzer.kt b/quickie/src/main/kotlin/io/github/g00fy2/quickie/QRCodeAnalyzer.kt index d47d9c31..b3afc64a 100644 --- a/quickie/src/main/kotlin/io/github/g00fy2/quickie/QRCodeAnalyzer.kt +++ b/quickie/src/main/kotlin/io/github/g00fy2/quickie/QRCodeAnalyzer.kt @@ -21,7 +21,12 @@ internal class QRCodeAnalyzer( } else { BarcodeScannerOptions.Builder().setBarcodeFormats(barcodeFormats.firstOrNull() ?: Barcode.FORMAT_UNKNOWN) } - BarcodeScanning.getClient(optionsBuilder.build()) + try { + BarcodeScanning.getClient(optionsBuilder.build()) + } catch (e: Exception) { // catch if for some reason MlKitContext has not been initialized + onFailure(e) + null + } } @Volatile @@ -39,17 +44,19 @@ internal class QRCodeAnalyzer( } failureOccurred = false - barcodeScanner.process(imageProxy.toInputImage()) - .addOnSuccessListener { codes -> codes.mapNotNull { it }.firstOrNull()?.let { onSuccess(it) } } - .addOnFailureListener { - failureOccurred = true - failureTimestamp = System.currentTimeMillis() - onFailure(it) - } - .addOnCompleteListener { - onPassCompleted(failureOccurred) - imageProxy.close() - } + barcodeScanner?.let { scanner -> + scanner.process(imageProxy.toInputImage()) + .addOnSuccessListener { codes -> codes.firstNotNullOfOrNull { it }?.let { onSuccess(it) } } + .addOnFailureListener { + failureOccurred = true + failureTimestamp = System.currentTimeMillis() + onFailure(it) + } + .addOnCompleteListener { + onPassCompleted(failureOccurred) + imageProxy.close() + } + } } @ExperimentalGetImage diff --git a/quickie/src/unbundled/AndroidManifest.xml b/quickie/src/unbundled/AndroidManifest.xml index 8191844f..229c7aa2 100644 --- a/quickie/src/unbundled/AndroidManifest.xml +++ b/quickie/src/unbundled/AndroidManifest.xml @@ -1,6 +1,5 @@ - + - + + android:theme="@style/Theme.Material3.DayNight" + tools:ignore="DataExtractionRules"> - + \ No newline at end of file