Skip to content

Commit

Permalink
Merge branch 'release/1.10.0'
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
  • Loading branch information
G00fY2 committed May 5, 2024
2 parents 78cc9ca + 8716a0f commit a971f09
Show file tree
Hide file tree
Showing 16 changed files with 84 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Make sure to get working code on a personal branch with tests and sanity checks
```shell
./gradlew detektBundledDebug detektUnbundledDebug
./gradlew test
./gradlew :sample:lintBundledDebug
./gradlew :sample:lintUnbundledDebug
./gradlew :sample:assembleBundledDebug
./gradlew :sample:assembleUnbundledDebug
```
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ jobs:
- name: Run bundled and unbundled unit tests
run: ./gradlew test

android_lint:
name: Android lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Run Android lint
run: ./gradlew :sample:lintBundledDebug :sample:lintUnbundledDebug

build_bundled:
name: Build bundled debug
runs-on: ubuntu-latest
Expand Down
5 changes: 3 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()`:

```kotlin
// bundled:
implementation("io.github.g00fy2.quickie:quickie-bundled:1.9.0")
implementation("io.github.g00fy2.quickie:quickie-bundled:1.10.0")

// unbundled:
implementation("io.github.g00fy2.quickie:quickie-unbundled:1.9.0")
implementation("io.github.g00fy2.quickie:quickie-unbundled:1.10.0")
```

## Quick Start
Expand Down Expand Up @@ -116,6 +116,7 @@ override fun onCreate(savedInstanceState: Bundle?) {
setShowCloseButton(true) // show or hide (default) close button
setHorizontalFrameRatio(2.2f) // set the horizontal overlay ratio (default is 1 / square frame)
setUseFrontCamera(true) // use the front camera
setKeepScreenOn(true) // keep the device's screen turned on
}
)
}
Expand Down
18 changes: 9 additions & 9 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
[versions]
quickie = "1.9.0"
quickie = "1.10.0"

androidconfig-minSdk = "21"
androidconfig-compileSdk = "34"
androidconfig-targetSdk = "33"
androidconfig-buildTools = "34.0.0"

androidGradle = "8.2.0"
kotlin = "1.9.21"
androidGradle = "8.4.0"
kotlin = "1.9.23"

appcompat = "1.6.1"
core = "1.12.0"
core = "1.13.1"

cameraX = "1.3.0"
cameraX = "1.3.3"

barcodeScanning = "17.2.0"
barcodeScanningGms = "18.3.0"

materialDesign = "1.10.0"
materialDesign = "1.12.0"

detekt = "1.23.4"
dokka = "1.9.10"
detekt = "1.23.6"
dokka = "1.9.20"

junit = "5.10.1"
junit = "5.10.2"

[libraries]
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
6 changes: 4 additions & 2 deletions quickie/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">

<uses-feature
android:name="android.hardware.camera"
Expand All @@ -12,7 +13,8 @@
<activity
android:name=".QRScannerActivity"
android:screenOrientation="behind"
android:theme="@style/QuickieScannerActivity"/>
android:theme="@style/QuickieScannerActivity"
tools:ignore="DiscouragedApi"/>

</application>

Expand Down
4 changes: 2 additions & 2 deletions quickie/src/main/kotlin/io/github/g00fy2/quickie/QRResult.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public sealed class QRResult {
/**
* Activity got cancelled by the user.
*/
public object QRUserCanceled : QRResult()
public data object QRUserCanceled : QRResult()

/**
* Camera permission was not granted.
*/
public object QRMissingPermission : QRResult()
public data object QRMissingPermission : QRResult()

/**
* Error while setting up CameraX or while MLKit analysis.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.util.Size
import android.view.HapticFeedbackConstants
import android.view.KeyEvent
import android.view.View
import android.view.WindowManager
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.view.ContextThemeWrapper
Expand Down Expand Up @@ -195,6 +196,8 @@ internal class QRScannerActivity : AppCompatActivity() {
showTorchToggle = it.showTorchToggle
useFrontCamera = it.useFrontCamera
showCloseButton = it.showCloseButton

if (it.keepScreenOn) window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ internal class ParcelableScannerConfig(
val horizontalFrameRatio: Float,
val useFrontCamera: Boolean,
val showCloseButton: Boolean,
val keepScreenOn: Boolean,
) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class ScannerConfig internal constructor(
internal val horizontalFrameRatio: Float,
internal val useFrontCamera: Boolean,
internal val showCloseButton: Boolean,
internal val keepScreenOn: Boolean,
) {

public class Builder {
Expand All @@ -27,6 +28,7 @@ public class ScannerConfig internal constructor(
private var horizontalFrameRatio: Float = 1f
private var useFrontCamera: Boolean = false
private var showCloseButton: Boolean = false
private var keepScreenOn: Boolean = false

/**
* Set a list of interested barcode formats. List must not be empty.
Expand Down Expand Up @@ -71,19 +73,25 @@ public class ScannerConfig internal constructor(
*/
public fun setShowCloseButton(enable: Boolean): Builder = apply { showCloseButton = enable }

/**
* Keep the device's screen turned on as long as the scanner is visible.
*/
public fun setKeepScreenOn(enable: Boolean): Builder = apply { keepScreenOn = enable }

/**
* Build the BarcodeConfig required by the ScanBarcode ActivityResultContract.
*/
public fun build(): ScannerConfig =
ScannerConfig(
barcodeFormats.map { it.value }.toIntArray(),
overlayStringRes,
overlayDrawableRes,
hapticSuccessFeedback,
showTorchToggle,
horizontalFrameRatio,
useFrontCamera,
showCloseButton,
formats = barcodeFormats.map { it.value }.toIntArray(),
stringRes = overlayStringRes,
drawableRes = overlayDrawableRes,
hapticFeedback = hapticSuccessFeedback,
showTorchToggle = showTorchToggle,
horizontalFrameRatio = horizontalFrameRatio,
useFrontCamera = useFrontCamera,
showCloseButton = showCloseButton,
keepScreenOn = keepScreenOn,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ internal fun ScannerConfig.toParcelableConfig() =
horizontalFrameRatio = horizontalFrameRatio,
useFrontCamera = useFrontCamera,
showCloseButton = showCloseButton,
keepScreenOn = keepScreenOn,
)
6 changes: 6 additions & 0 deletions sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ android {
buildConfig = true
viewBinding = true
}
lint {
abortOnError = true
warningsAsErrors = true
checkDependencies = true
disable.add("RtlEnabled")
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class MainActivity : AppCompatActivity() {
setShowCloseButton(true) // show or hide (default) close button
setHorizontalFrameRatio(2.2f) // set the horizontal overlay ratio (default is 1 / square frame)
setUseFrontCamera(false) // use the front camera
setKeepScreenOn(true) // keep the device's screen turned on
}
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package io.github.g00fy2.quickiesample.quicksettingstile

import android.app.PendingIntent
import android.content.ComponentName
import android.content.Intent
import android.os.Build
import android.os.IBinder
import android.service.quicksettings.Tile
import android.service.quicksettings.TileService
import androidx.annotation.RequiresApi
import androidx.core.service.quicksettings.PendingIntentActivityWrapper
import androidx.core.service.quicksettings.TileServiceCompat
import io.github.g00fy2.quickiesample.MainActivity

// optional service to allow launching the sample app from the quick settings
Expand All @@ -28,12 +31,15 @@ class QuickieTileService : TileService() {

override fun onClick() {
super.onClick()
@Suppress("DEPRECATION")
startActivityAndCollapse(
Intent(this, MainActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
putExtra(MainActivity.OPEN_SCANNER, true)
}

val intent = Intent(this, MainActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
putExtra(MainActivity.OPEN_SCANNER, true)
}

TileServiceCompat.startActivityAndCollapse(
this,
PendingIntentActivityWrapper(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT, true)
)
}
}

0 comments on commit a971f09

Please sign in to comment.