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

Update 3.x with master #286

Merged
merged 3 commits into from
Sep 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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))
([StackOverflow](https://stackoverflow.com/a/53358817))
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