Skip to content

Commit 4cfaac4

Browse files
authored
Merge pull request #27 from klippa-app/development
Development
2 parents a8f639c + 0954e65 commit 4cfaac4

File tree

8 files changed

+79
-14
lines changed

8 files changed

+79
-14
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 1.0.3
2+
3+
* Bumped Android to 4.0.5
4+
* Bumped iOS to 2.0.4
5+
* Added `userCanPickMediaFromStorage` and `shouldGoToReviewScreenOnFinishPressed`.
6+
* Added `brightnessLowerThreshold` and `brightnessUpperThreshold` for iOS.
7+
18
## 1.0.2
29

310
* Fixed issue where `PreviewDuration` was set incorrectly.

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ config.imageLimit = 10;
201201
// Whether the camera automatically saves the images to the camera roll (iOS) / gallery (Android). Default true.
202202
config.storeImagesToCameraRol = true;
203203
204+
// Whether to allow users to select media from their device (Shows a media button bottom left on the scanner screen).
205+
config.userCanPickMediaFromStorage = true;
206+
207+
// Whether the next button in the bottom right of the scanner screen goes to the review screen instead of finishing the session.
208+
config.shouldGoToReviewScreenOnFinishPressed = true;
209+
204210
// What the default color conversion will be (grayscale, original, enhanced).
205211
config.defaultColor = DefaultColor.original;
206212
@@ -260,6 +266,12 @@ config.isViewFinderEnabled = true;
260266
261267
// The threshold sensitive the motion detection is. (lower value is higher sensitivity, default 200).
262268
config.imageMovingSensitivityiOS = 200;
269+
270+
// The lower threshold before the warning message informs the environment is too dark (default 0).
271+
config.brightnessLowerThreshold = 0;
272+
273+
// The upper threshold before the warning message informs the environment is too bright (default 6).
274+
config.brightnessUpperThreshold = 6;
263275
```
264276

265277

android/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ android {
7777
}
7878

7979
dependencies {
80-
def fallbackKlippaScannerVersion = "4.0.1"
80+
def fallbackKlippaScannerVersion = "4.0.5"
8181
def klippaScannerVersion = project.hasProperty('klippaScannerVersion') ? project.klippaScannerVersion : fallbackKlippaScannerVersion
8282
implementation "com.klippa:scanner:$klippaScannerVersion"
8383
}

android/src/main/kotlin/com/klippa/scanner/klippa_scanner_sdk/KlippaScannerSdkPlugin.kt

+8-1
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,13 @@ class KlippaScannerSdkPlugin: FlutterPlugin, MethodCallHandler, ActivityAware, P
204204
scannerSession.menu.userCanChangeColorSetting = it
205205
}
206206

207+
call.argument<Boolean>("UserCanPickMediaFromStorage")?.let {
208+
scannerSession.menu.userCanPickMediaFromStorage = it
209+
}
210+
211+
call.argument<Boolean>("ShouldGoToReviewScreenOnFinishPressed")?.let {
212+
scannerSession.menu.shouldGoToReviewScreenOnFinishPressed = it
213+
}
207214

208215
val modes: MutableList<KlippaDocumentMode> = mutableListOf()
209216

@@ -333,7 +340,7 @@ class KlippaScannerSdkPlugin: FlutterPlugin, MethodCallHandler, ActivityAware, P
333340
}
334341

335342
private fun klippaScannerDidFailWithError(error: KlippaError) {
336-
resultHandler?.error(E_CANCELED, "Scanner was canceled with error: ${error.message()}", null)
343+
resultHandler?.error(E_CANCELED, "Scanner canceled with error: ${error.message()}", null)
337344
resultHandler = null
338345
}
339346

ios/Classes/SwiftKlippaScannerSdkPlugin.swift

+19-10
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,22 @@ public class SwiftKlippaScannerSdkPlugin: NSObject, FlutterPlugin, KlippaScanner
259259
builder.klippaImageAttributes.storeImagesToCameraRoll = storeImagesToCameraRoll
260260
}
261261

262+
if let userCanPickMediaFromStorage = builderArgs?["UserCanPickMediaFromStorage"] as? Bool {
263+
builder.klippaMenu.userCanPickMediaFromStorage = userCanPickMediaFromStorage
264+
}
265+
266+
if let shouldGoToReviewScreenOnFinishPressed = builderArgs?["ShouldGoToReviewScreenOnFinishPressed"] as? Bool {
267+
builder.klippaMenu.shouldGoToReviewScreenOnFinishPressed = shouldGoToReviewScreenOnFinishPressed
268+
}
269+
270+
if let brightnessLowerThreshold = builderArgs?["BrightnessLowerThreshold"] as? Double {
271+
builder.klippaImageAttributes.brightnessLowerThreshold = brightnessLowerThreshold
272+
}
273+
274+
if let brightnessUpperThreshold = builderArgs?["BrightnessUpperThreshold"] as? Double {
275+
builder.klippaImageAttributes.brightnessUpperThreshold = brightnessUpperThreshold
276+
}
277+
262278
var modes: [KlippaDocumentMode] = []
263279

264280
if let cameraModeSingle = builderArgs?["CameraModeSingle"] as? Dictionary<String, String?> {
@@ -356,13 +372,7 @@ public class SwiftKlippaScannerSdkPlugin: NSObject, FlutterPlugin, KlippaScanner
356372
}
357373

358374
public func klippaScannerDidFailWithError(error: Error) {
359-
print("didFailWithError");
360-
switch error {
361-
case let licenseError as KlippaScannerLicenseError:
362-
resultHandler!(FlutterError.init(code: E_MISSING_LICENSE, message: licenseError.localizedDescription, details: nil))
363-
default:
364-
resultHandler!(FlutterError.init(code: E_MISSING_LICENSE, message: error.localizedDescription, details: nil))
365-
}
375+
resultHandler?(FlutterError.init(code: E_CANCELED, message: "Scanner canceled with error: \(error.localizedDescription)", details: nil))
366376
resultHandler = nil;
367377
}
368378

@@ -386,13 +396,12 @@ public class SwiftKlippaScannerSdkPlugin: NSObject, FlutterPlugin, KlippaScanner
386396
"SegmentedDocumentModeInstructionsDismissed": segmentedDocumentModeInstructionsDismissed
387397
] as [String : Any]
388398

389-
resultHandler!(resultDict)
399+
resultHandler?(resultDict)
390400
resultHandler = nil
391401
}
392402

393403
public func klippaScannerDidCancel() {
394-
print("imageScannerControllerDidCancel");
395-
resultHandler!(FlutterError.init(code: E_CANCELED, message: "The user canceled", details: nil))
404+
resultHandler?(FlutterError.init(code: E_CANCELED, message: "The user canceled", details: nil))
396405
resultHandler = nil;
397406
}
398407

ios/sdk_version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.2
1+
2.0.4

lib/klippa_scanner_sdk.dart

+30
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ class CameraConfig {
151151
/// The starting index for which mode will be preselected when starting.
152152
num? startingIndex;
153153

154+
/// Whether to allow users to select media from their device (Shows a media button bottom left on the scanner screen).
155+
bool? userCanPickMediaFromStorage;
156+
157+
/// Whether the next button in the bottom right of the scanner screen goes to the review screen instead of finishing the session.
158+
bool? shouldGoToReviewScreenOnFinishPressed;
159+
154160
/// Android Options
155161
156162
/// Where to put the image results
@@ -238,6 +244,12 @@ class CameraConfig {
238244

239245
/// The threshold sensitive the motion detection is. (lower value is higher sensitivity, default 200).
240246
num? imageMovingSensitivityiOS;
247+
248+
/// The lower threshold before the warning message informs the environment is too dark (default 0).
249+
num? brightnessLowerThreshold;
250+
251+
/// The upper threshold before the warning message informs the environment is too bright (default 6).
252+
num? brightnessUpperThreshold;
241253
}
242254

243255
/// A helper to convert flutter Color to a hex ARGB.
@@ -373,6 +385,16 @@ class KlippaScannerSdk {
373385
config.userCanChangeColorSetting;
374386
}
375387

388+
if (config.userCanPickMediaFromStorage != null) {
389+
parameters["UserCanPickMediaFromStorage"] =
390+
config.userCanPickMediaFromStorage;
391+
}
392+
393+
if (config.shouldGoToReviewScreenOnFinishPressed != null) {
394+
parameters["ShouldGoToReviewScreenOnFinishPressed"] =
395+
config.shouldGoToReviewScreenOnFinishPressed;
396+
}
397+
376398
/// Android only
377399
378400
if (config.storagePath != null) {
@@ -523,6 +545,14 @@ class KlippaScannerSdk {
523545
config.imageMovingSensitivityiOS;
524546
}
525547

548+
if (config.brightnessLowerThreshold != null) {
549+
parameters["BrightnessLowerThreshold"] = config.brightnessLowerThreshold;
550+
}
551+
552+
if (config.brightnessUpperThreshold != null) {
553+
parameters["BrightnessUpperThreshold"] = config.brightnessUpperThreshold;
554+
}
555+
526556
final Map startSessionResult =
527557
await _channel.invokeMethod('startSession', parameters);
528558
return startSessionResult;

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: klippa_scanner_sdk
22
description: Allows you to do document scanning with the Klippa Scanner SDK from Flutter apps.
3-
version: 1.0.2
3+
version: 1.0.3
44
homepage: https://github.com/klippa-app/flutter-klippa-scanner-sdk
55

66
environment:

0 commit comments

Comments
 (0)