anyline-ocr-react-native-module 32.0.0 → 35.0.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/android/.gradle/6.5/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/6.5/fileChanges/last-build.bin +0 -0
- package/android/.gradle/6.5/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/6.5/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/6.5/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/caches/build_file_checksums.ser +0 -0
- package/android/.idea/compiler.xml +6 -0
- package/android/.idea/gradle.xml +21 -0
- package/android/.idea/jarRepositories.xml +30 -0
- package/android/.idea/libraries/Gradle__androidx_activity_activity_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_annotation_annotation_1_2_0.xml +11 -0
- package/android/.idea/libraries/Gradle__androidx_annotation_annotation_experimental_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_2_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_2_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_arch_core_core_common_2_1_0.xml +11 -0
- package/android/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_cardview_cardview_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_collection_collection_1_1_0.xml +11 -0
- package/android/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_2_0_1_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_solver_2_0_1.xml +9 -0
- package/android/.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_1_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_core_core_1_5_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_documentfile_documentfile_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_dynamicanimation_dynamicanimation_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_exifinterface_exifinterface_1_0_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_fragment_fragment_1_1_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_utils_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_1_0.xml +11 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_1_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_1_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_localbroadcastmanager_localbroadcastmanager_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_multidex_multidex_2_0_1_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_print_print_1_0_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_recyclerview_recyclerview_1_1_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_transition_transition_1_2_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_1_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_1_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_1_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_viewpager2_viewpager2_1_0_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__com_android_support_appcompat_v7_23_0_1_aar.xml +18 -0
- package/android/.idea/libraries/Gradle__com_android_support_recyclerview_v7_23_0_1_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_android_support_support_annotations_23_0_1.xml +13 -0
- package/android/.idea/libraries/Gradle__com_android_support_support_v4_23_0_1_aar.xml +19 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_drawee_0_8_1_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_fbcore_0_8_1_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_fresco_0_8_1_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_0_8_1_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_okhttp_0_8_1_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_react_react_native_0_20_1_aar.xml +19 -0
- package/android/.idea/libraries/Gradle__com_facebook_stetho_stetho_1_2_0.xml +13 -0
- package/android/.idea/libraries/Gradle__com_facebook_stetho_stetho_okhttp_1_2_0.xml +13 -0
- package/android/.idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_core_2_2_3.xml +13 -0
- package/android/.idea/libraries/Gradle__com_google_android_datatransport_transport_api_2_2_1_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__com_google_android_datatransport_transport_backend_cct_2_3_2_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__com_google_android_datatransport_transport_runtime_2_2_5_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_base_17_6_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_basement_17_6_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_clearcut_17_0_0_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_mlkit_barcode_scanning_16_1_4_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_phenotype_17_0_0_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_tasks_17_2_1_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__com_google_android_material_material_1_4_0_rc01_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_2.xml +13 -0
- package/android/.idea/libraries/Gradle__com_google_firebase_firebase_components_16_0_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_google_firebase_firebase_encoders_16_1_0.xml +13 -0
- package/android/.idea/libraries/Gradle__com_google_firebase_firebase_encoders_json_17_1_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_google_mlkit_barcode_scanning_16_1_1_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__com_google_mlkit_common_17_1_1_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__com_google_mlkit_vision_common_16_3_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__com_nineoldandroids_library_2_4_0.xml +13 -0
- package/android/.idea/libraries/Gradle__com_parse_bolts_bolts_android_1_1_4.xml +13 -0
- package/android/.idea/libraries/Gradle__com_squareup_okhttp_okhttp_2_5_0.xml +13 -0
- package/android/.idea/libraries/Gradle__com_squareup_okhttp_okhttp_ws_2_5_0.xml +13 -0
- package/android/.idea/libraries/Gradle__com_squareup_okio_okio_1_6_0.xml +13 -0
- package/android/.idea/libraries/Gradle__commons_cli_commons_cli_1_2.xml +13 -0
- package/android/.idea/libraries/Gradle__io_anyline_anylinesdk_34_0_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__javax_inject_javax_inject_1.xml +13 -0
- package/android/.idea/libraries/Gradle__org_webkit_android_jsc_r174650_aar.xml +11 -0
- package/android/.idea/misc.xml +9 -0
- package/android/.idea/modules/android.iml +120 -0
- package/android/.idea/modules.xml +8 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/.idea/workspace.xml +53 -0
- package/android/.settings/org.eclipse.buildship.core.prefs +11 -0
- package/android/build.gradle +1 -1
- package/android/local.properties +8 -0
- package/android/src/main/java/com/anyline/reactnative/Anyline4Activity.java +109 -47
- package/android/src/main/java/com/anyline/reactnative/Offset.java +21 -0
- package/android/src/main/java/com/anyline/reactnative/RotateButtonConfig.java +22 -0
- package/ios/ALPluginHelper.m +7 -4
- package/ios/ALPluginScanViewController.m +4 -0
- package/ios/AnylineReact.podspec +1 -1
- package/ios/AnylineSDKPlugin.m +16 -6
- package/package.json +9 -9
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.anyline.reactnative;
|
|
2
2
|
|
|
3
|
+
import android.content.pm.ActivityInfo;
|
|
3
4
|
import android.content.res.ColorStateList;
|
|
4
5
|
import android.graphics.Rect;
|
|
5
6
|
import android.os.Build;
|
|
@@ -7,6 +8,7 @@ import android.os.Bundle;
|
|
|
7
8
|
import android.os.Handler;
|
|
8
9
|
import android.util.Log;
|
|
9
10
|
import android.view.View;
|
|
11
|
+
import android.widget.Button;
|
|
10
12
|
import android.widget.RadioButton;
|
|
11
13
|
import android.widget.RadioGroup;
|
|
12
14
|
import android.widget.RelativeLayout;
|
|
@@ -30,8 +32,10 @@ import io.anyline.camera.CameraController;
|
|
|
30
32
|
import io.anyline.plugin.ScanResult;
|
|
31
33
|
import io.anyline.plugin.ScanResultListener;
|
|
32
34
|
import io.anyline.plugin.barcode.Barcode;
|
|
35
|
+
import io.anyline.plugin.barcode.BarcodeScanPlugin;
|
|
33
36
|
import io.anyline.plugin.barcode.BarcodeScanResult;
|
|
34
37
|
import io.anyline.plugin.barcode.BarcodeScanViewPlugin;
|
|
38
|
+
import io.anyline.plugin.barcode.PDF417;
|
|
35
39
|
import io.anyline.plugin.id.DrivingLicenseConfig;
|
|
36
40
|
import io.anyline.plugin.id.DrivingLicenseIdentification;
|
|
37
41
|
import io.anyline.plugin.id.GermanIdFrontConfig;
|
|
@@ -56,7 +60,6 @@ import io.anyline.view.ParallelScanViewComposite;
|
|
|
56
60
|
import io.anyline.view.ScanView;
|
|
57
61
|
import io.anyline.view.SerialScanViewComposite;
|
|
58
62
|
|
|
59
|
-
//import at.nineyards.anyline.modules.mrz.Identification;
|
|
60
63
|
|
|
61
64
|
public class Anyline4Activity extends AnylineBaseActivity {
|
|
62
65
|
private static final String TAG = Anyline4Activity.class.getSimpleName();
|
|
@@ -67,6 +70,7 @@ public class Anyline4Activity extends AnylineBaseActivity {
|
|
|
67
70
|
private AnylineUIConfig anylineUIConfig;
|
|
68
71
|
private String cropAndTransformError;
|
|
69
72
|
private Boolean isFirstCameraOpen; // only if camera is opened the first time get coordinates of the cutout to avoid flickering when switching between analog and digital
|
|
73
|
+
private RelativeLayout parentLayout;
|
|
70
74
|
|
|
71
75
|
@Override
|
|
72
76
|
protected void onCreate(Bundle savedInstanceState) {
|
|
@@ -76,6 +80,13 @@ public class Anyline4Activity extends AnylineBaseActivity {
|
|
|
76
80
|
|
|
77
81
|
// init the scan view
|
|
78
82
|
anylineScanView = new ScanView(this, null);
|
|
83
|
+
parentLayout = new RelativeLayout(this);
|
|
84
|
+
|
|
85
|
+
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
|
|
86
|
+
RelativeLayout.LayoutParams.MATCH_PARENT,
|
|
87
|
+
RelativeLayout.LayoutParams.MATCH_PARENT);
|
|
88
|
+
parentLayout.addView(anylineScanView, layoutParams);
|
|
89
|
+
setContentView(parentLayout, layoutParams);
|
|
79
90
|
|
|
80
91
|
try {
|
|
81
92
|
// start initialize anyline
|
|
@@ -157,14 +168,15 @@ public class Anyline4Activity extends AnylineBaseActivity {
|
|
|
157
168
|
scanViewPlugin = anylineScanView.getScanViewPlugin();
|
|
158
169
|
}
|
|
159
170
|
|
|
171
|
+
if (shouldShowRotateButton(json)) {
|
|
172
|
+
RotateButtonConfig rotateButtonConfig = new RotateButtonConfig(json.getJSONObject("rotateButton"));
|
|
173
|
+
addRotateButtonToView(rotateButtonConfig);
|
|
174
|
+
}
|
|
175
|
+
|
|
160
176
|
if (scanViewPlugin != null) {
|
|
161
177
|
//set nativeBarcodeMode
|
|
162
178
|
AnylinePluginHelper.setNativeBarcodeMode(json, anylineScanView);
|
|
163
179
|
|
|
164
|
-
if (!(scanViewPlugin instanceof MeterScanViewPlugin)) {
|
|
165
|
-
setContentView(anylineScanView);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
180
|
if (scanViewPlugin instanceof SerialScanViewComposite || scanViewPlugin instanceof ParallelScanViewComposite) {
|
|
169
181
|
scanViewPlugin.addScanResultListener(new ScanResultListener() {
|
|
170
182
|
@Override
|
|
@@ -236,24 +248,7 @@ public class Anyline4Activity extends AnylineBaseActivity {
|
|
|
236
248
|
e.printStackTrace();
|
|
237
249
|
}
|
|
238
250
|
} else if (subResult instanceof BarcodeScanResult) {
|
|
239
|
-
|
|
240
|
-
List<Barcode> barcodeList = (List<Barcode>) subResult.getResult();
|
|
241
|
-
|
|
242
|
-
JSONArray barcodeArray = new JSONArray();
|
|
243
|
-
if (barcodeList.size() > 1) {
|
|
244
|
-
for (int i = 0; i < barcodeList.size(); i++) {
|
|
245
|
-
barcodeArray.put(barcodeList.get(i).toJSONObject());
|
|
246
|
-
}
|
|
247
|
-
JSONObject finalObject = new JSONObject();
|
|
248
|
-
finalObject.put("multiBarcodes", barcodeArray);
|
|
249
|
-
jsonResult = AnylinePluginHelper.jsonHelper(Anyline4Activity.this, subResult, finalObject);
|
|
250
|
-
} else {
|
|
251
|
-
jsonResult = AnylinePluginHelper.jsonHelper(Anyline4Activity.this, subResult, barcodeList.get(0).toJSONObject());
|
|
252
|
-
|
|
253
|
-
}
|
|
254
|
-
} catch (JSONException e) {
|
|
255
|
-
e.printStackTrace();
|
|
256
|
-
}
|
|
251
|
+
jsonResult = extractBarcodeResult(jsonResult, subResult);
|
|
257
252
|
} else if (subResult instanceof MeterScanResult) {
|
|
258
253
|
JSONObject jsonMeterResult = new JSONObject();
|
|
259
254
|
try {
|
|
@@ -276,7 +271,6 @@ public class Anyline4Activity extends AnylineBaseActivity {
|
|
|
276
271
|
});
|
|
277
272
|
} else if (scanViewPlugin instanceof LicensePlateScanViewPlugin) {
|
|
278
273
|
if (json.has("reportingEnabled")) {
|
|
279
|
-
//(IdScanViewPlugin) scanViewPlugin.setReportingEnabled(json.optBoolean("reportingEnabled", true));
|
|
280
274
|
(((IdScanViewPlugin) scanViewPlugin).getScanPlugin()).setReportingEnabled(json.optBoolean("reportingEnabled", true));
|
|
281
275
|
}
|
|
282
276
|
scanViewPlugin.addScanResultListener(new ScanResultListener<LicensePlateScanResult>() {
|
|
@@ -336,13 +330,11 @@ public class Anyline4Activity extends AnylineBaseActivity {
|
|
|
336
330
|
}
|
|
337
331
|
|
|
338
332
|
});
|
|
339
|
-
} else if (((IdScanPlugin) ((IdScanViewPlugin) scanViewPlugin).getScanPlugin())
|
|
340
|
-
.getIdConfig() instanceof DrivingLicenseConfig) {
|
|
333
|
+
} else if (((IdScanPlugin) ((IdScanViewPlugin) scanViewPlugin).getScanPlugin()).getIdConfig() instanceof DrivingLicenseConfig) {
|
|
341
334
|
scanViewPlugin.addScanResultListener(new ScanResultListener<ScanResult<ID>>() {
|
|
342
335
|
@Override
|
|
343
336
|
public void onResult(ScanResult<ID> idScanResult) {
|
|
344
|
-
JSONObject jsonResult = ((DrivingLicenseIdentification) idScanResult.getResult())
|
|
345
|
-
.toJSONObject();
|
|
337
|
+
JSONObject jsonResult = ((DrivingLicenseIdentification) idScanResult.getResult()).toJSONObject();
|
|
346
338
|
|
|
347
339
|
try {
|
|
348
340
|
jsonResult = AnylinePluginHelper.jsonHelper(Anyline4Activity.this, idScanResult,
|
|
@@ -395,7 +387,6 @@ public class Anyline4Activity extends AnylineBaseActivity {
|
|
|
395
387
|
}
|
|
396
388
|
} else if (scanViewPlugin instanceof OcrScanViewPlugin) {
|
|
397
389
|
if (json.has("reportingEnabled")) {
|
|
398
|
-
//scanViewPlugin.setReportingEnabled(json.optBoolean("reportingEnabled", true));
|
|
399
390
|
(((OcrScanViewPlugin) scanViewPlugin).getScanPlugin()).setReportingEnabled(json.optBoolean("reportingEnabled", true));
|
|
400
391
|
}
|
|
401
392
|
|
|
@@ -418,6 +409,9 @@ public class Anyline4Activity extends AnylineBaseActivity {
|
|
|
418
409
|
|
|
419
410
|
} else if (scanViewPlugin instanceof BarcodeScanViewPlugin) {
|
|
420
411
|
|
|
412
|
+
if (shouldEnablePDF417(json)) {
|
|
413
|
+
((BarcodeScanPlugin) ((BarcodeScanViewPlugin) scanViewPlugin).getScanPlugin()).enablePDF417Parsing();
|
|
414
|
+
}
|
|
421
415
|
scanViewPlugin.addScanResultListener(new ScanResultListener<BarcodeScanResult>() {
|
|
422
416
|
@Override
|
|
423
417
|
public void onResult(BarcodeScanResult barcodeScanResult) {
|
|
@@ -432,6 +426,11 @@ public class Anyline4Activity extends AnylineBaseActivity {
|
|
|
432
426
|
barcode.put("value", barcodeList.get(i).getValue());
|
|
433
427
|
barcode.put("barcodeFormat", barcodeList.get(i).getBarcodeFormat());
|
|
434
428
|
|
|
429
|
+
PDF417 pdf417 = barcodeList.get(i).getParsedPDF417();
|
|
430
|
+
|
|
431
|
+
if(pdf417 != null) {
|
|
432
|
+
barcode.put("parsedPDF417", pdf417.toJSONObject());
|
|
433
|
+
}
|
|
435
434
|
barcodeArray.put(barcode);
|
|
436
435
|
}
|
|
437
436
|
JSONObject finalObject = new JSONObject();
|
|
@@ -451,12 +450,11 @@ public class Anyline4Activity extends AnylineBaseActivity {
|
|
|
451
450
|
|
|
452
451
|
} else if (scanViewPlugin instanceof MeterScanViewPlugin) {
|
|
453
452
|
if (json.has("reportingEnabled")) {
|
|
454
|
-
//scanViewPlugin.setReportingEnabled(json.optBoolean("reportingEnabled", true));
|
|
455
453
|
(((MeterScanViewPlugin) scanViewPlugin).getScanPlugin()).setReportingEnabled(json.optBoolean("reportingEnabled", true));
|
|
456
454
|
|
|
457
455
|
}
|
|
458
456
|
// create the radio button for the UI
|
|
459
|
-
|
|
457
|
+
addSegmentRadioButtonUI(json);
|
|
460
458
|
|
|
461
459
|
anylineScanView.setCameraOpenListener(this);
|
|
462
460
|
scanViewPlugin.addScanResultListener(new ScanResultListener<MeterScanResult>() {
|
|
@@ -492,6 +490,42 @@ public class Anyline4Activity extends AnylineBaseActivity {
|
|
|
492
490
|
|
|
493
491
|
}
|
|
494
492
|
|
|
493
|
+
private boolean shouldEnablePDF417(JSONObject jsonObject) {
|
|
494
|
+
JSONObject viewPlugin = jsonObject.optJSONObject("viewPlugin");
|
|
495
|
+
|
|
496
|
+
if (viewPlugin != null) {
|
|
497
|
+
JSONObject plugin = viewPlugin.optJSONObject("plugin");
|
|
498
|
+
|
|
499
|
+
if (plugin != null) {
|
|
500
|
+
JSONObject barcodePlugin = plugin.optJSONObject("barcodePlugin");
|
|
501
|
+
return barcodePlugin != null && barcodePlugin.optBoolean("enablePDF417Parsing");
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
return false;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
private JSONObject extractBarcodeResult(JSONObject jsonResult, ScanResult subResult) {
|
|
508
|
+
try {
|
|
509
|
+
List<Barcode> barcodeList = (List<Barcode>) subResult.getResult();
|
|
510
|
+
|
|
511
|
+
JSONArray barcodeArray = new JSONArray();
|
|
512
|
+
if (barcodeList.size() > 1) {
|
|
513
|
+
for (int i = 0; i < barcodeList.size(); i++) {
|
|
514
|
+
barcodeArray.put(barcodeList.get(i).toJSONObject());
|
|
515
|
+
}
|
|
516
|
+
JSONObject finalObject = new JSONObject();
|
|
517
|
+
finalObject.put("multiBarcodes", barcodeArray);
|
|
518
|
+
jsonResult = AnylinePluginHelper.jsonHelper(Anyline4Activity.this, subResult, finalObject);
|
|
519
|
+
} else {
|
|
520
|
+
jsonResult = AnylinePluginHelper.jsonHelper(Anyline4Activity.this, subResult, barcodeList.get(0).toJSONObject());
|
|
521
|
+
|
|
522
|
+
}
|
|
523
|
+
} catch (JSONException e) {
|
|
524
|
+
e.printStackTrace();
|
|
525
|
+
}
|
|
526
|
+
return jsonResult;
|
|
527
|
+
}
|
|
528
|
+
|
|
495
529
|
// this method is used only for the meter scanning which contains radio buttons
|
|
496
530
|
@Override
|
|
497
531
|
public void onCameraOpened(CameraController cameraController, int width, int height) {
|
|
@@ -523,20 +557,21 @@ public class Anyline4Activity extends AnylineBaseActivity {
|
|
|
523
557
|
});
|
|
524
558
|
}
|
|
525
559
|
|
|
526
|
-
private void
|
|
527
|
-
|
|
560
|
+
private void addSegmentRadioButtonUI(JSONObject json) {
|
|
528
561
|
final String scanModeString = ((MeterScanViewPlugin) scanViewPlugin).getScanMode().toString();
|
|
529
562
|
anylineUIConfig = new AnylineUIConfig(this, json);
|
|
530
563
|
|
|
531
|
-
|
|
532
|
-
final RelativeLayout relativeLayout = new RelativeLayout(this);
|
|
564
|
+
RadioGroup radioGroup = createRadioGroup(anylineUIConfig, scanModeString);
|
|
533
565
|
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
566
|
+
if (radioGroup != null) {
|
|
567
|
+
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
|
|
568
|
+
RelativeLayout.LayoutParams.WRAP_CONTENT);
|
|
569
|
+
lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
|
|
570
|
+
parentLayout.addView(radioGroup, lp);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
539
573
|
|
|
574
|
+
private RadioGroup createRadioGroup(AnylineUIConfig anylineUIConfig, String scanModeString) {
|
|
540
575
|
ArrayList<String> titles = anylineUIConfig.getTitles();
|
|
541
576
|
final ArrayList<String> modes = anylineUIConfig.getModes();
|
|
542
577
|
|
|
@@ -573,7 +608,6 @@ public class Anyline4Activity extends AnylineBaseActivity {
|
|
|
573
608
|
View button = group.findViewById(checkedId);
|
|
574
609
|
String mode = modes.get(group.indexOfChild(button));
|
|
575
610
|
((MeterScanViewPlugin) scanViewPlugin).setScanMode(MeterScanMode.valueOf(mode));
|
|
576
|
-
//anylineScanView.releaseCameraInBackground();
|
|
577
611
|
anylineScanView.stop();
|
|
578
612
|
try {
|
|
579
613
|
Thread.sleep(100);
|
|
@@ -584,16 +618,44 @@ public class Anyline4Activity extends AnylineBaseActivity {
|
|
|
584
618
|
}
|
|
585
619
|
});
|
|
586
620
|
|
|
587
|
-
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
|
|
588
|
-
RelativeLayout.LayoutParams.WRAP_CONTENT);
|
|
589
|
-
lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
|
|
590
|
-
|
|
591
621
|
radioGroup.setVisibility(View.INVISIBLE);
|
|
622
|
+
return radioGroup;
|
|
623
|
+
}
|
|
624
|
+
return null;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
private void addRotateButtonToView(RotateButtonConfig rotateButtonConfig) {
|
|
628
|
+
Button button = new Button(this);
|
|
629
|
+
button.setText("Rotate");
|
|
630
|
+
button.setOnClickListener(new View.OnClickListener() {
|
|
592
631
|
|
|
593
|
-
|
|
632
|
+
@Override
|
|
633
|
+
public void onClick(View v) {
|
|
634
|
+
if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
|
|
635
|
+
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
|
636
|
+
} else if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
|
|
637
|
+
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
RelativeLayout.LayoutParams buttonLayoutParams = new RelativeLayout.LayoutParams(
|
|
643
|
+
RelativeLayout.LayoutParams.WRAP_CONTENT,
|
|
644
|
+
RelativeLayout.LayoutParams.WRAP_CONTENT);
|
|
645
|
+
|
|
646
|
+
if (rotateButtonConfig.hasOffset()) {
|
|
647
|
+
Offset offset = rotateButtonConfig.getOffset();
|
|
648
|
+
buttonLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
|
|
649
|
+
buttonLayoutParams.setMargins(offset.getX(), offset.getY(), 0, 0);
|
|
650
|
+
} else {
|
|
651
|
+
buttonLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
|
|
652
|
+
buttonLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
|
|
594
653
|
}
|
|
595
|
-
setContentView(relativeLayout, matchParentParams);
|
|
596
654
|
|
|
655
|
+
parentLayout.addView(button, buttonLayoutParams);
|
|
597
656
|
}
|
|
598
657
|
|
|
658
|
+
private boolean shouldShowRotateButton(JSONObject jsonObject) {
|
|
659
|
+
return jsonObject.has("rotateButton");
|
|
660
|
+
}
|
|
599
661
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
package com.anyline.reactnative;
|
|
2
|
+
|
|
3
|
+
import org.json.JSONObject;
|
|
4
|
+
|
|
5
|
+
public class Offset {
|
|
6
|
+
private int x;
|
|
7
|
+
private int y;
|
|
8
|
+
|
|
9
|
+
public Offset(JSONObject jsonObject) {
|
|
10
|
+
this.x = jsonObject.optInt("x", 0);
|
|
11
|
+
this.y = jsonObject.optInt("y", 0);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public int getX() {
|
|
15
|
+
return x;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public int getY() {
|
|
19
|
+
return y;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package com.anyline.reactnative;
|
|
2
|
+
|
|
3
|
+
import org.json.JSONException;
|
|
4
|
+
import org.json.JSONObject;
|
|
5
|
+
|
|
6
|
+
public class RotateButtonConfig {
|
|
7
|
+
private Offset offset = null;
|
|
8
|
+
|
|
9
|
+
public RotateButtonConfig(JSONObject jsonObject) throws JSONException {
|
|
10
|
+
if (jsonObject.has("offset")) {
|
|
11
|
+
offset = new Offset(jsonObject.getJSONObject("offset"));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public Offset getOffset() {
|
|
16
|
+
return offset;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public boolean hasOffset() {
|
|
20
|
+
return offset != null;
|
|
21
|
+
}
|
|
22
|
+
}
|
package/ios/ALPluginHelper.m
CHANGED
|
@@ -562,10 +562,13 @@
|
|
|
562
562
|
|
|
563
563
|
|
|
564
564
|
for(ALBarcode *barcode in scanResult.result) {
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
565
|
+
NSMutableDictionary *barcodeDictionary = @{ @"value":barcode.value,
|
|
566
|
+
@"barcodeFormat": [ALPluginHelper barcodeFormatFromString:barcode.barcodeFormat]}.mutableCopy;
|
|
567
|
+
if (barcode.parsedPDF417 != nil) {
|
|
568
|
+
NSString *newValueWithPDF417 = [NSString stringWithFormat:@"{\"rawPDF417\" : \"%@\", \"parsedPDF417\" : \"%@\"}", barcode.value, [barcode.parsedPDF417[kPDF417ParsedBody] description]];
|
|
569
|
+
[barcodeDictionary setValue:newValueWithPDF417 forKey:@"value"];
|
|
570
|
+
}
|
|
571
|
+
[barcodeArray addObject:barcodeDictionary];
|
|
569
572
|
}
|
|
570
573
|
|
|
571
574
|
[dictResult setValue:barcodeArray forKey:@"barcodes"];
|
|
@@ -83,6 +83,10 @@
|
|
|
83
83
|
|
|
84
84
|
self.scanView.cameraConfig = [ALCameraConfig defaultCameraConfig];
|
|
85
85
|
}
|
|
86
|
+
|
|
87
|
+
if ([self.scanView.scanViewPlugin isKindOfClass:[ALBarcodeScanViewPlugin class]] && self.anylineConfig[@"viewPlugin"][@"plugin"][@"barcodePlugin"][@"enablePDF417Parsing"]) {
|
|
88
|
+
((ALBarcodeScanViewPlugin*)self.scanView.scanViewPlugin).barcodeScanPlugin.parsePDF417 = YES;
|
|
89
|
+
}
|
|
86
90
|
|
|
87
91
|
if(!self.scanView) {
|
|
88
92
|
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Could not start scanning" message:error.localizedDescription delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
|
package/ios/AnylineReact.podspec
CHANGED
|
@@ -19,6 +19,6 @@ Pod::Spec.new do |s|
|
|
|
19
19
|
s.source = { :git => "https://github.com/Anyline/anyline-ocr-react-native-module.git", :tag => "#{s.version}" }
|
|
20
20
|
|
|
21
21
|
s.source_files = "*.{h,m}"
|
|
22
|
-
s.dependency "Anyline", "~>
|
|
22
|
+
s.dependency "Anyline", "~> 35"
|
|
23
23
|
s.dependency "React"
|
|
24
24
|
end
|
package/ios/AnylineSDKPlugin.m
CHANGED
|
@@ -69,16 +69,26 @@ RCT_EXPORT_METHOD(getSDKVersion:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
|
|
|
69
69
|
|
|
70
70
|
-(void)initView:(NSString *)scanMode {
|
|
71
71
|
NSData *data = [self.config dataUsingEncoding:NSUTF8StringEncoding];
|
|
72
|
+
if(!data) {
|
|
73
|
+
[NSException raise:@"Config could not be loaded from disk" format:@"Config could not be loaded from disk"];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
NSError * error = nil;
|
|
72
77
|
id dictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
|
|
78
|
+
|
|
79
|
+
if(error) {
|
|
80
|
+
[NSException raise:@"Config could not be parsed to JSON" format:@"Config could not be parsed to JSON: %@", error.localizedDescription];
|
|
81
|
+
}
|
|
82
|
+
NSDictionary *optionsDictionary = [dictionary objectForKey:@"options"];
|
|
73
83
|
self.jsonConfigDictionary = dictionary;
|
|
74
84
|
|
|
75
85
|
self.appKey = [dictionary objectForKey:@"license"];
|
|
76
86
|
|
|
77
|
-
BOOL nativeBarcodeScanning = [[
|
|
87
|
+
BOOL nativeBarcodeScanning = [[optionsDictionary objectForKey:@"nativeBarcodeEnabled"] boolValue];
|
|
78
88
|
self.nativeBarcodeScanning = nativeBarcodeScanning ? nativeBarcodeScanning : NO;
|
|
79
89
|
|
|
80
|
-
self.jsonUIConf = [[ALJsonUIConfiguration alloc] initWithDictionary:
|
|
81
|
-
self.conf = [[ALScanViewPluginConfig alloc] initWithDictionary:
|
|
90
|
+
self.jsonUIConf = [[ALJsonUIConfiguration alloc] initWithDictionary:optionsDictionary];
|
|
91
|
+
self.conf = [[ALScanViewPluginConfig alloc] initWithDictionary:optionsDictionary];
|
|
82
92
|
self.conf.cancelOnResult = true;
|
|
83
93
|
self.ocrConfigDict = [dictionary objectForKey:@"ocr"];
|
|
84
94
|
|
|
@@ -103,7 +113,7 @@ RCT_EXPORT_METHOD(getSDKVersion:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
|
|
|
103
113
|
nfcScanViewController.cropAndTransformErrorMessage = str;
|
|
104
114
|
}
|
|
105
115
|
|
|
106
|
-
if ([
|
|
116
|
+
if ([optionsDictionary valueForKey:@"nativeBarcodeEnabled"]) {
|
|
107
117
|
nfcScanViewController.nativeBarcodeEnabled = [[self.jsonConfigDictionary objectForKey:@"nativeBarcodeEnabled"] boolValue];
|
|
108
118
|
}
|
|
109
119
|
|
|
@@ -133,7 +143,7 @@ RCT_EXPORT_METHOD(getSDKVersion:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
|
|
|
133
143
|
pluginScanViewController.cropAndTransformErrorMessage = str;
|
|
134
144
|
}
|
|
135
145
|
|
|
136
|
-
if ([
|
|
146
|
+
if ([optionsDictionary valueForKey:@"nativeBarcodeEnabled"]) {
|
|
137
147
|
pluginScanViewController.nativeBarcodeEnabled = [[self.jsonConfigDictionary objectForKey:@"nativeBarcodeEnabled"] boolValue];
|
|
138
148
|
}
|
|
139
149
|
|
|
@@ -158,7 +168,7 @@ RCT_EXPORT_METHOD(getSDKVersion:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
|
|
|
158
168
|
pluginScanViewController.cropAndTransformErrorMessage = str;
|
|
159
169
|
}
|
|
160
170
|
|
|
161
|
-
if ([
|
|
171
|
+
if ([optionsDictionary valueForKey:@"nativeBarcodeEnabled"]) {
|
|
162
172
|
pluginScanViewController.nativeBarcodeEnabled = [[self.jsonConfigDictionary objectForKey:@"nativeBarcodeEnabled"] boolValue];
|
|
163
173
|
}
|
|
164
174
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"_from": "anyline-ocr-react-native-module@^
|
|
3
|
-
"_id": "anyline-ocr-react-native-module@
|
|
2
|
+
"_from": "anyline-ocr-react-native-module@^35.0.0",
|
|
3
|
+
"_id": "anyline-ocr-react-native-module@35.0.0",
|
|
4
4
|
"_inBundle": false,
|
|
5
5
|
"_integrity": "sha512-BGi9zNkSsoxXywDBIqzgBRvKUBniQOJHDKBrozZubKthZNRBAj8Ry5tW0Me0yLXt/fauME//hbC0wsenfPJZqw==",
|
|
6
6
|
"_location": "/anyline-ocr-react-native-module",
|
|
@@ -8,19 +8,19 @@
|
|
|
8
8
|
"_requested": {
|
|
9
9
|
"type": "range",
|
|
10
10
|
"registry": true,
|
|
11
|
-
"raw": "anyline-ocr-react-native-module@^
|
|
11
|
+
"raw": "anyline-ocr-react-native-module@^35.0.0",
|
|
12
12
|
"name": "anyline-ocr-react-native-module",
|
|
13
13
|
"escapedName": "anyline-ocr-react-native-module",
|
|
14
|
-
"rawSpec": "^
|
|
14
|
+
"rawSpec": "^35.0.0",
|
|
15
15
|
"saveSpec": null,
|
|
16
|
-
"fetchSpec": "^
|
|
16
|
+
"fetchSpec": "^35.0.0"
|
|
17
17
|
},
|
|
18
18
|
"_requiredBy": [
|
|
19
19
|
"/"
|
|
20
20
|
],
|
|
21
|
-
"_resolved": "https://registry.npmjs.org/anyline-ocr-react-native-module/-/anyline-ocr-react-native-module-
|
|
22
|
-
"_shasum": "
|
|
23
|
-
"_spec": "anyline-ocr-react-native-module@^
|
|
21
|
+
"_resolved": "https://registry.npmjs.org/anyline-ocr-react-native-module/-/anyline-ocr-react-native-module-35.0.0.tgz",
|
|
22
|
+
"_shasum": "bacbcd260cc662244f59393ed81a6edba009b52c",
|
|
23
|
+
"_spec": "anyline-ocr-react-native-module@^35.0.0",
|
|
24
24
|
"_where": "/Users/amiransari/Projects/anyline-ocr-react-native-module1/example/RNExampleApp",
|
|
25
25
|
"bugs": {
|
|
26
26
|
"url": "https://github.com/Anyline/anyline-ocr-react-native-module/issues"
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"type": "git",
|
|
48
48
|
"url": "git+https://github.com/Anyline/anyline-ocr-react-native-module.git"
|
|
49
49
|
},
|
|
50
|
-
"version": "
|
|
50
|
+
"version": "35.0.0"
|
|
51
51
|
}
|