Skip to content

Commit 875b8af

Browse files
committed
Merge branch 'development'
2 parents 8759e94 + ebaa893 commit 875b8af

File tree

8 files changed

+88
-17
lines changed

8 files changed

+88
-17
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 1.0.3
2+
3+
* Bumped Android to 4.0.8
4+
* Bumped iOS to 2.0.6
5+
* Added method `purge()`.
6+
* Added setup options `PerformOnDeviceOCR` and `OutputFormat`.
7+
18
## 1.0.2
29

310
* Bumped Android to 4.0.6

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ KlippaScannerSDK.getCameraPermission().then((authStatus) => {
168168

169169
// What the default color conversion will be (grayscale, original, enhanced).
170170
DefaultColor: "original",
171+
172+
// Whether to perform on-device OCR after scanning completes.
173+
PerformOnDeviceOCR: false,
174+
175+
// What the output format will be (jpeg, pdfMerged, pdfSingle). (Default jpeg)
176+
OutputFormat: "jpeg",
171177

172178
// Optional. Only affects Android.
173179

@@ -385,6 +391,12 @@ CameraModeMulti: {name: "Name", message: "Message", image: "{name of image in As
385391
CameraModeSegmented: {name: "Name", message: "Message", image: "{name of image in Assets.xcassets}"}
386392
```
387393

394+
## How to clear the storage.
395+
396+
```javascript
397+
KlippaScannerSDK.purge()
398+
```
399+
388400
## Important iOS notes
389401
Older iOS versions do not ship the Swift libraries. To make sure the SDK works on older iOS versions, you can configure the build to embed the Swift libraries using the build setting `EMBEDDED_CONTENT_CONTAINS_SWIFT = YES`.
390402

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ repositories {
8888
}
8989

9090
dependencies {
91-
def fallbackKlippaScannerVersion = "4.0.6"
91+
def fallbackKlippaScannerVersion = "4.0.8"
9292
def klippaScannerVersion = project.hasProperty('klippaScannerVersion') ? project.klippaScannerVersion : fallbackKlippaScannerVersion
9393

9494
//noinspection GradleDynamicVersion

android/src/main/java/com/klippa/reactscanner/KlippaScannerSDKModule.kt

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ import com.klippa.scanner.model.KlippaError
2525
import com.klippa.scanner.model.KlippaImageColor
2626
import com.klippa.scanner.model.KlippaMultipleDocumentMode
2727
import com.klippa.scanner.model.KlippaObjectDetectionModel
28+
import com.klippa.scanner.model.KlippaOutputFormat
2829
import com.klippa.scanner.model.KlippaScannerResult
2930
import com.klippa.scanner.model.KlippaSegmentedDocumentMode
3031
import com.klippa.scanner.model.KlippaSingleDocumentMode
3132
import com.klippa.scanner.model.KlippaSize
33+
import com.klippa.scanner.storage.KlippaStorage
3234

3335
class KlippaScannerSDKModule(
3436
private val reactContext: ReactApplicationContext
@@ -95,6 +97,12 @@ class KlippaScannerSDKModule(
9597
reactContext.addActivityEventListener(activityEventListener)
9698
}
9799

100+
@ReactMethod
101+
fun purge(promise: Promise) {
102+
KlippaStorage.purge(reactContext)
103+
promise.resolve(null)
104+
}
105+
98106
@ReactMethod
99107
fun getCameraPermission(promise: Promise) {
100108
val map: WritableMap = WritableNativeMap()
@@ -143,7 +151,21 @@ class KlippaScannerSDKModule(
143151
when (config.getString("DefaultColor")) {
144152
"grayscale" -> scannerSession.imageAttributes.imageColorMode = KlippaImageColor.GRAYSCALE
145153
"enhanced" -> scannerSession.imageAttributes.imageColorMode = KlippaImageColor.ENHANCED
146-
else -> scannerSession.imageAttributes.imageColorMode = KlippaImageColor.ORIGINAL
154+
"original" -> scannerSession.imageAttributes.imageColorMode = KlippaImageColor.ORIGINAL
155+
}
156+
}
157+
158+
if (config.hasKey("OutputFormat")) {
159+
when (config.getString("OutputFormat")) {
160+
"jpeg" -> {
161+
scannerSession.imageAttributes.outputFormat = KlippaOutputFormat.JPEG
162+
}
163+
"pdfSingle" -> {
164+
scannerSession.imageAttributes.outputFormat = KlippaOutputFormat.PDF_SINGLE
165+
}
166+
"pdfMerged" -> {
167+
scannerSession.imageAttributes.outputFormat = KlippaOutputFormat.PDF_MERGED
168+
}
147169
}
148170
}
149171

@@ -163,6 +185,10 @@ class KlippaScannerSDKModule(
163185
}
164186
}
165187

188+
if (config.hasKey("PerformOnDeviceOCR")) {
189+
scannerSession.imageAttributes.performOnDeviceOCR = config.getBoolean("PerformOnDeviceOCR")
190+
}
191+
166192
if (config.hasKey("ImageLimit")) {
167193
scannerSession.imageAttributes.imageLimit = config.getInt("ImageLimit")
168194
}
@@ -347,8 +373,8 @@ class KlippaScannerSDKModule(
347373
}
348374

349375
val cameraModes = KlippaCameraModes(
350-
modes = modes,
351-
startingIndex = index
376+
modes = modes,
377+
startingIndex = index
352378
)
353379

354380
scannerSession.cameraModes = cameraModes
@@ -367,7 +393,7 @@ class KlippaScannerSDKModule(
367393
val cameraResult: WritableMap = WritableNativeMap()
368394
val images: WritableArray = WritableNativeArray()
369395

370-
val imageList = result.images
396+
val imageList = result.results
371397
val crop = result.cropEnabled
372398
val timerEnabled = result.timerEnabled
373399
val color = result.defaultImageColorLegacy

ios/.sdk_version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.5
1+
2.0.6

ios/KlippaScannerSDK.swift

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,31 @@ class KlippaScannerSDK: NSObject {
151151
}
152152

153153
if let imageColor = config["DefaultColor"] as? String {
154-
if(imageColor == "grayscale") {
155-
builder.klippaColors.imageColor = KlippaImageColor.grayscale
156-
} else if(imageColor == "enhanced") {
154+
switch imageColor {
155+
case "original":
156+
builder.klippaColors.imageColor = KlippaImageColor.original
157+
case "grayscale":
158+
builder.klippaColors.imageColor = KlippaImageColor.grayscale
159+
case "enhanced":
157160
builder.klippaColors.imageColor = KlippaImageColor.enhanced
158-
} else {
161+
default:
159162
builder.klippaColors.imageColor = KlippaImageColor.original
160163
}
161164
}
162165

166+
if let outputFormat = config["OutputFormat"] as? String {
167+
switch outputFormat {
168+
case "jpeg":
169+
builder.klippaImageAttributes.outputFormat = .jpeg
170+
case "pdfSingle":
171+
builder.klippaImageAttributes.outputFormat = .pdfSingle
172+
case "pdfMerged":
173+
builder.klippaImageAttributes.outputFormat = .pdfMerged
174+
default:
175+
builder.klippaImageAttributes.outputFormat = .jpeg
176+
}
177+
}
178+
163179
if let moveCloserMessage = config["MoveCloserMessage"] as? String {
164180
builder.klippaMessages.moveCloserMessage = moveCloserMessage
165181
}
@@ -321,6 +337,10 @@ class KlippaScannerSDK: NSObject {
321337
builder.klippaImageAttributes.storeImagesToCameraRoll = storeImagesToCameraRoll
322338
}
323339

340+
if let performOnDeviceOCR = config["PerformOnDeviceOCR"] as? Bool {
341+
builder.klippaImageAttributes.performOnDeviceOCR = performOnDeviceOCR
342+
}
343+
324344
if let userCanPickMediaFromStorage = config["UserCanPickMediaFromStorage"] as? Bool {
325345
builder.klippaMenu.userCanPickMediaFromStorage = userCanPickMediaFromStorage
326346
}
@@ -496,7 +516,7 @@ extension KlippaScannerSDK: KlippaScannerDelegate {
496516
func klippaScannerDidFinishScanningWithResult(result: KlippaScanner.KlippaScannerResult) {
497517

498518
var images = [Dictionary<String, String>]()
499-
for image in result.images {
519+
for image in result.results {
500520

501521
let path = image.path
502522
let imageDict = ["Filepath": path]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@klippa/react-native-klippa-scanner-sdk",
33
"title": "React Native Klippa Scanner SDK",
4-
"version": "1.0.2",
4+
"version": "1.0.3",
55
"description": "Allows you to take pictures with the Klippa Scanner SDK from React Native.",
66
"main": "index.js",
77
"files": [

types/index.d.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,20 @@ export class CameraConfig {
131131
// Whether the user must confirm the taken photo before the SDK continues.
132132
UserShouldAcceptResultToContinue: boolean;
133133

134+
// What the default color conversion will be (original, grayscale, enhanced).
135+
DefaultColor?: 'original' | 'grayscale' | 'enhanced';
136+
137+
// What the output format will be (jpeg, pdfMerged, pdfSingle). (Default jpeg)
138+
OutputFormat?: 'jpeg' | 'pdfMerged' | 'pdfSingle';
139+
140+
// Whether to perform on-device OCR after scanning completes.
141+
PerformOnDeviceOCR: boolean;
142+
134143
// Android options.
135144

136145
// Where to put the image results.
137146
StoragePath?: string;
138147

139-
// What the default color conversion will be (original, grayscale, enhanced).
140-
DefaultColor?: 'original' | 'grayscale' | 'enhanced';
141-
142148
OutputFilename?: string;
143149

144150
// The threshold sensitive the motion detection is. (lower value is higher sensitivity, default 50).
@@ -270,9 +276,9 @@ export class CameraResultImage {
270276
}
271277

272278
export class CameraPermissionResult {
273-
// Android always return Authorized, the SDK itself asks for permission.
274279
Status: 'Authorized' | 'Denied' | 'Restricted';
275280
}
276281

277282
export declare function getCameraPermission(): Promise<CameraPermissionResult>;
278-
export declare function getCameraResult(config: CameraConfig): Promise<CameraResult>;
283+
export declare function getCameraResult(config: CameraConfig): Promise<CameraResult>;
284+
export declare function purge(): Promise<void>;

0 commit comments

Comments
 (0)