Skip to content
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
14 changes: 8 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ jobs:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
- uses: actions/setup-java@v4
with:
java-version: '21.x'
distribution: 'temurin'
java-version: '21'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.24.3'
flutter-version: '3.35.6'
- run: dart --version
- run: flutter --version
- run: flutter pub get
Expand All @@ -44,12 +45,13 @@ jobs:
os: [macos-15]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
- uses: actions/setup-java@v4
with:
java-version: '21.x'
distribution: 'temurin'
java-version: '21'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.24.3'
flutter-version: '3.35.6'
- run: dart --version
- run: flutter --version
- run: flutter pub get
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 1.3.0

* Bumped Android to 4.4.0
* Bumped iOS to 2.3.0
* Added `userCanChangeDPI` and `userCanChangePageSize` to control visibility of DPI and page-size buttons in the per-image edit menu (both platforms).
* Added `editMenuButtonText`, `dpiEditButtonText`, `pageSizeEditButtonText`, `doneButtonText`, and `undoCropButtonText` for localizing the edit mode and crop screen controls (iOS only).
* Each image in the result now includes `DetectedTexts`, a list of detected text strings with bounding box positions. Populated when `performOnDeviceOCR` is `true`.
* `DPI.auto` (the default) now outputs images at native camera resolution regardless of `pageFormat` on both platforms.
* Deprecated `deleteOptionsButtonText` — will be removed in a future version.
* Minimum iOS version bumped to 15.

## 1.2.0

* Bumped Android to 4.3.0
Expand Down
59 changes: 46 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ config.userCanCropManually = false;
// Whether to hide or show the color changing button in the Review Screen. (default shown/true)
config.userCanChangeColorSetting = false;

// Whether to show the DPI button in the edit menu. (default false)
config.userCanChangeDPI = false;

// Whether to show the Page Size button in the edit menu. (default false)
config.userCanChangePageSize = false;

// To add extra horizontal and / or vertical padding to the cropped image.
config.cropPadding.width = 100;
config.cropPadding.height = 100;
Expand Down Expand Up @@ -264,19 +270,6 @@ config.imageMovingSensitivityAndroid = 50;

#### iOS only
```dart

// The text inside of the color selection alert dialog button named original.
config.imageColorOriginalText = "original";

// The text inside of the color selection alert dialog button named grayscale.
config.imageColorGrayscaleText = "grayscale";

// The text inside of the color selection alert dialog button named enhanced.
config.imageColorEnhancedText = "enhanced";

// The text inside of the color selection alert dialog button named black and white.
config.imageColorBlackAndWhiteText = "Black & White";

// Whether the camera has a view finder overlay (a helper grid so the user knows where the document should be), should be a Boolean.
config.isViewFinderEnabled = true;

Expand Down Expand Up @@ -310,6 +303,10 @@ Add or edit the file `android/app/src/res/values/colors.xml`, add the following:
<color name="klippa_scanner_sdk_color_button_with_icon_background">#444444</color>
<color name="klippa_scanner_sdk_color_primary_action_foreground">#ffffff</color>
<color name="klippa_scanner_sdk_color_primary_action_background">#2dc36a</color>
<color name="klippa_scanner_sdk_color_dialog_background">#ffffff</color>
<color name="klippa_scanner_sdk_color_dialog_text">#000000</color>
<color name="klippa_scanner_sdk_color_dialog_confirm_button">#d32f2f</color>
<color name="klippa_scanner_sdk_color_dialog_dismiss_button">#1976d2</color>
</resources>
```

Expand Down Expand Up @@ -436,6 +433,42 @@ config.continueButtonText = "Continue"

// The text shown in the crop screen to save the bounding box.
config.saveCropButtonText = "Save"

// The text inside of the color selection alert dialog button named original.
config.imageColorOriginalText = "original";

// The text inside of the color selection alert dialog button named grayscale.
config.imageColorGrayscaleText = "grayscale";

// The text inside of the color selection alert dialog button named enhanced.
config.imageColorEnhancedText = "enhanced";

// The text inside of the color selection alert dialog button named black and white.
config.imageColorBlackAndWhiteText = "Black & White";

// The text above the shutter button to indicate auto capture status.
config.autoCaptureButtonText = "Auto";

// The text above the shutter button to indicate auto capture status.
config.manualButtonText = "Manual";

// The title in the delete action alert dialog. (Deprecated: will be removed in a future version)
config.deleteOptionsButtonText = "Delete or Retake?";

// The text on the edit button in the review screen.
config.editMenuButtonText = "Edit";

// The text on the DPI button inside the edit menu.
config.dpiEditButtonText = "DPI";

// The text on the Page Size button inside the edit menu.
config.pageSizeEditButtonText = "Page Size";

// The text on the done button inside the edit menu.
config.doneButtonText = "Done";

// The text on the undo button in the crop screen.
config.undoCropButtonText = "Undo";
```

### Customize image in CameraMode instructions
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.3.0"
def fallbackKlippaScannerVersion = "4.4.0"
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 @@ -289,6 +289,14 @@ class KlippaScannerSdkPlugin: FlutterPlugin, MethodCallHandler, ActivityAware, P
scannerSession.menu.userCanChangeColorSetting = it
}

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

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

call.argument<Boolean>("UserCanPickMediaFromStorage")?.let {
scannerSession.menu.userCanPickMediaFromStorage = it
}
Expand Down Expand Up @@ -401,10 +409,20 @@ class KlippaScannerSdkPlugin: FlutterPlugin, MethodCallHandler, ActivityAware, P
}

private fun klippaScannerDidFinishScanningWithResult(result: KlippaScannerResult) {
val images: MutableList<Map<String, String>> = mutableListOf()
val images: MutableList<Map<String, Any>> = mutableListOf()

for (image in result.results) {
val imageDict = mapOf("Filepath" to image.location)
val detectedTexts: MutableList<Map<String, Any>> = mutableListOf()
for (detectedText in image.detectedTexts) {
val boundingBox = mapOf(
"x" to detectedText.boundingBox.x.toDouble(),
"y" to detectedText.boundingBox.y.toDouble(),
"width" to detectedText.boundingBox.width.toDouble(),
"height" to detectedText.boundingBox.height.toDouble()
)
detectedTexts.add(mapOf("Text" to detectedText.text, "BoundingBox" to boundingBox))
}
val imageDict = mapOf("Filepath" to image.location, "DetectedTexts" to detectedTexts)
images.add(imageDict)
}

Expand Down
4 changes: 2 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (flutterVersionName == null) {

android {
namespace "com.klippa.scanner.klippa_scanner_sdk_example"
compileSdk 35
compileSdk 36

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -46,7 +46,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.klippa.scanner.examplekotlin"
minSdkVersion 25
targetSdkVersion 35
targetSdkVersion 36
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Oct 11 10:23:14 CEST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions example/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.6.1" apply false
id "org.jetbrains.kotlin.android" version "2.0.20" apply false
id "com.android.application" version "8.12.3" apply false
id "org.jetbrains.kotlin.android" version "2.3.0" apply false
}

include ":app"
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
platform :ios, '14.0'
platform :ios, '15.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
12 changes: 6 additions & 6 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand All @@ -379,7 +379,7 @@
DEVELOPMENT_TEAM = 7ZXKJ433J8;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -439,7 +439,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -488,7 +488,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand All @@ -509,7 +509,7 @@
DEVELOPMENT_TEAM = 7ZXKJ433J8;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -533,7 +533,7 @@
DEVELOPMENT_TEAM = 7ZXKJ433J8;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
54 changes: 52 additions & 2 deletions ios/Classes/SwiftKlippaScannerSdkPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,38 @@ public class SwiftKlippaScannerSdkPlugin: NSObject, FlutterPlugin, KlippaScanner
builder.klippaButtonTexts.imageColorBlackAndWhiteText = imageColorBlackAndWhiteText
}

if let autoCaptureButtonText = builderArgs?["AutoCaptureButtonText"] as? String {
builder.klippaButtonTexts.autoCaptureButtonText = autoCaptureButtonText
}

if let manualButtonText = builderArgs?["ManualButtonText"] as? String {
builder.klippaButtonTexts.manualButtonText = manualButtonText
}

if let deleteOptionsButtonText = builderArgs?["DeleteOptionsButtonText"] as? String {
builder.klippaButtonTexts.deleteOptionsButtonText = deleteOptionsButtonText
}

if let editMenuButtonText = builderArgs?["EditMenuButtonText"] as? String {
builder.klippaButtonTexts.editMenuButtonText = editMenuButtonText
}

if let dpiEditButtonText = builderArgs?["DpiEditButtonText"] as? String {
builder.klippaButtonTexts.dpiEditButtonText = dpiEditButtonText
}

if let pageSizeEditButtonText = builderArgs?["PageSizeEditButtonText"] as? String {
builder.klippaButtonTexts.pageSizeEditButtonText = pageSizeEditButtonText
}

if let doneButtonText = builderArgs?["DoneButtonText"] as? String {
builder.klippaButtonTexts.doneButtonText = doneButtonText
}

if let undoCropButtonText = builderArgs?["UndoCropButtonText"] as? String {
builder.klippaButtonTexts.undoCropButtonText = undoCropButtonText
}

if let cancelConfirmationMessage = builderArgs?["CancelConfirmationMessage"] as? String {
builder.klippaMessages.cancelConfirmationMessage = cancelConfirmationMessage
}
Expand Down Expand Up @@ -229,6 +261,14 @@ public class SwiftKlippaScannerSdkPlugin: NSObject, FlutterPlugin, KlippaScanner
builder.klippaMenu.userCanChangeColorSetting = userCanChangeColorSetting
}

if let userCanChangeDPI = builderArgs?["UserCanChangeDPI"] as? Bool {
builder.klippaMenu.userCanChangeDPI = userCanChangeDPI
}

if let userCanChangePageSize = builderArgs?["UserCanChangePageSize"] as? Bool {
builder.klippaMenu.userCanChangePageSize = userCanChangePageSize
}

if let primaryColor = builderArgs?["PrimaryColor"] as? String {
builder.klippaColors.primaryColor = hexColorToUIColor(hex: primaryColor)
}
Expand Down Expand Up @@ -463,9 +503,19 @@ public class SwiftKlippaScannerSdkPlugin: NSObject, FlutterPlugin, KlippaScanner
}

public func klippaScannerDidFinishScanningWithResult(result: KlippaScannerResult) {
var images: [[String: String]] = []
var images: [[String: Any]] = []
for image in result.results {
let imageDict = ["Filepath" : image.path]
var detectedTexts: [[String: Any]] = []
for detectedText in image.detectedTexts {
let boundingBox: [String: Any] = [
"x": detectedText.boundingBox.origin.x,
"y": detectedText.boundingBox.origin.y,
"width": detectedText.boundingBox.size.width,
"height": detectedText.boundingBox.size.height
]
detectedTexts.append(["Text": detectedText.text, "BoundingBox": boundingBox])
}
let imageDict: [String: Any] = ["Filepath": image.path, "DetectedTexts": detectedTexts]
images.append(imageDict)
}

Expand Down
2 changes: 1 addition & 1 deletion ios/klippa_scanner_sdk.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Allows you to do document scanning with the Klippa Scanner SDK from Flutter apps
s.source_files = 'Classes/**/*'
s.dependency 'Flutter'
s.dependency 'Klippa-Scanner'
s.platform = :ios, '14.0'
s.platform = :ios, '15.0'

# Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
Expand Down
2 changes: 1 addition & 1 deletion ios/sdk_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.0
2.3.0
Loading
Loading