dynamsoft-capture-vision-react-native 2.6.1015 → 3.0.3100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +7 -9
- package/android/build.gradle +29 -42
- package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/CVRModule.kt +4 -4
- package/android/src/main/java/com/dynamsoft/reactnativelib/ReactNativeDcvPackage.kt +13 -85
- package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/VersionsModule.kt +2 -2
- package/android/src/main/java/com/dynamsoft/reactnativelib/cvr/CaptureVisionRouterModuleImpl.kt +23 -25
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraEnhancerModuleImpl.kt +2 -2
- package/android/src/main/java/com/dynamsoft/reactnativelib/license/LicenseModuleImpl.kt +1 -1
- package/android/src/main/java/com/dynamsoft/reactnativelib/utility/ImageManagerModuleImpl.kt +19 -4
- package/android/src/main/java/com/dynamsoft/reactnativelib/utils/ForCore.kt +14 -0
- package/android/src/main/java/com/dynamsoft/reactnativelib/utils/ForCvr.kt +12 -7
- package/android/src/main/java/com/dynamsoft/reactnativelib/utils/ForDBR.kt +1 -7
- package/android/src/main/java/com/dynamsoft/reactnativelib/utils/ForDCE.kt +2 -2
- package/android/src/main/java/com/dynamsoft/reactnativelib/utils/ForDDN.kt +27 -19
- package/android/src/main/jniLibs/debug/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/jniLibs/debug/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/jniLibs/debug/x86/librn_dys.so +0 -0
- package/android/src/main/jniLibs/debug/x86_64/librn_dys.so +0 -0
- package/android/src/main/jniLibs/release/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/jniLibs/release/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/jniLibs/release/x86/librn_dys.so +0 -0
- package/android/src/main/jniLibs/release/x86_64/librn_dys.so +0 -0
- package/dynamsoft-capture-vision-react-native.podspec +9 -7
- package/ios/CPP/DSImageData+HostObject.h +1 -1
- package/ios/CPP/RNDynamsoft+JSI.h +2 -2
- package/ios/CPP/RNDynamsoft+JSI.mm +18 -10
- package/ios/CPP/RNDynamsoft+Json.h +2 -13
- package/ios/CPP/RNDynamsoft+Json.m +48 -39
- package/ios/CPP/YeetJSIUtils.h +3 -1
- package/ios/CPP/YeetJSIUtils.mm +5 -0
- package/ios/RNDynamsoftCameraView.m +1 -1
- package/ios/RNDynamsoftCameraViewManager.m +18 -6
- package/ios/RNDynamsoftCaptureVisionRouter.mm +76 -45
- package/ios/RNDynamsoftImageEditorView.m +1 -1
- package/ios/RNDynamsoftImageEditorViewManager.mm +36 -13
- package/ios/RNDynamsoftImageManager.mm +33 -4
- package/ios/RNDynamsoftImageSourceAdapter.mm +1 -1
- package/ios/RNDynamsoftLicense.m +1 -1
- package/ios/RNDynamsoftMultiCrossFilter.m +9 -9
- package/ios/RNDynamsoftVersions.m +1 -13
- package/package.json +3 -11
- package/src/core/CapturedResultBase.tsx +18 -0
- package/src/core/EnumCaptureResultItemType.tsx +12 -6
- package/src/core/EnumCrossVerificationStatus.tsx +6 -6
- package/src/core/ImageData.tsx +1 -1
- package/src/core/index.tsx +1 -0
- package/src/cvr/CaptureVisionRouter.tsx +47 -51
- package/src/cvr/CapturedResult.tsx +24 -46
- package/src/cvr/CapturedResultReceiver.tsx +12 -19
- package/src/cvr/NativeDynamsoftCaptureVisionRouterModule.tsx +2 -2
- package/src/cvr/SimplifiedCaptureVisionSettings.tsx +4 -4
- package/src/dbr/DecodedBarcodesResult.tsx +3 -17
- package/src/dce/DynamsoftCameraViewNativeComponent.ts +2 -2
- package/src/dcp/ParsedResult.tsx +3 -14
- package/src/ddn/DeskewedImageResultItem.tsx +40 -0
- package/src/ddn/DetectedQuadResultItem.tsx +3 -1
- package/src/ddn/EnhancedImageResultItem.tsx +20 -0
- package/src/ddn/ProcessedDocumentResult.tsx +27 -0
- package/src/ddn/SimplifiedDocumentNormalizerSettings.tsx +18 -3
- package/src/ddn/index.tsx +3 -3
- package/src/dlr/RecognizedTextLinesResult.tsx +2 -16
- package/src/index.tsx +0 -1
- package/src/utility/ImageManager.tsx +66 -45
- package/android/src/main/java/com/dynamsoft/reactnativelib/rtu/BarcodeScannerModuleImpl.kt +0 -80
- package/android/src/main/java/com/dynamsoft/reactnativelib/rtu/MRZScannerModuleImpl.kt +0 -77
- package/android/src/main/java/com/dynamsoft/reactnativelib/rtu/ScannerInterface.kt +0 -47
- package/android/src/main/jniLibs/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/jniLibs/x86/librn_dys.so +0 -0
- package/android/src/main/jniLibs/x86_64/librn_dys.so +0 -0
- package/android/src/newarch/com/dynamsoft/reactnativelib/BarcodeScannerModule.kt +0 -22
- package/android/src/newarch/com/dynamsoft/reactnativelib/CVRModule.kt +0 -91
- package/android/src/newarch/com/dynamsoft/reactnativelib/CameraViewManager.kt +0 -52
- package/android/src/newarch/com/dynamsoft/reactnativelib/DCEModule.kt +0 -91
- package/android/src/newarch/com/dynamsoft/reactnativelib/ISAModule.kt +0 -60
- package/android/src/newarch/com/dynamsoft/reactnativelib/ImageEditorViewManager.kt +0 -16
- package/android/src/newarch/com/dynamsoft/reactnativelib/ImageEditorViewModule.kt +0 -24
- package/android/src/newarch/com/dynamsoft/reactnativelib/ImageManagerModule.kt +0 -12
- package/android/src/newarch/com/dynamsoft/reactnativelib/LicenseModule.kt +0 -14
- package/android/src/newarch/com/dynamsoft/reactnativelib/MRZScannerModule.kt +0 -22
- package/android/src/newarch/com/dynamsoft/reactnativelib/MultiCrossFilterModule.kt +0 -58
- package/android/src/newarch/com/dynamsoft/reactnativelib/VersionsModule.kt +0 -41
- package/android/src/oldarch/com/dynamsoft/reactnativelib/BarcodeScannerModule.kt +0 -24
- package/android/src/oldarch/com/dynamsoft/reactnativelib/MRZScannerModule.kt +0 -24
- package/ios/RNDynamsoftBarcodeScanner.h +0 -14
- package/ios/RNDynamsoftBarcodeScanner.m +0 -169
- package/ios/RNDynamsoftMRZScanner.h +0 -14
- package/ios/RNDynamsoftMRZScanner.m +0 -140
- package/src/ddn/DetectedQuadsResult.tsx +0 -31
- package/src/ddn/NormalizedImageResultItem.tsx +0 -32
- package/src/ddn/NormalizedImagesResult.tsx +0 -27
- package/src/rtu/BarcodeScanConfig.tsx +0 -104
- package/src/rtu/BarcodeScanResult.tsx +0 -31
- package/src/rtu/BarcodeScanner.tsx +0 -112
- package/src/rtu/EnumResultState.tsx +0 -21
- package/src/rtu/MRZScanConfig.tsx +0 -67
- package/src/rtu/MRZScanResult.tsx +0 -84
- package/src/rtu/MRZScanner.tsx +0 -90
- package/src/rtu/NativeDynamsoftBarcodeScannerModule.tsx +0 -6
- package/src/rtu/NativeDynamsoftMRZScannerModule.tsx +0 -6
- package/src/rtu/index.tsx +0 -7
- /package/android/src/main/{withNamespace/AndroidManifest.xml → AndroidManifest.xml} +0 -0
- /package/android/src/main/{withoutNamespace/AndroidManifest.xml → AndroidManifest_noPackage.xml} +0 -0
- /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/CameraViewManager.kt +0 -0
- /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/DCEModule.kt +0 -0
- /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/ISAModule.kt +0 -0
- /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/ImageEditorViewManager.kt +0 -0
- /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/ImageEditorViewModule.kt +0 -0
- /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/ImageManagerModule.kt +0 -0
- /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/LicenseModule.kt +0 -0
- /package/android/src/{oldarch → main/java}/com/dynamsoft/reactnativelib/MultiCrossFilterModule.kt +0 -0
package/src/ddn/index.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export * from "./DetectedQuadResultItem"
|
|
2
|
-
export * from "./
|
|
2
|
+
export * from "./DeskewedImageResultItem"
|
|
3
|
+
export * from "./EnhancedImageResultItem"
|
|
3
4
|
|
|
4
5
|
export * from "./DocumentNormalizerModule"
|
|
5
6
|
|
|
6
7
|
export * from "./EnumImageColourMode"
|
|
7
8
|
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./NormalizedImagesResult"
|
|
9
|
+
export * from "./ProcessedDocumentResult"
|
|
10
10
|
|
|
11
11
|
export * from "./SimplifiedDocumentNormalizerSettings"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type {TextLineResultItem} from "./TextLineResultItem";
|
|
2
2
|
import {type CapturedResultReceiver, IntermediateResultManager} from "../cvr";
|
|
3
|
+
import type {CapturedResultBase} from "../core";
|
|
3
4
|
|
|
4
5
|
/**{@link IntermediateResultManager}*/
|
|
5
6
|
/**
|
|
@@ -9,25 +10,10 @@ import {type CapturedResultReceiver, IntermediateResultManager} from "../cvr";
|
|
|
9
10
|
*
|
|
10
11
|
* @see {@link CapturedResultReceiver.onRecognizedTextLinesReceived}
|
|
11
12
|
* */
|
|
12
|
-
export interface RecognizedTextLinesResult {
|
|
13
|
-
/**
|
|
14
|
-
* The hash ID of the original image.
|
|
15
|
-
* @see {@link IntermediateResultManager.getOriginalImage}
|
|
16
|
-
* */
|
|
17
|
-
originalImageHashId: string;
|
|
18
|
-
|
|
13
|
+
export interface RecognizedTextLinesResult extends CapturedResultBase{
|
|
19
14
|
/**
|
|
20
15
|
* All the recognized text line result items.
|
|
21
16
|
* @see {@link TextLineResultItem}
|
|
22
17
|
* */
|
|
23
18
|
items?: Array<TextLineResultItem>;
|
|
24
|
-
|
|
25
|
-
/**The error code of the barcode reading result, if an error occurred.*/
|
|
26
|
-
errorCode: number;
|
|
27
|
-
|
|
28
|
-
/**The error message of the barcode reading result, if an error occurred.*/
|
|
29
|
-
errorMessage?: string;
|
|
30
|
-
|
|
31
|
-
/**the rotation transformation matrix of the original image relative to the rotated image.*/
|
|
32
|
-
rotationTransformMatrix: Array<number>;
|
|
33
19
|
}
|
package/src/index.tsx
CHANGED
|
@@ -5,20 +5,23 @@ import type {ImageData, Quadrilateral} from "../core";
|
|
|
5
5
|
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
6
6
|
|
|
7
7
|
const DynamsoftImageManagerModule = isTurboModuleEnabled ?
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
require("./NativeDynamsoftImageManagerModule").default :
|
|
9
|
+
NativeModules.DynamsoftImageManagerModule;
|
|
10
10
|
|
|
11
11
|
declare global {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
function imageManager_saveToFile(imageData: ImageData, path: string, overWrite: boolean): void;
|
|
13
|
+
|
|
14
|
+
function imageManager_drawOnImage(imageData: ImageData, quads: Quadrilateral[], colour: number, thickness: number): ImageData;
|
|
15
|
+
|
|
16
|
+
function imageManager_cropImage(imageData: ImageData, quads: Quadrilateral): ImageData | undefined;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
let isInstalled = false
|
|
17
20
|
const installMethods = () => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
if (!isInstalled) {
|
|
22
|
+
DynamsoftImageManagerModule.install()
|
|
23
|
+
isInstalled = true
|
|
24
|
+
}
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
/**
|
|
@@ -26,45 +29,63 @@ const installMethods = () => {
|
|
|
26
29
|
* It provides functionality for saving images to files and drawing various shapes on images.
|
|
27
30
|
* */
|
|
28
31
|
export class ImageManager {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
32
|
+
/**
|
|
33
|
+
* Saves an image to the specified path and format.
|
|
34
|
+
* The desired file format is inferred from the file extension provided in the path parameter.
|
|
35
|
+
*
|
|
36
|
+
* @param imageData - The image to be saved, of type {@link ImageData}.
|
|
37
|
+
* @param path - The absolute file path, name and extension name, as a string, under which the image will be saved.
|
|
38
|
+
* @param overWrite - A flag indicating whether to overwrite the file if it already exists. Defaults to true.
|
|
39
|
+
* */
|
|
40
|
+
saveToFile(imageData: ImageData | null | undefined, path: string | null | undefined, overWrite: boolean): void {
|
|
41
|
+
installMethods();
|
|
42
|
+
if (imageData && path) {
|
|
43
|
+
if (path.length > 0) {
|
|
44
|
+
global.imageManager_saveToFile(imageData, path, overWrite);
|
|
45
|
+
}
|
|
44
46
|
}
|
|
47
|
+
}
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
return global.imageManager_drawOnImage(imageData, quads, colorNumber, thickness);
|
|
66
|
-
}
|
|
49
|
+
/**
|
|
50
|
+
* Add quadrilaterals on the image.
|
|
51
|
+
*
|
|
52
|
+
* @param imageData - The {@link ImageData} to modify.
|
|
53
|
+
* @param quads - An array of {@link Quadrilateral} objects to be added on the image.
|
|
54
|
+
* @param colour - An ColorValue as an ARGB colour.
|
|
55
|
+
* @param thickness - The width of the border.
|
|
56
|
+
*
|
|
57
|
+
* @return {ImageData|null|undefined} - The modified ImageData.
|
|
58
|
+
* */
|
|
59
|
+
drawOnImage(imageData: ImageData | null | undefined, quads: Quadrilateral[] | null | undefined, colour: number | ColorValue, thickness: number): ImageData | null | undefined {
|
|
60
|
+
installMethods();
|
|
61
|
+
if (imageData && quads) {
|
|
62
|
+
const colorNumber = processColor(colour) as number;
|
|
63
|
+
if (colorNumber) {
|
|
64
|
+
const alpha = (colorNumber >> 24) & 0xff;
|
|
65
|
+
if (quads.length == 0 || thickness <= 0 || alpha == 0) {
|
|
66
|
+
return imageData;
|
|
67
67
|
}
|
|
68
|
-
return imageData;
|
|
68
|
+
return global.imageManager_drawOnImage(imageData, quads, colorNumber, thickness);
|
|
69
|
+
}
|
|
69
70
|
}
|
|
71
|
+
return imageData;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Crops an image using a quadrilateral.
|
|
77
|
+
* @param {ImageData} imageData - The image data to crop.
|
|
78
|
+
* @param {Quadrilateral} quad - The quadrilateral to use for cropping.
|
|
79
|
+
*
|
|
80
|
+
* @returns {ImageData|null|undefined} - The cropped image data.
|
|
81
|
+
* */
|
|
82
|
+
cropImage(imageData: ImageData | null | undefined, quad: Quadrilateral | null | undefined): ImageData | undefined | null {
|
|
83
|
+
installMethods();
|
|
84
|
+
if (!quad || !imageData) {
|
|
85
|
+
return imageData;
|
|
86
|
+
}
|
|
87
|
+
return global.imageManager_cropImage(imageData, quad);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
70
91
|
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
package com.dynamsoft.reactnativelib.rtu
|
|
2
|
-
|
|
3
|
-
import android.app.Activity
|
|
4
|
-
import android.content.Intent
|
|
5
|
-
import com.dynamsoft.dbr.EnumBarcodeFormat
|
|
6
|
-
import com.dynamsoft.dbrbundle.ui.BarcodeScanResult
|
|
7
|
-
import com.dynamsoft.dbrbundle.ui.BarcodeScannerActivity
|
|
8
|
-
import com.dynamsoft.dbrbundle.ui.BarcodeScannerConfig
|
|
9
|
-
import com.dynamsoft.reactnative.basicutils.toWritableArray
|
|
10
|
-
import com.dynamsoft.reactnativelib.utils.toScanRegion
|
|
11
|
-
import com.facebook.react.bridge.Arguments
|
|
12
|
-
import com.facebook.react.bridge.Promise
|
|
13
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
14
|
-
import com.facebook.react.bridge.ReadableMap
|
|
15
|
-
import com.facebook.react.bridge.WritableMap
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class BarcodeScannerModuleImpl(private val reactContext: ReactApplicationContext): ScannerModule(reactContext) {
|
|
19
|
-
companion object {
|
|
20
|
-
const val NAME = "DynamsoftBarcodeScannerModule"
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
fun startBarcodeScanner(config: ReadableMap, promise: Promise) {
|
|
24
|
-
super.startScanner(config, promise)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
fun closeBarcodeScanner(promise: Promise) {
|
|
28
|
-
super.closeScanner(promise)
|
|
29
|
-
}
|
|
30
|
-
override fun createIntent(config: ReadableMap) =
|
|
31
|
-
BarcodeScannerActivity.ResultContract().createIntent(reactContext, config.toBarcodeScannerConfig())
|
|
32
|
-
|
|
33
|
-
override fun getPromiseResolve(intent: Intent) = BarcodeScanResult(Activity.RESULT_OK, intent).toWritableMap()
|
|
34
|
-
|
|
35
|
-
private fun ReadableMap.toBarcodeScannerConfig() = BarcodeScannerConfig().also {
|
|
36
|
-
it.license = getString("license")
|
|
37
|
-
it.barcodeFormats = (getString("_barcodeFormatNumberString") ?: EnumBarcodeFormat.BF_DEFAULT.toString()).toULong().toLong()
|
|
38
|
-
// it.templateFilePath = getString("templateFilePath")
|
|
39
|
-
if(hasKey("scanRegion")) {
|
|
40
|
-
it.scanRegion = getMap("scanRegion")?.toScanRegion()
|
|
41
|
-
}
|
|
42
|
-
if (hasKey("isTorchButtonVisible")) {
|
|
43
|
-
it.isTorchButtonVisible = getBoolean("isTorchButtonVisible")
|
|
44
|
-
}
|
|
45
|
-
if (hasKey("isBeepEnabled")) {
|
|
46
|
-
it.isBeepEnabled = getBoolean("isBeepEnabled")
|
|
47
|
-
}
|
|
48
|
-
if (hasKey("isAutoZoomEnabled")) {
|
|
49
|
-
it.isAutoZoomEnabled = getBoolean("isAutoZoomEnabled")
|
|
50
|
-
}
|
|
51
|
-
if (hasKey("isCloseButtonVisible")) {
|
|
52
|
-
it.isCloseButtonVisible = getBoolean("isCloseButtonVisible")
|
|
53
|
-
}
|
|
54
|
-
if (hasKey("isScanLaserVisible")) {
|
|
55
|
-
it.isScanLaserVisible = getBoolean("isScanLaserVisible")
|
|
56
|
-
}
|
|
57
|
-
if(hasKey("maxConsecutiveStableFramesToExit")) {
|
|
58
|
-
it.maxConsecutiveStableFramesToExit = getInt("maxConsecutiveStableFramesToExit")
|
|
59
|
-
}
|
|
60
|
-
if(hasKey("scanningMode")) {
|
|
61
|
-
it.scanningMode = getInt("scanningMode")
|
|
62
|
-
}
|
|
63
|
-
if(hasKey("expectedBarcodesCount")) {
|
|
64
|
-
it.expectedBarcodesCount = getInt("expectedBarcodesCount")
|
|
65
|
-
}
|
|
66
|
-
if(hasKey("templateFile")) {
|
|
67
|
-
it.templateFile = getString("templateFile")
|
|
68
|
-
}
|
|
69
|
-
if(hasKey("isCameraToggleButtonVisible")) {
|
|
70
|
-
it.isCameraToggleButtonVisible = getBoolean("isCameraToggleButtonVisible")
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
private fun BarcodeScanResult.toWritableMap(): WritableMap = Arguments.createMap().apply {
|
|
75
|
-
putInt("resultStatus", resultStatus)
|
|
76
|
-
putInt("errorCode", errorCode)
|
|
77
|
-
putString("errorString", errorString)
|
|
78
|
-
putArray("barcodes", barcodes?.toWritableArray())
|
|
79
|
-
}
|
|
80
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
package com.dynamsoft.reactnativelib.rtu
|
|
2
|
-
|
|
3
|
-
import android.app.Activity
|
|
4
|
-
import android.content.Intent
|
|
5
|
-
import com.dynamsoft.mrzscannerbundle.ui.EnumDocumentType
|
|
6
|
-
import com.dynamsoft.mrzscannerbundle.ui.MRZData
|
|
7
|
-
import com.dynamsoft.mrzscannerbundle.ui.MRZScanResult
|
|
8
|
-
import com.dynamsoft.mrzscannerbundle.ui.MRZScannerActivity
|
|
9
|
-
import com.dynamsoft.mrzscannerbundle.ui.MRZScannerConfig
|
|
10
|
-
import com.facebook.react.bridge.Arguments
|
|
11
|
-
import com.facebook.react.bridge.Promise
|
|
12
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
13
|
-
import com.facebook.react.bridge.ReadableMap
|
|
14
|
-
import com.facebook.react.bridge.WritableMap
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class MRZScannerModuleImpl(private val reactContext: ReactApplicationContext): ScannerModule(reactContext) {
|
|
18
|
-
companion object {
|
|
19
|
-
const val NAME = "DynamsoftMRZScannerModule"
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
fun startMRZScanner(config: ReadableMap, promise: Promise) {
|
|
23
|
-
super.startScanner(config, promise)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
fun closeMRZScanner(promise: Promise) {
|
|
27
|
-
super.closeScanner(promise)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
override fun createIntent(config: ReadableMap) =
|
|
31
|
-
MRZScannerActivity.ResultContract().createIntent(reactContext, config.toMRZScannerConfig())
|
|
32
|
-
|
|
33
|
-
override fun getPromiseResolve(intent: Intent) = MRZScanResult(Activity.RESULT_OK, intent).toWritableMap()
|
|
34
|
-
|
|
35
|
-
private fun ReadableMap.toMRZScannerConfig() = MRZScannerConfig().also {
|
|
36
|
-
it.license = getString("license")
|
|
37
|
-
if (hasKey("isTorchButtonVisible")) {
|
|
38
|
-
it.isTorchButtonVisible = getBoolean("isTorchButtonVisible")
|
|
39
|
-
}
|
|
40
|
-
if (hasKey("isBeepEnabled")) {
|
|
41
|
-
it.isBeepEnabled = getBoolean("isBeepEnabled")
|
|
42
|
-
}
|
|
43
|
-
if (hasKey("isCloseButtonVisible")) {
|
|
44
|
-
it.isCloseButtonVisible = getBoolean("isCloseButtonVisible")
|
|
45
|
-
}
|
|
46
|
-
if (hasKey("isGuideFrameVisible")) {
|
|
47
|
-
it.isGuideFrameVisible = getBoolean("isGuideFrameVisible")
|
|
48
|
-
}
|
|
49
|
-
if (hasKey("documentType")) {
|
|
50
|
-
it.documentType = EnumDocumentType.values()[getInt("documentType")]
|
|
51
|
-
}
|
|
52
|
-
if(hasKey("templateFile")) {
|
|
53
|
-
it.templateFile = getString("templateFile")
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private fun MRZScanResult.toWritableMap(): WritableMap = Arguments.createMap().apply {
|
|
58
|
-
putInt("resultStatus", resultStatus)
|
|
59
|
-
putInt("errorCode", errorCode)
|
|
60
|
-
putString("errorString", errorString)
|
|
61
|
-
putMap("data", data.toWritableMap())
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
private fun MRZData.toWritableMap() = Arguments.createMap().apply {
|
|
65
|
-
putString("documentType", documentType)
|
|
66
|
-
putString("firstName", firstName)
|
|
67
|
-
putString("lastName", lastName)
|
|
68
|
-
putString("sex", sex)
|
|
69
|
-
putString("issuingState", issuingState)
|
|
70
|
-
putString("nationality", nationality)
|
|
71
|
-
putString("dateOfBirth", dateOfBirth)
|
|
72
|
-
putString("dateOfExpire", dateOfExpire)
|
|
73
|
-
putString("documentNumber", documentNumber)
|
|
74
|
-
putInt("age", age)
|
|
75
|
-
putString("mrzText", mrzText)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
package com.dynamsoft.reactnativelib.rtu
|
|
2
|
-
|
|
3
|
-
import android.app.Activity
|
|
4
|
-
import android.content.Intent
|
|
5
|
-
import com.facebook.react.bridge.ActivityEventListener
|
|
6
|
-
import com.facebook.react.bridge.Promise
|
|
7
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
8
|
-
import com.facebook.react.bridge.ReadableMap
|
|
9
|
-
import com.facebook.react.bridge.WritableMap
|
|
10
|
-
|
|
11
|
-
abstract class ScannerModule(private val reactContext: ReactApplicationContext): ActivityEventListener {
|
|
12
|
-
|
|
13
|
-
private var promises: HashMap<Int, Promise> = hashMapOf()
|
|
14
|
-
|
|
15
|
-
abstract fun createIntent(config: ReadableMap): Intent
|
|
16
|
-
|
|
17
|
-
abstract fun getPromiseResolve(intent: Intent): WritableMap
|
|
18
|
-
|
|
19
|
-
override fun onActivityResult(activity: Activity?, requestCode: Int, resultCode: Int, intent: Intent?) {
|
|
20
|
-
if(resultCode != Activity.RESULT_OK || intent == null) {
|
|
21
|
-
promises.remove(requestCode)?.resolve(null)
|
|
22
|
-
return
|
|
23
|
-
} else {
|
|
24
|
-
promises.remove(requestCode)?.apply {
|
|
25
|
-
resolve(getPromiseResolve(intent))
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
override fun onNewIntent(intent: Intent?) {
|
|
31
|
-
//No-op
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
fun startScanner(config: ReadableMap, promise: Promise) {
|
|
35
|
-
reactContext.addActivityEventListener(this)
|
|
36
|
-
promises[promise.hashCode()] = promise
|
|
37
|
-
reactContext.currentActivity?.startActivityForResult(
|
|
38
|
-
createIntent(config),
|
|
39
|
-
promise.hashCode()
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
fun closeScanner(promise: Promise) {
|
|
44
|
-
promise.resolve(null)
|
|
45
|
-
reactContext.removeActivityEventListener(this)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
package com.dynamsoft.reactnativelib
|
|
2
|
-
|
|
3
|
-
import com.dynamsoft.reactnativelib.rtu.BarcodeScannerModuleImpl
|
|
4
|
-
import com.facebook.react.bridge.Promise
|
|
5
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
7
|
-
import com.facebook.react.bridge.ReactMethod
|
|
8
|
-
import com.facebook.react.bridge.ReadableMap
|
|
9
|
-
|
|
10
|
-
class BarcodeScannerModule(reactApplicationContext: ReactApplicationContext) : NativeDynamsoftBarcodeScannerModuleSpec(reactApplicationContext) {
|
|
11
|
-
override fun getName() = BarcodeScannerModuleImpl.NAME
|
|
12
|
-
|
|
13
|
-
val impl by lazy { BarcodeScannerModuleImpl(reactApplicationContext) }
|
|
14
|
-
|
|
15
|
-
override fun startBarcodeScanner(config: ReadableMap, promise: Promise) {
|
|
16
|
-
impl.startBarcodeScanner(config, promise)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
override fun closeBarcodeScanner(promise: Promise) {
|
|
20
|
-
impl.closeBarcodeScanner(promise)
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
package com.dynamsoft.reactnativelib
|
|
2
|
-
|
|
3
|
-
import com.dynamsoft.reactnativelib.cvr.CaptureVisionRouterModuleImpl
|
|
4
|
-
import com.facebook.react.bridge.Arguments
|
|
5
|
-
import com.facebook.react.bridge.Promise
|
|
6
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
8
|
-
import com.facebook.react.bridge.ReadableMap
|
|
9
|
-
|
|
10
|
-
class CVRModule(reactApplicationContext: ReactApplicationContext) : NativeDynamsoftCaptureVisionRouterModuleSpec(reactApplicationContext) {
|
|
11
|
-
val impl = CaptureVisionRouterModuleImpl(reactApplicationContext)
|
|
12
|
-
|
|
13
|
-
override fun getName(): String = impl.getName()
|
|
14
|
-
override fun install(): Boolean {
|
|
15
|
-
return impl.install()
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
override fun startCapturing(template: String, promise: Promise) {
|
|
19
|
-
impl.startCapturing(template, promise)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
override fun stopCapturing(promise: Promise) {
|
|
23
|
-
impl.stopCapturing(promise)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
override fun setInput(isaId: String) {
|
|
27
|
-
impl.setInput(isaId)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
override fun continueCRR() {
|
|
31
|
-
impl.continueCRR()
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
override fun removeAllResultListeners() {
|
|
36
|
-
impl.removeAllResultListeners()
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
override fun addFilter(filterId: String) {
|
|
40
|
-
impl.addFilter(filterId)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
override fun removeFilter(filterId: String) {
|
|
44
|
-
impl.removeFilter(filterId)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
override fun resetSettings(promise: Promise) {
|
|
48
|
-
impl.resetSettings(promise)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
override fun getSimplifiedSettings(templateName: String, promise: Promise) {
|
|
52
|
-
impl.getSimplifiedSettings(templateName, promise)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
override fun updateSettings(settings: ReadableMap, templateName: String, promise: Promise) {
|
|
56
|
-
impl.updateSettings(settings, templateName, promise)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
override fun initSettings(content: String, promise: Promise) {
|
|
60
|
-
impl.initSettings(content, promise)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
override fun initSettingsFromFile(file: String, promise: Promise) {
|
|
64
|
-
impl.initSettingsFromFile(file, promise)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
override fun outputSettings(templateName: String, promise: Promise) {
|
|
68
|
-
impl.outputSettings(templateName, promise)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
override fun outputSettingsToFile(file: String, templateName: String, promise: Promise) {
|
|
72
|
-
impl.outputSettingsToFile(file, templateName, promise)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
override fun addListener(type: String) {
|
|
76
|
-
impl.addListener(type)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
override fun removeListeners(count: Double) {
|
|
80
|
-
impl.removeListeners(count.toInt())
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
override fun addResultReceiver(type: String?) {
|
|
84
|
-
//This is for IOS
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
override fun removeResultReceiver(type: String?) {
|
|
88
|
-
impl.removeListener(type)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
package com.dynamsoft.reactnativelib
|
|
2
|
-
|
|
3
|
-
import com.dynamsoft.dce.CameraView
|
|
4
|
-
import com.dynamsoft.reactnative.dce.CameraViewManagerImpl
|
|
5
|
-
import com.facebook.react.bridge.ReadableArray
|
|
6
|
-
import com.facebook.react.bridge.ReadableMap
|
|
7
|
-
import com.facebook.react.uimanager.SimpleViewManager
|
|
8
|
-
import com.facebook.react.uimanager.ThemedReactContext
|
|
9
|
-
import com.facebook.react.uimanager.annotations.ReactProp
|
|
10
|
-
import com.facebook.react.viewmanagers.DynamsoftCameraViewManagerInterface
|
|
11
|
-
|
|
12
|
-
class CameraViewManager : SimpleViewManager<CameraView>(),
|
|
13
|
-
DynamsoftCameraViewManagerInterface<CameraView> {
|
|
14
|
-
private val impl = CameraViewManagerImpl()
|
|
15
|
-
override fun createViewInstance(context: ThemedReactContext): CameraView {
|
|
16
|
-
return impl.createViewInstance(context)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
override fun getName(): String {
|
|
20
|
-
return impl.getName()
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@ReactProp(name = "VisibleLayerIds")
|
|
24
|
-
override fun setVisibleLayerIds(view: CameraView?, value: ReadableArray?) {
|
|
25
|
-
if (value != null) {
|
|
26
|
-
view?.let { impl.setVisibleLayerIds(it, value) }
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@ReactProp(name = "scanRegionMaskVisible")
|
|
31
|
-
override fun setScanRegionMaskVisible(view: CameraView?, value: Boolean) {
|
|
32
|
-
view?.let { impl.setScanRegionMaskVisible(it, value) }
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@ReactProp(name = "scanLaserVisible")
|
|
36
|
-
override fun setScanLaserVisible(view: CameraView?, value: Boolean) {
|
|
37
|
-
view?.let { impl.setScanLaserVisible(it, value) }
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@ReactProp(name = "torchButton")
|
|
41
|
-
override fun setTorchButton(view: CameraView?, value: ReadableMap?) {
|
|
42
|
-
if (value != null) {
|
|
43
|
-
view?.let { impl.setTorchButton(it, value) }
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@ReactProp(name = "torchButtonVisible")
|
|
48
|
-
override fun setTorchButtonVisible(view: CameraView?, value: Boolean) {
|
|
49
|
-
view?.let { impl.setTorchButtonVisible(it, value) }
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
package com.dynamsoft.reactnativelib
|
|
2
|
-
|
|
3
|
-
import com.dynamsoft.reactnativelib.dce.CameraEnhancerModuleImpl
|
|
4
|
-
import com.facebook.react.bridge.Promise
|
|
5
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
7
|
-
import com.facebook.react.bridge.ReadableMap
|
|
8
|
-
import com.facebook.react.bridge.WritableMap
|
|
9
|
-
|
|
10
|
-
class DCEModule(reactApplicationContext: ReactApplicationContext) : NativeDynamsoftCameraViewModuleSpec(reactApplicationContext) {
|
|
11
|
-
val impl = CameraEnhancerModuleImpl(reactApplicationContext)
|
|
12
|
-
|
|
13
|
-
override fun getName(): String = impl.getName()
|
|
14
|
-
override fun createInstance(): String {
|
|
15
|
-
return impl.createInstance()
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
override fun requestCameraPermission() {
|
|
19
|
-
impl.requestCameraPermission()
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
override fun open() {
|
|
23
|
-
impl.open()
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
override fun close() {
|
|
27
|
-
impl.close()
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
override fun setCameraView(viewId: Double) {
|
|
31
|
-
impl.setCameraView(viewId.toInt())
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
override fun selectCamera(position: Double) {
|
|
35
|
-
impl.selectCamera(position.toInt())
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
override fun getCameraPosition(promise: Promise) {
|
|
39
|
-
impl.getCameraPosition(promise)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
override fun setFocus(floatX: Double, floatY: Double, focusMode: Double) {
|
|
43
|
-
impl.setFocus(floatX.toFloat(), floatY.toFloat(), focusMode.toInt())
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
override fun getFocusMode(promise: Promise) {
|
|
48
|
-
impl.getFocusMode(promise)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
override fun setZoomFactor(factor: Double) {
|
|
52
|
-
impl.setZoomFactor(factor.toFloat())
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
override fun getZoomFactor(promise: Promise) {
|
|
56
|
-
impl.getZoomFactor(promise)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
override fun enableEnhancedFeatures(features: Double) {
|
|
60
|
-
impl.enableEnhancedFeatures(features.toInt())
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
override fun disableEnhancedFeatures(features: Double) {
|
|
64
|
-
impl.disableEnhancedFeatures(features.toInt())
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
override fun setScanRegion(region: ReadableMap?) {
|
|
68
|
-
impl.setScanRegion(region)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
override fun getScanRegion(promise: Promise) {
|
|
72
|
-
impl.getScanRegion(promise)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
override fun turnOnTorch() {
|
|
76
|
-
impl.turnOnTorch()
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
override fun turnOffTorch() {
|
|
80
|
-
impl.turnOffTorch()
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
override fun beep() {
|
|
84
|
-
impl.beep()
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
override fun vibrate() {
|
|
88
|
-
impl.vibrate()
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
}
|