react-native-scanbot-barcode-scanner-sdk 3.7.0 → 3.7.1-beta.2

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 (170) hide show
  1. package/RNScanbotBarcodeSDK.podspec +12 -9
  2. package/android/build.gradle +31 -27
  3. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  4. package/android/src/main/AndroidManifest.xml +1 -2
  5. package/android/src/main/java/com/reactlibrary/ScanbotBarcodeSdkModule.java +5 -12
  6. package/android/src/main/java/com/reactlibrary/ScanbotBarcodeSdkPackage.java +2 -2
  7. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ObjectMapper.java +24 -17
  8. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkConfiguration.java +5 -2
  9. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkModule.java +92 -84
  10. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkPackage.java +1 -2
  11. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/StorageUtils.java +5 -69
  12. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/barcode/ScanbotBarcodeDetectorAdditionalConfigBuilder.java +1 -1
  13. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/barcode/ScanbotBarcodeDetectorConfigBuilder.java +1 -1
  14. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraView.java +9 -15
  15. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewConfiguration.java +6 -5
  16. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/base/communication/ScanbotEventEmitter.java +5 -3
  17. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/base/communication/ScanbotEventReceiver.java +15 -4
  18. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/JSONUtils.java +29 -40
  19. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/LogUtils.java +4 -1
  20. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/ResponseUtils.java +2 -10
  21. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/ScanbotViewUtils.java +0 -17
  22. package/android/src/new-architecture/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewManager.java +127 -0
  23. package/android/src/{main/java → old-architecture}/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewManager.java +1 -1
  24. package/index.js +1 -1
  25. package/ios/Categories/SBSDKPolygon+JSON.h +1 -1
  26. package/ios/Categories/SBSDKPolygon+JSON.m +1 -1
  27. package/ios/Categories/UIColor+JSON.h +1 -1
  28. package/ios/Categories/UIColor+JSON.m +1 -1
  29. package/ios/Components/BarcodeCameraView/NewArchitecture/RTNScanbotBarcodeCameraView.h +45 -0
  30. package/ios/Components/BarcodeCameraView/NewArchitecture/RTNScanbotBarcodeCameraView.mm +364 -0
  31. package/ios/Components/BarcodeCameraView/NewArchitecture/RTNScanbotBarcodeCameraViewManager.mm +71 -0
  32. package/ios/Components/BarcodeCameraView/{RNScanbotBarcodeCameraView.h → OldArchitecture/RNScanbotBarcodeCameraView.h} +9 -4
  33. package/ios/Components/BarcodeCameraView/{RNScanbotBarcodeCameraView.m → OldArchitecture/RNScanbotBarcodeCameraView.mm} +24 -34
  34. package/ios/Components/BarcodeCameraView/{RNScanbotBarcodeCameraViewManager.h → OldArchitecture/RNScanbotBarcodeCameraViewManager.h} +7 -1
  35. package/ios/Components/BarcodeCameraView/{RNScanbotBarcodeCameraViewManager.m → OldArchitecture/RNScanbotBarcodeCameraViewManager.mm} +25 -6
  36. package/ios/ScanbotBarcodeSDKConfiguration.h +1 -1
  37. package/ios/ScanbotBarcodeSDKConfiguration.m +1 -1
  38. package/ios/ScanbotBarcodeSdk.h +2 -2
  39. package/ios/ScanbotBarcodeSdk.m +24 -23
  40. package/ios/SharedConfiguration.h +1 -1
  41. package/ios/SharedConfiguration.m +1 -1
  42. package/ios/Utils/BarcodeMapping.h +40 -33
  43. package/ios/Utils/HashUtils.h +1 -1
  44. package/ios/Utils/JSONMappings.h +1 -1
  45. package/ios/Utils/LoggingUtils.h +1 -1
  46. package/ios/Utils/ObjectMapper.h +1 -1
  47. package/ios/Utils/ObjectMapper.m +1 -1
  48. package/ios/Utils/ReactBarcodeExtensionsFilter.h +1 -1
  49. package/ios/Utils/ScanbotStorageUtils.h +1 -1
  50. package/ios/Utils/ScanbotStorageUtils.m +1 -1
  51. package/js/RTNScanbotBarcodeCameraViewNativeComponent.tsx +209 -0
  52. package/package.json +22 -2
  53. package/src/components/barcode-camera-view/scanbot-barcode-camera-view-types.tsx +8 -1
  54. package/src/components/barcode-camera-view/scanbot-barcode-camera-view.tsx +46 -12
  55. package/src/components/barcode-camera-view/scanbot-native-barcode-camera-view.tsx +7 -5
  56. package/src/configuration.ts +4 -1
  57. package/src/enum.ts +1 -1
  58. package/android/.gradle/6.1.1/executionHistory/executionHistory.bin +0 -0
  59. package/android/.gradle/6.1.1/executionHistory/executionHistory.lock +0 -0
  60. package/android/.gradle/6.1.1/fileChanges/last-build.bin +0 -0
  61. package/android/.gradle/6.1.1/fileHashes/fileHashes.bin +0 -0
  62. package/android/.gradle/6.1.1/fileHashes/fileHashes.lock +0 -0
  63. package/android/.gradle/6.1.1/gc.properties +0 -0
  64. package/android/.gradle/6.2/executionHistory/executionHistory.lock +0 -0
  65. package/android/.gradle/6.2/fileChanges/last-build.bin +0 -0
  66. package/android/.gradle/6.2/fileHashes/fileHashes.lock +0 -0
  67. package/android/.gradle/6.2/gc.properties +0 -0
  68. package/android/.gradle/6.8/executionHistory/executionHistory.lock +0 -0
  69. package/android/.gradle/6.8/fileChanges/last-build.bin +0 -0
  70. package/android/.gradle/6.8/fileHashes/fileHashes.lock +0 -0
  71. package/android/.gradle/6.8/gc.properties +0 -0
  72. package/android/.gradle/7.0-rc-1/dependencies-accessors/dependencies-accessors.lock +0 -0
  73. package/android/.gradle/7.0-rc-1/dependencies-accessors/gc.properties +0 -0
  74. package/android/.gradle/7.0-rc-1/fileChanges/last-build.bin +0 -0
  75. package/android/.gradle/7.0-rc-1/fileHashes/fileHashes.lock +0 -0
  76. package/android/.gradle/7.0-rc-1/gc.properties +0 -0
  77. package/android/.gradle/7.1.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  78. package/android/.gradle/7.1.1/dependencies-accessors/gc.properties +0 -0
  79. package/android/.gradle/7.1.1/executionHistory/executionHistory.lock +0 -0
  80. package/android/.gradle/7.1.1/fileChanges/last-build.bin +0 -0
  81. package/android/.gradle/7.1.1/fileHashes/fileHashes.lock +0 -0
  82. package/android/.gradle/7.1.1/gc.properties +0 -0
  83. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  84. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  85. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  86. package/android/.gradle/checksums/checksums.lock +0 -0
  87. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  88. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  89. package/android/.gradle/configuration-cache/gc.properties +0 -0
  90. package/android/.gradle/vcs-1/gc.properties +0 -0
  91. package/android/build/.transforms/8cdb68f56773f65afa4976aa86d988f7/classes/classes.dex +0 -0
  92. package/android/build/.transforms/8cdb68f56773f65afa4976aa86d988f7.bin +0 -1
  93. package/android/build/.transforms/991094845a707011dcf91007d9838bb7/classes/classes.dex +0 -0
  94. package/android/build/.transforms/991094845a707011dcf91007d9838bb7.bin +0 -1
  95. package/android/build/generated/source/buildConfig/debug/io/scanbot/barcodesdk/plugin/reactnative/BuildConfig.java +0 -18
  96. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +0 -11
  97. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output.json +0 -1
  98. package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +0 -1
  99. package/android/build/intermediates/compile_library_classes/debug/classes.jar +0 -0
  100. package/android/build/intermediates/compile_only_not_namespaced_r_class_jar/debug/R.jar +0 -0
  101. package/android/build/intermediates/incremental/debug-mergeNativeLibs/merge-state +0 -0
  102. package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +0 -2
  103. package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +0 -2
  104. package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +0 -2
  105. package/android/build/intermediates/incremental/packageDebugResources/compile-file-map.properties +0 -4
  106. package/android/build/intermediates/incremental/packageDebugResources/merger.xml +0 -2
  107. package/android/build/intermediates/javac/debug/classes/com/reactlibrary/ScanbotBarcodeSdkModule.class +0 -0
  108. package/android/build/intermediates/javac/debug/classes/com/reactlibrary/ScanbotBarcodeSdkPackage.class +0 -0
  109. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/BitmapHelper.class +0 -0
  110. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/BuildConfig.class +0 -0
  111. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/JSONUtils$WritableMapBuilder.class +0 -0
  112. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/JSONUtils.class +0 -0
  113. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/LogUtils.class +0 -0
  114. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ObjectMapper.class +0 -0
  115. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ReactBarcodeExtensionsFilter$1.class +0 -0
  116. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ReactBarcodeExtensionsFilter$Type.class +0 -0
  117. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ReactBarcodeExtensionsFilter.class +0 -0
  118. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ResponseUtils.class +0 -0
  119. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkConfiguration.class +0 -0
  120. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkModule$1.class +0 -0
  121. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkModule$2.class +0 -0
  122. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkModule$3.class +0 -0
  123. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkModule.class +0 -0
  124. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkPackage.class +0 -0
  125. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/StorageUtils.class +0 -0
  126. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/barcode/ScanbotBarcodeDetectorAdditionalConfigBuilder.class +0 -0
  127. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/barcode/ScanbotBarcodeDetectorConfigBuilder.class +0 -0
  128. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/EventEmitter$NativeEvent.class +0 -0
  129. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/EventEmitter.class +0 -0
  130. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewConfiguration.class +0 -0
  131. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewFragment$1.class +0 -0
  132. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewFragment$2.class +0 -0
  133. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewFragment.class +0 -0
  134. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewManager$1$1$1.class +0 -0
  135. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewManager$1$1.class +0 -0
  136. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewManager$1.class +0 -0
  137. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewManager.class +0 -0
  138. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/common/ScanbotComponentFrameLayout$1.class +0 -0
  139. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/common/ScanbotComponentFrameLayout$ILayoutChangeListener.class +0 -0
  140. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/common/ScanbotComponentFrameLayout.class +0 -0
  141. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/common/ScanbotComponentRootView$1.class +0 -0
  142. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/common/ScanbotComponentRootView$2.class +0 -0
  143. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/common/ScanbotComponentRootView$ILayoutChangeListener.class +0 -0
  144. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/common/ScanbotComponentRootView$IOnChildRemovedListener.class +0 -0
  145. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/components/common/ScanbotComponentRootView.class +0 -0
  146. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/filters/ReactBarcodeExtensionsFilter$1.class +0 -0
  147. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/filters/ReactBarcodeExtensionsFilter$Type.class +0 -0
  148. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/filters/ReactBarcodeExtensionsFilter.class +0 -0
  149. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/utils/BitmapHelper.class +0 -0
  150. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/utils/JSONUtils$WritableMapBuilder.class +0 -0
  151. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/utils/JSONUtils.class +0 -0
  152. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/utils/LogUtils.class +0 -0
  153. package/android/build/intermediates/javac/debug/classes/io/scanbot/barcodesdk/plugin/reactnative/utils/ResponseUtils.class +0 -0
  154. package/android/build/intermediates/library_java_res/debug/res.jar +0 -0
  155. package/android/build/intermediates/library_manifest/debug/AndroidManifest.xml +0 -11
  156. package/android/build/intermediates/local_only_symbol_list/debug/parseDebugLibraryResources/R-def.txt +0 -9
  157. package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +0 -13
  158. package/android/build/intermediates/merged_manifests/debug/output.json +0 -1
  159. package/android/build/intermediates/packaged_res/debug/drawable/ic_baseline_arrow_back_24.xml +0 -10
  160. package/android/build/intermediates/packaged_res/debug/layout/component_barcode_camera_view.xml +0 -11
  161. package/android/build/intermediates/packaged_res/debug/layout/fragment_barcode_scanner.xml +0 -23
  162. package/android/build/intermediates/res/symbol-table-with-package/debug/package-aware-r.txt +0 -3560
  163. package/android/build/intermediates/runtime_library_classes/debug/classes.jar +0 -0
  164. package/android/build/intermediates/symbols/debug/R.txt +0 -5107
  165. package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -37
  166. package/android/local.properties +0 -8
  167. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ReactBarcodeExtensionsFilter.java +0 -61
  168. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/BitmapHelper.java +0 -30
  169. package/ios/ScanbotBarcodeSdk.xcodeproj/xcuserdata/mayankpatil.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  170. package/ios/ScanbotBarcodeSdk.xcworkspace/xcuserdata/mayankpatil.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
@@ -1,19 +1,15 @@
1
1
  /*
2
2
  Scanbot Barcode Scanner SDK React Native Plugin
3
- Copyright (c) 2020 doo GmbH. All rights reserved.
3
+ Copyright (c) 2023 Scanbot SDK GmbH. All rights reserved.
4
4
  https://scanbot.io/sdk
5
5
  */
6
6
  package io.scanbot.barcodesdk.plugin.reactnative;
7
7
 
8
8
  import android.content.Context;
9
- import android.net.Uri;
10
9
 
11
- import java.io.*;
12
- import java.math.BigInteger;
13
- import java.nio.ByteBuffer;
14
- import java.security.MessageDigest;
15
- import java.security.NoSuchAlgorithmException;
16
- import java.util.UUID;
10
+ import java.io.File;
11
+ import java.io.FileNotFoundException;
12
+ import java.io.IOException;
17
13
 
18
14
  public final class StorageUtils {
19
15
 
@@ -37,78 +33,18 @@ public final class StorageUtils {
37
33
  pluginStorageDir = new File(context.getFilesDir(), PLUGIN_STORAGE_SUB_DIR);
38
34
  }
39
35
 
40
- pluginStorageDir.mkdirs();
36
+ boolean ignoredMkdirs = pluginStorageDir.mkdirs();
41
37
  if (!pluginStorageDir.isDirectory()) {
42
38
  throw new IOException("Could not create/get plugin storage directory: " + pluginStorageDir.getAbsolutePath());
43
39
  }
44
40
  return pluginStorageDir;
45
41
  }
46
42
 
47
-
48
- public static File generateRandomPluginStorageFile(final String extension, final Context context) throws IOException {
49
- final String imageFileName = UUID.randomUUID().toString() + "." + extension;
50
- return new File(getPluginStorageBaseDirectory(context), imageFileName);
51
- }
52
-
53
-
54
43
  public static void cleanupPluginStorageDirectory(final Context context) throws IOException {
55
44
  final File dir = getPluginStorageBaseDirectory(context);
56
45
  cleanDirectory(dir);
57
46
  }
58
47
 
59
- public static void copyFile(final File source, final File target) throws IOException {
60
- final InputStream in = new FileInputStream(source);
61
- final OutputStream out = new FileOutputStream(target);
62
- byte[] buf = new byte[1024];
63
- int len;
64
- while ((len = in.read(buf)) > 0) {
65
- out.write(buf, 0, len);
66
- }
67
- in.close();
68
- out.close();
69
- }
70
-
71
- static String uriWithHash(Uri fileUri) {
72
- String path = fileUri.getPath();
73
- File file = new File(path);
74
- RandomAccessFile fileReader = null;
75
- try {
76
- MessageDigest digest = MessageDigest.getInstance("MD5");
77
- ByteBuffer lengthBuffer = ByteBuffer.allocate(8);
78
- long length = file.length();
79
- lengthBuffer.putLong(length);
80
- digest.update(lengthBuffer.array());
81
-
82
- fileReader = new RandomAccessFile(file, "r");
83
- byte[] buffer = new byte[32768];
84
- if (length > buffer.length) {
85
- fileReader.seek((length - buffer.length) / 2);
86
- }
87
- fileReader.read(buffer);
88
- digest.update(buffer);
89
-
90
- String hash = new BigInteger(1, digest.digest()).toString(16);
91
- return fileUri.buildUpon().appendQueryParameter("minihash", hash).build().toString();
92
-
93
- } catch (NoSuchAlgorithmException e) {
94
- e.printStackTrace();
95
- } catch (FileNotFoundException e) {
96
- e.printStackTrace();
97
- } catch (IOException e) {
98
- e.printStackTrace();
99
- } finally {
100
- if (fileReader != null) {
101
- try {
102
- fileReader.close();
103
- } catch (IOException e) {
104
- e.printStackTrace();
105
- }
106
- }
107
- }
108
-
109
- return fileUri.toString();
110
- }
111
-
112
48
  private static void cleanDirectory(final File directory) throws IOException {
113
49
  final File[] files = verifiedListFiles(directory);
114
50
 
@@ -10,7 +10,7 @@ import kotlin.jvm.functions.Function1;
10
10
 
11
11
  class ScanbotBarcodeDetectorAdditionalConfigBuilder implements Function1<BarcodeScannerAdditionalConfigBuilder, Unit> {
12
12
 
13
- final ReadableMap options;
13
+ private final ReadableMap options;
14
14
 
15
15
  public ScanbotBarcodeDetectorAdditionalConfigBuilder(final ReadableMap options) {
16
16
  this.options = options;
@@ -14,7 +14,7 @@ import kotlin.jvm.functions.Function1;
14
14
 
15
15
  public class ScanbotBarcodeDetectorConfigBuilder implements Function1<BarcodeScannerConfigBuilder, Unit> {
16
16
 
17
- final ReadableMap options;
17
+ private final ReadableMap options;
18
18
 
19
19
  public ScanbotBarcodeDetectorConfigBuilder(final ReadableMap options) {
20
20
  this.options = options;
@@ -26,9 +26,8 @@ import com.facebook.react.views.view.ReactViewGroup;
26
26
  import java.util.Collections;
27
27
  import java.util.List;
28
28
 
29
- import io.scanbot.barcodesdk.plugin.reactnative.R;
30
- import io.scanbot.barcodesdk.plugin.reactnative.components.base.ui.ScanbotViewWrapper;
31
29
  import io.scanbot.barcodesdk.plugin.reactnative.components.base.communication.ScanbotEventEmitter;
30
+ import io.scanbot.barcodesdk.plugin.reactnative.components.base.ui.ScanbotViewWrapper;
32
31
  import io.scanbot.barcodesdk.plugin.reactnative.utils.JSONUtils;
33
32
  import io.scanbot.barcodesdk.plugin.reactnative.utils.ScanbotViewUtils;
34
33
  import io.scanbot.sdk.SdkLicenseError;
@@ -38,7 +37,6 @@ import io.scanbot.sdk.barcode.ScanbotBarcodeDetector;
38
37
  import io.scanbot.sdk.barcode.entity.BarcodeItem;
39
38
  import io.scanbot.sdk.barcode.entity.BarcodeScannerAdditionalConfig;
40
39
  import io.scanbot.sdk.barcode.entity.BarcodeScanningResult;
41
- import io.scanbot.sdk.camera.CameraOpenCallback;
42
40
  import io.scanbot.sdk.camera.FrameHandlerResult;
43
41
  import io.scanbot.sdk.ui.camera.FinderOverlayView;
44
42
  import io.scanbot.sdk.ui.camera.ScanbotCameraXView;
@@ -48,7 +46,7 @@ import kotlin.Unit;
48
46
  public class ScanbotBarcodeCameraView extends FrameLayout implements BarcodeDetectorFrameHandler.ResultHandler {
49
47
  // From Java to JavaScript
50
48
  public enum NativeEvents implements ScanbotEventEmitter.NativeEvent {
51
- BARCODE_SCANNER_RESULT("onBarcodeScannerResult");
49
+ BARCODE_SCANNER_RESULT("onNativeBarcodeScannerResult");
52
50
 
53
51
  private final String name;
54
52
  NativeEvents(final String name) {
@@ -68,7 +66,7 @@ public class ScanbotBarcodeCameraView extends FrameLayout implements BarcodeDete
68
66
  private FinderOverlayView finderOverlayView;
69
67
  private ViewGroup childrenContainerView;
70
68
 
71
- // Barcode Detection
69
+ /** @noinspection FieldCanBeLocal*/ // Barcode Detection
72
70
  private BarcodeDetectorFrameHandler frameHandler;
73
71
  private ScanbotBarcodeDetector barcodeDetector;
74
72
 
@@ -178,12 +176,7 @@ public class ScanbotBarcodeCameraView extends FrameLayout implements BarcodeDete
178
176
  finderOverlayView.setRequiredAspectRatios(Collections.singletonList(config.getFinderAspectRatio()));
179
177
  finderOverlayView.requestLayout();
180
178
 
181
- cameraView.setCameraOpenCallback(new CameraOpenCallback() {
182
- @Override
183
- public void onCameraOpened() {
184
- cameraView.useFlash(config.isFlashEnabled());
185
- }
186
- });
179
+ cameraView.setCameraOpenCallback(() -> cameraView.useFlash(config.isFlashEnabled()));
187
180
  // Camera View
188
181
  cameraView.useFlash(config.isFlashEnabled());
189
182
 
@@ -200,6 +193,7 @@ public class ScanbotBarcodeCameraView extends FrameLayout implements BarcodeDete
200
193
  if(!config.acceptedDocumentFormats.isEmpty()) {
201
194
  b.setAcceptedDocumentFormats(config.acceptedDocumentFormats);
202
195
  }
196
+
203
197
  b.setEngineMode(config.engineMode);
204
198
  if (config.additionalConfiguration != null) {
205
199
  // TODO: Re-use ScanbotBarcodeDetectorAdditionalConfigBuilder
@@ -256,7 +250,7 @@ public class ScanbotBarcodeCameraView extends FrameLayout implements BarcodeDete
256
250
  final FinderOverlayView finderView = new FinderOverlayView(context, null);
257
251
 
258
252
  finderView.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));
259
- finderView.setId(R.id.finder_overlay);
253
+ finderView.setId(io.scanbot.sdk.barcode.R.id.finder_overlay);
260
254
 
261
255
  ScanbotViewUtils.installHierarchyFitter(finderView);
262
256
 
@@ -336,14 +330,14 @@ public class ScanbotBarcodeCameraView extends FrameLayout implements BarcodeDete
336
330
  * Utils and overrides
337
331
  ---------------------------*/
338
332
  /**
339
- * WORKAROUND for React Native ISSUE #17968
333
+ * WORKAROUND for React Native
334
+ * <a href="https://github.com/facebook/react-native/issues/17968">ISSUE #17968</a>
340
335
  * Android native UI components are not re-layout on dynamically added views
341
- * https://github.com/facebook/react-native/issues/17968
342
336
  * @param cameraView - The view that CONTAINS a PreviewView
343
337
  */
344
338
  private void applyWorkaroundForReactNativeIssue17968(final ViewGroup cameraView) {
345
339
  ScanbotViewUtils.installHierarchyFitter(cameraView);
346
- ScanbotViewUtils.installHierarchyFitter(cameraView.findViewById(R.id.camera_preview_view));
340
+ ScanbotViewUtils.installHierarchyFitter(cameraView.findViewById(io.scanbot.sdk.barcode.R.id.camera_preview_view));
347
341
  }
348
342
 
349
343
  public static NativeEvents[] getNativeEvents() {
@@ -12,20 +12,20 @@ import java.util.List;
12
12
  import io.scanbot.barcodesdk.plugin.reactnative.ObjectMapper;
13
13
  import io.scanbot.barcodesdk.plugin.reactnative.components.base.models.ScanbotFinderInset;
14
14
  import io.scanbot.barcodesdk.plugin.reactnative.utils.JSONUtils;
15
+ import io.scanbot.sdk.AspectRatio;
15
16
  import io.scanbot.sdk.barcode.BarcodeFilter;
16
17
  import io.scanbot.sdk.barcode.entity.BarcodeDensity;
17
18
  import io.scanbot.sdk.barcode.entity.BarcodeDocumentFormat;
18
19
  import io.scanbot.sdk.barcode.entity.BarcodeFormat;
19
20
  import io.scanbot.sdk.barcode.entity.BarcodeScannerAdditionalConfig;
20
21
  import io.scanbot.sdk.barcode.entity.EngineMode;
21
- import io.scanbot.sdk.ui.camera.FinderAspectRatio;
22
22
 
23
23
  @SuppressWarnings("unused")
24
24
  public class ScanbotBarcodeCameraViewConfiguration {
25
25
  // Manually mapped properties (must NOT have a getter and setter)
26
26
  public List<BarcodeFormat> barcodeFormats = new ArrayList<>();
27
27
  public List<BarcodeDocumentFormat> acceptedDocumentFormats = new ArrayList<>();
28
- public EngineMode engineMode;
28
+ public EngineMode engineMode = EngineMode.NextGen;
29
29
  public BarcodeScannerAdditionalConfig additionalConfiguration;
30
30
  public BarcodeFilter barcodeFilter;
31
31
  public BarcodeDensity codeDensity;
@@ -40,7 +40,8 @@ public class ScanbotBarcodeCameraViewConfiguration {
40
40
  private float finderBackgroundOpacity = 0.66f;
41
41
  private float cameraZoomFactor = -1;
42
42
  private boolean flashEnabled = false;
43
- private FinderAspectRatio finderAspectRatio = new FinderAspectRatio(1, 1);
43
+
44
+ private AspectRatio finderAspectRatio = new AspectRatio(1, 1);
44
45
 
45
46
  public void setShouldUseFinderView(boolean shouldUseFinderView) {
46
47
  this.shouldUseFinderView = shouldUseFinderView;
@@ -62,7 +63,7 @@ public class ScanbotBarcodeCameraViewConfiguration {
62
63
  this.finderBackgroundColor = viewFinderBackgroundColor;
63
64
  }
64
65
 
65
- public void setFinderAspectRatio(FinderAspectRatio finderAspectRatio) {
66
+ public void setFinderAspectRatio(AspectRatio finderAspectRatio) {
66
67
  this.finderAspectRatio = finderAspectRatio;
67
68
  }
68
69
 
@@ -108,7 +109,7 @@ public class ScanbotBarcodeCameraViewConfiguration {
108
109
  return flashEnabled;
109
110
  }
110
111
 
111
- public FinderAspectRatio getFinderAspectRatio() {
112
+ public AspectRatio getFinderAspectRatio() {
112
113
  return finderAspectRatio;
113
114
  }
114
115
 
@@ -16,6 +16,7 @@ public class ScanbotEventEmitter {
16
16
  }
17
17
 
18
18
  public enum CommonEvents implements NativeEvent {
19
+ // TODO: requestComponentReload is not currently implemented
19
20
  REQUEST_COMPONENT_RELOAD("requestComponentReload");
20
21
 
21
22
  private final String name;
@@ -41,9 +42,10 @@ public class ScanbotEventEmitter {
41
42
  public void emitEvent(final NativeEvent event, final WritableMap data) {
42
43
  assert reactContext != null;
43
44
  jsEventEmitter.receiveEvent(
44
- rootViewGroup.getId(),
45
- event.getName(),
46
- data);
45
+ rootViewGroup.getId(),
46
+ event.getName(),
47
+ data
48
+ );
47
49
  }
48
50
 
49
51
  public static Map<String, Object> getMapForNativeEvents(NativeEvent[] events) {
@@ -25,6 +25,7 @@ public class ScanbotEventReceiver {
25
25
  this.name = name;
26
26
  }
27
27
 
28
+ @Override
28
29
  public String getName() {
29
30
  return name;
30
31
  }
@@ -45,12 +46,22 @@ public class ScanbotEventReceiver {
45
46
  }
46
47
 
47
48
  public void receiveCommand(@NonNull final String commandId, @Nullable final ReadableArray args) {
48
- int commandIdInt = Integer.parseInt(commandId);
49
- if (!eventsMap.containsKey(commandIdInt)) {
50
- return; // Command not handled
49
+ try {
50
+ // Legacy implementation uses integers for command identifiers
51
+ int commandIdInt = Integer.parseInt(commandId);
52
+ if (!eventsMap.containsKey(commandIdInt)) {
53
+ return; // Command not handled
54
+ }
55
+
56
+ final String eventName = eventsMap.get(commandIdInt);
57
+ handleReceivedCommandFromEventName(eventName, args);
58
+ } catch(NumberFormatException ignored) {
59
+ // New Architecture implementation uses strings for command identifiers
60
+ handleReceivedCommandFromEventName(commandId, args);
51
61
  }
62
+ }
52
63
 
53
- final String eventName = eventsMap.get(commandIdInt);
64
+ private void handleReceivedCommandFromEventName(final String eventName, @Nullable final ReadableArray args) {
54
65
  assert eventName != null;
55
66
  final JavaScriptEvent event = getEventFromName(eventName);
56
67
  handler.eventHandler_eventReceived(event, args);
@@ -1,12 +1,11 @@
1
1
  /*
2
2
  Scanbot Barcode Scanner SDK React Native Plugin
3
- Copyright (c) 2020 doo GmbH. All rights reserved.
3
+ Copyright (c) 2023 Scanbot SDK GmbH. All rights reserved.
4
4
  https://scanbot.io/sdk
5
5
  */
6
6
  package io.scanbot.barcodesdk.plugin.reactnative.utils;
7
7
 
8
8
  import android.graphics.Color;
9
- import android.graphics.PointF;
10
9
  import android.util.Log;
11
10
 
12
11
  import androidx.annotation.NonNull;
@@ -52,26 +51,31 @@ public final class JSONUtils {
52
51
 
53
52
  private final WritableNativeMap _writableMap = new WritableNativeMap();
54
53
 
54
+ /** @noinspection unused*/
55
55
  public WritableMapBuilder putBoolean(@NonNull String key, boolean value) {
56
56
  _writableMap.putBoolean(key, value);
57
57
  return this;
58
58
  }
59
59
 
60
+ /** @noinspection unused*/
60
61
  public WritableMapBuilder putDouble(@NonNull String key, double value) {
61
62
  _writableMap.putDouble(key, value);
62
63
  return this;
63
64
  }
64
65
 
66
+ /** @noinspection unused*/
65
67
  public WritableMapBuilder putInt(@NonNull String key, int value) {
66
68
  _writableMap.putInt(key, value);
67
69
  return this;
68
70
  }
69
71
 
72
+ /** @noinspection unused*/
70
73
  public WritableMapBuilder putNull(@NonNull String key) {
71
74
  _writableMap.putNull(key);
72
75
  return this;
73
76
  }
74
77
 
78
+ /** @noinspection unused*/
75
79
  public WritableMapBuilder putString(@NonNull String key, @Nullable String value) {
76
80
  _writableMap.putString(key, value);
77
81
  return this;
@@ -82,6 +86,7 @@ public final class JSONUtils {
82
86
  return this;
83
87
  }
84
88
 
89
+ /** @noinspection unused*/
85
90
  public WritableMapBuilder putArray(@NonNull String key, @Nullable ReadableArray value) {
86
91
  _writableMap.putArray(key, value);
87
92
  return this;
@@ -92,19 +97,6 @@ public final class JSONUtils {
92
97
  }
93
98
  }
94
99
 
95
- public static WritableArray sdkPolygonToWritableArray(final List<PointF> polygon) {
96
- WritableArray points = Arguments.createArray();
97
- if (polygon != null) {
98
- for (final PointF p : polygon) {
99
- WritableMap pointRecord = Arguments.createMap();
100
- pointRecord.putDouble("x", p.x);
101
- pointRecord.putDouble("y", p.y);
102
- points.pushMap(pointRecord);
103
- }
104
- }
105
- return points;
106
- }
107
-
108
100
  public static ArrayList<BarcodeFormat> extractBarcodeFormats(@NotNull ReadableMap configuration) {
109
101
  ArrayList<BarcodeFormat> nativeBarcodeFormats = new ArrayList<>();
110
102
  if (configuration.hasKey("barcodeFormats")) {
@@ -300,13 +292,6 @@ public final class JSONUtils {
300
292
  return EngineMode.NextGen;
301
293
  }
302
294
 
303
- public static boolean getBoolOrFalse(final ReadableMap map, final String key) {
304
- if (!map.hasKey(key)) {
305
- return false;
306
- }
307
- return map.getBoolean(key);
308
- }
309
-
310
295
  public static WritableMap jsonResultFromBarcodeResult(BarcodeScanningResult barcodeResult) {
311
296
  return jsonResultFromBarcodeItems(
312
297
  barcodeResult != null ? barcodeResult.getBarcodeItems() : new ArrayList<>()
@@ -331,9 +316,6 @@ public final class JSONUtils {
331
316
 
332
317
  public static ReadableArray jsonFromRawBytes(byte[] rawBytes) {
333
318
  final WritableArray jsonArray = Arguments.createArray();
334
- if (rawBytes.length == 0) {
335
- return jsonArray;
336
- }
337
319
 
338
320
  for (byte b : rawBytes) {
339
321
  jsonArray.pushInt(b);
@@ -343,19 +325,22 @@ public final class JSONUtils {
343
325
  }
344
326
 
345
327
  public static SelectionOverlayConfiguration extractSelectionOverlayConfiguration(ReadableMap configuration) {
346
-
347
328
  if (configuration.hasKey("overlayConfiguration")) {
348
329
  configuration = configuration.getMap("overlayConfiguration");
349
330
  } else {
350
331
  return null;
351
332
  }
352
333
 
353
- Boolean overlayEnabled = true;
334
+ if (configuration == null) {
335
+ return null;
336
+ }
337
+
338
+ boolean overlayEnabled = true;
354
339
  if (configuration.hasKey("overlayEnabled")) {
355
340
  overlayEnabled = configuration.getBoolean("overlayEnabled");
356
341
  }
357
342
 
358
- Boolean automaticSelectionEnabled = false;
343
+ boolean automaticSelectionEnabled = false;
359
344
  if (configuration.hasKey("automaticSelectionEnabled")) {
360
345
  automaticSelectionEnabled = configuration.getBoolean("automaticSelectionEnabled");
361
346
  }
@@ -392,27 +377,31 @@ public final class JSONUtils {
392
377
  highlightedTextContainerColor = Color.parseColor(configuration.getString("highlightedTextContainerColor"));
393
378
  }
394
379
 
395
- SelectionOverlayConfiguration selectionOverlayConfiguration = new SelectionOverlayConfiguration(
396
- overlayEnabled,
397
- automaticSelectionEnabled,
398
- textFormat,
399
- polygonColor,
400
- textColor,
401
- textContainerColor,
402
- highlightedPolygonColor,
403
- highlightedTextColor,
404
- highlightedTextContainerColor);
405
- return selectionOverlayConfiguration;
380
+ return new SelectionOverlayConfiguration(
381
+ overlayEnabled,
382
+ automaticSelectionEnabled,
383
+ textFormat,
384
+ polygonColor,
385
+ textColor,
386
+ textContainerColor,
387
+ highlightedPolygonColor,
388
+ highlightedTextColor,
389
+ highlightedTextContainerColor
390
+ );
406
391
  }
407
392
 
408
393
  private static BarcodeOverlayTextFormat extractOverlayTextFormat(ReadableMap configuration) {
409
- String textFormatString = "";
394
+ String textFormatString;
410
395
  if (configuration.hasKey("overlayTextFormat") && configuration.getString("overlayTextFormat") != null) {
411
396
  textFormatString = configuration.getString("overlayTextFormat");
412
397
  } else {
413
398
  return BarcodeOverlayTextFormat.CODE_AND_TYPE;
414
399
  }
415
400
 
401
+ if (textFormatString == null) {
402
+ return BarcodeOverlayTextFormat.CODE_AND_TYPE;
403
+ }
404
+
416
405
  switch (textFormatString) {
417
406
  case "NONE":
418
407
  return BarcodeOverlayTextFormat.NONE;
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  Scanbot Barcode Scanner SDK React Native Plugin
3
- Copyright (c) 2020 doo GmbH. All rights reserved.
3
+ Copyright (c) 2023 Scanbot SDK GmbH. All rights reserved.
4
4
  https://scanbot.io/sdk
5
5
  */
6
6
  package io.scanbot.barcodesdk.plugin.reactnative.utils;
@@ -19,6 +19,7 @@ public final class LogUtils {
19
19
  loggingEnabled = flag;
20
20
  }
21
21
 
22
+ /** @noinspection unused*/
22
23
  public static synchronized boolean isLoggingEnabled() {
23
24
  return loggingEnabled;
24
25
  }
@@ -29,10 +30,12 @@ public final class LogUtils {
29
30
  }
30
31
  }
31
32
 
33
+ /** @noinspection unused*/
32
34
  public static void errorLog(final String logTag, final String msg) {
33
35
  Log.e(logTag, msg);
34
36
  }
35
37
 
38
+ /** @noinspection unused*/
36
39
  public static void errorLog(final String logTag, final String msg, final Throwable e) {
37
40
  Log.e(logTag, msg, e);
38
41
  }
@@ -1,17 +1,13 @@
1
1
  /*
2
2
  Scanbot Barcode Scanner SDK React Native Plugin
3
- Copyright (c) 2020 doo GmbH. All rights reserved.
3
+ Copyright (c) 2023 Scanbot SDK GmbH. All rights reserved.
4
4
  https://scanbot.io/sdk
5
5
  */
6
6
  package io.scanbot.barcodesdk.plugin.reactnative.utils;
7
7
 
8
- import android.view.View;
9
-
10
8
  import com.facebook.react.bridge.Arguments;
11
9
  import com.facebook.react.bridge.Promise;
12
- import com.facebook.react.bridge.ReactContext;
13
10
  import com.facebook.react.bridge.WritableMap;
14
- import com.facebook.react.uimanager.events.RCTEventEmitter;
15
11
 
16
12
  public class ResponseUtils {
17
13
 
@@ -31,11 +27,7 @@ public class ResponseUtils {
31
27
  public static void errorMessageJson(final String msg, final Promise promise) {
32
28
  final WritableMap response = Arguments.createMap();
33
29
  response.putString("error", msg);
30
+ // TODO: Rejecting with string argument is deprecated
34
31
  promise.reject(msg);
35
32
  }
36
-
37
- public static void sendReactEvent(String eventName, WritableMap event, View view) {
38
- final ReactContext reactContext = (ReactContext)view.getContext();
39
- reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(view.getId(), eventName, event);
40
- }
41
33
  }
@@ -1,8 +1,6 @@
1
1
  package io.scanbot.barcodesdk.plugin.reactnative.utils;
2
2
 
3
3
  import android.graphics.Color;
4
- import android.util.Log;
5
- import android.view.Choreographer;
6
4
  import android.view.View;
7
5
  import android.view.ViewGroup;
8
6
 
@@ -25,21 +23,6 @@ public class ScanbotViewUtils {
25
23
  public void onChildViewRemoved(View parent, View child) {}
26
24
  });
27
25
  }
28
-
29
- public static void remeasureChildren(final ViewGroup view) {
30
- Choreographer.getInstance().postFrameCallback(frameTimeNanos -> {
31
- for (int i = 0; i < view.getChildCount(); i++) {
32
- View child = view.getChildAt(i);
33
- if (child instanceof ViewGroup) {
34
- child.measure(View.MeasureSpec.makeMeasureSpec(view.getMeasuredWidth(), View.MeasureSpec.EXACTLY),
35
- View.MeasureSpec.makeMeasureSpec(view.getMeasuredHeight(), View.MeasureSpec.EXACTLY));
36
- child.layout(0, 0, child.getMeasuredWidth(), child.getMeasuredHeight());
37
- }
38
- }
39
- view.getViewTreeObserver().dispatchOnGlobalLayout();
40
- });
41
- }
42
-
43
26
  @ColorInt
44
27
  public static int colorWithAlpha(@ColorInt int color, float factor) {
45
28
  int alpha = Math.round(Color.alpha(color) * factor);