From cc12c103e0f1f9f37da5aea59224a2e88e32141c Mon Sep 17 00:00:00 2001 From: Ralf Kistner Date: Mon, 25 Oct 2021 15:22:01 +0200 Subject: [PATCH] v4.3.0 and cleanup. --- CHANGES.md | 14 +++++++++ README.md | 46 +++++++++++------------------ build.gradle | 2 +- zxing-android-embedded/build.gradle | 1 + 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 7e2d4370f..9ce2ea8c9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,17 @@ +### 4.3.0 (2021-10-25) + +* Minimum SDK version 19, but requires additional config (see readme) for < 24 compatibility. +* Add ScanOptions and ScanContract for use with `registerForActivityResult()`. +* Deprecates IntentIntegrator. +* Use minimal AndroidX libraries. + +### 4.2.0 (2021-03-15) + +* Fix MediaPlayer warnings (#587). +* Prevent CameraConfigurationUtils clash (#609). +* Add licenses to POM (#556). +* Bug: Crashes on SDK versions older than 21 (#645). + ### 4.1.0 (2020-01-07) * Ability to hide the laser in ViewfinderView (#503). diff --git a/README.md b/README.md index f8a2030cb..e6d8b145c 100644 --- a/README.md +++ b/README.md @@ -27,13 +27,8 @@ repositories { } dependencies { - implementation 'com.journeyapps:zxing-android-embedded:4.2.0' + implementation 'com.journeyapps:zxing-android-embedded:4.3.0' } - -android { - buildToolsVersion '28.0.3' // Older versions may give compile errors -} - ``` ## Older SDK versions @@ -51,16 +46,12 @@ repositories { } dependencies { - implementation('com.journeyapps:zxing-android-embedded:4.2.0') { transitive = false } + implementation('com.journeyapps:zxing-android-embedded:4.3.0') { transitive = false } implementation 'com.google.zxing:core:3.3.0' } - -android { - buildToolsVersion '28.0.3' -} ``` -### Option 2: Desugaring +### Option 2: Desugaring (Advanced) This option does not require changing library versions, but may complicate the build process. @@ -108,23 +99,20 @@ See for details: https://developer.android.com/training/basics/intents/result `startActivityForResult` can still be used via `IntentIntegrator`, but that is not recommended anymore. ```java - // Note: startActivityForResult is deprecated, so this example uses registerForActivityResult instead. - // See for details: https://developer.android.com/training/basics/intents/result - - // Register the launcher and result handler - private final ActivityResultLauncher barcodeLauncher = registerForActivityResult(new ScanContract(), - result -> { - if(result.getContents() == null) { - Toast.makeText(MyActivity.this, "Cancelled", Toast.LENGTH_LONG).show(); - } else { - Toast.makeText(MyActivity.this, "Scanned: " + result.getContents(), Toast.LENGTH_LONG).show(); - } - }); - - // Launch - public void onButtonClick(View view) { - barcodeLauncher.launch(new ScanOptions()); - } +// Register the launcher and result handler +private final ActivityResultLauncher barcodeLauncher = registerForActivityResult(new ScanContract(), + result -> { + if(result.getContents() == null) { + Toast.makeText(MyActivity.this, "Cancelled", Toast.LENGTH_LONG).show(); + } else { + Toast.makeText(MyActivity.this, "Scanned: " + result.getContents(), Toast.LENGTH_LONG).show(); + } + }); + +// Launch +public void onButtonClick(View view) { + barcodeLauncher.launch(new ScanOptions()); +} ``` Customize options: diff --git a/build.gradle b/build.gradle index b33070f45..2f030a799 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ subprojects { mavenCentral() } - version = '4.2.0' + version = '4.3.0' group = 'com.journeyapps' ext.androidTargetSdk = 30 diff --git a/zxing-android-embedded/build.gradle b/zxing-android-embedded/build.gradle index 2e957711b..b54e03801 100644 --- a/zxing-android-embedded/build.gradle +++ b/zxing-android-embedded/build.gradle @@ -70,6 +70,7 @@ android { // We test with primitives such as Rect, and rely on their default behaviour working. unitTests.returnDefaultValues = true } + defaultConfig { minSdkVersion 19 }