anyline-ocr-react-native-module 33.0.0 → 36.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.
Files changed (111) hide show
  1. package/android/.classpath +2 -2
  2. package/android/.gradle/6.5/executionHistory/executionHistory.lock +0 -0
  3. package/android/.gradle/6.5/fileChanges/last-build.bin +0 -0
  4. package/android/.gradle/6.5/fileHashes/fileHashes.bin +0 -0
  5. package/android/.gradle/6.5/fileHashes/fileHashes.lock +0 -0
  6. package/android/.gradle/6.5/gc.properties +0 -0
  7. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  8. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  9. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  10. package/android/.gradle/checksums/checksums.lock +0 -0
  11. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  12. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  13. package/android/.gradle/vcs-1/gc.properties +0 -0
  14. package/android/.idea/caches/build_file_checksums.ser +0 -0
  15. package/android/.idea/compiler.xml +6 -0
  16. package/android/.idea/gradle.xml +21 -0
  17. package/android/.idea/jarRepositories.xml +30 -0
  18. package/android/.idea/libraries/Gradle__androidx_activity_activity_1_0_0_aar.xml +13 -0
  19. package/android/.idea/libraries/Gradle__androidx_annotation_annotation_1_2_0.xml +11 -0
  20. package/android/.idea/libraries/Gradle__androidx_annotation_annotation_experimental_1_0_0_aar.xml +13 -0
  21. package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_2_0_aar.xml +16 -0
  22. package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_2_0_aar.xml +13 -0
  23. package/android/.idea/libraries/Gradle__androidx_arch_core_core_common_2_1_0.xml +11 -0
  24. package/android/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_0_0_aar.xml +13 -0
  25. package/android/.idea/libraries/Gradle__androidx_cardview_cardview_1_0_0_aar.xml +13 -0
  26. package/android/.idea/libraries/Gradle__androidx_collection_collection_1_1_0.xml +11 -0
  27. package/android/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_2_0_1_aar.xml +11 -0
  28. package/android/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_solver_2_0_1.xml +9 -0
  29. package/android/.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_1_0_aar.xml +16 -0
  30. package/android/.idea/libraries/Gradle__androidx_core_core_1_5_0_aar.xml +16 -0
  31. package/android/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml +13 -0
  32. package/android/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml +13 -0
  33. package/android/.idea/libraries/Gradle__androidx_documentfile_documentfile_1_0_0_aar.xml +13 -0
  34. package/android/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml +16 -0
  35. package/android/.idea/libraries/Gradle__androidx_dynamicanimation_dynamicanimation_1_0_0_aar.xml +13 -0
  36. package/android/.idea/libraries/Gradle__androidx_exifinterface_exifinterface_1_0_0_aar.xml +16 -0
  37. package/android/.idea/libraries/Gradle__androidx_fragment_fragment_1_1_0_aar.xml +16 -0
  38. package/android/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml +13 -0
  39. package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_utils_1_0_0_aar.xml +13 -0
  40. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_1_0.xml +11 -0
  41. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml +13 -0
  42. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_0_0_aar.xml +13 -0
  43. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_1_0_aar.xml +13 -0
  44. package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_1_0_aar.xml +13 -0
  45. package/android/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml +13 -0
  46. package/android/.idea/libraries/Gradle__androidx_localbroadcastmanager_localbroadcastmanager_1_0_0_aar.xml +13 -0
  47. package/android/.idea/libraries/Gradle__androidx_multidex_multidex_2_0_1_aar.xml +13 -0
  48. package/android/.idea/libraries/Gradle__androidx_print_print_1_0_0_aar.xml +16 -0
  49. package/android/.idea/libraries/Gradle__androidx_recyclerview_recyclerview_1_1_0_aar.xml +16 -0
  50. package/android/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_0_0_aar.xml +13 -0
  51. package/android/.idea/libraries/Gradle__androidx_transition_transition_1_2_0_aar.xml +16 -0
  52. package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_1_0_aar.xml +13 -0
  53. package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_1_0_aar.xml +13 -0
  54. package/android/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_1_aar.xml +13 -0
  55. package/android/.idea/libraries/Gradle__androidx_viewpager2_viewpager2_1_0_0_aar.xml +16 -0
  56. package/android/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml +13 -0
  57. package/android/.idea/libraries/Gradle__com_android_support_appcompat_v7_23_0_1_aar.xml +18 -0
  58. package/android/.idea/libraries/Gradle__com_android_support_recyclerview_v7_23_0_1_aar.xml +15 -0
  59. package/android/.idea/libraries/Gradle__com_android_support_support_annotations_23_0_1.xml +13 -0
  60. package/android/.idea/libraries/Gradle__com_android_support_support_v4_23_0_1_aar.xml +19 -0
  61. package/android/.idea/libraries/Gradle__com_facebook_fresco_drawee_0_8_1_aar.xml +15 -0
  62. package/android/.idea/libraries/Gradle__com_facebook_fresco_fbcore_0_8_1_aar.xml +15 -0
  63. package/android/.idea/libraries/Gradle__com_facebook_fresco_fresco_0_8_1_aar.xml +15 -0
  64. package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_0_8_1_aar.xml +15 -0
  65. package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_okhttp_0_8_1_aar.xml +15 -0
  66. package/android/.idea/libraries/Gradle__com_facebook_react_react_native_0_20_1_aar.xml +19 -0
  67. package/android/.idea/libraries/Gradle__com_facebook_stetho_stetho_1_2_0.xml +13 -0
  68. package/android/.idea/libraries/Gradle__com_facebook_stetho_stetho_okhttp_1_2_0.xml +13 -0
  69. package/android/.idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_core_2_2_3.xml +13 -0
  70. package/android/.idea/libraries/Gradle__com_google_android_datatransport_transport_api_2_2_1_aar.xml +13 -0
  71. package/android/.idea/libraries/Gradle__com_google_android_datatransport_transport_backend_cct_2_3_2_aar.xml +13 -0
  72. package/android/.idea/libraries/Gradle__com_google_android_datatransport_transport_runtime_2_2_5_aar.xml +13 -0
  73. package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_base_17_6_0_aar.xml +13 -0
  74. package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_basement_17_6_0_aar.xml +13 -0
  75. package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_clearcut_17_0_0_aar.xml +11 -0
  76. package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_mlkit_barcode_scanning_16_1_4_aar.xml +13 -0
  77. package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_phenotype_17_0_0_aar.xml +11 -0
  78. package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_tasks_17_2_1_aar.xml +13 -0
  79. package/android/.idea/libraries/Gradle__com_google_android_material_material_1_4_0_rc01_aar.xml +16 -0
  80. package/android/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_2.xml +13 -0
  81. package/android/.idea/libraries/Gradle__com_google_firebase_firebase_components_16_0_0_aar.xml +15 -0
  82. package/android/.idea/libraries/Gradle__com_google_firebase_firebase_encoders_16_1_0.xml +13 -0
  83. package/android/.idea/libraries/Gradle__com_google_firebase_firebase_encoders_json_17_1_0_aar.xml +15 -0
  84. package/android/.idea/libraries/Gradle__com_google_mlkit_barcode_scanning_16_1_1_aar.xml +13 -0
  85. package/android/.idea/libraries/Gradle__com_google_mlkit_common_17_1_1_aar.xml +13 -0
  86. package/android/.idea/libraries/Gradle__com_google_mlkit_vision_common_16_3_0_aar.xml +13 -0
  87. package/android/.idea/libraries/Gradle__com_nineoldandroids_library_2_4_0.xml +13 -0
  88. package/android/.idea/libraries/Gradle__com_parse_bolts_bolts_android_1_1_4.xml +13 -0
  89. package/android/.idea/libraries/Gradle__com_squareup_okhttp_okhttp_2_5_0.xml +13 -0
  90. package/android/.idea/libraries/Gradle__com_squareup_okhttp_okhttp_ws_2_5_0.xml +13 -0
  91. package/android/.idea/libraries/Gradle__com_squareup_okio_okio_1_6_0.xml +13 -0
  92. package/android/.idea/libraries/Gradle__commons_cli_commons_cli_1_2.xml +13 -0
  93. package/android/.idea/libraries/Gradle__io_anyline_anylinesdk_34_0_0_aar.xml +16 -0
  94. package/android/.idea/libraries/Gradle__javax_inject_javax_inject_1.xml +13 -0
  95. package/android/.idea/libraries/Gradle__org_webkit_android_jsc_r174650_aar.xml +11 -0
  96. package/android/.idea/misc.xml +9 -0
  97. package/android/.idea/modules/android.iml +120 -0
  98. package/android/.idea/modules.xml +8 -0
  99. package/android/.idea/vcs.xml +6 -0
  100. package/android/.idea/workspace.xml +53 -0
  101. package/android/.settings/org.eclipse.buildship.core.prefs +11 -0
  102. package/android/build.gradle +1 -1
  103. package/android/local.properties +8 -0
  104. package/android/src/main/java/com/anyline/reactnative/Anyline4Activity.java +131 -106
  105. package/android/src/main/java/com/anyline/reactnative/Offset.java +21 -0
  106. package/android/src/main/java/com/anyline/reactnative/RotateButtonConfig.java +22 -0
  107. package/ios/ALPluginHelper.m +8 -45
  108. package/ios/ALPluginScanViewController.m +4 -0
  109. package/ios/AnylineReact.podspec +1 -1
  110. package/ios/AnylineSDKPlugin.m +8 -8
  111. 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,12 +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;
35
- import io.anyline.plugin.id.DrivingLicenseConfig;
36
- import io.anyline.plugin.id.DrivingLicenseIdentification;
37
- import io.anyline.plugin.id.GermanIdFrontConfig;
38
- import io.anyline.plugin.id.GermanIdFrontIdentification;
38
+ import io.anyline.plugin.barcode.PDF417;
39
39
  import io.anyline.plugin.id.ID;
40
40
  import io.anyline.plugin.id.IdScanPlugin;
41
41
  import io.anyline.plugin.id.IdScanViewPlugin;
@@ -56,7 +56,6 @@ import io.anyline.view.ParallelScanViewComposite;
56
56
  import io.anyline.view.ScanView;
57
57
  import io.anyline.view.SerialScanViewComposite;
58
58
 
59
- //import at.nineyards.anyline.modules.mrz.Identification;
60
59
 
61
60
  public class Anyline4Activity extends AnylineBaseActivity {
62
61
  private static final String TAG = Anyline4Activity.class.getSimpleName();
@@ -67,15 +66,28 @@ public class Anyline4Activity extends AnylineBaseActivity {
67
66
  private AnylineUIConfig anylineUIConfig;
68
67
  private String cropAndTransformError;
69
68
  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
69
+ private RelativeLayout parentLayout;
70
+ private boolean defaultOrientationApplied;
71
+ private static final String KEY_DEFAULT_ORIENTATION_APPLIED = "default_orientation_applied";
70
72
 
71
73
  @Override
72
74
  protected void onCreate(Bundle savedInstanceState) {
73
75
  super.onCreate(savedInstanceState);
74
-
75
76
  isFirstCameraOpen = true;
76
77
 
77
78
  // init the scan view
78
79
  anylineScanView = new ScanView(this, null);
80
+ parentLayout = new RelativeLayout(this);
81
+
82
+ RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
83
+ RelativeLayout.LayoutParams.MATCH_PARENT,
84
+ RelativeLayout.LayoutParams.MATCH_PARENT);
85
+ parentLayout.addView(anylineScanView, layoutParams);
86
+ setContentView(parentLayout, layoutParams);
87
+
88
+ if (savedInstanceState != null) {
89
+ defaultOrientationApplied = savedInstanceState.getBoolean(KEY_DEFAULT_ORIENTATION_APPLIED);
90
+ }
79
91
 
80
92
  try {
81
93
  // start initialize anyline
@@ -87,6 +99,12 @@ public class Anyline4Activity extends AnylineBaseActivity {
87
99
  setDebugListener();
88
100
  }
89
101
 
102
+ @Override
103
+ protected void onSaveInstanceState(Bundle outState) {
104
+ super.onSaveInstanceState(outState);
105
+ outState.putBoolean(KEY_DEFAULT_ORIENTATION_APPLIED, defaultOrientationApplied);
106
+ }
107
+
90
108
  @Override
91
109
  protected void onResume() {
92
110
  super.onResume();
@@ -157,14 +175,17 @@ public class Anyline4Activity extends AnylineBaseActivity {
157
175
  scanViewPlugin = anylineScanView.getScanViewPlugin();
158
176
  }
159
177
 
178
+ if (shouldShowRotateButton(json)) {
179
+ RotateButtonConfig rotateButtonConfig = new RotateButtonConfig(json.getJSONObject("rotateButton"));
180
+ addRotateButtonToView(rotateButtonConfig);
181
+ }
182
+
183
+ setDefaultOrientation(json);
184
+
160
185
  if (scanViewPlugin != null) {
161
186
  //set nativeBarcodeMode
162
187
  AnylinePluginHelper.setNativeBarcodeMode(json, anylineScanView);
163
188
 
164
- if (!(scanViewPlugin instanceof MeterScanViewPlugin)) {
165
- setContentView(anylineScanView);
166
- }
167
-
168
189
  if (scanViewPlugin instanceof SerialScanViewComposite || scanViewPlugin instanceof ParallelScanViewComposite) {
169
190
  scanViewPlugin.addScanResultListener(new ScanResultListener() {
170
191
  @Override
@@ -200,27 +221,6 @@ public class Anyline4Activity extends AnylineBaseActivity {
200
221
  jsonIdResult = AnylinePluginHelper.jsonHelper(Anyline4Activity.this, subResult,
201
222
  jsonIdResult);
202
223
 
203
- jsonResult.put(subResult.getPluginId(), jsonIdResult);
204
- } catch (JSONException e) {
205
- e.printStackTrace();
206
- }
207
- } else if (subResult.getResult() instanceof DrivingLicenseIdentification) {
208
- JSONObject jsonIdResult = ((DrivingLicenseIdentification) subResult.getResult())
209
- .toJSONObject();
210
- try {
211
- jsonIdResult = AnylinePluginHelper.jsonHelper(Anyline4Activity.this, subResult,
212
- jsonIdResult);
213
-
214
- jsonResult.put(subResult.getPluginId(), jsonIdResult);
215
- } catch (JSONException e) {
216
- e.printStackTrace();
217
- }
218
- } else if (subResult.getResult() instanceof GermanIdFrontIdentification) {
219
- JSONObject jsonIdResult = ((GermanIdFrontIdentification) subResult.getResult()).toJSONObject();
220
- try {
221
- jsonIdResult = AnylinePluginHelper.jsonHelper(Anyline4Activity.this, subResult,
222
- jsonIdResult);
223
-
224
224
  jsonResult.put(subResult.getPluginId(), jsonIdResult);
225
225
  } catch (JSONException e) {
226
226
  e.printStackTrace();
@@ -236,24 +236,7 @@ public class Anyline4Activity extends AnylineBaseActivity {
236
236
  e.printStackTrace();
237
237
  }
238
238
  } else if (subResult instanceof BarcodeScanResult) {
239
- try {
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
- }
239
+ jsonResult = extractBarcodeResult(jsonResult, subResult);
257
240
  } else if (subResult instanceof MeterScanResult) {
258
241
  JSONObject jsonMeterResult = new JSONObject();
259
242
  try {
@@ -276,7 +259,6 @@ public class Anyline4Activity extends AnylineBaseActivity {
276
259
  });
277
260
  } else if (scanViewPlugin instanceof LicensePlateScanViewPlugin) {
278
261
  if (json.has("reportingEnabled")) {
279
- //(IdScanViewPlugin) scanViewPlugin.setReportingEnabled(json.optBoolean("reportingEnabled", true));
280
262
  (((IdScanViewPlugin) scanViewPlugin).getScanPlugin()).setReportingEnabled(json.optBoolean("reportingEnabled", true));
281
263
  }
282
264
  scanViewPlugin.addScanResultListener(new ScanResultListener<LicensePlateScanResult>() {
@@ -336,43 +318,6 @@ public class Anyline4Activity extends AnylineBaseActivity {
336
318
  }
337
319
 
338
320
  });
339
- } else if (((IdScanPlugin) ((IdScanViewPlugin) scanViewPlugin).getScanPlugin())
340
- .getIdConfig() instanceof DrivingLicenseConfig) {
341
- scanViewPlugin.addScanResultListener(new ScanResultListener<ScanResult<ID>>() {
342
- @Override
343
- public void onResult(ScanResult<ID> idScanResult) {
344
- JSONObject jsonResult = ((DrivingLicenseIdentification) idScanResult.getResult())
345
- .toJSONObject();
346
-
347
- try {
348
- jsonResult = AnylinePluginHelper.jsonHelper(Anyline4Activity.this, idScanResult,
349
- jsonResult);
350
- } catch (Exception e) {
351
- Log.e(TAG, "Exception is: ", e);
352
-
353
- }
354
-
355
- setResult(scanViewPlugin, jsonResult);
356
-
357
- }
358
-
359
- });
360
- } else if (((IdScanPlugin) ((IdScanViewPlugin) scanViewPlugin).getScanPlugin()).getIdConfig() instanceof GermanIdFrontConfig) {
361
- scanViewPlugin.addScanResultListener(new ScanResultListener<ScanResult<ID>>() {
362
- @Override
363
- public void onResult(ScanResult<ID> idScanResult) {
364
- JSONObject jsonResult = ((GermanIdFrontIdentification) idScanResult.getResult()).toJSONObject();
365
-
366
- try {
367
- jsonResult = AnylinePluginHelper.jsonHelper(Anyline4Activity.this, idScanResult,
368
- jsonResult);
369
- } catch (Exception e) {
370
- Log.e(TAG, "Exception is: ", e);
371
-
372
- }
373
- setResult(scanViewPlugin, jsonResult);
374
- }
375
- });
376
321
  } else if (((IdScanPlugin) ((IdScanViewPlugin) scanViewPlugin).getScanPlugin()).getIdConfig() instanceof UniversalIdConfig) {
377
322
  scanViewPlugin.addScanResultListener(new ScanResultListener<ScanResult<ID>>() {
378
323
  @Override
@@ -395,7 +340,6 @@ public class Anyline4Activity extends AnylineBaseActivity {
395
340
  }
396
341
  } else if (scanViewPlugin instanceof OcrScanViewPlugin) {
397
342
  if (json.has("reportingEnabled")) {
398
- //scanViewPlugin.setReportingEnabled(json.optBoolean("reportingEnabled", true));
399
343
  (((OcrScanViewPlugin) scanViewPlugin).getScanPlugin()).setReportingEnabled(json.optBoolean("reportingEnabled", true));
400
344
  }
401
345
 
@@ -418,6 +362,9 @@ public class Anyline4Activity extends AnylineBaseActivity {
418
362
 
419
363
  } else if (scanViewPlugin instanceof BarcodeScanViewPlugin) {
420
364
 
365
+ if (shouldEnablePDF417(json)) {
366
+ ((BarcodeScanPlugin) ((BarcodeScanViewPlugin) scanViewPlugin).getScanPlugin()).enablePDF417Parsing();
367
+ }
421
368
  scanViewPlugin.addScanResultListener(new ScanResultListener<BarcodeScanResult>() {
422
369
  @Override
423
370
  public void onResult(BarcodeScanResult barcodeScanResult) {
@@ -432,6 +379,11 @@ public class Anyline4Activity extends AnylineBaseActivity {
432
379
  barcode.put("value", barcodeList.get(i).getValue());
433
380
  barcode.put("barcodeFormat", barcodeList.get(i).getBarcodeFormat());
434
381
 
382
+ PDF417 pdf417 = barcodeList.get(i).getParsedPDF417();
383
+
384
+ if (pdf417 != null) {
385
+ barcode.put("parsedPDF417", pdf417.toJSONObject());
386
+ }
435
387
  barcodeArray.put(barcode);
436
388
  }
437
389
  JSONObject finalObject = new JSONObject();
@@ -451,12 +403,11 @@ public class Anyline4Activity extends AnylineBaseActivity {
451
403
 
452
404
  } else if (scanViewPlugin instanceof MeterScanViewPlugin) {
453
405
  if (json.has("reportingEnabled")) {
454
- //scanViewPlugin.setReportingEnabled(json.optBoolean("reportingEnabled", true));
455
406
  (((MeterScanViewPlugin) scanViewPlugin).getScanPlugin()).setReportingEnabled(json.optBoolean("reportingEnabled", true));
456
407
 
457
408
  }
458
409
  // create the radio button for the UI
459
- createSegmentRadioButtonUI(json);
410
+ addSegmentRadioButtonUI(json);
460
411
 
461
412
  anylineScanView.setCameraOpenListener(this);
462
413
  scanViewPlugin.addScanResultListener(new ScanResultListener<MeterScanResult>() {
@@ -489,7 +440,53 @@ public class Anyline4Activity extends AnylineBaseActivity {
489
440
  getString(getResources().getIdentifier("error_invalid_json_data", "string", getPackageName()))
490
441
  + "\n" + e.getLocalizedMessage());
491
442
  }
443
+ }
444
+
445
+ private void setDefaultOrientation(JSONObject jsonObject) {
446
+ if (defaultOrientationApplied) return;
447
+
448
+ if (jsonObject.has("defaultOrientation")
449
+ && jsonObject.optString("defaultOrientation").equals("landscape")
450
+ && getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
451
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
452
+ }
453
+ defaultOrientationApplied = true;
454
+ }
455
+
456
+ private boolean shouldEnablePDF417(JSONObject jsonObject) {
457
+ JSONObject viewPlugin = jsonObject.optJSONObject("viewPlugin");
458
+
459
+ if (viewPlugin != null) {
460
+ JSONObject plugin = viewPlugin.optJSONObject("plugin");
461
+
462
+ if (plugin != null) {
463
+ JSONObject barcodePlugin = plugin.optJSONObject("barcodePlugin");
464
+ return barcodePlugin != null && barcodePlugin.optBoolean("enablePDF417Parsing");
465
+ }
466
+ }
467
+ return false;
468
+ }
469
+
470
+ private JSONObject extractBarcodeResult(JSONObject jsonResult, ScanResult subResult) {
471
+ try {
472
+ List<Barcode> barcodeList = (List<Barcode>) subResult.getResult();
492
473
 
474
+ JSONArray barcodeArray = new JSONArray();
475
+ if (barcodeList.size() > 1) {
476
+ for (int i = 0; i < barcodeList.size(); i++) {
477
+ barcodeArray.put(barcodeList.get(i).toJSONObject());
478
+ }
479
+ JSONObject finalObject = new JSONObject();
480
+ finalObject.put("multiBarcodes", barcodeArray);
481
+ jsonResult = AnylinePluginHelper.jsonHelper(Anyline4Activity.this, subResult, finalObject);
482
+ } else {
483
+ jsonResult = AnylinePluginHelper.jsonHelper(Anyline4Activity.this, subResult, barcodeList.get(0).toJSONObject());
484
+
485
+ }
486
+ } catch (JSONException e) {
487
+ e.printStackTrace();
488
+ }
489
+ return jsonResult;
493
490
  }
494
491
 
495
492
  // this method is used only for the meter scanning which contains radio buttons
@@ -523,20 +520,21 @@ public class Anyline4Activity extends AnylineBaseActivity {
523
520
  });
524
521
  }
525
522
 
526
- private void createSegmentRadioButtonUI(JSONObject json) {
527
-
523
+ private void addSegmentRadioButtonUI(JSONObject json) {
528
524
  final String scanModeString = ((MeterScanViewPlugin) scanViewPlugin).getScanMode().toString();
529
525
  anylineUIConfig = new AnylineUIConfig(this, json);
530
526
 
531
- // Creating a new RelativeLayout
532
- final RelativeLayout relativeLayout = new RelativeLayout(this);
527
+ RadioGroup radioGroup = createRadioGroup(anylineUIConfig, scanModeString);
533
528
 
534
- // Defining the RelativeLayout layout parameters.
535
- // In this case I want to fill its parent
536
- RelativeLayout.LayoutParams matchParentParams = new RelativeLayout.LayoutParams(
537
- RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
538
- relativeLayout.addView(anylineScanView, matchParentParams);
529
+ if (radioGroup != null) {
530
+ RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
531
+ RelativeLayout.LayoutParams.WRAP_CONTENT);
532
+ lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
533
+ parentLayout.addView(radioGroup, lp);
534
+ }
535
+ }
539
536
 
537
+ private RadioGroup createRadioGroup(AnylineUIConfig anylineUIConfig, String scanModeString) {
540
538
  ArrayList<String> titles = anylineUIConfig.getTitles();
541
539
  final ArrayList<String> modes = anylineUIConfig.getModes();
542
540
 
@@ -573,7 +571,6 @@ public class Anyline4Activity extends AnylineBaseActivity {
573
571
  View button = group.findViewById(checkedId);
574
572
  String mode = modes.get(group.indexOfChild(button));
575
573
  ((MeterScanViewPlugin) scanViewPlugin).setScanMode(MeterScanMode.valueOf(mode));
576
- //anylineScanView.releaseCameraInBackground();
577
574
  anylineScanView.stop();
578
575
  try {
579
576
  Thread.sleep(100);
@@ -584,16 +581,44 @@ public class Anyline4Activity extends AnylineBaseActivity {
584
581
  }
585
582
  });
586
583
 
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
584
  radioGroup.setVisibility(View.INVISIBLE);
585
+ return radioGroup;
586
+ }
587
+ return null;
588
+ }
589
+
590
+ private void addRotateButtonToView(RotateButtonConfig rotateButtonConfig) {
591
+ Button button = new Button(this);
592
+ button.setText("Rotate");
593
+ button.setOnClickListener(new View.OnClickListener() {
592
594
 
593
- relativeLayout.addView(radioGroup, lp);
595
+ @Override
596
+ public void onClick(View v) {
597
+ if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
598
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
599
+ } else if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
600
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
601
+ }
602
+ }
603
+ });
604
+
605
+ RelativeLayout.LayoutParams buttonLayoutParams = new RelativeLayout.LayoutParams(
606
+ RelativeLayout.LayoutParams.WRAP_CONTENT,
607
+ RelativeLayout.LayoutParams.WRAP_CONTENT);
608
+
609
+ if (rotateButtonConfig.hasOffset()) {
610
+ Offset offset = rotateButtonConfig.getOffset();
611
+ buttonLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
612
+ buttonLayoutParams.setMargins(offset.getX(), offset.getY(), 0, 0);
613
+ } else {
614
+ buttonLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
615
+ buttonLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
594
616
  }
595
- setContentView(relativeLayout, matchParentParams);
596
617
 
618
+ parentLayout.addView(button, buttonLayoutParams);
597
619
  }
598
620
 
621
+ private boolean shouldShowRotateButton(JSONObject jsonObject) {
622
+ return jsonObject.has("rotateButton");
623
+ }
599
624
  }
@@ -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
+ }
@@ -423,46 +423,6 @@
423
423
  [dictResult setValue:[ALPluginHelper stringForDate:[scanResult.result dayOfBirthDateObject]] forKey:@"dateOfBirthObject"];
424
424
  [dictResult setValue:[ALPluginHelper stringForDate:[scanResult.result dateOfExpiryObject]] forKey:@"dateOfExpiryObject"];
425
425
  [dictResult setValue:confidences forKey:@"fieldConfidences"];
426
- } else if ([scanResult.result isKindOfClass:[ALDrivingLicenseIdentification class]]) {
427
- NSMutableArray<NSString *> *keys=[@[
428
- @"surname",
429
- @"givenNames",
430
- @"dateOfBirth",
431
- @"placeOfBirth",
432
- @"dateOfIssue",
433
- @"dateOfExpiry",
434
- @"authority",
435
- @"documentNumber",
436
- @"categories",
437
- @"drivingLicenseString"
438
- ] mutableCopy];
439
- dictResult = [[scanResult.result dictionaryWithValuesForKeys:keys] mutableCopy];
440
- //we have field confidences for everything but drivingLicenseString
441
- [keys removeObject:@"drivingLicenseString"];
442
- [dictResult setValue:[[scanResult.result fieldConfidences] dictionaryWithValuesForKeys:keys] forKey:@"fieldConfidences"];
443
- [dictResult setValue:[ALPluginHelper stringForDate:[scanResult.result dateOfBirthObject]] forKey:@"dateOfBirthObject"];
444
- [dictResult setValue:[ALPluginHelper stringForDate:[scanResult.result dateOfIssueObject]] forKey:@"dateOfIssueObject"];
445
- [dictResult setValue:[ALPluginHelper stringForDate:[scanResult.result dateOfExpiryObject]] forKey:@"dateOfExpiryObject"];
446
-
447
- } else if ([scanResult.result isKindOfClass:[ALGermanIDFrontIdentification class]]) {
448
- ALGermanIDFrontIdentification *germanIDFrontIdentification = (ALGermanIDFrontIdentification *)scanResult.result;
449
- NSMutableArray<NSString *> *keys=[@[
450
- @"surname",
451
- @"givenNames",
452
- @"dateOfBirth",
453
- @"nationality",
454
- @"placeOfBirth",
455
- @"dateOfExpiry",
456
- @"documentNumber",
457
- @"cardAccessNumber",
458
- @"germanIdFrontString"
459
- ] mutableCopy];
460
- dictResult = [[germanIDFrontIdentification dictionaryWithValuesForKeys:keys] mutableCopy];
461
- //we have field confidences for everything but germanIdFrontString
462
- [keys removeObject:@"germanIdFrontString"];
463
- [dictResult setValue:[[scanResult.result fieldConfidences] dictionaryWithValuesForKeys:keys] forKey:@"fieldConfidences"];
464
- [dictResult setValue:[ALPluginHelper stringForDate:[scanResult.result dateOfBirthObject]] forKey:@"dateOfBirthObject"];
465
- [dictResult setValue:[ALPluginHelper stringForDate:[scanResult.result dateOfExpiryObject]] forKey:@"dateOfExpiryObject"];
466
426
  }
467
427
 
468
428
  [dictResult setValue:imagePath forKey:@"imagePath"];
@@ -562,11 +522,13 @@
562
522
 
563
523
 
564
524
  for(ALBarcode *barcode in scanResult.result) {
565
- NSString * value = barcode.value ? barcode.value : barcode.base64;
566
- [barcodeArray addObject:@{
567
- @"value" : value ? value : @"",
568
- @"barcodeFormat" : [ALPluginHelper barcodeFormatFromString:barcode.barcodeFormat]
569
- }];
525
+ NSMutableDictionary *barcodeDictionary = @{ @"value":barcode.value,
526
+ @"barcodeFormat": [ALPluginHelper barcodeFormatFromString:barcode.barcodeFormat]}.mutableCopy;
527
+ if (barcode.parsedPDF417 != nil) {
528
+ NSString *newValueWithPDF417 = [NSString stringWithFormat:@"{\"rawPDF417\" : \"%@\", \"parsedPDF417\" : \"%@\"}", barcode.value, [barcode.parsedPDF417[kPDF417ParsedBody] description]];
529
+ [barcodeDictionary setValue:newValueWithPDF417 forKey:@"value"];
530
+ }
531
+ [barcodeArray addObject:barcodeDictionary];
570
532
  }
571
533
 
572
534
  [dictResult setValue:barcodeArray forKey:@"barcodes"];
@@ -595,6 +557,7 @@
595
557
  //Create the result Object
596
558
  NSMutableDictionary *dictResult = [NSMutableDictionary dictionaryWithCapacity:5];
597
559
  [dictResult setValue:scanResult.country forKey:@"country"];
560
+ [dictResult setValue:scanResult.area forKey:@"area"];
598
561
  [dictResult setValue:scanResult.result forKey:@"licensePlate"];
599
562
  [dictResult setValue:[ALPluginHelper stringForOutline:outline] forKey:@"outline"];
600
563
  [dictResult setValue:@(scanResult.confidence) forKey:@"confidence"];
@@ -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];
@@ -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", "~> 33"
22
+ s.dependency "Anyline", "~> 36"
23
23
  s.dependency "React"
24
24
  end
@@ -79,16 +79,16 @@ RCT_EXPORT_METHOD(getSDKVersion:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
79
79
  if(error) {
80
80
  [NSException raise:@"Config could not be parsed to JSON" format:@"Config could not be parsed to JSON: %@", error.localizedDescription];
81
81
  }
82
-
82
+ NSDictionary *optionsDictionary = [dictionary objectForKey:@"options"];
83
83
  self.jsonConfigDictionary = dictionary;
84
84
 
85
85
  self.appKey = [dictionary objectForKey:@"license"];
86
86
 
87
- BOOL nativeBarcodeScanning = [[dictionary objectForKey:@"nativeBarcodeEnabled"] boolValue];
87
+ BOOL nativeBarcodeScanning = [[optionsDictionary objectForKey:@"nativeBarcodeEnabled"] boolValue];
88
88
  self.nativeBarcodeScanning = nativeBarcodeScanning ? nativeBarcodeScanning : NO;
89
89
 
90
- self.jsonUIConf = [[ALJsonUIConfiguration alloc] initWithDictionary:[dictionary objectForKey:@"options"]];
91
- self.conf = [[ALScanViewPluginConfig alloc] initWithDictionary:[dictionary objectForKey:@"options"]];
90
+ self.jsonUIConf = [[ALJsonUIConfiguration alloc] initWithDictionary:optionsDictionary];
91
+ self.conf = [[ALScanViewPluginConfig alloc] initWithDictionary:optionsDictionary];
92
92
  self.conf.cancelOnResult = true;
93
93
  self.ocrConfigDict = [dictionary objectForKey:@"ocr"];
94
94
 
@@ -113,7 +113,7 @@ RCT_EXPORT_METHOD(getSDKVersion:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
113
113
  nfcScanViewController.cropAndTransformErrorMessage = str;
114
114
  }
115
115
 
116
- if ([self.jsonConfigDictionary valueForKey:@"nativeBarcodeEnabled"]) {
116
+ if ([optionsDictionary valueForKey:@"nativeBarcodeEnabled"]) {
117
117
  nfcScanViewController.nativeBarcodeEnabled = [[self.jsonConfigDictionary objectForKey:@"nativeBarcodeEnabled"] boolValue];
118
118
  }
119
119
 
@@ -143,7 +143,7 @@ RCT_EXPORT_METHOD(getSDKVersion:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
143
143
  pluginScanViewController.cropAndTransformErrorMessage = str;
144
144
  }
145
145
 
146
- if ([self.jsonConfigDictionary valueForKey:@"nativeBarcodeEnabled"]) {
146
+ if ([optionsDictionary valueForKey:@"nativeBarcodeEnabled"]) {
147
147
  pluginScanViewController.nativeBarcodeEnabled = [[self.jsonConfigDictionary objectForKey:@"nativeBarcodeEnabled"] boolValue];
148
148
  }
149
149
 
@@ -168,7 +168,7 @@ RCT_EXPORT_METHOD(getSDKVersion:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
168
168
  pluginScanViewController.cropAndTransformErrorMessage = str;
169
169
  }
170
170
 
171
- if ([self.jsonConfigDictionary valueForKey:@"nativeBarcodeEnabled"]) {
171
+ if ([optionsDictionary valueForKey:@"nativeBarcodeEnabled"]) {
172
172
  pluginScanViewController.nativeBarcodeEnabled = [[self.jsonConfigDictionary objectForKey:@"nativeBarcodeEnabled"] boolValue];
173
173
  }
174
174
 
@@ -235,7 +235,7 @@ RCT_EXPORT_METHOD(getSDKVersion:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
235
235
 
236
236
  - (BOOL)scanModeIndex:(NSString *)scanMode{
237
237
 
238
- NSArray *possibleScanModes = @[@"DOCUMENT", @"MRZ", @"BARCODE", @"LICENSE_PLATE", @"ANYLINE_OCR", @"ANALOG_METER", @"DIGITAL_METER", @"AUTO_ANALOG_DIGITAL_METER",
238
+ NSArray *possibleScanModes = @[@"DOCUMENT", @"MRZ", @"BARCODE", @"LICENSE_PLATE", @"LICENSE_PLATE_US", @"ANYLINE_OCR", @"ANALOG_METER", @"DIGITAL_METER", @"AUTO_ANALOG_DIGITAL_METER",
239
239
  @"DIAL_METER", @"SERIAL_NUMBER", @"HEAT_METER_4", @"HEAT_METER_5", @"HEAT_METER_6", @"DOT_MATRIX_METER"];
240
240
 
241
241
  return [possibleScanModes containsObject: [scanMode uppercaseString]];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "_from": "anyline-ocr-react-native-module@^33.0.0",
3
- "_id": "anyline-ocr-react-native-module@33.0.0",
2
+ "_from": "anyline-ocr-react-native-module@^36.0.0",
3
+ "_id": "anyline-ocr-react-native-module@36.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@^33.0.0",
11
+ "raw": "anyline-ocr-react-native-module@^36.0.0",
12
12
  "name": "anyline-ocr-react-native-module",
13
13
  "escapedName": "anyline-ocr-react-native-module",
14
- "rawSpec": "^33.0.0",
14
+ "rawSpec": "^36.0.0",
15
15
  "saveSpec": null,
16
- "fetchSpec": "^33.0.0"
16
+ "fetchSpec": "^36.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-33.0.0.tgz",
22
- "_shasum": "62ab2a6c30e365851e5c6951546576a711d9183e",
23
- "_spec": "anyline-ocr-react-native-module@^33.0.0",
21
+ "_resolved": "https://registry.npmjs.org/anyline-ocr-react-native-module/-/anyline-ocr-react-native-module-36.0.0.tgz",
22
+ "_shasum": "bacbcd260cc662244f59393ed81a6edba009b52c",
23
+ "_spec": "anyline-ocr-react-native-module@^36.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": "33.0.0"
50
+ "version": "36.0.0"
51
51
  }