From a049a26911fb7854d6bf27603322272767f1db3b Mon Sep 17 00:00:00 2001 From: Joshua Hoogstraat <34964599+jhoogstraat@users.noreply.github.com> Date: Sat, 23 Oct 2021 11:04:06 +0200 Subject: [PATCH] Fix pauseDetector on iOS --- fast_barcode_scanner/CHANGELOG.md | 5 +++++ fast_barcode_scanner/android/build.gradle | 4 ++-- .../example/android/app/build.gradle | 4 ++-- .../ios/Classes/BarcodeReader.swift | 16 ++++++++++------ .../ios/Classes/FastBarcodeScannerPlugin.swift | 2 +- fast_barcode_scanner/pubspec.yaml | 2 +- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/fast_barcode_scanner/CHANGELOG.md b/fast_barcode_scanner/CHANGELOG.md index a99f577b..4c3eab80 100644 --- a/fast_barcode_scanner/CHANGELOG.md +++ b/fast_barcode_scanner/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.1.4 + +- Fixes `pauseDetector` on iOS +- Updates CameraX (compileSdk is now 31) + ## 1.1.3 - Remove references to FlutterActivity (required by local_auth package) diff --git a/fast_barcode_scanner/android/build.gradle b/fast_barcode_scanner/android/build.gradle index 893b0f6b..fe22c3a9 100644 --- a/fast_barcode_scanner/android/build.gradle +++ b/fast_barcode_scanner/android/build.gradle @@ -25,7 +25,7 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 30 + compileSdkVersion 31 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -53,7 +53,7 @@ android { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - def camerax_version = "1.1.0-alpha08" + def camerax_version = "1.1.0-alpha10" def mlkit_version = "17.0.0" implementation "androidx.camera:camera-camera2:$camerax_version" implementation "androidx.camera:camera-lifecycle:$camerax_version" diff --git a/fast_barcode_scanner/example/android/app/build.gradle b/fast_barcode_scanner/example/android/app/build.gradle index ab5f3866..ac3e9106 100644 --- a/fast_barcode_scanner/example/android/app/build.gradle +++ b/fast_barcode_scanner/example/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 30 + compileSdkVersion 31 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -35,7 +35,7 @@ android { defaultConfig { applicationId "com.jhoogstraat.fast_barcode_scanner_example" minSdkVersion 21 - targetSdkVersion 30 + targetSdkVersion 31 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/fast_barcode_scanner/ios/Classes/BarcodeReader.swift b/fast_barcode_scanner/ios/Classes/BarcodeReader.swift index 0494307a..b1c2a333 100644 --- a/fast_barcode_scanner/ios/Classes/BarcodeReader.swift +++ b/fast_barcode_scanner/ios/Classes/BarcodeReader.swift @@ -208,13 +208,17 @@ class BarcodeReader: NSObject { return captureDevice.isTorchActive } - func pauseIfRequired() { - switch detectionMode { - case .continuous: return - case .pauseDetection: - captureSession.removeOutput(metadataOutput) - case .pauseVideo: + func pauseIfRequired(force: Bool = false) { + if force { stop(pause: true) + } else { + switch detectionMode { + case .continuous: return + case .pauseDetection: + captureSession.removeOutput(metadataOutput) + case .pauseVideo: + stop(pause: true) + } } } diff --git a/fast_barcode_scanner/ios/Classes/FastBarcodeScannerPlugin.swift b/fast_barcode_scanner/ios/Classes/FastBarcodeScannerPlugin.swift index b23edc04..83e6ceb8 100644 --- a/fast_barcode_scanner/ios/Classes/FastBarcodeScannerPlugin.swift +++ b/fast_barcode_scanner/ios/Classes/FastBarcodeScannerPlugin.swift @@ -118,7 +118,7 @@ public class FastBarcodeScannerPlugin: NSObject, FlutterPlugin { } func pause(result: @escaping FlutterResult) { - reader?.pauseIfRequired() + reader?.pauseIfRequired(force: true) result(nil) } diff --git a/fast_barcode_scanner/pubspec.yaml b/fast_barcode_scanner/pubspec.yaml index 77ffa46a..6b36b701 100644 --- a/fast_barcode_scanner/pubspec.yaml +++ b/fast_barcode_scanner/pubspec.yaml @@ -16,7 +16,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^1.0.3 + flutter_lints: ^1.0.4 flutter: plugin: