scandit-capacitor-datacapture-core 6.26.0 → 6.27.1
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/ScanditCapacitorDatacaptureCore.podspec +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/ScanditCaptureCoreNative.kt +28 -42
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/communication/CameraPermissionGrantedListener.kt +0 -11
package/android/build.gradle
CHANGED
package/android/src/main/java/com/scandit/capacitor/datacapture/core/ScanditCaptureCoreNative.kt
CHANGED
|
@@ -6,13 +6,12 @@ import com.getcapacitor.*
|
|
|
6
6
|
import com.getcapacitor.annotation.CapacitorPlugin
|
|
7
7
|
import com.getcapacitor.annotation.Permission
|
|
8
8
|
import com.getcapacitor.annotation.PermissionCallback
|
|
9
|
-
import com.scandit.capacitor.datacapture.core.communication.CameraPermissionGrantedListener
|
|
10
9
|
import com.scandit.capacitor.datacapture.core.data.ResizeAndMoveInfo
|
|
11
|
-
import com.scandit.capacitor.datacapture.core.data.defaults.*
|
|
12
10
|
import com.scandit.capacitor.datacapture.core.errors.*
|
|
13
11
|
import com.scandit.capacitor.datacapture.core.handlers.DataCaptureViewHandler
|
|
14
12
|
import com.scandit.capacitor.datacapture.core.utils.CapacitorResult
|
|
15
|
-
import com.scandit.datacapture.core.source
|
|
13
|
+
import com.scandit.datacapture.core.source.FrameSourceState
|
|
14
|
+
import com.scandit.datacapture.core.source.FrameSourceStateDeserializer
|
|
16
15
|
import com.scandit.datacapture.core.ui.DataCaptureView
|
|
17
16
|
import com.scandit.datacapture.frameworks.core.CoreModule
|
|
18
17
|
import com.scandit.datacapture.frameworks.core.deserialization.DefaultDeserializationLifecycleObserver
|
|
@@ -128,45 +127,26 @@ class ScanditCaptureCoreNative :
|
|
|
128
127
|
private fun checkCameraPermission(): Boolean =
|
|
129
128
|
getPermissionState("camera") == PermissionState.GRANTED
|
|
130
129
|
|
|
131
|
-
private fun
|
|
132
|
-
if (
|
|
133
|
-
requestPermissionForAlias("camera", call, "
|
|
130
|
+
private fun checkOrRequestCameraPermissions(call: PluginCall) {
|
|
131
|
+
if (!checkCameraPermission()) {
|
|
132
|
+
requestPermissionForAlias("camera", call, "onCameraPermissionResult")
|
|
134
133
|
} else {
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
private fun checkOrRequestUpdateCameraPermission(call: PluginCall) {
|
|
140
|
-
if (getPermissionState("camera") != PermissionState.GRANTED) {
|
|
141
|
-
requestPermissionForAlias("camera", call, "updateCameraPermsCallback")
|
|
142
|
-
} else {
|
|
143
|
-
updateContext(call)
|
|
134
|
+
onCameraPermissionResult(call)
|
|
144
135
|
}
|
|
145
136
|
}
|
|
146
137
|
|
|
147
138
|
@Suppress("unused")
|
|
148
139
|
@PermissionCallback
|
|
149
|
-
private fun
|
|
150
|
-
if (
|
|
151
|
-
|
|
140
|
+
private fun onCameraPermissionResult(call: PluginCall) {
|
|
141
|
+
if (checkCameraPermission()) {
|
|
142
|
+
coreModule.switchToDesiredCameraState(lastFrameSourceState)
|
|
143
|
+
call.resolve()
|
|
144
|
+
return
|
|
152
145
|
}
|
|
153
|
-
updateContext(call)
|
|
154
|
-
}
|
|
155
146
|
|
|
156
|
-
|
|
157
|
-
@PermissionCallback
|
|
158
|
-
private fun updateCameraPermsCallback(call: PluginCall) {
|
|
159
|
-
if (getPermissionState("camera") == PermissionState.GRANTED) {
|
|
160
|
-
notifyCameraPermissionGrantedToPlugins()
|
|
161
|
-
}
|
|
162
|
-
updateContext(call)
|
|
147
|
+
call.reject("Camera permissions not granted.")
|
|
163
148
|
}
|
|
164
149
|
|
|
165
|
-
private fun notifyCameraPermissionGrantedToPlugins() =
|
|
166
|
-
plugins.filterIsInstance(CameraPermissionGrantedListener::class.java).forEach {
|
|
167
|
-
it.onCameraPermissionGranted()
|
|
168
|
-
}
|
|
169
|
-
|
|
170
150
|
//region CameraProxy
|
|
171
151
|
@PluginMethod
|
|
172
152
|
fun getCurrentCameraState(call: PluginCall) =
|
|
@@ -192,19 +172,27 @@ class ScanditCaptureCoreNative :
|
|
|
192
172
|
|
|
193
173
|
@PluginMethod
|
|
194
174
|
fun switchCameraToDesiredState(call: PluginCall) {
|
|
195
|
-
val desiredStateJson = call.data.getString("desiredState") ?:
|
|
196
|
-
|
|
175
|
+
val desiredStateJson = call.data.getString("desiredState") ?: run {
|
|
176
|
+
call.reject(
|
|
177
|
+
"Missing desiredState argument in switchCameraToDesiredState."
|
|
178
|
+
)
|
|
179
|
+
return
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (checkCameraPermission()) {
|
|
183
|
+
coreModule.switchCameraToDesiredState(desiredStateJson, CapacitorResult(call))
|
|
184
|
+
lastFrameSourceState = coreModule.getCurrentCameraDesiredState() ?: FrameSourceState.OFF
|
|
185
|
+
return
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
lastFrameSourceState = FrameSourceStateDeserializer.fromJson(desiredStateJson)
|
|
189
|
+
checkOrRequestCameraPermissions(call)
|
|
197
190
|
}
|
|
198
191
|
//endregion
|
|
199
192
|
|
|
200
193
|
//region DataCaptureContextProxy
|
|
201
194
|
@PluginMethod
|
|
202
195
|
fun contextFromJSON(call: PluginCall) {
|
|
203
|
-
initializeContextFromJson(call)
|
|
204
|
-
checkOrRequestInitialCameraPermission(call)
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
private fun initializeContextFromJson(call: PluginCall) {
|
|
208
196
|
val jsonString = call.data.getString("context")
|
|
209
197
|
?: return call.reject(EMPTY_STRING_ERROR)
|
|
210
198
|
coreModule.createContextFromJson(jsonString, CapacitorResult(call))
|
|
@@ -220,9 +208,7 @@ class ScanditCaptureCoreNative :
|
|
|
220
208
|
}
|
|
221
209
|
|
|
222
210
|
@PluginMethod
|
|
223
|
-
fun updateContextFromJSON(call: PluginCall)
|
|
224
|
-
|
|
225
|
-
private fun updateContext(call: PluginCall) {
|
|
211
|
+
fun updateContextFromJSON(call: PluginCall) {
|
|
226
212
|
val jsonString = call.data.getString("context")
|
|
227
213
|
?: return call.reject(EMPTY_STRING_ERROR)
|
|
228
214
|
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scandit-capacitor-datacapture-core",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.27.1",
|
|
4
4
|
"description": "Scandit Data Capture SDK for Capacitor",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"private": false,
|
|
@@ -73,6 +73,6 @@
|
|
|
73
73
|
"swiftlint": "@ionic/swiftlint-config",
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@capacitor/cli": "^4.3.0",
|
|
76
|
-
"scandit-datacapture-frameworks-core": "6.
|
|
76
|
+
"scandit-datacapture-frameworks-core": "6.27.1"
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of the Scandit Data Capture SDK
|
|
3
|
-
*
|
|
4
|
-
* Copyright (C) 2019- Scandit AG. All rights reserved.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
package com.scandit.capacitor.datacapture.core.communication
|
|
8
|
-
|
|
9
|
-
interface CameraPermissionGrantedListener {
|
|
10
|
-
fun onCameraPermissionGranted()
|
|
11
|
-
}
|