@regulaforensics/react-native-document-reader-api 6.4.0 → 6.6.0
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/RNDocumentReaderApi.podspec +1 -1
- package/android/build.gradle +4 -29
- package/android/src/main/AndroidManifest.xml +5 -1
- package/android/src/main/java/com/regula/documentreader/BluetoothUtil.kt +108 -0
- package/android/src/main/java/com/regula/documentreader/Helpers.java +5 -6
- package/android/src/main/java/com/regula/documentreader/JSONConstructor.java +171 -1389
- package/android/src/main/java/com/regula/documentreader/RNRegulaDocumentReaderModule.java +111 -26
- package/android/src/main/java/com/regula/documentreader/RegulaConfig.java +68 -7
- package/example/App.js +170 -168
- package/example/android/app/build.gradle +0 -6
- package/example/android/app/src/main/AndroidManifest.xml +2 -0
- package/example/android/build.gradle +5 -10
- package/example/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/example/ios/Podfile +8 -0
- package/example/metro.config.js +10 -8
- package/example/package.json +2 -2
- package/index.d.ts +3552 -3393
- package/index.js +3361 -3247
- package/ios/RGLWJSONConstructor.h +7 -0
- package/ios/RGLWJSONConstructor.m +124 -4
- package/ios/RNRegulaDocumentReader.m +85 -35
- package/ios/RegulaConfig.m +62 -7
- package/package.json +1 -1
|
@@ -22,6 +22,7 @@ import com.facebook.react.bridge.ReactMethod;
|
|
|
22
22
|
import com.facebook.react.bridge.ReadableArray;
|
|
23
23
|
import com.facebook.react.bridge.WritableMap;
|
|
24
24
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
25
|
+
import com.regula.documentreader.api.completions.ICheckDatabaseUpdate;
|
|
25
26
|
import com.regula.documentreader.api.completions.IDocumentReaderCompletion;
|
|
26
27
|
import com.regula.documentreader.api.completions.IDocumentReaderInitCompletion;
|
|
27
28
|
import com.regula.documentreader.api.completions.IDocumentReaderPrepareCompletion;
|
|
@@ -32,14 +33,15 @@ import com.regula.documentreader.api.completions.ITccParamsCompletion;
|
|
|
32
33
|
import com.regula.documentreader.api.enums.DocReaderAction;
|
|
33
34
|
import com.regula.documentreader.api.errors.DocumentReaderException;
|
|
34
35
|
import com.regula.documentreader.api.internal.core.CoreScenarioUtil;
|
|
36
|
+
import com.regula.documentreader.api.params.BleDeviceConfig;
|
|
35
37
|
import com.regula.documentreader.api.params.DocReaderConfig;
|
|
36
38
|
import com.regula.documentreader.api.params.ImageInputData;
|
|
37
|
-
import com.regula.documentreader.api.params.ImageInputParam;
|
|
39
|
+
import com.regula.documentreader.api.internal.params.ImageInputParam;
|
|
38
40
|
import com.regula.documentreader.api.params.rfid.PKDCertificate;
|
|
39
41
|
import com.regula.documentreader.api.params.rfid.authorization.PAResourcesIssuer;
|
|
40
42
|
import com.regula.documentreader.api.params.rfid.authorization.TAChallenge;
|
|
41
43
|
import com.regula.documentreader.api.results.DocumentReaderResults;
|
|
42
|
-
import com.regula.documentreader.api.parser.DocReaderResultsJsonParser;
|
|
44
|
+
import com.regula.documentreader.api.internal.parser.DocReaderResultsJsonParser;
|
|
43
45
|
|
|
44
46
|
import org.json.JSONArray;
|
|
45
47
|
import org.json.JSONException;
|
|
@@ -55,15 +57,21 @@ import static com.regula.documentreader.api.DocumentReader.Instance;
|
|
|
55
57
|
|
|
56
58
|
import androidx.annotation.NonNull;
|
|
57
59
|
|
|
58
|
-
@SuppressWarnings({"ConstantConditions", "RedundantSuppression"})
|
|
60
|
+
@SuppressWarnings({"ConstantConditions", "RedundantSuppression", "MissingPermission"})
|
|
59
61
|
public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule implements ActivityEventListener, LifecycleEventListener {
|
|
60
62
|
private final static String prepareDatabaseProgressChangeEvent = "prepareDatabaseProgressChangeEvent";
|
|
61
63
|
private final static String completionEvent = "completionEvent";
|
|
62
64
|
private final static String videoEncoderCompletionEvent = "videoEncoderCompletionEvent";
|
|
63
65
|
private final static String rfidNotificationCompletionEvent = "rfidNotificationCompletionEvent";
|
|
66
|
+
|
|
64
67
|
private final static String paCertificateCompletionEvent = "paCertificateCompletionEvent";
|
|
65
68
|
private final static String taCertificateCompletionEvent = "taCertificateCompletionEvent";
|
|
66
69
|
private final static String taSignatureCompletionEvent = "taSignatureCompletionEvent";
|
|
70
|
+
|
|
71
|
+
private final static String bleOnServiceConnectedEvent = "bleOnServiceConnectedEvent";
|
|
72
|
+
private final static String bleOnServiceDisconnectedEvent = "bleOnServiceDisconnectedEvent";
|
|
73
|
+
private final static String bleOnDeviceReadyEvent = "bleOnDeviceReadyEvent";
|
|
74
|
+
|
|
67
75
|
private static int databaseDownloadProgress = 0;
|
|
68
76
|
JSONArray data;
|
|
69
77
|
private final ReactContext reactContext;
|
|
@@ -124,40 +132,51 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
124
132
|
return (T) data.get(index);
|
|
125
133
|
}
|
|
126
134
|
|
|
127
|
-
|
|
135
|
+
static void send(ReactContext reactContext, String event, String data) {
|
|
128
136
|
WritableMap map = Arguments.createMap();
|
|
129
137
|
map.putString("msg", data);
|
|
130
138
|
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(event, map);
|
|
131
139
|
}
|
|
132
140
|
|
|
133
141
|
private void sendProgress(int progress) {
|
|
134
|
-
send(prepareDatabaseProgressChangeEvent, progress + "");
|
|
142
|
+
send(reactContext, prepareDatabaseProgressChangeEvent, progress + "");
|
|
135
143
|
}
|
|
136
144
|
|
|
137
145
|
private void sendCompletion(int action, DocumentReaderResults results, DocumentReaderException error) {
|
|
138
|
-
send(completionEvent, JSONConstructor.generateCompletion(action, results, error, getContext()).toString());
|
|
146
|
+
send(reactContext, completionEvent, JSONConstructor.generateCompletion(action, results, error, getContext()).toString());
|
|
139
147
|
}
|
|
140
148
|
|
|
141
149
|
private void sendVideoEncoderCompletion(String sessionId, File file) {
|
|
142
|
-
send(videoEncoderCompletionEvent, JSONConstructor.generateVideoEncoderCompletion(sessionId, file).toString());
|
|
150
|
+
send(reactContext, videoEncoderCompletionEvent, JSONConstructor.generateVideoEncoderCompletion(sessionId, file).toString());
|
|
143
151
|
}
|
|
144
152
|
|
|
145
153
|
private void sendIRfidNotificationCompletion(int notification, Bundle value) {
|
|
146
|
-
send(rfidNotificationCompletionEvent, JSONConstructor.generateRfidNotificationCompletion(notification, value).toString());
|
|
154
|
+
send(reactContext, rfidNotificationCompletionEvent, JSONConstructor.generateRfidNotificationCompletion(notification, value).toString());
|
|
147
155
|
}
|
|
148
156
|
|
|
149
157
|
private void sendPACertificateCompletion(byte[] serialNumber, PAResourcesIssuer issuer) {
|
|
150
|
-
send(paCertificateCompletionEvent, JSONConstructor.generatePACertificateCompletion(serialNumber, issuer).toString());
|
|
158
|
+
send(reactContext, paCertificateCompletionEvent, JSONConstructor.generatePACertificateCompletion(serialNumber, issuer).toString());
|
|
151
159
|
}
|
|
152
160
|
|
|
153
161
|
private void sendTACertificateCompletion(String keyCAR) {
|
|
154
|
-
send(taCertificateCompletionEvent, keyCAR);
|
|
162
|
+
send(reactContext, taCertificateCompletionEvent, keyCAR);
|
|
155
163
|
}
|
|
156
164
|
|
|
157
165
|
private void sendTASignatureCompletion(TAChallenge challenge) {
|
|
158
|
-
send(taSignatureCompletionEvent, JSONConstructor.generateTAChallenge(challenge).toString());
|
|
166
|
+
send(reactContext, taSignatureCompletionEvent, JSONConstructor.generateTAChallenge(challenge).toString());
|
|
159
167
|
}
|
|
160
168
|
|
|
169
|
+
private void sendBleOnServiceConnectedEvent(boolean isBleManagerConnected) {
|
|
170
|
+
send(reactContext, bleOnServiceConnectedEvent, isBleManagerConnected +"");
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
private void sendBleOnServiceDisconnectedEvent() {
|
|
174
|
+
send(reactContext, bleOnServiceDisconnectedEvent, "");
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
private void sendBleOnDeviceReadyEvent() {
|
|
178
|
+
send(reactContext, bleOnDeviceReadyEvent, "");
|
|
179
|
+
}
|
|
161
180
|
|
|
162
181
|
private interface Callback {
|
|
163
182
|
void success(Object o);
|
|
@@ -194,6 +213,18 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
194
213
|
case "initializeReaderAutomatically":
|
|
195
214
|
initializeReaderAutomatically(callback);
|
|
196
215
|
break;
|
|
216
|
+
case "isBlePermissionsGranted":
|
|
217
|
+
isBlePermissionsGranted(callback);
|
|
218
|
+
break;
|
|
219
|
+
case "startBluetoothService":
|
|
220
|
+
startBluetoothService(callback);
|
|
221
|
+
break;
|
|
222
|
+
case "initializeReaderBleDeviceConfig":
|
|
223
|
+
initializeReaderBleDeviceConfig(callback);
|
|
224
|
+
break;
|
|
225
|
+
case "getTag":
|
|
226
|
+
getTag(callback);
|
|
227
|
+
break;
|
|
197
228
|
case "getAPIVersion":
|
|
198
229
|
getAPIVersion(callback);
|
|
199
230
|
break;
|
|
@@ -314,6 +345,12 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
314
345
|
case "setCameraSessionIsPaused":
|
|
315
346
|
setCameraSessionIsPaused(callback, args(0));
|
|
316
347
|
break;
|
|
348
|
+
case "setTag":
|
|
349
|
+
setTag(callback, args(0));
|
|
350
|
+
break;
|
|
351
|
+
case "checkDatabaseUpdate":
|
|
352
|
+
checkDatabaseUpdate(callback, args(0));
|
|
353
|
+
break;
|
|
317
354
|
case "getScenario":
|
|
318
355
|
getScenario(callback, args(0));
|
|
319
356
|
break;
|
|
@@ -341,6 +378,9 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
341
378
|
case "recognizeImage":
|
|
342
379
|
recognizeImage(callback, args(0));
|
|
343
380
|
break;
|
|
381
|
+
case "recognizeData":
|
|
382
|
+
recognizeData(callback, args(0));
|
|
383
|
+
break;
|
|
344
384
|
case "setRfidSessionStatus":
|
|
345
385
|
setRfidSessionStatus(callback, args(0));
|
|
346
386
|
break;
|
|
@@ -359,9 +399,6 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
359
399
|
case "setTCCParams":
|
|
360
400
|
setTCCParams(callback, args(0));
|
|
361
401
|
break;
|
|
362
|
-
case "initializeReaderWithDatabase":
|
|
363
|
-
initializeReaderWithDatabase(callback, args(0), args(1));
|
|
364
|
-
break;
|
|
365
402
|
case "recognizeImageWithOpts":
|
|
366
403
|
recognizeImageWithOpts(callback, args(0), args(1));
|
|
367
404
|
break;
|
|
@@ -378,7 +415,8 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
378
415
|
recognizeImagesWithImageInputs(callback, args(0));
|
|
379
416
|
break;
|
|
380
417
|
}
|
|
381
|
-
} catch (Exception
|
|
418
|
+
} catch (Exception e) {
|
|
419
|
+
e.printStackTrace();
|
|
382
420
|
}
|
|
383
421
|
}
|
|
384
422
|
|
|
@@ -421,6 +459,37 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
421
459
|
callback.success("already initialized");
|
|
422
460
|
}
|
|
423
461
|
|
|
462
|
+
private void isBlePermissionsGranted(Callback callback) {
|
|
463
|
+
callback.success(BluetoothUtil.Companion.isBlePermissionsGranted(getActivity()));
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
private void startBluetoothService(Callback callback) {
|
|
467
|
+
BluetoothUtil.Companion.startBluetoothService(
|
|
468
|
+
getActivity(),
|
|
469
|
+
isBleManagerConnected -> {
|
|
470
|
+
sendBleOnServiceConnectedEvent(isBleManagerConnected);
|
|
471
|
+
return null;
|
|
472
|
+
},
|
|
473
|
+
() -> {
|
|
474
|
+
sendBleOnServiceDisconnectedEvent();
|
|
475
|
+
return null;
|
|
476
|
+
},
|
|
477
|
+
() -> {
|
|
478
|
+
sendBleOnDeviceReadyEvent();
|
|
479
|
+
return null;
|
|
480
|
+
}
|
|
481
|
+
);
|
|
482
|
+
callback.success();
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
private void initializeReaderBleDeviceConfig(Callback callback) {
|
|
486
|
+
if (BluetoothUtil.Companion.getBleManager() == null) callback.error("bleManager is null");
|
|
487
|
+
if (!Instance().isReady())
|
|
488
|
+
Instance().initializeReader(getContext(), new BleDeviceConfig(BluetoothUtil.Companion.getBleManager()), getInitCompletion(callback));
|
|
489
|
+
else
|
|
490
|
+
callback.success("already initialized");
|
|
491
|
+
}
|
|
492
|
+
|
|
424
493
|
private void getAvailableScenarios(Callback callback) throws JSONException {
|
|
425
494
|
callback.success(JSONConstructor.generateList(Instance().availableScenarios, JSONConstructor::generateDocumentReaderScenario).toString());
|
|
426
495
|
}
|
|
@@ -525,16 +594,9 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
525
594
|
callback.success(Instance().isRFIDAvailableForUse());
|
|
526
595
|
}
|
|
527
596
|
|
|
528
|
-
private void initializeReader(Callback callback,
|
|
597
|
+
private void initializeReader(Callback callback, JSONObject config) {
|
|
529
598
|
if (!Instance().isReady())
|
|
530
|
-
Instance().initializeReader(getContext(),
|
|
531
|
-
else
|
|
532
|
-
callback.success("already initialized");
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
private void initializeReaderWithDatabase(Callback callback, Object license, Object db) {
|
|
536
|
-
if (!Instance().isReady())
|
|
537
|
-
Instance().initializeReader(getContext(), new DocReaderConfig(Base64.decode(license.toString(), Base64.DEFAULT), Base64.decode(db.toString(), Base64.DEFAULT)), getInitCompletion(callback));
|
|
599
|
+
Instance().initializeReader(getContext(), JSONConstructor.DocReaderConfigFromJSON(config), getInitCompletion(callback));
|
|
538
600
|
else
|
|
539
601
|
callback.success("already initialized");
|
|
540
602
|
}
|
|
@@ -544,6 +606,20 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
544
606
|
callback.success();
|
|
545
607
|
}
|
|
546
608
|
|
|
609
|
+
private void getTag(Callback callback) {
|
|
610
|
+
callback.success(Instance().tag);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
private void setTag(Callback callback, String tag) {
|
|
614
|
+
Instance().tag = tag;
|
|
615
|
+
callback.success();
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
private void checkDatabaseUpdate(Callback callback, String databaseId) {
|
|
619
|
+
Instance().checkDatabaseUpdate(getContext(), databaseId, getCheckDatabaseUpdateCompletion(callback));
|
|
620
|
+
callback.success();
|
|
621
|
+
}
|
|
622
|
+
|
|
547
623
|
private void startNewPage(Callback callback) {
|
|
548
624
|
Instance().startNewPage();
|
|
549
625
|
callback.success();
|
|
@@ -559,6 +635,11 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
559
635
|
Instance().recognizeImage(Helpers.bitmapFromBase64(base64Image), getCompletion());
|
|
560
636
|
}
|
|
561
637
|
|
|
638
|
+
private void recognizeData(@SuppressWarnings("unused") Callback callback, Object data) {
|
|
639
|
+
stopBackgroundRFID();
|
|
640
|
+
Instance().recognizeImage(Base64.decode(data.toString(), Base64.DEFAULT), getCompletion());
|
|
641
|
+
}
|
|
642
|
+
|
|
562
643
|
private void recognizeImages(@SuppressWarnings("unused") Callback callback, JSONArray base64Images) throws JSONException {
|
|
563
644
|
stopBackgroundRFID();
|
|
564
645
|
Bitmap[] images = new Bitmap[base64Images.length()];
|
|
@@ -580,7 +661,7 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
580
661
|
}
|
|
581
662
|
|
|
582
663
|
private void cancelDBUpdate(Callback callback) {
|
|
583
|
-
callback.success(Instance().cancelDBUpdate());
|
|
664
|
+
callback.success(Instance().cancelDBUpdate(getContext()));
|
|
584
665
|
}
|
|
585
666
|
|
|
586
667
|
private void resetConfiguration(Callback callback) {
|
|
@@ -726,7 +807,7 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
726
807
|
callback.error("getCameraSessionIsPaused() is an ios-only method");
|
|
727
808
|
}
|
|
728
809
|
|
|
729
|
-
private void stopRFIDReaderWithErrorMessage(Callback callback, String message) {
|
|
810
|
+
private void stopRFIDReaderWithErrorMessage(Callback callback, @SuppressWarnings("unused") String message) {
|
|
730
811
|
callback.error("stopRFIDReaderWithErrorMessage() is an ios-only method");
|
|
731
812
|
}
|
|
732
813
|
|
|
@@ -782,6 +863,10 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
782
863
|
};
|
|
783
864
|
}
|
|
784
865
|
|
|
866
|
+
private ICheckDatabaseUpdate getCheckDatabaseUpdateCompletion(Callback callback) {
|
|
867
|
+
return (database) -> callback.success(JSONConstructor.generateDocReaderDocumentsDatabase(database));
|
|
868
|
+
}
|
|
869
|
+
|
|
785
870
|
private ITccParamsCompletion getTCCParamsCompletion(Callback callback) {
|
|
786
871
|
return (success, error) -> {
|
|
787
872
|
if (success)
|
|
@@ -6,11 +6,14 @@ import org.json.JSONException;
|
|
|
6
6
|
|
|
7
7
|
import com.regula.documentreader.api.DocumentReader;
|
|
8
8
|
import com.regula.documentreader.api.params.ImageQA;
|
|
9
|
+
import com.regula.documentreader.api.params.OnlineProcessingConfig;
|
|
9
10
|
import com.regula.documentreader.api.params.ParamsCustomization;
|
|
10
11
|
import com.regula.documentreader.api.params.Functionality;
|
|
11
12
|
import com.regula.documentreader.api.params.ProcessParam;
|
|
13
|
+
import com.regula.documentreader.api.params.rfid.ReprocParams;
|
|
12
14
|
import com.regula.documentreader.api.params.rfid.dg.DataGroups;
|
|
13
15
|
|
|
16
|
+
import android.annotation.SuppressLint;
|
|
14
17
|
import android.content.Context;
|
|
15
18
|
import android.graphics.Paint;
|
|
16
19
|
import android.text.SpannableString;
|
|
@@ -41,6 +44,7 @@ class RegulaConfig {
|
|
|
41
44
|
return object;
|
|
42
45
|
}
|
|
43
46
|
|
|
47
|
+
@SuppressLint("MissingPermission")
|
|
44
48
|
private static void setFunctionality(Functionality functionality, JSONObject opts) throws JSONException {
|
|
45
49
|
Functionality.FunctionalityEditor editor = functionality.edit();
|
|
46
50
|
if (opts.has("pictureOnBoundsReady"))
|
|
@@ -59,8 +63,6 @@ class RegulaConfig {
|
|
|
59
63
|
editor.setShowCaptureButtonDelayFromDetect(opts.getInt("showCaptureButtonDelayFromDetect"));
|
|
60
64
|
if (opts.has("showCaptureButtonDelayFromStart"))
|
|
61
65
|
editor.setShowCaptureButtonDelayFromStart(opts.getInt("showCaptureButtonDelayFromStart"));
|
|
62
|
-
if (opts.has("isOnlineMode"))
|
|
63
|
-
editor.setOnlineMode(opts.getBoolean("isOnlineMode"));
|
|
64
66
|
if (opts.has("databaseAutoupdate"))
|
|
65
67
|
editor.setDatabaseAutoupdate(opts.getBoolean("databaseAutoupdate"));
|
|
66
68
|
if (opts.has("showSkipNextPageButton"))
|
|
@@ -73,8 +75,6 @@ class RegulaConfig {
|
|
|
73
75
|
editor.setShowCameraSwitchButton(opts.getBoolean("showCameraSwitchButton"));
|
|
74
76
|
if (opts.has("cameraFrame"))
|
|
75
77
|
editor.setCameraFrame(opts.getString("cameraFrame"));
|
|
76
|
-
if (opts.has("serviceURL"))
|
|
77
|
-
editor.setServiceURL(opts.getString("serviceURL"));
|
|
78
78
|
if (opts.has("btDeviceName"))
|
|
79
79
|
editor.setBtDeviceName(opts.getString("btDeviceName"));
|
|
80
80
|
if (opts.has("orientation"))
|
|
@@ -105,6 +105,8 @@ class RegulaConfig {
|
|
|
105
105
|
editor.setExposure(BigDecimal.valueOf(opts.getDouble("exposure")).floatValue());
|
|
106
106
|
if (opts.has("rfidTimeout"))
|
|
107
107
|
editor.setRfidTimeout(opts.getInt("rfidTimeout"));
|
|
108
|
+
if (opts.has("onlineProcessingConfiguration"))
|
|
109
|
+
editor.setOnlineProcessingConfiguration(OnlineProcessingConfigFromJSON(opts.getJSONObject("onlineProcessingConfiguration")));
|
|
108
110
|
|
|
109
111
|
editor.apply();
|
|
110
112
|
}
|
|
@@ -213,6 +215,18 @@ class RegulaConfig {
|
|
|
213
215
|
processParams.parseBarcodes = opts.getBoolean("parseBarcodes");
|
|
214
216
|
if (opts.has("shouldReturnPackageForReprocess"))
|
|
215
217
|
processParams.shouldReturnPackageForReprocess = opts.getBoolean("shouldReturnPackageForReprocess");
|
|
218
|
+
if (opts.has("imageOutputMaxHeight"))
|
|
219
|
+
processParams.imageOutputMaxHeight = opts.getInt("imageOutputMaxHeight");
|
|
220
|
+
if (opts.has("imageOutputMaxWidth"))
|
|
221
|
+
processParams.imageOutputMaxWidth = opts.getInt("imageOutputMaxWidth");
|
|
222
|
+
if (opts.has("disablePerforationOCR"))
|
|
223
|
+
processParams.disablePerforationOCR = opts.getBoolean("disablePerforationOCR");
|
|
224
|
+
if (opts.has("documentGroupFilter"))
|
|
225
|
+
processParams.documentGroupFilter = intArrayFromJson(opts.getJSONArray("documentGroupFilter"));
|
|
226
|
+
if (opts.has("respectImageQuality"))
|
|
227
|
+
processParams.respectImageQuality = opts.getBoolean("respectImageQuality");
|
|
228
|
+
if (opts.has("splitNames"))
|
|
229
|
+
processParams.splitNames = opts.getBoolean("splitNames");
|
|
216
230
|
}
|
|
217
231
|
|
|
218
232
|
private static void setCustomization(ParamsCustomization customization, JSONObject opts, Context context) throws JSONException {
|
|
@@ -349,14 +363,12 @@ class RegulaConfig {
|
|
|
349
363
|
object.put("showChangeFrameButton", functionality.isShowChangeFrameButton());
|
|
350
364
|
object.put("showCaptureButtonDelayFromDetect", functionality.getShowCaptureButtonDelayFromDetect());
|
|
351
365
|
object.put("showCaptureButtonDelayFromStart", functionality.getShowCaptureButtonDelayFromStart());
|
|
352
|
-
object.put("isOnlineMode", functionality.isOnlineMode());
|
|
353
366
|
object.put("databaseAutoupdate", functionality.isDatabaseAutoupdate());
|
|
354
367
|
object.put("showSkipNextPageButton", functionality.isShowSkipNextPageButton());
|
|
355
368
|
object.put("useAuthenticator", functionality.isUseAuthenticator());
|
|
356
369
|
object.put("skipFocusingFrames", functionality.isSkipFocusingFrames());
|
|
357
370
|
object.put("showCameraSwitchButton", functionality.isShowCameraSwitchButton());
|
|
358
371
|
object.put("cameraFrame", functionality.getCameraFrame());
|
|
359
|
-
object.put("serviceURL", functionality.getServiceURL());
|
|
360
372
|
object.put("btDeviceName", functionality.getBtDeviceName());
|
|
361
373
|
object.put("orientation", functionality.getOrientation());
|
|
362
374
|
object.put("BTDeviceApiPresent", functionality.isBTDeviceApiPresent());
|
|
@@ -487,7 +499,7 @@ class RegulaConfig {
|
|
|
487
499
|
object.put("matchTextFieldMask", processParams.matchTextFieldMask);
|
|
488
500
|
object.put("fastDocDetect", processParams.fastDocDetect);
|
|
489
501
|
object.put("updateOCRValidityByGlare", processParams.updateOCRValidityByGlare);
|
|
490
|
-
object.put("imageQA", processParams.imageQA
|
|
502
|
+
object.put("imageQA", processParams.imageQA.toJsonObject());
|
|
491
503
|
object.put("forceDocFormat", processParams.forceDocFormat);
|
|
492
504
|
object.put("noGraphics", processParams.noGraphics);
|
|
493
505
|
object.put("documentAreaMin", processParams.documentAreaMin);
|
|
@@ -498,6 +510,12 @@ class RegulaConfig {
|
|
|
498
510
|
object.put("forceReadMrzBeforeLocate", processParams.forceReadMrzBeforeLocate);
|
|
499
511
|
object.put("parseBarcodes", processParams.parseBarcodes);
|
|
500
512
|
object.put("shouldReturnPackageForReprocess", processParams.shouldReturnPackageForReprocess);
|
|
513
|
+
object.put("imageOutputMaxHeight", processParams.imageOutputMaxHeight);
|
|
514
|
+
object.put("imageOutputMaxWidth", processParams.imageOutputMaxWidth);
|
|
515
|
+
object.put("disablePerforationOCR", processParams.disablePerforationOCR);
|
|
516
|
+
object.put("documentGroupFilter", generateIntArray(processParams.documentGroupFilter));
|
|
517
|
+
object.put("respectImageQuality", processParams.respectImageQuality);
|
|
518
|
+
object.put("splitNames", processParams.splitNames);
|
|
501
519
|
|
|
502
520
|
return object;
|
|
503
521
|
}
|
|
@@ -603,6 +621,10 @@ class RegulaConfig {
|
|
|
603
621
|
setDataGroups(DocumentReader.Instance().rfidScenario().eIDDataGroups(), opts.getJSONObject("eIDDataGroups"));
|
|
604
622
|
if (opts.has("eDLDataGroups"))
|
|
605
623
|
setDataGroups(DocumentReader.Instance().rfidScenario().eDLDataGroups(), opts.getJSONObject("eDLDataGroups"));
|
|
624
|
+
if (opts.has("reprocessParams"))
|
|
625
|
+
DocumentReader.Instance().rfidScenario().setReprocessParams(ReprocParamsFromJSON(opts.getJSONObject("reprocessParams")));
|
|
626
|
+
if (opts.has("defaultReadingBufferSize"))
|
|
627
|
+
DocumentReader.Instance().rfidScenario().setDefaultReadingBufferSize(opts.getInt("defaultReadingBufferSize"));
|
|
606
628
|
}
|
|
607
629
|
|
|
608
630
|
private static void setDataGroups(DataGroups dataGroup, JSONObject opts) throws JSONException {
|
|
@@ -649,4 +671,43 @@ class RegulaConfig {
|
|
|
649
671
|
if (opts.has("DG21"))
|
|
650
672
|
dataGroup.setDG14(opts.getBoolean("DG21"));
|
|
651
673
|
}
|
|
674
|
+
|
|
675
|
+
private static ReprocParams ReprocParamsFromJSON(JSONObject input) {
|
|
676
|
+
try {
|
|
677
|
+
ReprocParams result;
|
|
678
|
+
if (input.has("serviceUrl"))
|
|
679
|
+
result = new ReprocParams(input.getString("serviceUrl"));
|
|
680
|
+
else return null;
|
|
681
|
+
if (input.has("failIfNoService"))
|
|
682
|
+
result.setFailIfNoService(input.getBoolean("failIfNoService"));
|
|
683
|
+
return result;
|
|
684
|
+
} catch (JSONException e) {
|
|
685
|
+
e.printStackTrace();
|
|
686
|
+
}
|
|
687
|
+
return null;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
private static OnlineProcessingConfig OnlineProcessingConfigFromJSON(JSONObject input) {
|
|
691
|
+
try {
|
|
692
|
+
OnlineProcessingConfig.Builder builder;
|
|
693
|
+
if (input.has("mode"))
|
|
694
|
+
builder = new OnlineProcessingConfig.Builder(input.getInt("mode"));
|
|
695
|
+
else return null;
|
|
696
|
+
if (input.has("imageFormat"))
|
|
697
|
+
builder.setImageFormat(input.getInt("imageFormat"));
|
|
698
|
+
if (input.has("url"))
|
|
699
|
+
builder.setUrl(input.getString("url"));
|
|
700
|
+
if (input.has("imageCompressionQuality"))
|
|
701
|
+
builder.setImageCompressionQuality((float) input.getDouble("imageCompressionQuality"));
|
|
702
|
+
if (input.has("processParams")) {
|
|
703
|
+
ProcessParam params = new ProcessParam();
|
|
704
|
+
setProcessParams(params, input.getJSONObject("processParams"));
|
|
705
|
+
builder.setProcessParams(params);
|
|
706
|
+
}
|
|
707
|
+
return builder.build();
|
|
708
|
+
} catch (JSONException e) {
|
|
709
|
+
e.printStackTrace();
|
|
710
|
+
}
|
|
711
|
+
return null;
|
|
712
|
+
}
|
|
652
713
|
}
|