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..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 @@ -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 } ) } @@ -119,6 +120,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) diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index d43898cb..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 @@ -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,11 +18,11 @@ 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.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/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/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 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..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,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(false) // use the front camera } ) }