scandit-capacitor-datacapture-barcode 6.26.0-beta.2 → 6.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -17,5 +17,5 @@ Pod::Spec.new do |s|
|
|
|
17
17
|
|
|
18
18
|
s.dependency "Capacitor"
|
|
19
19
|
s.dependency "ScanditCapacitorDatacaptureCore", "= #{version}"
|
|
20
|
-
s.dependency "scandit-datacapture-frameworks-barcode", '= 6.
|
|
20
|
+
s.dependency "scandit-datacapture-frameworks-barcode", '= 6.27.0'
|
|
21
21
|
end
|
package/android/build.gradle
CHANGED
package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/ScanditBarcodeNative.kt
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
package com.scandit.capacitor.datacapture.barcode
|
|
7
7
|
|
|
8
|
+
import android.Manifest
|
|
8
9
|
import android.graphics.Bitmap
|
|
9
10
|
import android.graphics.BitmapFactory
|
|
10
11
|
import android.util.Base64
|
|
@@ -12,10 +13,14 @@ import android.view.View
|
|
|
12
13
|
import android.view.ViewGroup
|
|
13
14
|
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
|
|
14
15
|
import com.getcapacitor.JSObject
|
|
16
|
+
import com.getcapacitor.PermissionState
|
|
15
17
|
import com.getcapacitor.Plugin
|
|
16
18
|
import com.getcapacitor.PluginCall
|
|
19
|
+
import com.getcapacitor.PluginHandle
|
|
17
20
|
import com.getcapacitor.PluginMethod
|
|
18
21
|
import com.getcapacitor.annotation.CapacitorPlugin
|
|
22
|
+
import com.getcapacitor.annotation.Permission
|
|
23
|
+
import com.getcapacitor.annotation.PermissionCallback
|
|
19
24
|
import com.scandit.capacitor.datacapture.barcode.count.BarcodeCountViewHandler
|
|
20
25
|
import com.scandit.capacitor.datacapture.barcode.factories.BarcodeCaptureActionFactory
|
|
21
26
|
import com.scandit.capacitor.datacapture.barcode.find.BarcodeFindViewHandler
|
|
@@ -67,7 +72,10 @@ import org.json.JSONException
|
|
|
67
72
|
import org.json.JSONObject
|
|
68
73
|
|
|
69
74
|
@CapacitorPlugin(
|
|
70
|
-
name = "ScanditBarcodeNative"
|
|
75
|
+
name = "ScanditBarcodeNative",
|
|
76
|
+
permissions = [
|
|
77
|
+
Permission(strings = [Manifest.permission.CAMERA], alias = "camera")
|
|
78
|
+
]
|
|
71
79
|
)
|
|
72
80
|
class ScanditBarcodeNative :
|
|
73
81
|
Plugin(),
|
|
@@ -81,6 +89,7 @@ class ScanditBarcodeNative :
|
|
|
81
89
|
private const val WEB_VIEW_NOT_ATTACHED = "WebView not attached yet"
|
|
82
90
|
}
|
|
83
91
|
|
|
92
|
+
private var corePlugin: PluginHandle? = null
|
|
84
93
|
private val barcodeModule = BarcodeModule()
|
|
85
94
|
private val barcodeCaptureModule = BarcodeCaptureModule(FrameworksBarcodeCaptureListener(this))
|
|
86
95
|
private val barcodeTrackingModule = BarcodeTrackingModule(
|
|
@@ -124,9 +133,9 @@ class ScanditBarcodeNative :
|
|
|
124
133
|
super.load()
|
|
125
134
|
|
|
126
135
|
// We need to register the plugin with its Core dependency for serializers to load.
|
|
127
|
-
|
|
136
|
+
corePlugin = bridge.getPlugin(CORE_PLUGIN_NAME)
|
|
128
137
|
if (corePlugin != null) {
|
|
129
|
-
(corePlugin
|
|
138
|
+
(corePlugin!!.instance as ScanditCaptureCoreNative).registerPluginInstance(
|
|
130
139
|
pluginHandle.instance
|
|
131
140
|
)
|
|
132
141
|
} else {
|
|
@@ -170,6 +179,28 @@ class ScanditBarcodeNative :
|
|
|
170
179
|
barcodePickModule.viewOnResume()
|
|
171
180
|
}
|
|
172
181
|
|
|
182
|
+
private fun checkCameraPermission(): Boolean =
|
|
183
|
+
getPermissionState("camera") == PermissionState.GRANTED
|
|
184
|
+
|
|
185
|
+
fun checkOrRequestCameraPermissions(call: PluginCall) {
|
|
186
|
+
if (!checkCameraPermission()) {
|
|
187
|
+
requestPermissionForAlias("camera", call, "onCameraPermissionResult")
|
|
188
|
+
} else {
|
|
189
|
+
onCameraPermissionResult(call)
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
@Suppress("unused")
|
|
194
|
+
@PermissionCallback
|
|
195
|
+
private fun onCameraPermissionResult(call: PluginCall) {
|
|
196
|
+
if (checkCameraPermission()) {
|
|
197
|
+
call.resolve()
|
|
198
|
+
return
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
call.reject("Camera permissions not granted.")
|
|
202
|
+
}
|
|
203
|
+
|
|
173
204
|
@PluginMethod
|
|
174
205
|
fun finishCallback(call: PluginCall) {
|
|
175
206
|
try {
|
|
@@ -1177,6 +1208,7 @@ class ScanditBarcodeNative :
|
|
|
1177
1208
|
}
|
|
1178
1209
|
|
|
1179
1210
|
sparkScanModule.sparkScanView?.bringToFront()
|
|
1211
|
+
checkOrRequestCameraPermissions(call)
|
|
1180
1212
|
}
|
|
1181
1213
|
|
|
1182
1214
|
@PluginMethod
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scandit-capacitor-datacapture-barcode",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.27.0",
|
|
4
4
|
"description": "Scandit Data Capture SDK for Capacitor",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"private": false,
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"watch": "tsc --watch"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"scandit-capacitor-datacapture-core": "6.
|
|
27
|
-
"scandit-datacapture-frameworks-barcode": "6.
|
|
28
|
-
"scandit-datacapture-frameworks-core": "6.
|
|
26
|
+
"scandit-capacitor-datacapture-core": "6.27.0",
|
|
27
|
+
"scandit-datacapture-frameworks-barcode": "6.27.0",
|
|
28
|
+
"scandit-datacapture-frameworks-core": "6.27.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|