diff --git a/.github/workflows/alpaka_build.yml b/.github/workflows/alpaka_build.yml
new file mode 100644
index 0000000..12a8133
--- /dev/null
+++ b/.github/workflows/alpaka_build.yml
@@ -0,0 +1,28 @@
+name: Build and upload to Alpaka
+
+on: [ push, workflow_dispatch ]
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ build:
+ strategy:
+ fail-fast: false
+ max-parallel: 4
+ matrix:
+ flavor: [ 'prod' ]
+ uses: UbiqueInnovation/actions-android/.github/workflows/android_build_alpaka_upload.yml@v1.6.6
+ with:
+ flavor: '${{ matrix.flavor }}'
+ appModule: 'example'
+ concurrencyGroup: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.flavor }}
+ runs-on: '["ubuntu-latest"]'
+ secrets:
+ ANDROID_JENKINS_PAT: ${{ secrets.GITHUB_TOKEN }}
+ UB_ARTIFACTORY_URL_ANDROID: ${{ secrets.UB_ARTIFACTORY_URL_ANDROID }}
+ UB_ARTIFACTORY_USER: ${{ secrets.UB_ARTIFACTORY_USER }}
+ UB_ARTIFACTORY_PASSWORD: ${{ secrets.UB_ARTIFACTORY_PASSWORD }}
+ ALPAKA_UPLOAD_KEY: ${{ secrets.ALPAKA_UPLOAD_KEY }}
+ ADDITIONAL_GRADLE_PROPS: "-PstorePassword=${{ secrets.KEYSTORE_PASSWORD }} -PkeyAlias=${{ secrets.KEY_ALIAS }} -PkeyPassword=${{ secrets.KEY_PASSWORD }}"
diff --git a/.github/workflows/maven-central-dev.yml b/.github/workflows/maven-central-dev.yml
deleted file mode 100644
index 2e75b8f..0000000
--- a/.github/workflows/maven-central-dev.yml
+++ /dev/null
@@ -1,39 +0,0 @@
-name: Publish dev artifacts to Maven Central
-
-on:
- push:
- branches: [ main ]
-
-jobs:
- build:
- name: "Publish dev artifacts to Maven Central"
- runs-on: ubuntu-latest
-
- steps:
- - uses: actions/checkout@v2
- - name: set up JDK 11
- uses: actions/setup-java@v1
- with:
- java-version: 11
- - name: Publish artifact
- env:
- SIGNING_KEY_ARMOR: ${{ secrets.MAVEN_SIGNING_KEY_ARMOR_BASE64 }}
- SIGNING_KEY_ID: ${{ secrets.MAVEN_SIGNING_KEY_ID }}
- SIGNING_KEY_PASSWORD: ${{ secrets.MAVEN_SIGNING_KEY_PASSPHRASE }}
- MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
- MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
- run: |
- echo "Appending dev-suffix to version name"
- sed -i "/^VERSION_NAME=/s/$/-dev-$GITHUB_RUN_NUMBER/" gradle.properties
-
- echo "Create .gpg key from secret"
- echo $SIGNING_KEY_ARMOR | base64 --decode > ./signingkey.asc
- gpg --quiet --output $GITHUB_WORKSPACE/signingkey.gpg --dearmor ./signingkey.asc
-
- ./gradlew publish -Psigning.secretKeyRingFile=$GITHUB_WORKSPACE/signingkey.gpg -Psigning.password=$SIGNING_KEY_PASSWORD -Psigning.keyId=$SIGNING_KEY_ID -PmavenCentralUsername=$MAVEN_CENTRAL_USERNAME -PmavenCentralPassword=$MAVEN_CENTRAL_PASSWORD
- - name: Close and release Sonatype repository
- if: ${{ success() }}
- env:
- MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
- MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
- run: ./gradlew closeAndReleaseRepository -PmavenCentralUsername=$MAVEN_CENTRAL_USERNAME -PmavenCentralPassword=$MAVEN_CENTRAL_PASSWORD
diff --git a/.github/workflows/maven-central-tags.yml b/.github/workflows/maven-central-tags.yml
index 4cd314d..51c3398 100644
--- a/.github/workflows/maven-central-tags.yml
+++ b/.github/workflows/maven-central-tags.yml
@@ -1,37 +1,39 @@
-name: Publish release artifacts to Maven Central
+name: Publish tagged artifacts to Maven Central
on:
push:
tags:
- - 'v*'
+ - 'v[0-9]+.[0-9]+.[0-9]+-[a-zA-Z0-9]+'
+ - 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
build:
- name: "Publish release artifacts to Maven Central"
+ name: "Publish tagged artifacts to Maven Central"
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
- - name: set up JDK 11
- uses: actions/setup-java@v1
+ - uses: actions/checkout@v4.2.1
+ - name: set up JDK 17
+ uses: actions/setup-java@v4.4.0
with:
- java-version: 11
+ distribution: 'zulu'
+ java-version: '17'
- name: Publish artifact
env:
SIGNING_KEY_ARMOR: ${{ secrets.MAVEN_SIGNING_KEY_ARMOR_BASE64 }}
SIGNING_KEY_ID: ${{ secrets.MAVEN_SIGNING_KEY_ID }}
SIGNING_KEY_PASSWORD: ${{ secrets.MAVEN_SIGNING_KEY_PASSPHRASE }}
- MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
- MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
+ OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
+ OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
run: |
echo "Create .gpg key from secret"
echo $SIGNING_KEY_ARMOR | base64 --decode > ./signingkey.asc
gpg --quiet --output $GITHUB_WORKSPACE/signingkey.gpg --dearmor ./signingkey.asc
- ./gradlew publish -Psigning.secretKeyRingFile=$GITHUB_WORKSPACE/signingkey.gpg -Psigning.password=$SIGNING_KEY_PASSWORD -Psigning.keyId=$SIGNING_KEY_ID -PmavenCentralUsername=$MAVEN_CENTRAL_USERNAME -PmavenCentralPassword=$MAVEN_CENTRAL_PASSWORD
+ ./gradlew publish -Psigning.secretKeyRingFile=$GITHUB_WORKSPACE/signingkey.gpg -Psigning.password=$SIGNING_KEY_PASSWORD -Psigning.keyId=$SIGNING_KEY_ID -PossrhUsername=$OSSRH_USERNAME -PossrhPassword=$OSSRH_PASSWORD
- name: Close and release Sonatype repository
if: ${{ success() }}
env:
- MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
- MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
- run: ./gradlew closeAndReleaseRepository -PmavenCentralUsername=$MAVEN_CENTRAL_USERNAME -PmavenCentralPassword=$MAVEN_CENTRAL_PASSWORD
+ OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
+ OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
+ run: ./gradlew closeAndReleaseRepository -PossrhUsername=$OSSRH_USERNAME -PossrhPassword=$OSSRH_PASSWORD
diff --git a/.gitignore b/.gitignore
index 76641bf..7d16d0a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -143,10 +143,6 @@ captures/
*~
*.swp
-# Keystore files
-*.jks
-*.keystore
-
# Google Services (e.g. APIs or Firebase)
# google-services.json
diff --git a/build.gradle b/build.gradle
index fb45456..9aafa97 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,8 +1,11 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
- id 'com.android.application' version '7.1.0' apply false
- id 'com.android.library' version '7.1.0' apply false
- id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
+ alias libs.plugins.android.application apply false
+ alias libs.plugins.android.library apply false
+ alias libs.plugins.kotlinAndroid apply false
+ alias libs.plugins.mavenPublish apply false
+ alias libs.plugins.ubique.alpaka apply false
+ alias libs.plugins.ubique.preset apply false
}
task clean(type: Delete) {
diff --git a/example/build.gradle b/example/build.gradle
index d32c361..3650008 100644
--- a/example/build.gradle
+++ b/example/build.gradle
@@ -1,66 +1,73 @@
+import ch.ubique.gradle.preset.utils.PropertyUtilsKt
+
plugins {
- id 'com.android.application'
- id 'org.jetbrains.kotlin.android'
+ alias libs.plugins.android.application
+ alias libs.plugins.kotlinAndroid
+ alias libs.plugins.compose.compiler
+ alias libs.plugins.ubique.alpaka
+ alias libs.plugins.ubique.preset
}
android {
- compileSdk 31
+ namespace "ch.ubique.qrscanner.example"
+ compileSdk 34
defaultConfig {
applicationId "ch.ubique.qrscanner.example"
minSdk 23
- targetSdk 31
+ targetSdk 34
versionCode 1
- versionName "1.0"
+ versionName "1.0.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+
+ alpakaUploadKey = System.getenv("ALPAKA_UPLOAD_KEY") ?: ""
}
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ productFlavors {
+ prod {
+ // Required for the Alpaka upload
}
}
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
+ signingConfigs {
+ ubique {
+ storeFile file("keystore.jks")
+ storePassword System.getenv("KEYSTORE_PASSWORD") ?: PropertyUtilsKt.readProperty(project, "storePassword")
+ keyAlias System.getenv("KEY_ALIAS") ?: PropertyUtilsKt.readProperty(project, "keyAlias")
+ keyPassword System.getenv("KEY_PASSWORD") ?: PropertyUtilsKt.readProperty(project, "keyPassword")
+ }
}
- kotlinOptions {
- jvmTarget = '1.8'
+ buildTypes {
+ release {
+ signingConfig = signingConfigs.ubique
+ }
}
buildFeatures {
viewBinding true
compose true
}
-
- composeOptions {
- kotlinCompilerExtensionVersion '1.1.0'
- }
}
dependencies {
- implementation 'androidx.core:core-ktx:1.7.0'
- implementation 'androidx.appcompat:appcompat:1.4.1'
- implementation 'com.google.android.material:material:1.5.0'
- implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
-
implementation project(':qrscanner-zxing')
implementation project(':qrscanner-mlkit')
implementation project(':qrscanner-compose')
- def compose_version = '1.1.0'
- implementation "androidx.compose.ui:ui:$compose_version"
- implementation "androidx.compose.ui:ui-tooling:$compose_version"
- implementation "androidx.compose.ui:ui-unit:$compose_version"
- implementation "androidx.compose.foundation:foundation:$compose_version"
- implementation "androidx.compose.material:material:$compose_version"
- implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
+ implementation libs.core.ktx
+ implementation libs.material
+ implementation libs.androidx.constraintlayout
+
+ implementation platform(libs.compose.bom)
+ implementation libs.compose.ui
+ implementation libs.compose.ui.tooling
+ implementation libs.compose.ui.unit
+ implementation libs.compose.foundation
+ implementation libs.compose.material
- testImplementation 'junit:junit:4.13.2'
- androidTestImplementation 'androidx.test.ext:junit:1.1.3'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
+ testImplementation libs.junit
+ androidTestImplementation libs.androidx.test.ext.junit
+ androidTestImplementation libs.espresso.core
}
\ No newline at end of file
diff --git a/example/keystore.jks b/example/keystore.jks
new file mode 100644
index 0000000..6896e9b
Binary files /dev/null and b/example/keystore.jks differ
diff --git a/example/src/main/AndroidManifest.xml b/example/src/main/AndroidManifest.xml
index f272f37..7885f23 100644
--- a/example/src/main/AndroidManifest.xml
+++ b/example/src/main/AndroidManifest.xml
@@ -23,7 +23,7 @@
android:theme="@style/Theme.QRScanner">
@@ -33,7 +33,7 @@
diff --git a/example/src/main/ic_launcher-playstore.png b/example/src/main/ic_launcher-playstore.png
new file mode 100644
index 0000000..ae7b162
Binary files /dev/null and b/example/src/main/ic_launcher-playstore.png differ
diff --git a/gradle.properties b/gradle.properties
index 2065d04..de21e98 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -21,6 +21,7 @@ kotlin.code.style=official
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
+android.enableR8.fullMode=false
###########################
# Library wide POM metadata
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
new file mode 100644
index 0000000..1299bf8
--- /dev/null
+++ b/gradle/libs.versions.toml
@@ -0,0 +1,52 @@
+[versions]
+agp = "8.7.0"
+androidx-camera = "1.3.4"
+androidx-core = "1.13.1"
+androidx-fragment = "1.8.4"
+androidx-test-ext-junit = "1.2.1"
+compose = "2024.09.03"
+constraintlayout = "2.1.4"
+espresso-core = "3.6.1"
+junit = "4.13.2"
+kotlin = "2.0.20"
+kotlinx-coroutines = "1.9.0"
+material = "1.12.0"
+maven-publish = "0.27.0"
+mlkit = "17.3.0"
+ubique-alpaka = "8.7.0"
+ubique-preset = "8.7.0"
+zxing = "3.5.3"
+
+[bundles]
+
+[libraries]
+androidx-camera-camera2 = { module = "androidx.camera:camera-camera2", version.ref = "androidx-camera" }
+androidx-camera-view = { module = "androidx.camera:camera-view", version.ref = "androidx-camera" }
+androidx-camera-lifecycle = { module = "androidx.camera:camera-lifecycle", version.ref = "androidx-camera" }
+androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintlayout" }
+androidx-fragmentKtx = { module = "androidx.fragment:fragment-ktx", version.ref = "androidx-fragment" }
+androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext-junit" }
+compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose" }
+compose-ui = { group = "androidx.compose.ui", name = "ui" }
+compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
+compose-ui-unit = { group = "androidx.compose.ui", name = "ui-unit" }
+compose-foundation = { group = "androidx.compose.foundation", name = "foundation" }
+compose-material = { group = "androidx.compose.material", name = "material" }
+core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidx-core" }
+espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso-core" }
+junit = { group = "junit", name = "junit", version.ref = "junit" }
+kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" }
+material = { group = "com.google.android.material", name = "material", version.ref = "material" }
+mlkit-barcode = { module = "com.google.mlkit:barcode-scanning", version.ref = "mlkit" }
+zxing-core = { module = "com.google.zxing:core", version.ref = "zxing" }
+
+[plugins]
+android-application = { id = "com.android.application", version.ref = "agp" }
+android-library = { id = "com.android.library", version.ref = "agp" }
+compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
+kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
+mavenPublish = { id = "com.vanniktech.maven.publish", version.ref = "maven-publish" }
+ubique-alpaka = { id = "ch.ubique.gradle.alpaka", version.ref = "ubique-alpaka" }
+ubique-preset = { id = "ch.ubique.gradle.preset", version.ref = "ubique-preset" }
+
+
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index bdb33c1..3152c21 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Mon Feb 14 13:55:22 CET 2022
+#Tue Oct 08 13:27:36 CEST 2024
distributionBase=GRADLE_USER_HOME
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionPath=wrapper/dists
-zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/qrscanner-compose/build.gradle b/qrscanner-compose/build.gradle
index 93bb18b..0dfa98f 100644
--- a/qrscanner-compose/build.gradle
+++ b/qrscanner-compose/build.gradle
@@ -1,15 +1,17 @@
plugins {
- id 'com.android.library'
- id 'org.jetbrains.kotlin.android'
- id 'com.vanniktech.maven.publish' version '0.18.0'
+ alias libs.plugins.android.library
+ alias libs.plugins.kotlinAndroid
+ alias libs.plugins.compose.compiler
+ alias libs.plugins.mavenPublish
}
android {
- compileSdk 31
+ namespace "ch.ubique.qrscanner.compose"
+ compileSdk 34
defaultConfig {
minSdk 23
- targetSdk 31
+ targetSdk 34
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
@@ -23,38 +25,33 @@ android {
}
compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
+ sourceCompatibility JavaVersion.VERSION_17
+ targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
- jvmTarget = '1.8'
+ jvmTarget = '17'
}
buildFeatures {
compose true
}
-
- composeOptions {
- kotlinCompilerExtensionVersion '1.1.0'
- }
}
dependencies {
api project(':qrscanner-core')
- implementation 'androidx.core:core-ktx:1.7.0'
- implementation 'androidx.appcompat:appcompat:1.4.1'
- implementation 'androidx.fragment:fragment-ktx:1.4.1'
+ implementation libs.core.ktx
+ implementation libs.androidx.fragmentKtx
// Jetpack Compose
- def compose_version = '1.1.0'
- implementation "androidx.compose.ui:ui:$compose_version"
- implementation "androidx.compose.ui:ui-tooling:$compose_version"
- implementation "androidx.compose.ui:ui-unit:$compose_version"
- implementation "androidx.compose.material:material:$compose_version"
-
- testImplementation 'junit:junit:4.13.2'
- androidTestImplementation 'androidx.test.ext:junit:1.1.3'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
+ implementation platform(libs.compose.bom)
+ implementation libs.compose.ui
+ implementation libs.compose.ui.tooling
+ implementation libs.compose.ui.unit
+ implementation libs.compose.material
+
+ testImplementation libs.junit
+ androidTestImplementation libs.androidx.test.ext.junit
+ androidTestImplementation libs.espresso.core
}
\ No newline at end of file
diff --git a/qrscanner-compose/src/main/AndroidManifest.xml b/qrscanner-compose/src/main/AndroidManifest.xml
index 669a6e4..568741e 100644
--- a/qrscanner-compose/src/main/AndroidManifest.xml
+++ b/qrscanner-compose/src/main/AndroidManifest.xml
@@ -1,5 +1,2 @@
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/qrscanner-compose/src/main/java/ch/ubique/qrscanner/compose/QrScanner.kt b/qrscanner-compose/src/main/java/ch/ubique/qrscanner/compose/QrScanner.kt
index 69170e0..04ff083 100644
--- a/qrscanner-compose/src/main/java/ch/ubique/qrscanner/compose/QrScanner.kt
+++ b/qrscanner-compose/src/main/java/ch/ubique/qrscanner/compose/QrScanner.kt
@@ -1,21 +1,23 @@
package ch.ubique.qrscanner.compose
-import android.util.Size
import android.view.Display
import android.view.Surface
import androidx.camera.core.Camera
import androidx.camera.core.CameraSelector
import androidx.camera.core.ImageAnalysis
import androidx.camera.core.Preview
+import androidx.camera.core.resolutionselector.AspectRatioStrategy
+import androidx.camera.core.resolutionselector.ResolutionSelector
+import androidx.camera.core.resolutionselector.ResolutionStrategy
import androidx.camera.lifecycle.ProcessCameraProvider
import androidx.camera.view.PreviewView
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
-import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.viewinterop.AndroidView
import androidx.core.content.ContextCompat
import androidx.core.hardware.display.DisplayManagerCompat
+import androidx.lifecycle.compose.LocalLifecycleOwner
import androidx.lifecycle.lifecycleScope
import ch.ubique.qrscanner.scanner.ImageAnalyzer
import ch.ubique.qrscanner.scanner.ImageDecoder
@@ -31,7 +33,7 @@ fun QrScanner(
modifier: Modifier = Modifier,
scanningMode: ScanningMode = ScanningMode.PARALLEL,
isFlashEnabled: State = remember { mutableStateOf(false) },
- linearZoom: State = remember { mutableStateOf(0f) },
+ linearZoom: State = remember { mutableFloatStateOf(0f) },
) {
val context = LocalContext.current
val lifecycleOwner = LocalLifecycleOwner.current
@@ -40,7 +42,12 @@ fun QrScanner(
val rotation = DisplayManagerCompat.getInstance(context).getDisplay(Display.DEFAULT_DISPLAY)?.rotation ?: Surface.ROTATION_0
val preview = Preview.Builder()
- .setTargetResolution(Size(720, 1280))
+ .setResolutionSelector(
+ ResolutionSelector.Builder()
+ .setResolutionStrategy(ResolutionStrategy.HIGHEST_AVAILABLE_STRATEGY)
+ .setAspectRatioStrategy(AspectRatioStrategy.RATIO_16_9_FALLBACK_AUTO_STRATEGY)
+ .build()
+ )
.setTargetRotation(rotation)
.build()
@@ -49,7 +56,12 @@ fun QrScanner(
.build()
val imageAnalysis = ImageAnalysis.Builder()
- .setTargetResolution(Size(720, 1280))
+ .setResolutionSelector(
+ ResolutionSelector.Builder()
+ .setResolutionStrategy(ResolutionStrategy.HIGHEST_AVAILABLE_STRATEGY)
+ .setAspectRatioStrategy(AspectRatioStrategy.RATIO_16_9_FALLBACK_AUTO_STRATEGY)
+ .build()
+ )
.setTargetRotation(rotation)
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
.build()
diff --git a/qrscanner-core/build.gradle b/qrscanner-core/build.gradle
index 007d05c..4672b06 100644
--- a/qrscanner-core/build.gradle
+++ b/qrscanner-core/build.gradle
@@ -1,15 +1,16 @@
plugins {
- id 'com.android.library'
- id 'org.jetbrains.kotlin.android'
- id 'com.vanniktech.maven.publish' version '0.18.0'
+ alias libs.plugins.android.library
+ alias libs.plugins.kotlinAndroid
+ alias libs.plugins.mavenPublish
}
android {
- compileSdk 31
+ namespace "ch.ubique.qrscanner"
+ compileSdk 34
defaultConfig {
minSdk 23
- targetSdk 31
+ targetSdk 34
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
@@ -23,12 +24,12 @@ android {
}
compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
+ sourceCompatibility JavaVersion.VERSION_17
+ targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
- jvmTarget = '1.8'
+ jvmTarget = '17'
}
buildFeatures {
@@ -37,16 +38,15 @@ android {
}
dependencies {
- api 'androidx.camera:camera-camera2:1.0.2'
- api 'androidx.camera:camera-lifecycle:1.0.2'
- api 'androidx.camera:camera-view:1.0.0-alpha32'
-
- implementation 'androidx.core:core-ktx:1.7.0'
- implementation 'androidx.appcompat:appcompat:1.4.1'
- implementation 'androidx.fragment:fragment-ktx:1.4.1'
- implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2'
-
- testImplementation 'junit:junit:4.13.2'
- androidTestImplementation 'androidx.test.ext:junit:1.1.3'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
+ api libs.androidx.camera.camera2
+ api libs.androidx.camera.lifecycle
+ api libs.androidx.camera.view
+
+ implementation libs.core.ktx
+ implementation libs.androidx.fragmentKtx
+ implementation libs.kotlinx.coroutines.android
+
+ testImplementation libs.junit
+ androidTestImplementation libs.androidx.test.ext.junit
+ androidTestImplementation libs.espresso.core
}
\ No newline at end of file
diff --git a/qrscanner-core/src/main/AndroidManifest.xml b/qrscanner-core/src/main/AndroidManifest.xml
index 9676f73..568741e 100644
--- a/qrscanner-core/src/main/AndroidManifest.xml
+++ b/qrscanner-core/src/main/AndroidManifest.xml
@@ -1,5 +1,2 @@
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/qrscanner-core/src/main/java/ch/ubique/qrscanner/state/DecodingState.kt b/qrscanner-core/src/main/java/ch/ubique/qrscanner/state/DecodingState.kt
index e8888fd..b581e81 100644
--- a/qrscanner-core/src/main/java/ch/ubique/qrscanner/state/DecodingState.kt
+++ b/qrscanner-core/src/main/java/ch/ubique/qrscanner/state/DecodingState.kt
@@ -1,7 +1,7 @@
package ch.ubique.qrscanner.state
sealed class DecodingState {
- object NotFound : DecodingState()
+ data object NotFound : DecodingState()
data class Decoded(val content: String) : DecodingState()
data class Error(val errorCode: Int): DecodingState()
}
\ No newline at end of file
diff --git a/qrscanner-core/src/main/java/ch/ubique/qrscanner/view/QrScannerView.kt b/qrscanner-core/src/main/java/ch/ubique/qrscanner/view/QrScannerView.kt
index 1fc4287..cd28580 100644
--- a/qrscanner-core/src/main/java/ch/ubique/qrscanner/view/QrScannerView.kt
+++ b/qrscanner-core/src/main/java/ch/ubique/qrscanner/view/QrScannerView.kt
@@ -11,6 +11,10 @@ import android.view.Surface
import android.widget.FrameLayout
import androidx.annotation.FloatRange
import androidx.camera.core.*
+import androidx.camera.core.impl.utils.ResolutionSelectorUtil
+import androidx.camera.core.resolutionselector.AspectRatioStrategy
+import androidx.camera.core.resolutionselector.ResolutionSelector
+import androidx.camera.core.resolutionselector.ResolutionStrategy
import androidx.camera.lifecycle.ProcessCameraProvider
import androidx.camera.view.PreviewView
import androidx.core.content.ContextCompat
@@ -70,7 +74,7 @@ class QrScannerView @JvmOverloads constructor(
}
@SuppressLint("ClickableViewAccessibility")
- override fun onTouchEvent(event: MotionEvent?): Boolean {
+ override fun onTouchEvent(event: MotionEvent): Boolean {
return if (tapToFocusDetector.onTouchEvent(event)) {
true
} else {
@@ -225,7 +229,12 @@ class QrScannerView @JvmOverloads constructor(
private fun initializePreview() {
preview = Preview.Builder()
- .setTargetResolution(Size(720, 1280))
+ .setResolutionSelector(
+ ResolutionSelector.Builder()
+ .setResolutionStrategy(ResolutionStrategy.HIGHEST_AVAILABLE_STRATEGY)
+ .setAspectRatioStrategy(AspectRatioStrategy.RATIO_16_9_FALLBACK_AUTO_STRATEGY)
+ .build()
+ )
.setTargetRotation(rotation)
.build()
.apply { setSurfaceProvider(previewView.surfaceProvider) }
@@ -240,7 +249,12 @@ class QrScannerView @JvmOverloads constructor(
this.imageAnalyzer = analyzer
imageAnalysis = ImageAnalysis.Builder()
- .setTargetResolution(Size(720, 1280))
+ .setResolutionSelector(
+ ResolutionSelector.Builder()
+ .setResolutionStrategy(ResolutionStrategy.HIGHEST_AVAILABLE_STRATEGY)
+ .setAspectRatioStrategy(AspectRatioStrategy.RATIO_16_9_FALLBACK_AUTO_STRATEGY)
+ .build()
+ )
.setTargetRotation(rotation)
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
.build()
diff --git a/qrscanner-mlkit/build.gradle b/qrscanner-mlkit/build.gradle
index 754229f..c03261e 100644
--- a/qrscanner-mlkit/build.gradle
+++ b/qrscanner-mlkit/build.gradle
@@ -1,15 +1,16 @@
plugins {
- id 'com.android.library'
- id 'org.jetbrains.kotlin.android'
- id 'com.vanniktech.maven.publish' version '0.18.0'
+ alias libs.plugins.android.library
+ alias libs.plugins.kotlinAndroid
+ alias libs.plugins.mavenPublish
}
android {
- compileSdk 31
+ namespace "ch.ubique.qrscanner.mlkit"
+ compileSdk 34
defaultConfig {
minSdk 23
- targetSdk 31
+ targetSdk 34
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
@@ -23,12 +24,12 @@ android {
}
compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
+ sourceCompatibility JavaVersion.VERSION_17
+ targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
- jvmTarget = '1.8'
+ jvmTarget = '17'
}
}
@@ -36,13 +37,12 @@ dependencies {
api project(':qrscanner-core')
// Use bundled mlkit model. See: https://developers.google.com/ml-kit/vision/barcode-scanning/android
- api 'com.google.mlkit:barcode-scanning:17.0.2'
+ api libs.mlkit.barcode
- implementation 'androidx.core:core-ktx:1.7.0'
- implementation 'androidx.appcompat:appcompat:1.4.1'
- implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2'
+ implementation libs.core.ktx
+ implementation libs.kotlinx.coroutines.android
- testImplementation 'junit:junit:4.13.2'
- androidTestImplementation 'androidx.test.ext:junit:1.1.3'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
+ testImplementation libs.junit
+ androidTestImplementation libs.androidx.test.ext.junit
+ androidTestImplementation libs.espresso.core
}
\ No newline at end of file
diff --git a/qrscanner-mlkit/src/main/AndroidManifest.xml b/qrscanner-mlkit/src/main/AndroidManifest.xml
index c9e4fd6..568741e 100644
--- a/qrscanner-mlkit/src/main/AndroidManifest.xml
+++ b/qrscanner-mlkit/src/main/AndroidManifest.xml
@@ -1,5 +1,2 @@
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/qrscanner-zxing/build.gradle b/qrscanner-zxing/build.gradle
index 77f8511..4e48de2 100644
--- a/qrscanner-zxing/build.gradle
+++ b/qrscanner-zxing/build.gradle
@@ -1,15 +1,16 @@
plugins {
- id 'com.android.library'
- id 'org.jetbrains.kotlin.android'
- id 'com.vanniktech.maven.publish' version '0.18.0'
+ alias libs.plugins.android.library
+ alias libs.plugins.kotlinAndroid
+ alias libs.plugins.mavenPublish
}
android {
- compileSdk 31
+ namespace "ch.ubique.qrscanner.zxking"
+ compileSdk 34
defaultConfig {
minSdk 23
- targetSdk 31
+ targetSdk 34
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
@@ -23,24 +24,23 @@ android {
}
compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
+ sourceCompatibility JavaVersion.VERSION_17
+ targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
- jvmTarget = '1.8'
+ jvmTarget = '17'
}
}
dependencies {
api project(':qrscanner-core')
- api 'com.google.zxing:core:3.4.1'
+ api libs.zxing.core
- implementation 'androidx.core:core-ktx:1.7.0'
- implementation 'androidx.appcompat:appcompat:1.4.1'
- implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2'
+ implementation libs.core.ktx
+ implementation libs.kotlinx.coroutines.android
- testImplementation 'junit:junit:4.13.2'
- androidTestImplementation 'androidx.test.ext:junit:1.1.3'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
+ testImplementation libs.junit
+ androidTestImplementation libs.androidx.test.ext.junit
+ androidTestImplementation libs.espresso.core
}
\ No newline at end of file
diff --git a/qrscanner-zxing/src/main/AndroidManifest.xml b/qrscanner-zxing/src/main/AndroidManifest.xml
index 4f71769..568741e 100644
--- a/qrscanner-zxing/src/main/AndroidManifest.xml
+++ b/qrscanner-zxing/src/main/AndroidManifest.xml
@@ -1,5 +1,2 @@
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/renovate.json b/renovate.json
new file mode 100644
index 0000000..81ea0f2
--- /dev/null
+++ b/renovate.json
@@ -0,0 +1,9 @@
+{
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
+ "extends": [
+ "github>UbiqueInnovation/renovate-config-android:base.json5"
+ ],
+ "reviewers": [
+ "M-Wong"
+ ]
+}
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index 06c9a86..c6f5882 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -5,6 +5,7 @@ pluginManagement {
mavenCentral()
}
}
+
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
@@ -12,7 +13,7 @@ dependencyResolutionManagement {
mavenCentral()
}
}
-rootProject.name = "QR Scanner"
+
include ':example'
include ':qrscanner-core'
include ':qrscanner-zxing'