diff --git a/CHANGELOG.md b/CHANGELOG.md index 628fed3..0883849 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 1.0.3 + +* Bumped Android to 4.0.5 +* Bumped iOS to 2.0.4 +* Added `userCanPickMediaFromStorage` and `shouldGoToReviewScreenOnFinishPressed`. +* Added `brightnessLowerThreshold` and `brightnessUpperThreshold` for iOS. + ## 1.0.2 * Fixed issue where `PreviewDuration` was set incorrectly. diff --git a/README.md b/README.md index 60a0074..b46a755 100644 --- a/README.md +++ b/README.md @@ -201,6 +201,12 @@ config.imageLimit = 10; // Whether the camera automatically saves the images to the camera roll (iOS) / gallery (Android). Default true. config.storeImagesToCameraRol = true; +// Whether to allow users to select media from their device (Shows a media button bottom left on the scanner screen). +config.userCanPickMediaFromStorage = true; + +// Whether the next button in the bottom right of the scanner screen goes to the review screen instead of finishing the session. +config.shouldGoToReviewScreenOnFinishPressed = true; + // What the default color conversion will be (grayscale, original, enhanced). config.defaultColor = DefaultColor.original; @@ -260,6 +266,12 @@ config.isViewFinderEnabled = true; // The threshold sensitive the motion detection is. (lower value is higher sensitivity, default 200). config.imageMovingSensitivityiOS = 200; + +// The lower threshold before the warning message informs the environment is too dark (default 0). +config.brightnessLowerThreshold = 0; + +// The upper threshold before the warning message informs the environment is too bright (default 6). +config.brightnessUpperThreshold = 6; ``` diff --git a/android/build.gradle b/android/build.gradle index 26285fd..f960ccb 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -77,7 +77,7 @@ android { } dependencies { - def fallbackKlippaScannerVersion = "4.0.1" + def fallbackKlippaScannerVersion = "4.0.5" def klippaScannerVersion = project.hasProperty('klippaScannerVersion') ? project.klippaScannerVersion : fallbackKlippaScannerVersion implementation "com.klippa:scanner:$klippaScannerVersion" } diff --git a/android/src/main/kotlin/com/klippa/scanner/klippa_scanner_sdk/KlippaScannerSdkPlugin.kt b/android/src/main/kotlin/com/klippa/scanner/klippa_scanner_sdk/KlippaScannerSdkPlugin.kt index 46daca5..9fbaf70 100644 --- a/android/src/main/kotlin/com/klippa/scanner/klippa_scanner_sdk/KlippaScannerSdkPlugin.kt +++ b/android/src/main/kotlin/com/klippa/scanner/klippa_scanner_sdk/KlippaScannerSdkPlugin.kt @@ -204,6 +204,13 @@ class KlippaScannerSdkPlugin: FlutterPlugin, MethodCallHandler, ActivityAware, P scannerSession.menu.userCanChangeColorSetting = it } + call.argument("UserCanPickMediaFromStorage")?.let { + scannerSession.menu.userCanPickMediaFromStorage = it + } + + call.argument("ShouldGoToReviewScreenOnFinishPressed")?.let { + scannerSession.menu.shouldGoToReviewScreenOnFinishPressed = it + } val modes: MutableList = mutableListOf() @@ -333,7 +340,7 @@ class KlippaScannerSdkPlugin: FlutterPlugin, MethodCallHandler, ActivityAware, P } private fun klippaScannerDidFailWithError(error: KlippaError) { - resultHandler?.error(E_CANCELED, "Scanner was canceled with error: ${error.message()}", null) + resultHandler?.error(E_CANCELED, "Scanner canceled with error: ${error.message()}", null) resultHandler = null } diff --git a/ios/Classes/SwiftKlippaScannerSdkPlugin.swift b/ios/Classes/SwiftKlippaScannerSdkPlugin.swift index 6edf05a..ae744fd 100644 --- a/ios/Classes/SwiftKlippaScannerSdkPlugin.swift +++ b/ios/Classes/SwiftKlippaScannerSdkPlugin.swift @@ -259,6 +259,22 @@ public class SwiftKlippaScannerSdkPlugin: NSObject, FlutterPlugin, KlippaScanner builder.klippaImageAttributes.storeImagesToCameraRoll = storeImagesToCameraRoll } + if let userCanPickMediaFromStorage = builderArgs?["UserCanPickMediaFromStorage"] as? Bool { + builder.klippaMenu.userCanPickMediaFromStorage = userCanPickMediaFromStorage + } + + if let shouldGoToReviewScreenOnFinishPressed = builderArgs?["ShouldGoToReviewScreenOnFinishPressed"] as? Bool { + builder.klippaMenu.shouldGoToReviewScreenOnFinishPressed = shouldGoToReviewScreenOnFinishPressed + } + + if let brightnessLowerThreshold = builderArgs?["BrightnessLowerThreshold"] as? Double { + builder.klippaImageAttributes.brightnessLowerThreshold = brightnessLowerThreshold + } + + if let brightnessUpperThreshold = builderArgs?["BrightnessUpperThreshold"] as? Double { + builder.klippaImageAttributes.brightnessUpperThreshold = brightnessUpperThreshold + } + var modes: [KlippaDocumentMode] = [] if let cameraModeSingle = builderArgs?["CameraModeSingle"] as? Dictionary { @@ -356,13 +372,7 @@ public class SwiftKlippaScannerSdkPlugin: NSObject, FlutterPlugin, KlippaScanner } public func klippaScannerDidFailWithError(error: Error) { - print("didFailWithError"); - switch error { - case let licenseError as KlippaScannerLicenseError: - resultHandler!(FlutterError.init(code: E_MISSING_LICENSE, message: licenseError.localizedDescription, details: nil)) - default: - resultHandler!(FlutterError.init(code: E_MISSING_LICENSE, message: error.localizedDescription, details: nil)) - } + resultHandler?(FlutterError.init(code: E_CANCELED, message: "Scanner canceled with error: \(error.localizedDescription)", details: nil)) resultHandler = nil; } @@ -386,13 +396,12 @@ public class SwiftKlippaScannerSdkPlugin: NSObject, FlutterPlugin, KlippaScanner "SegmentedDocumentModeInstructionsDismissed": segmentedDocumentModeInstructionsDismissed ] as [String : Any] - resultHandler!(resultDict) + resultHandler?(resultDict) resultHandler = nil } public func klippaScannerDidCancel() { - print("imageScannerControllerDidCancel"); - resultHandler!(FlutterError.init(code: E_CANCELED, message: "The user canceled", details: nil)) + resultHandler?(FlutterError.init(code: E_CANCELED, message: "The user canceled", details: nil)) resultHandler = nil; } diff --git a/ios/sdk_version b/ios/sdk_version index e9307ca..2165f8f 100644 --- a/ios/sdk_version +++ b/ios/sdk_version @@ -1 +1 @@ -2.0.2 +2.0.4 diff --git a/lib/klippa_scanner_sdk.dart b/lib/klippa_scanner_sdk.dart index 1a73961..ac083d7 100644 --- a/lib/klippa_scanner_sdk.dart +++ b/lib/klippa_scanner_sdk.dart @@ -151,6 +151,12 @@ class CameraConfig { /// The starting index for which mode will be preselected when starting. num? startingIndex; + /// Whether to allow users to select media from their device (Shows a media button bottom left on the scanner screen). + bool? userCanPickMediaFromStorage; + + /// Whether the next button in the bottom right of the scanner screen goes to the review screen instead of finishing the session. + bool? shouldGoToReviewScreenOnFinishPressed; + /// Android Options /// Where to put the image results @@ -238,6 +244,12 @@ class CameraConfig { /// The threshold sensitive the motion detection is. (lower value is higher sensitivity, default 200). num? imageMovingSensitivityiOS; + + /// The lower threshold before the warning message informs the environment is too dark (default 0). + num? brightnessLowerThreshold; + + /// The upper threshold before the warning message informs the environment is too bright (default 6). + num? brightnessUpperThreshold; } /// A helper to convert flutter Color to a hex ARGB. @@ -373,6 +385,16 @@ class KlippaScannerSdk { config.userCanChangeColorSetting; } + if (config.userCanPickMediaFromStorage != null) { + parameters["UserCanPickMediaFromStorage"] = + config.userCanPickMediaFromStorage; + } + + if (config.shouldGoToReviewScreenOnFinishPressed != null) { + parameters["ShouldGoToReviewScreenOnFinishPressed"] = + config.shouldGoToReviewScreenOnFinishPressed; + } + /// Android only if (config.storagePath != null) { @@ -523,6 +545,14 @@ class KlippaScannerSdk { config.imageMovingSensitivityiOS; } + if (config.brightnessLowerThreshold != null) { + parameters["BrightnessLowerThreshold"] = config.brightnessLowerThreshold; + } + + if (config.brightnessUpperThreshold != null) { + parameters["BrightnessUpperThreshold"] = config.brightnessUpperThreshold; + } + final Map startSessionResult = await _channel.invokeMethod('startSession', parameters); return startSessionResult; diff --git a/pubspec.yaml b/pubspec.yaml index 872cddd..201454f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: klippa_scanner_sdk description: Allows you to do document scanning with the Klippa Scanner SDK from Flutter apps. -version: 1.0.2 +version: 1.0.3 homepage: https://github.com/klippa-app/flutter-klippa-scanner-sdk environment: