anyline-ocr-react-native-module 34.0.0 → 37.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.
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <classpath>
3
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
3
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-15/"/>
4
4
  <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
5
- <classpathentry kind="output" path="bin"/>
5
+ <classpathentry kind="output" path="bin/default"/>
6
6
  </classpath>
File without changes
@@ -1,2 +1,2 @@
1
- #Mon Aug 23 14:02:24 CEST 2021
2
- gradle.version=6.5
1
+ #Wed Feb 16 10:59:23 CET 2022
2
+ gradle.version=6.7
package/android/.project CHANGED
@@ -20,4 +20,15 @@
20
20
  <nature>org.eclipse.jdt.core.javanature</nature>
21
21
  <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
22
22
  </natures>
23
+ <filteredResources>
24
+ <filter>
25
+ <id>1644311700731</id>
26
+ <name></name>
27
+ <type>30</type>
28
+ <matcher>
29
+ <id>org.eclipse.core.resources.regexFilterMatcher</id>
30
+ <arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
31
+ </matcher>
32
+ </filter>
33
+ </filteredResources>
23
34
  </projectDescription>
@@ -65,7 +65,7 @@ repositories {
65
65
 
66
66
  dependencies {
67
67
  implementation fileTree(dir: "libs", include: ["*.jar"])
68
- implementation 'io.anyline:anylinesdk:34.0.0'
68
+ implementation 'io.anyline:anylinesdk:37.0.0'
69
69
  implementation "com.facebook.react:react-native:+" // from node_modules
70
70
  implementation("com.google.android.material:material:1.4.0-rc01")
71
71
  implementation 'androidx.multidex:multidex:2.0.1'
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
3
3
  distributionPath=wrapper/dists
4
4
  zipStoreBase=GRADLE_USER_HOME
5
5
  zipStorePath=wrapper/dists
6
- distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
6
+ distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
@@ -1,3 +1,19 @@
1
+ @rem
2
+ @rem Copyright 2015 the original author or authors.
3
+ @rem
4
+ @rem Licensed under the Apache License, Version 2.0 (the "License");
5
+ @rem you may not use this file except in compliance with the License.
6
+ @rem You may obtain a copy of the License at
7
+ @rem
8
+ @rem https://www.apache.org/licenses/LICENSE-2.0
9
+ @rem
10
+ @rem Unless required by applicable law or agreed to in writing, software
11
+ @rem distributed under the License is distributed on an "AS IS" BASIS,
12
+ @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ @rem See the License for the specific language governing permissions and
14
+ @rem limitations under the License.
15
+ @rem
16
+
1
17
  @if "%DEBUG%" == "" @echo off
2
18
  @rem ##########################################################################
3
19
  @rem
@@ -8,20 +24,23 @@
8
24
  @rem Set local scope for the variables with windows NT shell
9
25
  if "%OS%"=="Windows_NT" setlocal
10
26
 
11
- @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12
- set DEFAULT_JVM_OPTS=
13
-
14
27
  set DIRNAME=%~dp0
15
28
  if "%DIRNAME%" == "" set DIRNAME=.
16
29
  set APP_BASE_NAME=%~n0
17
30
  set APP_HOME=%DIRNAME%
18
31
 
32
+ @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33
+ for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34
+
35
+ @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36
+ set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37
+
19
38
  @rem Find java.exe
20
39
  if defined JAVA_HOME goto findJavaFromJavaHome
21
40
 
22
41
  set JAVA_EXE=java.exe
23
42
  %JAVA_EXE% -version >NUL 2>&1
24
- if "%ERRORLEVEL%" == "0" goto init
43
+ if "%ERRORLEVEL%" == "0" goto execute
25
44
 
26
45
  echo.
27
46
  echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -35,7 +54,7 @@ goto fail
35
54
  set JAVA_HOME=%JAVA_HOME:"=%
36
55
  set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37
56
 
38
- if exist "%JAVA_EXE%" goto init
57
+ if exist "%JAVA_EXE%" goto execute
39
58
 
40
59
  echo.
41
60
  echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -45,34 +64,14 @@ echo location of your Java installation.
45
64
 
46
65
  goto fail
47
66
 
48
- :init
49
- @rem Get command-line arguments, handling Windowz variants
50
-
51
- if not "%OS%" == "Windows_NT" goto win9xME_args
52
- if "%@eval[2+2]" == "4" goto 4NT_args
53
-
54
- :win9xME_args
55
- @rem Slurp the command line arguments.
56
- set CMD_LINE_ARGS=
57
- set _SKIP=2
58
-
59
- :win9xME_args_slurp
60
- if "x%~1" == "x" goto execute
61
-
62
- set CMD_LINE_ARGS=%*
63
- goto execute
64
-
65
- :4NT_args
66
- @rem Get arguments from the 4NT Shell from JP Software
67
- set CMD_LINE_ARGS=%$
68
-
69
67
  :execute
70
68
  @rem Setup the command line
71
69
 
72
70
  set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73
71
 
72
+
74
73
  @rem Execute Gradle
75
- "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
74
+ "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76
75
 
77
76
  :end
78
77
  @rem End local scope for the variables with windows NT shell
@@ -87,4 +86,4 @@ exit /b 1
87
86
  :mainEnd
88
87
  if "%OS%"=="Windows_NT" endlocal
89
88
 
90
- :omega
89
+ :omega
@@ -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;
@@ -50,13 +50,15 @@ import io.anyline.plugin.meter.MeterScanResult;
50
50
  import io.anyline.plugin.meter.MeterScanViewPlugin;
51
51
  import io.anyline.plugin.ocr.OcrScanResult;
52
52
  import io.anyline.plugin.ocr.OcrScanViewPlugin;
53
+ import io.anyline.plugin.tire.TireScanResult;
54
+ import io.anyline.plugin.tire.TireScanPlugin;
55
+ import io.anyline.plugin.tire.TireScanViewPlugin;
53
56
  import io.anyline.view.AbstractBaseScanViewPlugin;
54
57
  import io.anyline.view.CutoutRect;
55
58
  import io.anyline.view.ParallelScanViewComposite;
56
59
  import io.anyline.view.ScanView;
57
60
  import io.anyline.view.SerialScanViewComposite;
58
61
 
59
- //import at.nineyards.anyline.modules.mrz.Identification;
60
62
 
61
63
  public class Anyline4Activity extends AnylineBaseActivity {
62
64
  private static final String TAG = Anyline4Activity.class.getSimpleName();
@@ -67,15 +69,28 @@ public class Anyline4Activity extends AnylineBaseActivity {
67
69
  private AnylineUIConfig anylineUIConfig;
68
70
  private String cropAndTransformError;
69
71
  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
72
+ private RelativeLayout parentLayout;
73
+ private boolean defaultOrientationApplied;
74
+ private static final String KEY_DEFAULT_ORIENTATION_APPLIED = "default_orientation_applied";
70
75
 
71
76
  @Override
72
77
  protected void onCreate(Bundle savedInstanceState) {
73
78
  super.onCreate(savedInstanceState);
74
-
75
79
  isFirstCameraOpen = true;
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);
90
+
91
+ if (savedInstanceState != null) {
92
+ defaultOrientationApplied = savedInstanceState.getBoolean(KEY_DEFAULT_ORIENTATION_APPLIED);
93
+ }
79
94
 
80
95
  try {
81
96
  // start initialize anyline
@@ -87,6 +102,12 @@ public class Anyline4Activity extends AnylineBaseActivity {
87
102
  setDebugListener();
88
103
  }
89
104
 
105
+ @Override
106
+ protected void onSaveInstanceState(Bundle outState) {
107
+ super.onSaveInstanceState(outState);
108
+ outState.putBoolean(KEY_DEFAULT_ORIENTATION_APPLIED, defaultOrientationApplied);
109
+ }
110
+
90
111
  @Override
91
112
  protected void onResume() {
92
113
  super.onResume();
@@ -157,14 +178,17 @@ public class Anyline4Activity extends AnylineBaseActivity {
157
178
  scanViewPlugin = anylineScanView.getScanViewPlugin();
158
179
  }
159
180
 
181
+ if (shouldShowRotateButton(json)) {
182
+ RotateButtonConfig rotateButtonConfig = new RotateButtonConfig(json.getJSONObject("rotateButton"));
183
+ addRotateButtonToView(rotateButtonConfig);
184
+ }
185
+
186
+ setDefaultOrientation(json);
187
+
160
188
  if (scanViewPlugin != null) {
161
189
  //set nativeBarcodeMode
162
190
  AnylinePluginHelper.setNativeBarcodeMode(json, anylineScanView);
163
191
 
164
- if (!(scanViewPlugin instanceof MeterScanViewPlugin)) {
165
- setContentView(anylineScanView);
166
- }
167
-
168
192
  if (scanViewPlugin instanceof SerialScanViewComposite || scanViewPlugin instanceof ParallelScanViewComposite) {
169
193
  scanViewPlugin.addScanResultListener(new ScanResultListener() {
170
194
  @Override
@@ -200,27 +224,6 @@ public class Anyline4Activity extends AnylineBaseActivity {
200
224
  jsonIdResult = AnylinePluginHelper.jsonHelper(Anyline4Activity.this, subResult,
201
225
  jsonIdResult);
202
226
 
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
227
  jsonResult.put(subResult.getPluginId(), jsonIdResult);
225
228
  } catch (JSONException e) {
226
229
  e.printStackTrace();
@@ -236,24 +239,7 @@ public class Anyline4Activity extends AnylineBaseActivity {
236
239
  e.printStackTrace();
237
240
  }
238
241
  } 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
- }
242
+ jsonResult = extractBarcodeResult(jsonResult, subResult);
257
243
  } else if (subResult instanceof MeterScanResult) {
258
244
  JSONObject jsonMeterResult = new JSONObject();
259
245
  try {
@@ -275,10 +261,6 @@ public class Anyline4Activity extends AnylineBaseActivity {
275
261
  }
276
262
  });
277
263
  } else if (scanViewPlugin instanceof LicensePlateScanViewPlugin) {
278
- if (json.has("reportingEnabled")) {
279
- //(IdScanViewPlugin) scanViewPlugin.setReportingEnabled(json.optBoolean("reportingEnabled", true));
280
- (((IdScanViewPlugin) scanViewPlugin).getScanPlugin()).setReportingEnabled(json.optBoolean("reportingEnabled", true));
281
- }
282
264
  scanViewPlugin.addScanResultListener(new ScanResultListener<LicensePlateScanResult>() {
283
265
  @Override
284
266
  public void onResult(LicensePlateScanResult licensePlateResult) {
@@ -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
@@ -394,11 +339,6 @@ public class Anyline4Activity extends AnylineBaseActivity {
394
339
  });
395
340
  }
396
341
  } else if (scanViewPlugin instanceof OcrScanViewPlugin) {
397
- if (json.has("reportingEnabled")) {
398
- //scanViewPlugin.setReportingEnabled(json.optBoolean("reportingEnabled", true));
399
- (((OcrScanViewPlugin) scanViewPlugin).getScanPlugin()).setReportingEnabled(json.optBoolean("reportingEnabled", true));
400
- }
401
-
402
342
  scanViewPlugin.addScanResultListener(new ScanResultListener<OcrScanResult>() {
403
343
  @Override
404
344
  public void onResult(OcrScanResult ocrScanResult) {
@@ -416,8 +356,29 @@ public class Anyline4Activity extends AnylineBaseActivity {
416
356
 
417
357
  });
418
358
 
359
+ } else if (scanViewPlugin instanceof TireScanViewPlugin) {
360
+ scanViewPlugin.addScanResultListener(new ScanResultListener<TireScanResult>() {
361
+ @Override
362
+ public void onResult(TireScanResult tireScanResult) {
363
+ JSONObject jsonResult = new JSONObject();
364
+ try {
365
+ jsonResult.put("text", tireScanResult.getResult().trim());
366
+ jsonResult = AnylinePluginHelper.jsonHelper(Anyline4Activity.this, tireScanResult,
367
+ jsonResult);
368
+ } catch (JSONException e) {
369
+ e.printStackTrace();
370
+ }
371
+ setResult(scanViewPlugin, jsonResult);
372
+
373
+ }
374
+
375
+ });
376
+
419
377
  } else if (scanViewPlugin instanceof BarcodeScanViewPlugin) {
420
378
 
379
+ if (shouldEnablePDF417(json)) {
380
+ ((BarcodeScanPlugin) ((BarcodeScanViewPlugin) scanViewPlugin).getScanPlugin()).enablePDF417Parsing();
381
+ }
421
382
  scanViewPlugin.addScanResultListener(new ScanResultListener<BarcodeScanResult>() {
422
383
  @Override
423
384
  public void onResult(BarcodeScanResult barcodeScanResult) {
@@ -432,6 +393,11 @@ public class Anyline4Activity extends AnylineBaseActivity {
432
393
  barcode.put("value", barcodeList.get(i).getValue());
433
394
  barcode.put("barcodeFormat", barcodeList.get(i).getBarcodeFormat());
434
395
 
396
+ PDF417 pdf417 = barcodeList.get(i).getParsedPDF417();
397
+
398
+ if (pdf417 != null) {
399
+ barcode.put("parsedPDF417", pdf417.toJSONObject());
400
+ }
435
401
  barcodeArray.put(barcode);
436
402
  }
437
403
  JSONObject finalObject = new JSONObject();
@@ -450,13 +416,8 @@ public class Anyline4Activity extends AnylineBaseActivity {
450
416
  });
451
417
 
452
418
  } else if (scanViewPlugin instanceof MeterScanViewPlugin) {
453
- if (json.has("reportingEnabled")) {
454
- //scanViewPlugin.setReportingEnabled(json.optBoolean("reportingEnabled", true));
455
- (((MeterScanViewPlugin) scanViewPlugin).getScanPlugin()).setReportingEnabled(json.optBoolean("reportingEnabled", true));
456
-
457
- }
458
419
  // create the radio button for the UI
459
- createSegmentRadioButtonUI(json);
420
+ addSegmentRadioButtonUI(json);
460
421
 
461
422
  anylineScanView.setCameraOpenListener(this);
462
423
  scanViewPlugin.addScanResultListener(new ScanResultListener<MeterScanResult>() {
@@ -489,7 +450,53 @@ public class Anyline4Activity extends AnylineBaseActivity {
489
450
  getString(getResources().getIdentifier("error_invalid_json_data", "string", getPackageName()))
490
451
  + "\n" + e.getLocalizedMessage());
491
452
  }
453
+ }
454
+
455
+ private void setDefaultOrientation(JSONObject jsonObject) {
456
+ if (defaultOrientationApplied) return;
492
457
 
458
+ if (jsonObject.has("defaultOrientation")
459
+ && jsonObject.optString("defaultOrientation").equals("landscape")
460
+ && getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
461
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
462
+ }
463
+ defaultOrientationApplied = true;
464
+ }
465
+
466
+ private boolean shouldEnablePDF417(JSONObject jsonObject) {
467
+ JSONObject viewPlugin = jsonObject.optJSONObject("viewPlugin");
468
+
469
+ if (viewPlugin != null) {
470
+ JSONObject plugin = viewPlugin.optJSONObject("plugin");
471
+
472
+ if (plugin != null) {
473
+ JSONObject barcodePlugin = plugin.optJSONObject("barcodePlugin");
474
+ return barcodePlugin != null && barcodePlugin.optBoolean("enablePDF417Parsing");
475
+ }
476
+ }
477
+ return false;
478
+ }
479
+
480
+ private JSONObject extractBarcodeResult(JSONObject jsonResult, ScanResult subResult) {
481
+ try {
482
+ List<Barcode> barcodeList = (List<Barcode>) subResult.getResult();
483
+
484
+ JSONArray barcodeArray = new JSONArray();
485
+ if (barcodeList.size() > 1) {
486
+ for (int i = 0; i < barcodeList.size(); i++) {
487
+ barcodeArray.put(barcodeList.get(i).toJSONObject());
488
+ }
489
+ JSONObject finalObject = new JSONObject();
490
+ finalObject.put("multiBarcodes", barcodeArray);
491
+ jsonResult = AnylinePluginHelper.jsonHelper(Anyline4Activity.this, subResult, finalObject);
492
+ } else {
493
+ jsonResult = AnylinePluginHelper.jsonHelper(Anyline4Activity.this, subResult, barcodeList.get(0).toJSONObject());
494
+
495
+ }
496
+ } catch (JSONException e) {
497
+ e.printStackTrace();
498
+ }
499
+ return jsonResult;
493
500
  }
494
501
 
495
502
  // this method is used only for the meter scanning which contains radio buttons
@@ -523,20 +530,21 @@ public class Anyline4Activity extends AnylineBaseActivity {
523
530
  });
524
531
  }
525
532
 
526
- private void createSegmentRadioButtonUI(JSONObject json) {
527
-
533
+ private void addSegmentRadioButtonUI(JSONObject json) {
528
534
  final String scanModeString = ((MeterScanViewPlugin) scanViewPlugin).getScanMode().toString();
529
535
  anylineUIConfig = new AnylineUIConfig(this, json);
530
536
 
531
- // Creating a new RelativeLayout
532
- final RelativeLayout relativeLayout = new RelativeLayout(this);
537
+ RadioGroup radioGroup = createRadioGroup(anylineUIConfig, scanModeString);
533
538
 
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);
539
+ if (radioGroup != null) {
540
+ RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
541
+ RelativeLayout.LayoutParams.WRAP_CONTENT);
542
+ lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
543
+ parentLayout.addView(radioGroup, lp);
544
+ }
545
+ }
539
546
 
547
+ private RadioGroup createRadioGroup(AnylineUIConfig anylineUIConfig, String scanModeString) {
540
548
  ArrayList<String> titles = anylineUIConfig.getTitles();
541
549
  final ArrayList<String> modes = anylineUIConfig.getModes();
542
550
 
@@ -573,7 +581,6 @@ public class Anyline4Activity extends AnylineBaseActivity {
573
581
  View button = group.findViewById(checkedId);
574
582
  String mode = modes.get(group.indexOfChild(button));
575
583
  ((MeterScanViewPlugin) scanViewPlugin).setScanMode(MeterScanMode.valueOf(mode));
576
- //anylineScanView.releaseCameraInBackground();
577
584
  anylineScanView.stop();
578
585
  try {
579
586
  Thread.sleep(100);
@@ -584,16 +591,44 @@ public class Anyline4Activity extends AnylineBaseActivity {
584
591
  }
585
592
  });
586
593
 
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
594
  radioGroup.setVisibility(View.INVISIBLE);
595
+ return radioGroup;
596
+ }
597
+ return null;
598
+ }
592
599
 
593
- relativeLayout.addView(radioGroup, lp);
600
+ private void addRotateButtonToView(RotateButtonConfig rotateButtonConfig) {
601
+ Button button = new Button(this);
602
+ button.setText("Rotate");
603
+ button.setOnClickListener(new View.OnClickListener() {
604
+
605
+ @Override
606
+ public void onClick(View v) {
607
+ if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
608
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
609
+ } else if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
610
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
611
+ }
612
+ }
613
+ });
614
+
615
+ RelativeLayout.LayoutParams buttonLayoutParams = new RelativeLayout.LayoutParams(
616
+ RelativeLayout.LayoutParams.WRAP_CONTENT,
617
+ RelativeLayout.LayoutParams.WRAP_CONTENT);
618
+
619
+ if (rotateButtonConfig.hasOffset()) {
620
+ Offset offset = rotateButtonConfig.getOffset();
621
+ buttonLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
622
+ buttonLayoutParams.setMargins(offset.getX(), offset.getY(), 0, 0);
623
+ } else {
624
+ buttonLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
625
+ buttonLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
594
626
  }
595
- setContentView(relativeLayout, matchParentParams);
596
627
 
628
+ parentLayout.addView(button, buttonLayoutParams);
597
629
  }
598
630
 
631
+ private boolean shouldShowRotateButton(JSONObject jsonObject) {
632
+ return jsonObject.has("rotateButton");
633
+ }
599
634
  }
@@ -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
+ }
@@ -1,7 +1,7 @@
1
1
  <resources>
2
2
 
3
3
  <!-- Base application theme. -->
4
- <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
4
+ <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
5
5
  <!-- Customize your theme here. -->
6
6
  </style>
7
7
 
@@ -85,6 +85,9 @@ NS_ASSUME_NONNULL_BEGIN
85
85
  detectedBarcodes:(NSMutableArray<NSDictionary *> *)detectedBarcodes
86
86
  quality:(NSInteger)quality;
87
87
 
88
+ + (NSDictionary *)dictionaryForTireResult:(ALTireResult *)scanResult
89
+ quality:(NSInteger)quality;
90
+
88
91
  @end
89
92
 
90
93
  NS_ASSUME_NONNULL_END
@@ -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"];
@@ -653,6 +616,24 @@
653
616
  return dictResult;
654
617
  }
655
618
 
619
+ + (NSDictionary *)dictionaryForTireResult:(ALTireResult *)scanResult
620
+ quality:(NSInteger)quality {
621
+ CGFloat dividedCompRate = (CGFloat)quality/100;
622
+
623
+ NSMutableDictionary *dictResult = [NSMutableDictionary dictionaryWithCapacity:4];
624
+
625
+ [dictResult setObject:scanResult.result forKey:@"text"];
626
+
627
+ NSString *imagePath = [ALPluginHelper saveImageToFileSystem:scanResult.image compressionQuality:dividedCompRate];
628
+
629
+ [dictResult setValue:imagePath forKey:@"imagePath"];
630
+
631
+ NSString *fullImagePath = [ALPluginHelper saveImageToFileSystem:scanResult.fullImage compressionQuality:dividedCompRate];
632
+ [dictResult setValue:fullImagePath forKey:@"fullImagePath"];
633
+ [dictResult setValue:@(scanResult.confidence) forKey:@"confidence"];
634
+ [dictResult setValue:scanResult.pluginID forKey:@"pluginID"];
635
+ return dictResult;
636
+ }
656
637
 
657
638
  + (NSDictionary *)dictForResult:(ALScanResult *)result
658
639
  detectedBarcodes:(NSMutableArray<NSDictionary *> *)detectedBarcodes
@@ -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];
@@ -257,6 +261,14 @@
257
261
 
258
262
  }
259
263
 
264
+ - (void)anylineTireScanPlugin:(ALTireScanPlugin * _Nonnull)anylineTireScanPlugin
265
+ didFindResult:(ALTireResult * _Nonnull)scanResult {
266
+ NSDictionary *dictResult = [ALPluginHelper dictionaryForTireResult:scanResult
267
+ quality:self.quality];
268
+
269
+ [self handleResult:dictResult result:scanResult];
270
+ }
271
+
260
272
  - (void)anylineCaptureDeviceManager:(ALCaptureDeviceManager * _Nonnull)captureDeviceManager
261
273
  didFindBarcodeResult:(NSString * _Nonnull)scanResult
262
274
  type:(NSString * _Nonnull)barcodeType {
@@ -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", "~> 34"
22
+ s.dependency "Anyline", "~> 37"
23
23
  s.dependency "React"
24
24
  end
@@ -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", @"TIRE", @"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@^34.0.0",
3
- "_id": "anyline-ocr-react-native-module@34.0.0",
2
+ "_from": "anyline-ocr-react-native-module@^37.0.0",
3
+ "_id": "anyline-ocr-react-native-module@37.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@^34.0.0",
11
+ "raw": "anyline-ocr-react-native-module@^37.0.0",
12
12
  "name": "anyline-ocr-react-native-module",
13
13
  "escapedName": "anyline-ocr-react-native-module",
14
- "rawSpec": "^34.0.0",
14
+ "rawSpec": "^37.0.0",
15
15
  "saveSpec": null,
16
- "fetchSpec": "^34.0.0"
16
+ "fetchSpec": "^37.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-34.0.0.tgz",
22
- "_shasum": "62ab2a6c30e365851e5c6951546576a711d9183e",
23
- "_spec": "anyline-ocr-react-native-module@^34.0.0",
21
+ "_resolved": "https://registry.npmjs.org/anyline-ocr-react-native-module/-/anyline-ocr-react-native-module-37.0.0.tgz",
22
+ "_shasum": "bacbcd260cc662244f59393ed81a6edba009b52c",
23
+ "_spec": "anyline-ocr-react-native-module@^37.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": "34.0.0"
50
+ "version": "37.0.0"
51
51
  }