Skip to content
This repository has been archived by the owner on Oct 10, 2020. It is now read-only.

Commit

Permalink
3.0.1 (#237)
Browse files Browse the repository at this point in the history
* 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 <iRaySpace@users.noreply.github.com>
Co-authored-by: Vincenzo <vincenzo.salerno@live.it>
Co-authored-by: GabrieleVolpato <6254043+GabrieleVolpato@users.noreply.github.com>
  • Loading branch information
4 people committed May 8, 2020
1 parent a293425 commit c08ffc5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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

Expand Down Expand Up @@ -151,4 +165,4 @@ class BarcodeScannerActivity : Activity(), ZXingScannerView.ResultHandler {

return types
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
}
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit c08ffc5

Please sign in to comment.