From eb3ef7bef65427d5da7a3c2725a11cf0cd29ff89 Mon Sep 17 00:00:00 2001 From: Thomas Wirth Date: Fri, 7 Jan 2022 23:04:01 +0100 Subject: [PATCH 1/6] Update gradle and plugins --- buildSrc/src/main/kotlin/Versions.kt | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index d43898cb..4d7053cb 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -21,8 +21,8 @@ object Versions { const val materialDesign = "1.4.0" const val detekt = "1.19.0" - const val gradleVersions = "0.39.0" - const val dokka = "1.6.0" + const val gradleVersions = "0.41.0" + const val dokka = "1.6.10" const val junit = "5.8.2" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d2880ba8..2e6e5897 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From e4b41325faa1b5954233b6c5f5cf946ad3d25ce9 Mon Sep 17 00:00:00 2001 From: Thomas Wirth Date: Sun, 16 Jan 2022 13:21:02 +0100 Subject: [PATCH 2/6] Add CONTRIBUTING.md and update README.md --- CONTRIBUTING.md | 23 +++++++++++++++++++++++ README.md | 5 +++++ 2 files changed, 28 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..c176ba11 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,23 @@ +# Contributing to quickie + +Welcome and thanks for being interested in contributing to quickie! + +Quickie is a minimal barcode scanning library with an opinionated design. +Therefore there are currently no plans to allow enhanced customization of the scanner overview ui. +See this comment for further explanation [#14](https://github.com/G00fY2/quickie/pull/14#issuecomment-877804346). + +## Creating Pull Requests +* This project uses Git Flow as branching strategy. Make sure to use the **develop** branch as the base branch when creating a pull request. +* For first time contributors GitHub will not run the GitHub Actions automatically. You should make sure that all tasks succeed before committing (see [Code Contributions](#code-contributions)). + +## Code Contributions +Make sure to get working code on a personal branch with tests and sanity checks passing before you submit a PR: +```shell +./gradlew detektBundledDebug detektUnbundledDebug +./gradlew test +./gradlew :sample:assembleBundledDebug +./gradlew :sample:assembleUnbundledDebug +``` +Please make every effort to follow existing conventions and style in order to keep the code as readable as possible. + +Contribute code changes through GitHub by forking the repository and sending a pull request. I will squash all pull requests on merge. diff --git a/README.md b/README.md index b4cf1920..d8e8c91e 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,11 @@ You can find the sample app APKs inside the [release](https://github.com/G00fY2/ * Min SDK 21+ (required by CameraX) * (Google Play Services available on the end device if using `quickie-unbundled`) +## Contributing +See [CONTRIBUTING](CONTRIBUTING.md) + +Thanks to everyone who contributed to quickie! + ## License The MIT License (MIT) From c6548c65a7c5f9eed02696750ecb5e7f747c7684 Mon Sep 17 00:00:00 2001 From: Thomas Wirth Date: Sun, 16 Jan 2022 13:44:27 +0100 Subject: [PATCH 3/6] Update dependencies --- buildSrc/src/main/kotlin/Versions.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 4d7053cb..756dee6c 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -10,7 +10,7 @@ object Versions { const val androidGradle = "7.0.4" const val kotlin = "1.6.10" - const val appcompat = "1.4.0" + const val appcompat = "1.4.1" const val cameraX = "1.0.2" const val cameraView = "1.0.0-alpha32" @@ -18,7 +18,7 @@ object Versions { const val barcodeScanning = "17.0.1" const val barcodeScanningGms = "17.0.0" - const val materialDesign = "1.4.0" + const val materialDesign = "1.5.0" const val detekt = "1.19.0" const val gradleVersions = "0.41.0" From dc364e06628cfac2478bab41b5242f7bb894a5fe Mon Sep 17 00:00:00 2001 From: Justin Wyer Date: Sun, 16 Jan 2022 14:45:34 +0200 Subject: [PATCH 4/6] Add scanner config for using the front camera (#24) --- detekt.yml | 1 + .../kotlin/io/github/g00fy2/quickie/QRScannerActivity.kt | 9 ++++++++- .../g00fy2/quickie/config/ParcelableScannerConfig.kt | 1 + .../io/github/g00fy2/quickie/config/ScannerConfig.kt | 8 ++++++++ .../g00fy2/quickie/extensions/ScannerConfigExtensions.kt | 1 + .../io/github/g00fy2/quickiesample/MainActivity.kt | 1 + 6 files changed, 20 insertions(+), 1 deletion(-) diff --git a/detekt.yml b/detekt.yml index 9f9051be..66f48b5a 100644 --- a/detekt.yml +++ b/detekt.yml @@ -3,6 +3,7 @@ complexity: ignoreSingleWhenExpression: true LongParameterList: ignoreAnnotated: ['Parcelize'] + constructorThreshold: 8 exceptions: TooGenericExceptionCaught: diff --git a/quickie/src/main/kotlin/io/github/g00fy2/quickie/QRScannerActivity.kt b/quickie/src/main/kotlin/io/github/g00fy2/quickie/QRScannerActivity.kt index e87f29b8..41bef1fc 100644 --- a/quickie/src/main/kotlin/io/github/g00fy2/quickie/QRScannerActivity.kt +++ b/quickie/src/main/kotlin/io/github/g00fy2/quickie/QRScannerActivity.kt @@ -37,6 +37,7 @@ internal class QRScannerActivity : AppCompatActivity() { private var barcodeFormats = intArrayOf(Barcode.FORMAT_QR_CODE) private var hapticFeedback = true private var showTorchToggle = false + private var useFrontCamera = false internal var errorDialog: Dialog? = null set(value) { field = value @@ -106,7 +107,12 @@ internal class QRScannerActivity : AppCompatActivity() { cameraProvider.unbindAll() try { - val camera = cameraProvider.bindToLifecycle(this, CameraSelector.DEFAULT_BACK_CAMERA, preview, imageAnalysis) + val cameraSelector = if (useFrontCamera) { + CameraSelector.DEFAULT_FRONT_CAMERA + } else { + CameraSelector.DEFAULT_BACK_CAMERA + } + val camera = cameraProvider.bindToLifecycle(this, cameraSelector, preview, imageAnalysis) binding.overlayView.visibility = View.VISIBLE if (showTorchToggle && camera.cameraInfo.hasFlashUnit()) { binding.overlayView.setTorchVisibilityAndOnClick(true) { camera.cameraControl.enableTorch(it) } @@ -165,6 +171,7 @@ internal class QRScannerActivity : AppCompatActivity() { binding.overlayView.setHorizontalFrameRatio(it.horizontalFrameRatio) hapticFeedback = it.hapticFeedback showTorchToggle = it.showTorchToggle + useFrontCamera = it.useFrontCamera } } diff --git a/quickie/src/main/kotlin/io/github/g00fy2/quickie/config/ParcelableScannerConfig.kt b/quickie/src/main/kotlin/io/github/g00fy2/quickie/config/ParcelableScannerConfig.kt index 015371ec..2b3433d6 100644 --- a/quickie/src/main/kotlin/io/github/g00fy2/quickie/config/ParcelableScannerConfig.kt +++ b/quickie/src/main/kotlin/io/github/g00fy2/quickie/config/ParcelableScannerConfig.kt @@ -11,4 +11,5 @@ internal class ParcelableScannerConfig( val hapticFeedback: Boolean, val showTorchToggle: Boolean, val horizontalFrameRatio: Float, + val useFrontCamera: Boolean, ) : Parcelable \ No newline at end of file diff --git a/quickie/src/main/kotlin/io/github/g00fy2/quickie/config/ScannerConfig.kt b/quickie/src/main/kotlin/io/github/g00fy2/quickie/config/ScannerConfig.kt index 021257cd..a9c2d8cc 100644 --- a/quickie/src/main/kotlin/io/github/g00fy2/quickie/config/ScannerConfig.kt +++ b/quickie/src/main/kotlin/io/github/g00fy2/quickie/config/ScannerConfig.kt @@ -13,6 +13,7 @@ public class ScannerConfig internal constructor( internal val hapticFeedback: Boolean, internal val showTorchToggle: Boolean, internal val horizontalFrameRatio: Float, + internal val useFrontCamera: Boolean, ) { public class Builder { @@ -22,6 +23,7 @@ public class ScannerConfig internal constructor( private var hapticSuccessFeedback: Boolean = true private var showTorchToggle: Boolean = false private var horizontalFrameRatio: Float = 1f + private var useFrontCamera: Boolean = false /** * Set a list of interested barcode formats. List must not be empty. @@ -56,6 +58,11 @@ public class ScannerConfig internal constructor( */ public fun setShowTorchToggle(enable: Boolean): Builder = apply { showTorchToggle = enable } + /** + * Use the front camera. + */ + public fun setUseFrontCamera(enable: Boolean): Builder = apply { useFrontCamera = enable } + /** * Build the BarcodeConfig required by the ScanBarcode ActivityResultContract. */ @@ -67,6 +74,7 @@ public class ScannerConfig internal constructor( hapticSuccessFeedback, showTorchToggle, horizontalFrameRatio, + useFrontCamera, ) } diff --git a/quickie/src/main/kotlin/io/github/g00fy2/quickie/extensions/ScannerConfigExtensions.kt b/quickie/src/main/kotlin/io/github/g00fy2/quickie/extensions/ScannerConfigExtensions.kt index d90e2d95..09912755 100644 --- a/quickie/src/main/kotlin/io/github/g00fy2/quickie/extensions/ScannerConfigExtensions.kt +++ b/quickie/src/main/kotlin/io/github/g00fy2/quickie/extensions/ScannerConfigExtensions.kt @@ -11,4 +11,5 @@ internal fun ScannerConfig.toParcelableConfig() = hapticFeedback = hapticFeedback, showTorchToggle = showTorchToggle, horizontalFrameRatio = horizontalFrameRatio, + useFrontCamera = useFrontCamera, ) \ No newline at end of file diff --git a/sample/src/main/kotlin/io/github/g00fy2/quickiesample/MainActivity.kt b/sample/src/main/kotlin/io/github/g00fy2/quickiesample/MainActivity.kt index 6ec64b44..e825b74c 100644 --- a/sample/src/main/kotlin/io/github/g00fy2/quickiesample/MainActivity.kt +++ b/sample/src/main/kotlin/io/github/g00fy2/quickiesample/MainActivity.kt @@ -47,6 +47,7 @@ class MainActivity : AppCompatActivity() { setHapticSuccessFeedback(false) // enable (default) or disable haptic feedback when a barcode was detected setShowTorchToggle(true) // show or hide (default) torch/flashlight toggle button setHorizontalFrameRatio(2.2f) // set the horizontal overlay ratio (default is 1 / square frame) + setUseFrontCamera(true) // use the front camera } ) } From c34c41bce381e7c584c1e7363eabca3ef8b86608 Mon Sep 17 00:00:00 2001 From: Thomas Wirth Date: Sun, 16 Jan 2022 13:51:16 +0100 Subject: [PATCH 5/6] Update Readme and change sample app config --- README.md | 1 + .../main/kotlin/io/github/g00fy2/quickiesample/MainActivity.kt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d8e8c91e..229d9a83 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,7 @@ override fun onCreate(savedInstanceState: Bundle?) { setHapticSuccessFeedback(false) // enable (default) or disable haptic feedback when a barcode was detected setShowTorchToggle(true) // show or hide (default) torch/flashlight toggle button setHorizontalFrameRatio(2.2f) // set the horizontal overlay ratio (default is 1 / square frame) + setUseFrontCamera(true) // use the front camera } ) } diff --git a/sample/src/main/kotlin/io/github/g00fy2/quickiesample/MainActivity.kt b/sample/src/main/kotlin/io/github/g00fy2/quickiesample/MainActivity.kt index e825b74c..e7caf85e 100644 --- a/sample/src/main/kotlin/io/github/g00fy2/quickiesample/MainActivity.kt +++ b/sample/src/main/kotlin/io/github/g00fy2/quickiesample/MainActivity.kt @@ -47,7 +47,7 @@ class MainActivity : AppCompatActivity() { setHapticSuccessFeedback(false) // enable (default) or disable haptic feedback when a barcode was detected setShowTorchToggle(true) // show or hide (default) torch/flashlight toggle button setHorizontalFrameRatio(2.2f) // set the horizontal overlay ratio (default is 1 / square frame) - setUseFrontCamera(true) // use the front camera + setUseFrontCamera(false) // use the front camera } ) } From 9c479645f5442c91e5e6d5adf851606be4ad4771 Mon Sep 17 00:00:00 2001 From: Thomas Wirth Date: Sun, 16 Jan 2022 13:52:59 +0100 Subject: [PATCH 6/6] Bump version to 1.4.0 --- README.md | 4 ++-- buildSrc/src/main/kotlin/Versions.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 229d9a83..f77d7c8f 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,10 @@ There are two different flavors available on `mavenCentral()`: | V3 model is used (faster, more accurate) | currently V1 model will be downloaded ```kotlin // bundled: -implementation("io.github.g00fy2.quickie:quickie-bundled:1.3.3") +implementation("io.github.g00fy2.quickie:quickie-bundled:1.4.0") // unbundled: -implementation("io.github.g00fy2.quickie:quickie-unbundled:1.3.3") +implementation("io.github.g00fy2.quickie:quickie-unbundled:1.4.0") ``` ## Quick Start diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 756dee6c..d4ea424c 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -1,6 +1,6 @@ object Versions { - const val quickie = "1.3.3" + const val quickie = "1.4.0" const val androidMinSdk = 21 const val androidCompileSdk = 31