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

Commit

Permalink
Merge branch 'oznecniV97-fix-autofocus' into 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
devtronic committed May 8, 2020
2 parents 58bb4c0 + bcb31de commit 88bd07a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
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

## v3.0.0 - 2020-04-18

Bugfixes:
Expand Down
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)
}
}
}

0 comments on commit 88bd07a

Please sign in to comment.