react-native-scanbot-barcode-scanner-sdk 4.0.4 → 4.2.0-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 (83) hide show
  1. package/LICENSE +1 -1
  2. package/Libraries.txt +85 -419
  3. package/RNScanbotBarcodeSDK.podspec +3 -3
  4. package/android/build.gradle +12 -13
  5. package/android/src/main/AndroidManifest.xml +2 -2
  6. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkModule.kt +179 -0
  7. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkPackage.kt +23 -0
  8. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkPluginResultDelegate.kt +23 -0
  9. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraView.java +79 -70
  10. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/extensions/JSONObject.kt +90 -0
  11. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/extensions/ReadableMap.kt +53 -0
  12. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/JSONUtils.kt +24 -0
  13. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/ScanbotViewUtils.java +4 -0
  14. package/android/src/new-architecture/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewManager.java +0 -2
  15. package/index.d.ts +24 -29
  16. package/index.js +9 -2
  17. package/ios/Components/BarcodeCameraView/NewArchitecture/RTNScanbotBarcodeCameraView.h +0 -1
  18. package/ios/Components/BarcodeCameraView/NewArchitecture/RTNScanbotBarcodeCameraView.mm +120 -148
  19. package/ios/Components/BarcodeCameraView/OldArchitecture/RNScanbotBarcodeCameraView.h +0 -31
  20. package/ios/Components/BarcodeCameraView/OldArchitecture/RNScanbotBarcodeCameraView.mm +45 -158
  21. package/ios/Components/BarcodeCameraView/OldArchitecture/RNScanbotBarcodeCameraViewManager.mm +0 -1
  22. package/ios/ScanbotBarcodeSdk.h +1 -12
  23. package/ios/ScanbotBarcodeSdk.m +64 -489
  24. package/ios/ScanbotBarcodeSdkPluginResultDelegate.h +18 -0
  25. package/ios/ScanbotBarcodeSdkPluginResultDelegate.m +36 -0
  26. package/js/{RTNScanbotBarcodeCameraViewNativeComponent.tsx → RTNScanbotBarcodeCameraViewNativeComponent.ts} +7 -35
  27. package/package.json +5 -2
  28. package/src/components/barcode-camera-view/{scanbot-barcode-camera-view-types.tsx → scanbot-barcode-camera-view-types.ts} +57 -16
  29. package/src/components/barcode-camera-view/scanbot-barcode-camera-view.tsx +14 -4
  30. package/src/configurations.ts +374 -0
  31. package/src/customConfigurations.ts +97 -0
  32. package/src/customResults.ts +6 -0
  33. package/src/customTypes.ts +10 -0
  34. package/src/results.ts +38 -0
  35. package/src/types.ts +1355 -0
  36. package/android/.project +0 -34
  37. package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
  38. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  39. package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  40. package/android/gradlew +0 -185
  41. package/android/gradlew.bat +0 -89
  42. package/android/src/main/java/com/reactlibrary/ScanbotBarcodeSdkModule.java +0 -19
  43. package/android/src/main/java/com/reactlibrary/ScanbotBarcodeSdkPackage.java +0 -38
  44. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ObjectMapper.java +0 -166
  45. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkConfiguration.java +0 -75
  46. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkModule.java +0 -460
  47. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkPackage.java +0 -36
  48. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/StorageUtils.java +0 -108
  49. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/barcode/ScanbotBarcodeDetectorAdditionalConfigBuilder.java +0 -37
  50. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/barcode/ScanbotBarcodeDetectorConfigBuilder.java +0 -45
  51. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewConfiguration.java +0 -195
  52. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/filters/ReactBarcodeExtensionsFilter.java +0 -59
  53. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/JSONUtils.java +0 -440
  54. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/LogUtils.java +0 -43
  55. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/ResponseUtils.java +0 -33
  56. package/android/src/main/res/drawable/ic_baseline_arrow_back_24.xml +0 -10
  57. package/android/src/main/res/values/attrs.xml +0 -5
  58. package/ios/Categories/SBSDKPolygon+JSON.h +0 -16
  59. package/ios/Categories/SBSDKPolygon+JSON.m +0 -21
  60. package/ios/Categories/UIColor+JSON.h +0 -14
  61. package/ios/Categories/UIColor+JSON.m +0 -61
  62. package/ios/ScanbotBarcodeSDKConfiguration.h +0 -15
  63. package/ios/ScanbotBarcodeSDKConfiguration.m +0 -13
  64. package/ios/ScanbotBarcodeSdk.xcodeproj/project.pbxproj +0 -271
  65. package/ios/ScanbotBarcodeSdk.xcworkspace/contents.xcworkspacedata +0 -7
  66. package/ios/ScanbotBarcodeSdk.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  67. package/ios/SharedConfiguration.h +0 -18
  68. package/ios/SharedConfiguration.m +0 -20
  69. package/ios/Utils/BarcodeMapping.h +0 -336
  70. package/ios/Utils/HashUtils.h +0 -46
  71. package/ios/Utils/JSONMappings.h +0 -25
  72. package/ios/Utils/LoggingUtils.h +0 -23
  73. package/ios/Utils/ObjectMapper.h +0 -26
  74. package/ios/Utils/ObjectMapper.m +0 -143
  75. package/ios/Utils/ReactBarcodeExtensionsFilter.h +0 -22
  76. package/ios/Utils/ReactBarcodeExtensionsFilter.m +0 -55
  77. package/ios/Utils/ScanbotStorageUtils.h +0 -25
  78. package/ios/Utils/ScanbotStorageUtils.m +0 -111
  79. package/src/configuration.ts +0 -328
  80. package/src/enum.ts +0 -106
  81. package/src/model.ts +0 -104
  82. package/src/result.ts +0 -45
  83. /package/src/components/barcode-camera-view/{scanbot-native-barcode-camera-view.tsx → scanbot-native-barcode-camera-view.ts} +0 -0
package/android/.project DELETED
@@ -1,34 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <projectDescription>
3
- <name>android</name>
4
- <comment>Project android created by Buildship.</comment>
5
- <projects>
6
- </projects>
7
- <buildSpec>
8
- <buildCommand>
9
- <name>org.eclipse.jdt.core.javabuilder</name>
10
- <arguments>
11
- </arguments>
12
- </buildCommand>
13
- <buildCommand>
14
- <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
15
- <arguments>
16
- </arguments>
17
- </buildCommand>
18
- </buildSpec>
19
- <natures>
20
- <nature>org.eclipse.jdt.core.javanature</nature>
21
- <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
22
- </natures>
23
- <filteredResources>
24
- <filter>
25
- <id>1673971796447</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>
34
- </projectDescription>
@@ -1,13 +0,0 @@
1
- arguments=
2
- auto.sync=false
3
- build.scans.enabled=false
4
- connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(7.1.1))
5
- connection.project.dir=
6
- eclipse.preferences.version=1
7
- gradle.user.home=
8
- java.home=/Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home
9
- jvm.arguments=
10
- offline.mode=false
11
- override.workspace.settings=true
12
- show.console.view=true
13
- show.executions.view=true
@@ -1,5 +0,0 @@
1
- distributionBase=GRADLE_USER_HOME
2
- distributionPath=wrapper/dists
3
- distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
4
- zipStoreBase=GRADLE_USER_HOME
5
- zipStorePath=wrapper/dists
package/android/gradlew DELETED
@@ -1,185 +0,0 @@
1
- #!/usr/bin/env sh
2
-
3
- #
4
- # Copyright 2015 the original author or authors.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # https://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- ##############################################################################
20
- ##
21
- ## Gradle start up script for UN*X
22
- ##
23
- ##############################################################################
24
-
25
- # Attempt to set APP_HOME
26
- # Resolve links: $0 may be a link
27
- PRG="$0"
28
- # Need this for relative symlinks.
29
- while [ -h "$PRG" ] ; do
30
- ls=`ls -ld "$PRG"`
31
- link=`expr "$ls" : '.*-> \(.*\)$'`
32
- if expr "$link" : '/.*' > /dev/null; then
33
- PRG="$link"
34
- else
35
- PRG=`dirname "$PRG"`"/$link"
36
- fi
37
- done
38
- SAVED="`pwd`"
39
- cd "`dirname \"$PRG\"`/" >/dev/null
40
- APP_HOME="`pwd -P`"
41
- cd "$SAVED" >/dev/null
42
-
43
- APP_NAME="Gradle"
44
- APP_BASE_NAME=`basename "$0"`
45
-
46
- # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47
- DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48
-
49
- # Use the maximum available, or set MAX_FD != -1 to use that value.
50
- MAX_FD="maximum"
51
-
52
- warn () {
53
- echo "$*"
54
- }
55
-
56
- die () {
57
- echo
58
- echo "$*"
59
- echo
60
- exit 1
61
- }
62
-
63
- # OS specific support (must be 'true' or 'false').
64
- cygwin=false
65
- msys=false
66
- darwin=false
67
- nonstop=false
68
- case "`uname`" in
69
- CYGWIN* )
70
- cygwin=true
71
- ;;
72
- Darwin* )
73
- darwin=true
74
- ;;
75
- MINGW* )
76
- msys=true
77
- ;;
78
- NONSTOP* )
79
- nonstop=true
80
- ;;
81
- esac
82
-
83
- CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84
-
85
-
86
- # Determine the Java command to use to start the JVM.
87
- if [ -n "$JAVA_HOME" ] ; then
88
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89
- # IBM's JDK on AIX uses strange locations for the executables
90
- JAVACMD="$JAVA_HOME/jre/sh/java"
91
- else
92
- JAVACMD="$JAVA_HOME/bin/java"
93
- fi
94
- if [ ! -x "$JAVACMD" ] ; then
95
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96
-
97
- Please set the JAVA_HOME variable in your environment to match the
98
- location of your Java installation."
99
- fi
100
- else
101
- JAVACMD="java"
102
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103
-
104
- Please set the JAVA_HOME variable in your environment to match the
105
- location of your Java installation."
106
- fi
107
-
108
- # Increase the maximum file descriptors if we can.
109
- if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110
- MAX_FD_LIMIT=`ulimit -H -n`
111
- if [ $? -eq 0 ] ; then
112
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113
- MAX_FD="$MAX_FD_LIMIT"
114
- fi
115
- ulimit -n $MAX_FD
116
- if [ $? -ne 0 ] ; then
117
- warn "Could not set maximum file descriptor limit: $MAX_FD"
118
- fi
119
- else
120
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121
- fi
122
- fi
123
-
124
- # For Darwin, add options to specify how the application appears in the dock
125
- if $darwin; then
126
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127
- fi
128
-
129
- # For Cygwin or MSYS, switch paths to Windows format before running java
130
- if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133
-
134
- JAVACMD=`cygpath --unix "$JAVACMD"`
135
-
136
- # We build the pattern for arguments to be converted via cygpath
137
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138
- SEP=""
139
- for dir in $ROOTDIRSRAW ; do
140
- ROOTDIRS="$ROOTDIRS$SEP$dir"
141
- SEP="|"
142
- done
143
- OURCYGPATTERN="(^($ROOTDIRS))"
144
- # Add a user-defined pattern to the cygpath arguments
145
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147
- fi
148
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
149
- i=0
150
- for arg in "$@" ; do
151
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153
-
154
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156
- else
157
- eval `echo args$i`="\"$arg\""
158
- fi
159
- i=`expr $i + 1`
160
- done
161
- case $i in
162
- 0) set -- ;;
163
- 1) set -- "$args0" ;;
164
- 2) set -- "$args0" "$args1" ;;
165
- 3) set -- "$args0" "$args1" "$args2" ;;
166
- 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167
- 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168
- 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169
- 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170
- 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171
- 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172
- esac
173
- fi
174
-
175
- # Escape application args
176
- save () {
177
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178
- echo " "
179
- }
180
- APP_ARGS=`save "$@"`
181
-
182
- # Collect all arguments for the java command, following the shell quoting and substitution rules
183
- eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184
-
185
- exec "$JAVACMD" "$@"
@@ -1,89 +0,0 @@
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
-
17
- @if "%DEBUG%" == "" @echo off
18
- @rem ##########################################################################
19
- @rem
20
- @rem Gradle startup script for Windows
21
- @rem
22
- @rem ##########################################################################
23
-
24
- @rem Set local scope for the variables with windows NT shell
25
- if "%OS%"=="Windows_NT" setlocal
26
-
27
- set DIRNAME=%~dp0
28
- if "%DIRNAME%" == "" set DIRNAME=.
29
- set APP_BASE_NAME=%~n0
30
- set APP_HOME=%DIRNAME%
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
-
38
- @rem Find java.exe
39
- if defined JAVA_HOME goto findJavaFromJavaHome
40
-
41
- set JAVA_EXE=java.exe
42
- %JAVA_EXE% -version >NUL 2>&1
43
- if "%ERRORLEVEL%" == "0" goto execute
44
-
45
- echo.
46
- echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47
- echo.
48
- echo Please set the JAVA_HOME variable in your environment to match the
49
- echo location of your Java installation.
50
-
51
- goto fail
52
-
53
- :findJavaFromJavaHome
54
- set JAVA_HOME=%JAVA_HOME:"=%
55
- set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56
-
57
- if exist "%JAVA_EXE%" goto execute
58
-
59
- echo.
60
- echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61
- echo.
62
- echo Please set the JAVA_HOME variable in your environment to match the
63
- echo location of your Java installation.
64
-
65
- goto fail
66
-
67
- :execute
68
- @rem Setup the command line
69
-
70
- set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71
-
72
-
73
- @rem Execute Gradle
74
- "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75
-
76
- :end
77
- @rem End local scope for the variables with windows NT shell
78
- if "%ERRORLEVEL%"=="0" goto mainEnd
79
-
80
- :fail
81
- rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82
- rem the _cmd.exe /c_ return code!
83
- if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84
- exit /b 1
85
-
86
- :mainEnd
87
- if "%OS%"=="Windows_NT" endlocal
88
-
89
- :omega
@@ -1,19 +0,0 @@
1
- /*
2
- Scanbot Barcode Scanner SDK React Native Plugin
3
- Copyright (c) 2023 Scanbot SDK GmbH. All rights reserved.
4
- https://scanbot.io/sdk
5
- */
6
- package com.reactlibrary;
7
-
8
- import androidx.annotation.NonNull;
9
-
10
- import com.facebook.react.bridge.ReactContextBaseJavaModule;
11
-
12
- /** @noinspection unused*/
13
- public class ScanbotBarcodeSdkModule extends ReactContextBaseJavaModule {
14
- @NonNull
15
- @Override
16
- public String getName() {
17
- return "ScanbotBarcodeSdk";
18
- }
19
- }
@@ -1,38 +0,0 @@
1
- /*
2
- Scanbot Barcode Scanner SDK React Native Plugin
3
- Copyright (c) 2023 Scanbot SDK GmbH. All rights reserved.
4
- https://scanbot.io/sdk
5
- */
6
- package com.reactlibrary;
7
-
8
- import androidx.annotation.NonNull;
9
-
10
- import java.util.Collections;
11
- import java.util.List;
12
-
13
- import com.facebook.react.ReactPackage;
14
- import com.facebook.react.bridge.NativeModule;
15
- import com.facebook.react.bridge.ReactApplicationContext;
16
- import com.facebook.react.uimanager.ViewManager;
17
-
18
- import io.scanbot.barcodesdk.plugin.reactnative.ScanbotBarcodeSdkModule;
19
- import io.scanbot.barcodesdk.plugin.reactnative.components.barcodecameraview.ScanbotBarcodeCameraViewManager;
20
-
21
- /** @noinspection unused*/
22
- public class ScanbotBarcodeSdkPackage implements ReactPackage {
23
- @NonNull
24
- @Override
25
- public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
26
- return Collections.singletonList(new ScanbotBarcodeSdkModule(reactContext));
27
- }
28
-
29
- /*
30
- * Here the native components are exposed to React Native
31
- */
32
- @NonNull
33
- @SuppressWarnings({ "rawtypes" })
34
- @Override
35
- public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
36
- return Collections.singletonList(new ScanbotBarcodeCameraViewManager());
37
- }
38
- }
@@ -1,166 +0,0 @@
1
- /*
2
- Scanbot Barcode Scanner SDK React Native Plugin
3
- Copyright (c) 2023 Scanbot SDK GmbH. All rights reserved.
4
- https://scanbot.io/sdk
5
- */
6
- package io.scanbot.barcodesdk.plugin.reactnative;
7
-
8
- import android.graphics.Color;
9
-
10
- import com.facebook.react.bridge.ReadableMap;
11
-
12
- import java.lang.reflect.InvocationTargetException;
13
- import java.lang.reflect.Method;
14
- import java.util.HashMap;
15
- import java.util.Map;
16
-
17
- import io.scanbot.sdk.AspectRatio;
18
-
19
- public final class ObjectMapper {
20
- private static final Map<String, Map<String, Method>> methodCache = new HashMap<>();
21
-
22
- private static Map<String, Map<String, String>> enumMappings;
23
-
24
- /*
25
- * Properties listed here will be skipped by the Object Mapper
26
- */
27
- private final static String[] kIgnoredProperties = new String[] {
28
- "engineMode",
29
- "barcodeFilter",
30
- "cameraZoomRange"
31
- };
32
-
33
- public static class InvalidJSONException extends RuntimeException {
34
- public InvalidJSONException(String message) {
35
- super(message);
36
- }
37
- }
38
-
39
- public static void map(ReadableMap source, Object target)
40
- throws IllegalAccessException, InvocationTargetException {
41
- map(source.toHashMap(), target);
42
- }
43
-
44
- public static void setEnumMappings(Map<String, Map<String, String>> enumMappings) {
45
- ObjectMapper.enumMappings = enumMappings;
46
- }
47
-
48
- @SuppressWarnings({"unchecked", "SuspiciousMethodCalls", "rawtypes"})
49
- private static void map(final Map<String, Object> source, final Object target)
50
- throws IllegalAccessException, InvocationTargetException {
51
- final Class cls = target.getClass();
52
-
53
- final Map<String, Method> methodMap;
54
- if (!methodCache.containsKey(cls.getName())) {
55
- methodMap = new HashMap<>();
56
- methodCache.put(cls.getName(), methodMap);
57
-
58
- final Method[] methods = cls.getMethods();
59
- for (final Method m : methods) {
60
- methodMap.put(m.getName(), m);
61
- }
62
- } else {
63
- methodMap = methodCache.get(cls.getName());
64
- }
65
-
66
- if (methodMap == null) {
67
- throw new IllegalAccessException("Internal error. methodMap is null");
68
- }
69
-
70
- for (HashMap.Entry<String, Object> entry : source.entrySet()) {
71
- String prop = entry.getKey();
72
- Object value = entry.getValue();
73
- if (value == null) {
74
- continue;
75
- }
76
-
77
- if (shouldIgnoreProperty(prop)) {
78
- continue;
79
- }
80
-
81
- // The default FRONT camera module should be FRONT_MIRRORED on Android
82
- if ("cameraModule".equals(prop) && "FRONT".equals(value)) {
83
- value = "FRONT_MIRRORED";
84
- }
85
-
86
- // for android this property is "initialScanDelayMs" and "delayAfterScanMs" respectively.
87
- if (prop.equals("initialScanDelay") || prop.equals("delayAfterScan")) {
88
- prop += "Ms";
89
- value = ((double)value)*1000; // converting seconds to millisecond
90
- }
91
-
92
- final String setterName = "set" + prop.substring(0, 1).toUpperCase() + prop.substring(1);
93
-
94
- if (methodMap.containsKey(setterName)) {
95
- final Method setter = methodMap.get(setterName);
96
-
97
- if (setter == null) {
98
- throw new IllegalAccessException("Internal error. Setter method not found: " + setterName);
99
- }
100
-
101
- if (enumMappings != null && enumMappings.containsKey(prop)) {
102
- Map<String, String> enumNames = enumMappings.get(prop);
103
- if (enumNames != null && enumNames.containsKey(value)) {
104
- value = enumNames.get(value);
105
- }
106
- }
107
-
108
- if (setterName.equals("setFinderAspectRatio")) {
109
- final Map<String, Object> pointMap = (Map<String, Object>) value;
110
- if (pointMap != null) {
111
- final Object widthObj = pointMap.get("width");
112
- final Object heightObj = pointMap.get("height");
113
- if (widthObj != null && heightObj != null) {
114
- int x = ((Number) widthObj).intValue();
115
- int y = ((Number) heightObj).intValue();
116
- setter.invoke(target, new AspectRatio(x, y));
117
- }
118
- }
119
- } else if (setter.getParameterTypes().length == 2 && value instanceof Map) {
120
- final Map<String, Object> pointMap = (Map<String, Object>) value;
121
- final Object widthObj = pointMap.get("width");
122
- final Object heightObj = pointMap.get("width");
123
- if (widthObj != null && heightObj != null) {
124
- int x = ((Number) widthObj).intValue();
125
- int y = ((Number) heightObj).intValue();
126
- setter.invoke(target, new AspectRatio(x, y));
127
- }
128
- } else {
129
- final Class paramType = setter.getParameterTypes()[0];
130
- if (setterName.contains("Color")) {
131
- value = Color.parseColor((String) value);
132
- } else if (paramType == int.class) {
133
- assert value instanceof Number;
134
- value = ((Number)value).intValue();
135
- } else if (paramType == float.class) {
136
- assert value instanceof Number;
137
- value = ((Number) value).floatValue();
138
- } else if (paramType == double.class) {
139
- assert value instanceof Number;
140
- value = ((Number) value).doubleValue();
141
- } else if (paramType == long.class) {
142
- assert value instanceof Number;
143
- value = ((Number) value).longValue();
144
- } else if (paramType.isEnum() && value != null) {
145
- try {
146
- value = Enum.valueOf(paramType, (String) value);
147
- } catch (final Exception ignored) {
148
- continue;
149
- }
150
- }
151
-
152
- setter.invoke(target, value);
153
- }
154
- }
155
- }
156
- }
157
-
158
- private static boolean shouldIgnoreProperty(final String propertyKey) {
159
- for(String property: kIgnoredProperties) {
160
- if (property.equals(propertyKey)) {
161
- return true;
162
- }
163
- }
164
- return false;
165
- }
166
- }
@@ -1,75 +0,0 @@
1
- /*
2
- Scanbot Barcode Scanner SDK React Native Plugin
3
- Copyright (c) 2023 Scanbot SDK GmbH. All rights reserved.
4
- https://scanbot.io/sdk
5
- */
6
- package io.scanbot.barcodesdk.plugin.reactnative;
7
-
8
- // The following noinspection rule has been introduced since
9
- // methods in this class are called through reflection
10
- /** @noinspection unused*/
11
- public class ScanbotBarcodeSdkConfiguration {
12
- private boolean loggingEnabled = false;
13
- private boolean enableNativeLogging = false;
14
- private String licenseKey;
15
- private String storageBaseDirectory = null;
16
- private boolean useCameraX = true;
17
- private boolean allowXnnpackAcceleration = true;
18
- private boolean allowGpuAcceleration = true;
19
-
20
- public boolean isLoggingEnabled() {
21
- return loggingEnabled;
22
- }
23
-
24
- public void setLoggingEnabled(boolean loggingEnabled) {
25
- this.loggingEnabled = loggingEnabled;
26
- }
27
-
28
- public String getLicenseKey() {
29
- return licenseKey;
30
- }
31
-
32
- public void setLicenseKey(String licenseKey) {
33
- this.licenseKey = licenseKey;
34
- }
35
-
36
- public String getStorageBaseDirectory() {
37
- return storageBaseDirectory;
38
- }
39
-
40
- public void setStorageBaseDirectory(String storageBaseDirectory) {
41
- this.storageBaseDirectory = storageBaseDirectory;
42
- }
43
-
44
- public boolean getAllowGpuAcceleration() {
45
- return allowGpuAcceleration;
46
- }
47
-
48
- public void setAllowGpuAcceleration(boolean allowGpuAcceleration) {
49
- this.allowGpuAcceleration = allowGpuAcceleration;
50
- }
51
-
52
- public boolean getUseCameraX() {
53
- return useCameraX;
54
- }
55
-
56
- public void setUseCameraX(boolean useCameraX) {
57
- this.useCameraX = useCameraX;
58
- }
59
-
60
- public boolean getAllowXnnpackAcceleration() {
61
- return allowXnnpackAcceleration;
62
- }
63
-
64
- public void setAllowXnnpackAcceleration(boolean allowXnnpackAcceleration) {
65
- this.allowXnnpackAcceleration = allowXnnpackAcceleration;
66
- }
67
-
68
- public boolean getEnableNativeLogging() {
69
- return enableNativeLogging;
70
- }
71
-
72
- public void setEnableNativeLogging(boolean enableNativeLogging) {
73
- this.enableNativeLogging = enableNativeLogging;
74
- }
75
- }