Skip to content

Commit

Permalink
Merge branch 'release/1.4.0' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
G00fY2 committed Jan 16, 2022
2 parents 3a71d77 + 9c47964 commit 6847647
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 9 deletions.
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
)
}
Expand All @@ -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)

Expand Down
10 changes: 5 additions & 5 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -10,19 +10,19 @@ 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"

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"

Expand Down
1 change: 1 addition & 0 deletions detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ complexity:
ignoreSingleWhenExpression: true
LongParameterList:
ignoreAnnotated: ['Parcelize']
constructorThreshold: 8

exceptions:
TooGenericExceptionCaught:
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) }
Expand Down Expand Up @@ -165,6 +171,7 @@ internal class QRScannerActivity : AppCompatActivity() {
binding.overlayView.setHorizontalFrameRatio(it.horizontalFrameRatio)
hapticFeedback = it.hapticFeedback
showTorchToggle = it.showTorchToggle
useFrontCamera = it.useFrontCamera
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ internal class ParcelableScannerConfig(
val hapticFeedback: Boolean,
val showTorchToggle: Boolean,
val horizontalFrameRatio: Float,
val useFrontCamera: Boolean,
) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.
Expand Down Expand Up @@ -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.
*/
Expand All @@ -67,6 +74,7 @@ public class ScannerConfig internal constructor(
hapticSuccessFeedback,
showTorchToggle,
horizontalFrameRatio,
useFrontCamera,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ internal fun ScannerConfig.toParcelableConfig() =
hapticFeedback = hapticFeedback,
showTorchToggle = showTorchToggle,
horizontalFrameRatio = horizontalFrameRatio,
useFrontCamera = useFrontCamera,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
)
}
Expand Down

0 comments on commit 6847647

Please sign in to comment.