From c08ffc57a02da2b1ce26864a4eca23b5236f6f2b Mon Sep 17 00:00:00 2001 From: Julian Finkler Date: Fri, 8 May 2020 19:08:01 +0200 Subject: [PATCH 1/3] 3.0.1 (#237) * feat: added cancel for ux (#198) * feat: added cancel for ux * re(feat): apply cancel functionality to merged * fix: return true * fix(syntax): flashButton and cancelButton * fix: syntax * Changelog updated * add fix for autofocus with logging * add comment and remove log for merge on master project * Update the 3.x branch (#229) * Update issue templates * Update UPGRADE.md * Fix camera selection in Android. * CHANGELOG updated * Release prepared Co-authored-by: Ivan Ray Altomera Co-authored-by: Vincenzo Co-authored-by: GabrieleVolpato <6254043+GabrieleVolpato@users.noreply.github.com> --- CHANGELOG.md | 9 ++++++++ .../barcode_scan/BarcodeScannerActivity.kt | 22 +++++++++++++++---- .../barcode_scan/ZXingAutofocusScannerView.kt | 7 +++++- pubspec.yaml | 2 +- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d486458a..b45f95ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## v3.0.1 - 2020-05-08 + +Features: +- [Added cancel for ux](https://github.com/mintware-de/flutter_barcode_reader/pull/198) - @iRaySpace + +Bugfixes: +- [Fix autofocus crash](https://github.com/mintware-de/flutter_barcode_reader/pull/228) - @oznecniV97 +- [Fix camera selection in Android](https://github.com/mintware-de/flutter_barcode_reader/pull/231) - @GabrieleVolpato + ## v3.0.0 - 2020-04-18 Bugfixes: diff --git a/android/src/main/kotlin/de/mintware/barcode_scan/BarcodeScannerActivity.kt b/android/src/main/kotlin/de/mintware/barcode_scan/BarcodeScannerActivity.kt index 1797de20..7e27ebe3 100644 --- a/android/src/main/kotlin/de/mintware/barcode_scan/BarcodeScannerActivity.kt +++ b/android/src/main/kotlin/de/mintware/barcode_scan/BarcodeScannerActivity.kt @@ -20,6 +20,7 @@ class BarcodeScannerActivity : Activity(), ZXingScannerView.ResultHandler { companion object { const val TOGGLE_FLASH = 200 + const val CANCEL = 300 const val EXTRA_CONFIG = "config" const val EXTRA_RESULT = "scan_result" const val EXTRA_ERROR_CODE = "error_code" @@ -76,8 +77,12 @@ class BarcodeScannerActivity : Activity(), ZXingScannerView.ResultHandler { if (scannerView?.flash == true) { buttonText = config.stringsMap["flash_off"] } - val item = menu.add(0, TOGGLE_FLASH, 0, buttonText) - item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS) + val flashButton = menu.add(0, TOGGLE_FLASH, 0, buttonText) + flashButton.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS) + + val cancelButton = menu.add(0, CANCEL, 0, config.stringsMap["cancel"]) + cancelButton.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS) + return super.onCreateOptionsMenu(menu) } @@ -87,6 +92,11 @@ class BarcodeScannerActivity : Activity(), ZXingScannerView.ResultHandler { this.invalidateOptionsMenu() return true } + if (item.itemId == CANCEL) { + setResult(RESULT_CANCELED) + finish() + return true + } return super.onOptionsItemSelected(item) } @@ -99,7 +109,11 @@ class BarcodeScannerActivity : Activity(), ZXingScannerView.ResultHandler { super.onResume() setupScannerView() scannerView?.setResultHandler(this) - scannerView?.startCamera() + if (config.useCamera > -1) { + scannerView?.startCamera(config.useCamera) + } else { + scannerView?.startCamera() + } } // endregion @@ -151,4 +165,4 @@ class BarcodeScannerActivity : Activity(), ZXingScannerView.ResultHandler { return types } -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/de/mintware/barcode_scan/ZXingAutofocusScannerView.kt b/android/src/main/kotlin/de/mintware/barcode_scan/ZXingAutofocusScannerView.kt index b12c0c9b..8b68fe55 100644 --- a/android/src/main/kotlin/de/mintware/barcode_scan/ZXingAutofocusScannerView.kt +++ b/android/src/main/kotlin/de/mintware/barcode_scan/ZXingAutofocusScannerView.kt @@ -9,10 +9,12 @@ import me.dm7.barcodescanner.zxing.ZXingScannerView class ZXingAutofocusScannerView(context: Context) : ZXingScannerView(context) { private var callbackFocus = false + private var autofocusPresence = false override fun setupCameraPreview(cameraWrapper: CameraWrapper?) { cameraWrapper?.mCamera?.parameters?.let { parameters -> try { + autofocusPresence = parameters.supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO); parameters.focusMode = Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE cameraWrapper.mCamera.parameters = parameters } catch (ex: Exception) { @@ -23,6 +25,9 @@ class ZXingAutofocusScannerView(context: Context) : ZXingScannerView(context) { } override fun setAutoFocus(state: Boolean) { - super.setAutoFocus(callbackFocus) + //Fix to avoid crash on devices without autofocus (Issue #226) + if(autofocusPresence){ + super.setAutoFocus(callbackFocus) + } } } \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 593d657a..f25b22f8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: barcode_scan description: A flutter plugin for scanning 2D barcodes and QRCodes via camera. -version: 3.0.0 +version: 3.0.1 homepage: https://github.com/mintware-de/flutter_barcode_reader dependencies: From 08eda5400d5576508959310fc4f1003fbb3ae320 Mon Sep 17 00:00:00 2001 From: Julian Finkler Date: Sat, 9 May 2020 08:51:52 +0200 Subject: [PATCH 2/3] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 096f8c4f..b403ad87 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,6 +7,9 @@ assignees: '' --- +**BUG REPORTS WITHOUT PROVIDING THESE INFORMATIONS WILL BE CLOSED DIRECTLY. DON'T REMOVE THE SECTIONS!** + + **Describe the bug** A clear and concise description of what the bug is. From bf7a8e04cbcb00ca6d07db3e2275f842c26622a7 Mon Sep 17 00:00:00 2001 From: Muzammil Bilwani Date: Fri, 14 Aug 2020 17:50:21 +0500 Subject: [PATCH 3/3] Scan Options Descriptions correction. (#270) --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index efd367a5..4b076fd7 100644 --- a/README.md +++ b/README.md @@ -121,8 +121,8 @@ void main() async { | `restrictFormat` | `BarcodeFormat[]` | Restrict the formats which are recognized | iOS + Android | | `useCamera` | `int` | The index of the camera which is used for scanning (See `BarcodeScanner.numberOfCameras`) | iOS + Android | | `autoEnableFlash` | `bool` | Enable the flash when start scanning | iOS + Android | -| `android.aspectTolerance` | `double` | Enable the flash when start scanning | Android only | -| `android.useAutoFocus` | `bool` | Enable the flash when start scanning | Android only | +| `android.aspectTolerance` | `double` | Enable auto focus on Android | Android only | +| `android.useAutoFocus` | `bool` | Set aspect ratio tolerance level used in calculating the optimal Camera preview size | Android only | ## Development setup @@ -151,4 +151,4 @@ If you changed the protos.proto you've to execute the ./generate_proto.sh to upd ## Common problems ### Android "Could not find org.jetbrains.kotlin:kotlin-stdlib-jre..." Change `org.jetbrains.kotlin:kotlin-stdlib-jre` to `org.jetbrains.kotlin:kotlin-stdlib-jdk` -([StackOverflow](https://stackoverflow.com/a/53358817)) \ No newline at end of file +([StackOverflow](https://stackoverflow.com/a/53358817))