Skip to content

Commit

Permalink
Merge pull request #27 from klippa-app/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
RobinFarmer authored Dec 3, 2024
2 parents a8f639c + 0954e65 commit 4cfaac4
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 14 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
```


Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ class KlippaScannerSdkPlugin: FlutterPlugin, MethodCallHandler, ActivityAware, P
scannerSession.menu.userCanChangeColorSetting = it
}

call.argument<Boolean>("UserCanPickMediaFromStorage")?.let {
scannerSession.menu.userCanPickMediaFromStorage = it
}

call.argument<Boolean>("ShouldGoToReviewScreenOnFinishPressed")?.let {
scannerSession.menu.shouldGoToReviewScreenOnFinishPressed = it
}

val modes: MutableList<KlippaDocumentMode> = mutableListOf()

Expand Down Expand Up @@ -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
}

Expand Down
29 changes: 19 additions & 10 deletions ios/Classes/SwiftKlippaScannerSdkPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String?> {
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion ios/sdk_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.2
2.0.4
30 changes: 30 additions & 0 deletions lib/klippa_scanner_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 4cfaac4

Please sign in to comment.