react-native-scanbot-barcode-scanner-sdk 4.2.0 → 4.3.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.
- package/Libraries.txt +31 -31
- package/RNScanbotBarcodeSDK.podspec +1 -4
- package/android/build.gradle +6 -5
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkPackage.kt +9 -7
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcode_scanner_view/ScanbotBarcodeScannerView.kt +114 -0
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcode_scanner_view/ScanbotBarcodeScannerViewEvents.kt +56 -0
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcode_scanner_view/ScanbotBarcodeScannerViewManager.kt +259 -0
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/extensions/JSONObject.kt +18 -2
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/extensions/ReadableMap.kt +3 -4
- package/android/src/newarch/ScanbotBarcodeScannerViewManagerSpec.kt +19 -0
- package/android/src/oldarch/ScanbotBarcodeScannerViewManagerSpec.kt +29 -0
- package/dist/components/barcode-camera-view/ScanbotBarcodeCameraView.d.ts +3 -0
- package/dist/components/barcode-camera-view/ScanbotBarcodeCameraView.js +121 -0
- package/dist/components/barcode-camera-view/ScanbotBarcodeCameraViewProperties.d.ts +89 -0
- package/dist/components/barcode-camera-view/ScanbotBarcodeCameraViewProperties.js +2 -0
- package/dist/components/spec/ScanbotBarcodeScannerViewNativeComponent.d.ts +54 -0
- package/dist/components/spec/ScanbotBarcodeScannerViewNativeComponent.js +12 -0
- package/dist/configurations.d.ts +241 -0
- package/dist/configurations.js +2 -0
- package/dist/customConfigurations.d.ts +94 -0
- package/dist/customConfigurations.js +2 -0
- package/dist/customResults.d.ts +5 -0
- package/dist/customResults.js +2 -0
- package/dist/customTypes.d.ts +7 -0
- package/dist/customTypes.js +2 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +34 -0
- package/dist/results.d.ts +29 -0
- package/dist/results.js +2 -0
- package/dist/types.d.ts +1194 -0
- package/dist/types.js +2 -0
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerLegacyView.h +19 -0
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerLegacyView.m +189 -0
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerView.h +18 -0
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerView.mm +254 -0
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerViewControllerWrapper.h +93 -0
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerViewControllerWrapper.m +190 -0
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerViewManager.mm +76 -0
- package/package.json +16 -21
- package/src/components/barcode-camera-view/ScanbotBarcodeCameraView.tsx +114 -0
- package/src/components/barcode-camera-view/ScanbotBarcodeCameraViewProperties.ts +106 -0
- package/src/components/spec/ScanbotBarcodeScannerViewNativeComponent.ts +59 -0
- package/src/index.ts +58 -0
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraView.java +0 -401
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/base/communication/ScanbotEventEmitter.java +0 -78
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/base/communication/ScanbotEventReceiver.java +0 -119
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/base/ui/ScanbotViewWrapper.java +0 -26
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/JSONUtils.kt +0 -24
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/ScanbotViewUtils.java +0 -43
- package/android/src/new-architecture/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewManager.java +0 -125
- package/android/src/old-architecture/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewManager.java +0 -114
- package/index.d.ts +0 -42
- package/index.js +0 -20
- package/ios/Components/BarcodeCameraView/NewArchitecture/RTNScanbotBarcodeCameraView.h +0 -44
- package/ios/Components/BarcodeCameraView/NewArchitecture/RTNScanbotBarcodeCameraView.mm +0 -338
- package/ios/Components/BarcodeCameraView/NewArchitecture/RTNScanbotBarcodeCameraViewManager.mm +0 -71
- package/ios/Components/BarcodeCameraView/OldArchitecture/RNScanbotBarcodeCameraView.h +0 -36
- package/ios/Components/BarcodeCameraView/OldArchitecture/RNScanbotBarcodeCameraView.mm +0 -181
- package/ios/Components/BarcodeCameraView/OldArchitecture/RNScanbotBarcodeCameraViewManager.h +0 -28
- package/ios/Components/BarcodeCameraView/OldArchitecture/RNScanbotBarcodeCameraViewManager.mm +0 -89
- package/js/RTNScanbotBarcodeCameraViewNativeComponent.ts +0 -186
- package/src/components/barcode-camera-view/scanbot-barcode-camera-view-types.ts +0 -175
- package/src/components/barcode-camera-view/scanbot-barcode-camera-view.tsx +0 -270
- package/src/components/barcode-camera-view/scanbot-native-barcode-camera-view.ts +0 -7
package/Libraries.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Open Source libraries used in the Scanbot Barcode SDK for React Native version 4.
|
|
1
|
+
Open Source libraries used in the Scanbot Barcode SDK for React Native version 4.3.0
|
|
2
2
|
|
|
3
3
|
```text
|
|
4
4
|
Open Source libraries used in the Scanbot Barcode Scanner SDK for iOS version 4.2.2:
|
|
@@ -78,7 +78,7 @@ record keeping.)
|
|
|
78
78
|
* are met:
|
|
79
79
|
*
|
|
80
80
|
* 1. Redistributions of source code must retain the above copyright
|
|
81
|
-
* notice, this list of conditions and the following disclaimer.
|
|
81
|
+
* notice, this list of conditions and the following disclaimer.
|
|
82
82
|
*
|
|
83
83
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
84
84
|
* notice, this list of conditions and the following disclaimer in
|
|
@@ -133,21 +133,21 @@ record keeping.)
|
|
|
133
133
|
* This package is an SSL implementation written
|
|
134
134
|
* by Eric Young (eay@cryptsoft.com).
|
|
135
135
|
* The implementation was written so as to conform with Netscapes SSL.
|
|
136
|
-
*
|
|
136
|
+
*
|
|
137
137
|
* This library is free for commercial and non-commercial use as long as
|
|
138
138
|
* the following conditions are aheared to. The following conditions
|
|
139
139
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
|
140
140
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
|
141
141
|
* included with this distribution is covered by the same copyright terms
|
|
142
142
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
|
143
|
-
*
|
|
143
|
+
*
|
|
144
144
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
|
145
145
|
* the code are not to be removed.
|
|
146
146
|
* If this package is used in a product, Eric Young should be given attribution
|
|
147
147
|
* as the author of the parts of the library used.
|
|
148
148
|
* This can be in the form of a textual message at program startup or
|
|
149
149
|
* in documentation (online or textual) provided with the package.
|
|
150
|
-
*
|
|
150
|
+
*
|
|
151
151
|
* Redistribution and use in source and binary forms, with or without
|
|
152
152
|
* modification, are permitted provided that the following conditions
|
|
153
153
|
* are met:
|
|
@@ -162,10 +162,10 @@ record keeping.)
|
|
|
162
162
|
* Eric Young (eay@cryptsoft.com)"
|
|
163
163
|
* The word 'cryptographic' can be left out if the rouines from the library
|
|
164
164
|
* being used are not cryptographic related :-).
|
|
165
|
-
* 4. If you include any Windows specific code (or a derivative thereof) from
|
|
165
|
+
* 4. If you include any Windows specific code (or a derivative thereof) from
|
|
166
166
|
* the apps directory (application code) you must include an acknowledgement:
|
|
167
167
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
|
168
|
-
*
|
|
168
|
+
*
|
|
169
169
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
|
170
170
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
171
171
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
@@ -177,7 +177,7 @@ record keeping.)
|
|
|
177
177
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
178
178
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
179
179
|
* SUCH DAMAGE.
|
|
180
|
-
*
|
|
180
|
+
*
|
|
181
181
|
* The licence and distribution terms for any publically available version or
|
|
182
182
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
|
183
183
|
* copied and put under another distribution licence
|
|
@@ -831,7 +831,7 @@ JSON for Modern C++
|
|
|
831
831
|
Version v3.11.2
|
|
832
832
|
(https://github.com/nlohmann/json)
|
|
833
833
|
|
|
834
|
-
MIT License
|
|
834
|
+
MIT License
|
|
835
835
|
|
|
836
836
|
Copyright (c) 2013-2022 Niels Lohmann
|
|
837
837
|
|
|
@@ -902,18 +902,18 @@ Copyright (C) 2007-2009 Antony Dovgal
|
|
|
902
902
|
|
|
903
903
|
This software is provided 'as-is', without any express or implied warranty.
|
|
904
904
|
|
|
905
|
-
In no event will the authors be held liable for any damages arising from the
|
|
905
|
+
In no event will the authors be held liable for any damages arising from the
|
|
906
906
|
use of this software.
|
|
907
907
|
|
|
908
|
-
Permission is granted to anyone to use this software for any purpose,including
|
|
909
|
-
commercial applications, and to alter it and redistribute it freely, subject
|
|
908
|
+
Permission is granted to anyone to use this software for any purpose,including
|
|
909
|
+
commercial applications, and to alter it and redistribute it freely, subject
|
|
910
910
|
to the following restrictions:
|
|
911
911
|
|
|
912
|
-
1. The origin of this software must not be misrepresented; you must not claim
|
|
913
|
-
that you wrote the original software. If you use this software in a
|
|
914
|
-
product, an acknowledgment in the product documentation would be
|
|
912
|
+
1. The origin of this software must not be misrepresented; you must not claim
|
|
913
|
+
that you wrote the original software. If you use this software in a
|
|
914
|
+
product, an acknowledgment in the product documentation would be
|
|
915
915
|
appreciated but is not required.
|
|
916
|
-
2. Altered source versions must be plainly marked as such, and must not be
|
|
916
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
|
917
917
|
misrepresented as being the original software.
|
|
918
918
|
3. This notice may not be removed or altered from any source distribution.
|
|
919
919
|
|
|
@@ -1212,7 +1212,7 @@ Version 4.2.0
|
|
|
1212
1212
|
Copyright (c) 1988-1997 Sam Leffler
|
|
1213
1213
|
Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
|
1214
1214
|
|
|
1215
|
-
Permission to use, copy, modify, distribute, and sell this software and
|
|
1215
|
+
Permission to use, copy, modify, distribute, and sell this software and
|
|
1216
1216
|
its documentation for any purpose is hereby granted without fee, provided
|
|
1217
1217
|
that (i) the above copyright notices and this permission notice appear in
|
|
1218
1218
|
all copies of the software and related documentation, and (ii) the names of
|
|
@@ -1220,15 +1220,15 @@ Sam Leffler and Silicon Graphics may not be used in any advertising or
|
|
|
1220
1220
|
publicity relating to the software without the specific, prior written
|
|
1221
1221
|
permission of Sam Leffler and Silicon Graphics.
|
|
1222
1222
|
|
|
1223
|
-
THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
|
1224
|
-
EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
|
1225
|
-
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
|
1223
|
+
THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
|
1224
|
+
EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
|
1225
|
+
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
|
1226
1226
|
|
|
1227
1227
|
IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
|
1228
1228
|
ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
|
1229
1229
|
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
1230
|
-
WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
|
1231
|
-
LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
|
1230
|
+
WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
|
1231
|
+
LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
|
1232
1232
|
OF THIS SOFTWARE.
|
|
1233
1233
|
|
|
1234
1234
|
|
|
@@ -1529,7 +1529,7 @@ Version 1.1.1t
|
|
|
1529
1529
|
* are met:
|
|
1530
1530
|
*
|
|
1531
1531
|
* 1. Redistributions of source code must retain the above copyright
|
|
1532
|
-
* notice, this list of conditions and the following disclaimer.
|
|
1532
|
+
* notice, this list of conditions and the following disclaimer.
|
|
1533
1533
|
*
|
|
1534
1534
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
1535
1535
|
* notice, this list of conditions and the following disclaimer in
|
|
@@ -1584,21 +1584,21 @@ Version 1.1.1t
|
|
|
1584
1584
|
* This package is an SSL implementation written
|
|
1585
1585
|
* by Eric Young (eay@cryptsoft.com).
|
|
1586
1586
|
* The implementation was written so as to conform with Netscapes SSL.
|
|
1587
|
-
*
|
|
1587
|
+
*
|
|
1588
1588
|
* This library is free for commercial and non-commercial use as long as
|
|
1589
1589
|
* the following conditions are aheared to. The following conditions
|
|
1590
1590
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
|
1591
1591
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
|
1592
1592
|
* included with this distribution is covered by the same copyright terms
|
|
1593
1593
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
|
1594
|
-
*
|
|
1594
|
+
*
|
|
1595
1595
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
|
1596
1596
|
* the code are not to be removed.
|
|
1597
1597
|
* If this package is used in a product, Eric Young should be given attribution
|
|
1598
1598
|
* as the author of the parts of the library used.
|
|
1599
1599
|
* This can be in the form of a textual message at program startup or
|
|
1600
1600
|
* in documentation (online or textual) provided with the package.
|
|
1601
|
-
*
|
|
1601
|
+
*
|
|
1602
1602
|
* Redistribution and use in source and binary forms, with or without
|
|
1603
1603
|
* modification, are permitted provided that the following conditions
|
|
1604
1604
|
* are met:
|
|
@@ -1613,10 +1613,10 @@ Version 1.1.1t
|
|
|
1613
1613
|
* Eric Young (eay@cryptsoft.com)"
|
|
1614
1614
|
* The word 'cryptographic' can be left out if the rouines from the library
|
|
1615
1615
|
* being used are not cryptographic related :-).
|
|
1616
|
-
* 4. If you include any Windows specific code (or a derivative thereof) from
|
|
1616
|
+
* 4. If you include any Windows specific code (or a derivative thereof) from
|
|
1617
1617
|
* the apps directory (application code) you must include an acknowledgement:
|
|
1618
1618
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
|
1619
|
-
*
|
|
1619
|
+
*
|
|
1620
1620
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
|
1621
1621
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
1622
1622
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
@@ -1628,7 +1628,7 @@ Version 1.1.1t
|
|
|
1628
1628
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
1629
1629
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
1630
1630
|
* SUCH DAMAGE.
|
|
1631
|
-
*
|
|
1631
|
+
*
|
|
1632
1632
|
* The licence and distribution terms for any publically available version or
|
|
1633
1633
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
|
1634
1634
|
* copied and put under another distribution licence
|
|
@@ -1646,7 +1646,7 @@ Version v1.9.2
|
|
|
1646
1646
|
|
|
1647
1647
|
The MIT License (MIT)
|
|
1648
1648
|
|
|
1649
|
-
Copyright (c) 2016 Gabi Melman.
|
|
1649
|
+
Copyright (c) 2016 Gabi Melman.
|
|
1650
1650
|
|
|
1651
1651
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1652
1652
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -4882,4 +4882,4 @@ Version 1.1.0
|
|
|
4882
4882
|
See the License for the specific language governing permissions and
|
|
4883
4883
|
limitations under the License.
|
|
4884
4884
|
|
|
4885
|
-
```
|
|
4885
|
+
```
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# AUTOGENERATED: DO NOT MODIFY MANUALLY
|
|
2
|
-
|
|
3
1
|
require "json"
|
|
4
2
|
|
|
5
3
|
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
@@ -15,8 +13,7 @@ Pod::Spec.new do |s|
|
|
|
15
13
|
s.license = { :type => 'Commercial' }
|
|
16
14
|
s.platforms = { :ios => "13.0" }
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
s.source = { :http => 'https://download.scanbot.io/barcode-scanner-sdk/react-native/react-native-scanbot-barcode-scanner-sdk-' + package['version'] + '.tgz' }
|
|
16
|
+
s.source = { :http => 'https://download.scanbot.io/barcode-scanner-sdk/react-native/react-native-scanbot-barcode-scanner-sdk-' + package['version'] + '.tgz' }
|
|
20
17
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
21
18
|
s.requires_arc = true
|
|
22
19
|
|
package/android/build.gradle
CHANGED
|
@@ -17,10 +17,9 @@ buildscript {
|
|
|
17
17
|
repositories {
|
|
18
18
|
google()
|
|
19
19
|
gradlePluginPortal()
|
|
20
|
-
jcenter()
|
|
21
20
|
mavenCentral()
|
|
22
21
|
}
|
|
23
|
-
|
|
22
|
+
|
|
24
23
|
def kotlin_version = safeExtGet('ScanbotBarcodeScannerSdk_kotlinVersion', '1.7.20')
|
|
25
24
|
|
|
26
25
|
dependencies {
|
|
@@ -47,9 +46,12 @@ android {
|
|
|
47
46
|
sourceSets {
|
|
48
47
|
main {
|
|
49
48
|
if (isNewArchitectureEnabled()) {
|
|
50
|
-
java.srcDirs += [
|
|
49
|
+
java.srcDirs += [
|
|
50
|
+
"src/newarch",
|
|
51
|
+
"${project.buildDir}/generated/source/codegen/java"
|
|
52
|
+
]
|
|
51
53
|
} else {
|
|
52
|
-
java.srcDirs += [
|
|
54
|
+
java.srcDirs += ["src/oldarch"]
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
57
|
}
|
|
@@ -69,7 +71,6 @@ repositories {
|
|
|
69
71
|
mavenLocal()
|
|
70
72
|
mavenCentral()
|
|
71
73
|
google()
|
|
72
|
-
jcenter()
|
|
73
74
|
|
|
74
75
|
// Scanbot SDK Maven Repositories (NEXUS)
|
|
75
76
|
maven {
|
package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkPackage.kt
CHANGED
|
@@ -9,15 +9,17 @@ import com.facebook.react.ReactPackage
|
|
|
9
9
|
import com.facebook.react.bridge.NativeModule
|
|
10
10
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
11
11
|
import com.facebook.react.uimanager.ViewManager
|
|
12
|
+
import io.scanbot.barcodesdk.plugin.reactnative.components.barcode_scanner_view.ScanbotBarcodeScannerViewManager
|
|
12
13
|
|
|
13
|
-
import io.scanbot.barcodesdk.plugin.reactnative.components.barcodecameraview.ScanbotBarcodeCameraViewManager
|
|
14
14
|
|
|
15
15
|
class ScanbotBarcodeSdkPackage : ReactPackage {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
17
|
+
return listOf(ScanbotBarcodeSdkModule(reactContext))
|
|
18
|
+
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
21
|
+
val viewManagers: MutableList<ViewManager<*, *>> = ArrayList()
|
|
22
|
+
viewManagers.add(ScanbotBarcodeScannerViewManager())
|
|
23
|
+
return viewManagers
|
|
24
|
+
}
|
|
23
25
|
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
package io.scanbot.barcodesdk.plugin.reactnative.components.barcode_scanner_view
|
|
2
|
+
|
|
3
|
+
import android.Manifest
|
|
4
|
+
import android.app.Activity
|
|
5
|
+
import android.content.Context
|
|
6
|
+
import android.content.pm.PackageManager
|
|
7
|
+
import android.util.AttributeSet
|
|
8
|
+
import android.view.View
|
|
9
|
+
import android.view.ViewGroup
|
|
10
|
+
import android.widget.FrameLayout
|
|
11
|
+
import androidx.core.app.ActivityCompat
|
|
12
|
+
import androidx.core.content.ContextCompat
|
|
13
|
+
import com.facebook.react.bridge.LifecycleEventListener
|
|
14
|
+
import com.facebook.react.bridge.ReactContext
|
|
15
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
16
|
+
import io.scanbot.sdk.barcode.ScanbotBarcodeDetector
|
|
17
|
+
import io.scanbot.sdk.barcode.ui.BarcodeScannerView
|
|
18
|
+
import io.scanbot.sdk.barcode.ui.IBarcodeScannerViewCallback
|
|
19
|
+
import io.scanbot.sdk.barcode_scanner.ScanbotBarcodeScannerSDK
|
|
20
|
+
import io.scanbot.sdk.camera.CaptureInfo
|
|
21
|
+
import io.scanbot.sdk.camera.FrameHandlerResult
|
|
22
|
+
import io.scanbot.sdk.ui.camera.CameraUiSettings
|
|
23
|
+
|
|
24
|
+
class ScanbotBarcodeScannerView : FrameLayout {
|
|
25
|
+
constructor(context: Context) : super(context)
|
|
26
|
+
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
|
27
|
+
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
|
28
|
+
context,
|
|
29
|
+
attrs,
|
|
30
|
+
defStyleAttr
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
var barcodeScanner: BarcodeScannerView
|
|
34
|
+
var barcodeDetector: ScanbotBarcodeDetector
|
|
35
|
+
var flashState: Boolean = false
|
|
36
|
+
|
|
37
|
+
init {
|
|
38
|
+
barcodeDetector = ScanbotBarcodeScannerSDK(context).createBarcodeDetector()
|
|
39
|
+
barcodeScanner = BarcodeScannerView(context).apply {
|
|
40
|
+
initCamera(CameraUiSettings(true))
|
|
41
|
+
initDetectionBehavior(barcodeDetector, {
|
|
42
|
+
if (it is FrameHandlerResult.Success) {
|
|
43
|
+
it.value?.let { result ->
|
|
44
|
+
sendEvent(BarcodeScannerResultEvent(result))
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
false
|
|
48
|
+
}, object : IBarcodeScannerViewCallback {
|
|
49
|
+
override fun onCameraOpen() {
|
|
50
|
+
viewController.useFlash(flashState)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
override fun onPictureTaken(image: ByteArray, captureInfo: CaptureInfo) {
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
})
|
|
57
|
+
viewController.barcodeDetectionInterval = 0
|
|
58
|
+
|
|
59
|
+
(context as ReactContext).addLifecycleEventListener(object : LifecycleEventListener {
|
|
60
|
+
override fun onHostResume() {
|
|
61
|
+
checkPermission()
|
|
62
|
+
viewController.onResume()
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
override fun onHostPause() {
|
|
66
|
+
viewController.onPause()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
override fun onHostDestroy() {
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
layoutParams = ViewGroup.LayoutParams(
|
|
76
|
+
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
77
|
+
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
78
|
+
)
|
|
79
|
+
addView(barcodeScanner)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
override fun requestLayout() {
|
|
83
|
+
super.requestLayout()
|
|
84
|
+
post {
|
|
85
|
+
layoutView()
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private fun View.layoutView() {
|
|
90
|
+
measure(
|
|
91
|
+
MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY),
|
|
92
|
+
MeasureSpec.makeMeasureSpec(measuredHeight, MeasureSpec.EXACTLY)
|
|
93
|
+
)
|
|
94
|
+
layout(left, top, right, bottom)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private fun sendEvent(event: BaseEvent) {
|
|
98
|
+
val surfaceId = UIManagerHelper.getSurfaceId(this)
|
|
99
|
+
val eventDispatcher =
|
|
100
|
+
UIManagerHelper.getEventDispatcherForReactTag((context as ReactContext), id)
|
|
101
|
+
eventDispatcher?.dispatchEvent(ComponentEvent(event, surfaceId, id))
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private fun checkPermission() {
|
|
105
|
+
val activity: Activity = (context as ReactContext).currentActivity ?: return
|
|
106
|
+
if (ContextCompat.checkSelfPermission(
|
|
107
|
+
activity,
|
|
108
|
+
Manifest.permission.CAMERA
|
|
109
|
+
) != PackageManager.PERMISSION_GRANTED
|
|
110
|
+
) {
|
|
111
|
+
ActivityCompat.requestPermissions(activity, arrayOf(Manifest.permission.CAMERA), 3000)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
package io.scanbot.barcodesdk.plugin.reactnative.components.barcode_scanner_view
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
4
|
+
import com.facebook.react.bridge.WritableMap
|
|
5
|
+
import com.facebook.react.uimanager.events.Event
|
|
6
|
+
import io.scanbot.barcodesdk.plugin.reactnative.extensions.toWritableMap
|
|
7
|
+
import io.scanbot.sdk.barcode.entity.BarcodeScanningResult
|
|
8
|
+
import io.scanbot.sdk_wrapper.SBWrapper
|
|
9
|
+
import io.scanbot.sdk_wrapper.barcode.results.SBWrapperBarcodeScannerResult
|
|
10
|
+
import org.json.JSONObject
|
|
11
|
+
|
|
12
|
+
interface BaseEvent {
|
|
13
|
+
val eventName: String
|
|
14
|
+
fun parseData(): WritableMap
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
class ComponentEvent(
|
|
18
|
+
private val baseEvent: BaseEvent,
|
|
19
|
+
sID: Int,
|
|
20
|
+
vID: Int,
|
|
21
|
+
) : Event<ComponentEvent>(sID, vID) {
|
|
22
|
+
override fun getEventData(): WritableMap {
|
|
23
|
+
return baseEvent.parseData()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
override fun getEventName(): String {
|
|
27
|
+
return baseEvent.eventName
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
override fun canCoalesce(): Boolean {
|
|
31
|
+
return false
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
class BarcodeScannerResultEvent(
|
|
36
|
+
private val barcodeResult: BarcodeScanningResult,
|
|
37
|
+
) : BaseEvent {
|
|
38
|
+
|
|
39
|
+
companion object {
|
|
40
|
+
const val NAME = "barcodeScannerResult"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
override val eventName = NAME
|
|
44
|
+
override fun parseData(): WritableMap {
|
|
45
|
+
return Arguments.createMap().apply {
|
|
46
|
+
putMap(
|
|
47
|
+
"result", JSONObject(
|
|
48
|
+
SBWrapper.gson.toJson(
|
|
49
|
+
SBWrapperBarcodeScannerResult.fromNativeBarcodeResult(barcodeResult)
|
|
50
|
+
)
|
|
51
|
+
).toWritableMap()
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
}
|