scandit-capacitor-datacapture-core 8.1.1 → 8.2.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.
- package/ScanditCapacitorDatacaptureCore.podspec +1 -1
- package/android/build.gradle +76 -24
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/ScanditCaptureCoreNative.java +311 -0
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/data/ResizeAndMoveInfo.java +44 -0
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/errors/ActionError.java +33 -0
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/errors/JsonParseError.java +18 -0
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/handlers/DataCaptureViewHandler.java +422 -0
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/utils/{Callback.kt → Callback.java} +7 -8
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/utils/CapacitorExtensions.java +31 -0
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/utils/CapacitorMethodCall.java +57 -0
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/utils/CapacitorResult.java +129 -0
- package/dist/core.js +473 -102
- package/dist/core.js.map +1 -1
- package/dist/dts/definitions.d.ts +6 -0
- package/dist/index.js +16 -4
- package/dist/index.js.map +1 -1
- package/ios/Sources/ScanditCapacitorCore/CapacitorMethodCall.swift +24 -1
- package/ios/Sources/ScanditCapacitorCore/CapacitorResult.swift +4 -0
- package/ios/Sources/ScanditCapacitorCore/ScanditCaptureCore.swift +21 -229
- package/package.json +7 -7
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/ScanditCaptureCoreNative.kt +0 -402
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/data/ResizeAndMoveInfo.kt +0 -15
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/data/SerializableCallbackAction.kt +0 -34
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/data/SerializableData.kt +0 -13
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/data/SerializableFinishModeCallbackData.kt +0 -20
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/data/defaults/SerializableBrushDefaults.kt +0 -49
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/data/defaults/SerializableCameraSettingsDefault.kt +0 -51
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/errors/ActionError.kt +0 -27
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/errors/JsonParseError.kt +0 -18
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/handlers/DataCaptureViewHandler.kt +0 -363
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/utils/CapacitorMethodCall.kt +0 -22
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/utils/CapacitorResult.kt +0 -40
- package/android/src/main/java/com/scandit/capacitor/datacapture/core/utils/Extensions.kt +0 -28
package/android/src/main/java/com/scandit/capacitor/datacapture/core/ScanditCaptureCoreNative.kt
DELETED
|
@@ -1,402 +0,0 @@
|
|
|
1
|
-
package com.scandit.capacitor.datacapture.core
|
|
2
|
-
|
|
3
|
-
import android.Manifest
|
|
4
|
-
import android.util.Log
|
|
5
|
-
import com.getcapacitor.JSObject
|
|
6
|
-
import com.getcapacitor.PermissionState
|
|
7
|
-
import com.getcapacitor.Plugin
|
|
8
|
-
import com.getcapacitor.PluginCall
|
|
9
|
-
import com.getcapacitor.PluginMethod
|
|
10
|
-
import com.getcapacitor.annotation.CapacitorPlugin
|
|
11
|
-
import com.getcapacitor.annotation.Permission
|
|
12
|
-
import com.getcapacitor.annotation.PermissionCallback
|
|
13
|
-
import com.scandit.capacitor.datacapture.core.data.ResizeAndMoveInfo
|
|
14
|
-
import com.scandit.capacitor.datacapture.core.errors.JsonParseError
|
|
15
|
-
import com.scandit.capacitor.datacapture.core.handlers.DataCaptureViewHandler
|
|
16
|
-
import com.scandit.capacitor.datacapture.core.utils.CapacitorResult
|
|
17
|
-
import com.scandit.datacapture.core.source.FrameSourceState
|
|
18
|
-
import com.scandit.datacapture.core.source.FrameSourceStateDeserializer
|
|
19
|
-
import com.scandit.datacapture.frameworks.core.CoreModule
|
|
20
|
-
import com.scandit.datacapture.frameworks.core.events.Emitter
|
|
21
|
-
import com.scandit.datacapture.frameworks.core.lifecycle.ActivityLifecycleDispatcher
|
|
22
|
-
import com.scandit.datacapture.frameworks.core.lifecycle.DefaultActivityLifecycle
|
|
23
|
-
import org.json.JSONException
|
|
24
|
-
import org.json.JSONObject
|
|
25
|
-
|
|
26
|
-
@CapacitorPlugin(
|
|
27
|
-
name = "ScanditCaptureCoreNative",
|
|
28
|
-
permissions = [
|
|
29
|
-
Permission(strings = [Manifest.permission.CAMERA], alias = "camera")
|
|
30
|
-
]
|
|
31
|
-
)
|
|
32
|
-
class ScanditCaptureCoreNative :
|
|
33
|
-
Plugin(),
|
|
34
|
-
Emitter {
|
|
35
|
-
|
|
36
|
-
companion object {
|
|
37
|
-
private const val EMPTY_STRING_ERROR = "Empty strings are not allowed."
|
|
38
|
-
private fun missingParameter(parameterName: String) =
|
|
39
|
-
"Missing parameter '$parameterName' in call."
|
|
40
|
-
|
|
41
|
-
private val SCANDIT_PLUGINS = listOf(
|
|
42
|
-
"ScanditBarcodeNative",
|
|
43
|
-
"ScanditParserNative",
|
|
44
|
-
"ScanditIdNative",
|
|
45
|
-
"ScanditTextNative"
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
private val lifecycleDispatcher: ActivityLifecycleDispatcher =
|
|
50
|
-
DefaultActivityLifecycle.getInstance()
|
|
51
|
-
private val captureViewHandler = DataCaptureViewHandler()
|
|
52
|
-
private val coreModule = CoreModule.create(this)
|
|
53
|
-
private var lastFrameSourceState: FrameSourceState = FrameSourceState.OFF
|
|
54
|
-
|
|
55
|
-
private val plugins = mutableListOf<Plugin>()
|
|
56
|
-
fun registerPluginInstance(instance: Plugin) {
|
|
57
|
-
plugins.add(instance)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
override fun load() {
|
|
61
|
-
super.load()
|
|
62
|
-
|
|
63
|
-
val registeredPlugins = plugins.map {
|
|
64
|
-
it.pluginHandle.id
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
SCANDIT_PLUGINS.forEach {
|
|
68
|
-
if (!registeredPlugins.contains(it)) {
|
|
69
|
-
val unregisteredPlugin = bridge.getPlugin(it)
|
|
70
|
-
|
|
71
|
-
if (unregisteredPlugin != null) {
|
|
72
|
-
registerPluginInstance(unregisteredPlugin.instance)
|
|
73
|
-
} else {
|
|
74
|
-
Log.e("Registering:", "$it not found")
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
coreModule.onCreate(this.context)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
override fun handleOnStart() {
|
|
82
|
-
if (checkCameraPermission()) {
|
|
83
|
-
coreModule.switchToDesiredCameraState(lastFrameSourceState)
|
|
84
|
-
}
|
|
85
|
-
coreModule.registerDataCaptureContextListener()
|
|
86
|
-
coreModule.registerTopmostDataCaptureViewListener()
|
|
87
|
-
coreModule.registerFrameSourceListener()
|
|
88
|
-
lifecycleDispatcher.dispatchOnStart()
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
override fun handleOnStop() {
|
|
92
|
-
lifecycleDispatcher.dispatchOnStop()
|
|
93
|
-
lastFrameSourceState = coreModule.getCurrentCameraDesiredState() ?: FrameSourceState.OFF
|
|
94
|
-
coreModule.switchToDesiredCameraState(FrameSourceState.OFF)
|
|
95
|
-
coreModule.unregisterDataCaptureContextListener()
|
|
96
|
-
coreModule.unregisterTopmostDataCaptureViewListener()
|
|
97
|
-
coreModule.unregisterFrameSourceListener()
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
override fun handleOnDestroy() {
|
|
101
|
-
lifecycleDispatcher.dispatchOnDestroy()
|
|
102
|
-
coreModule.onDestroy()
|
|
103
|
-
captureViewHandler.disposeCurrentWebView()
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
override fun handleOnResume() {
|
|
107
|
-
lifecycleDispatcher.dispatchOnResume()
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
override fun handleOnPause() {
|
|
111
|
-
lifecycleDispatcher.dispatchOnPause()
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
private fun checkCameraPermission(): Boolean =
|
|
115
|
-
getPermissionState("camera") == PermissionState.GRANTED
|
|
116
|
-
|
|
117
|
-
private fun checkOrRequestCameraPermissions(call: PluginCall) {
|
|
118
|
-
if (!checkCameraPermission()) {
|
|
119
|
-
requestPermissionForAlias("camera", call, "onCameraPermissionResult")
|
|
120
|
-
} else {
|
|
121
|
-
onCameraPermissionResult(call)
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
@Suppress("unused")
|
|
126
|
-
@PermissionCallback
|
|
127
|
-
private fun onCameraPermissionResult(call: PluginCall) {
|
|
128
|
-
if (checkCameraPermission()) {
|
|
129
|
-
coreModule.switchToDesiredCameraState(lastFrameSourceState)
|
|
130
|
-
call.resolve()
|
|
131
|
-
return
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
call.reject("Camera permissions not granted.")
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
//region CameraProxy
|
|
138
|
-
@PluginMethod
|
|
139
|
-
fun getCurrentCameraState(call: PluginCall) {
|
|
140
|
-
val positionJson = call.data.getString("position") ?: run {
|
|
141
|
-
call.reject(missingParameter("position"))
|
|
142
|
-
return
|
|
143
|
-
}
|
|
144
|
-
coreModule.getCameraState(positionJson, CapacitorResult(call))
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
@PluginMethod
|
|
148
|
-
fun isTorchAvailable(call: PluginCall) {
|
|
149
|
-
val positionJson = call.data.getString("position") ?: run {
|
|
150
|
-
call.reject(missingParameter("position"))
|
|
151
|
-
return
|
|
152
|
-
}
|
|
153
|
-
coreModule.isTorchAvailable(positionJson, CapacitorResult(call))
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
@PluginMethod
|
|
157
|
-
fun registerListenerForCameraEvents(call: PluginCall) {
|
|
158
|
-
coreModule.registerFrameSourceListener()
|
|
159
|
-
call.resolve()
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
@PluginMethod
|
|
163
|
-
fun unregisterListenerForCameraEvents(call: PluginCall) {
|
|
164
|
-
coreModule.unregisterFrameSourceListener()
|
|
165
|
-
call.resolve()
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
@PluginMethod
|
|
169
|
-
fun switchCameraToDesiredState(call: PluginCall) {
|
|
170
|
-
val desiredStateJson = call.data.getString("desiredStateJson") ?: run {
|
|
171
|
-
call.reject(missingParameter("desiredStateJson"))
|
|
172
|
-
return
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (checkCameraPermission()) {
|
|
176
|
-
coreModule.switchCameraToDesiredState(desiredStateJson, CapacitorResult(call))
|
|
177
|
-
lastFrameSourceState = coreModule.getCurrentCameraDesiredState() ?: FrameSourceState.OFF
|
|
178
|
-
return
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
lastFrameSourceState = FrameSourceStateDeserializer.fromJson(desiredStateJson)
|
|
182
|
-
checkOrRequestCameraPermissions(call)
|
|
183
|
-
}
|
|
184
|
-
//endregion
|
|
185
|
-
|
|
186
|
-
//region DataCaptureContextProxy
|
|
187
|
-
@PluginMethod
|
|
188
|
-
fun contextFromJSON(call: PluginCall) {
|
|
189
|
-
val jsonString = call.data.getString("contextJson")
|
|
190
|
-
?: return call.reject(EMPTY_STRING_ERROR)
|
|
191
|
-
coreModule.createContextFromJson(jsonString, CapacitorResult(call))
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
@PluginMethod
|
|
195
|
-
fun disposeContext(call: PluginCall) {
|
|
196
|
-
coreModule.disposeContext()
|
|
197
|
-
removeAllListeners(call)
|
|
198
|
-
plugins.forEach {
|
|
199
|
-
it.removeAllListeners(call)
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
@PluginMethod
|
|
204
|
-
fun updateContextFromJSON(call: PluginCall) {
|
|
205
|
-
val jsonString = call.data.getString("contextJson")
|
|
206
|
-
?: return call.reject(EMPTY_STRING_ERROR)
|
|
207
|
-
|
|
208
|
-
coreModule.updateContextFromJson(jsonString, CapacitorResult(call))
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
//endregion
|
|
212
|
-
|
|
213
|
-
//region DataCaptureViewProxy
|
|
214
|
-
@PluginMethod
|
|
215
|
-
fun setDataCaptureViewPositionAndSize(call: PluginCall) {
|
|
216
|
-
try {
|
|
217
|
-
val top = call.data.getDouble("top")
|
|
218
|
-
val left = call.data.getDouble("left")
|
|
219
|
-
val width = call.data.getDouble("width")
|
|
220
|
-
val height = call.data.getDouble("height")
|
|
221
|
-
val shouldBeUnderWebView = call.data.getBoolean("shouldBeUnderWebView")
|
|
222
|
-
|
|
223
|
-
captureViewHandler.setResizeAndMoveInfo(
|
|
224
|
-
ResizeAndMoveInfo(
|
|
225
|
-
top = top.toFloat(),
|
|
226
|
-
left = left.toFloat(),
|
|
227
|
-
width = width.toFloat(),
|
|
228
|
-
height = height.toFloat(),
|
|
229
|
-
shouldBeUnderWebView = shouldBeUnderWebView
|
|
230
|
-
)
|
|
231
|
-
)
|
|
232
|
-
call.resolve()
|
|
233
|
-
} catch (e: JSONException) {
|
|
234
|
-
call.reject(JsonParseError(e.message).toString())
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
@PluginMethod
|
|
239
|
-
fun showDataCaptureView(call: PluginCall) {
|
|
240
|
-
captureViewHandler.setVisible()
|
|
241
|
-
call.resolve()
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
@PluginMethod
|
|
245
|
-
fun hideDataCaptureView(call: PluginCall) {
|
|
246
|
-
captureViewHandler.setInvisible()
|
|
247
|
-
call.resolve()
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
@PluginMethod
|
|
251
|
-
fun viewPointForFramePoint(call: PluginCall) {
|
|
252
|
-
val pointJson = call.data.getString("pointJson")
|
|
253
|
-
?: return call.reject(EMPTY_STRING_ERROR)
|
|
254
|
-
|
|
255
|
-
val viewId = call.data.getInt("viewId")
|
|
256
|
-
|
|
257
|
-
coreModule.viewPointForFramePoint(viewId, pointJson, CapacitorResult(call))
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
@PluginMethod
|
|
261
|
-
fun viewQuadrilateralForFrameQuadrilateral(call: PluginCall) {
|
|
262
|
-
val quadrilateralJson = call.data.getString("quadrilateralJson")
|
|
263
|
-
?: return call.reject(EMPTY_STRING_ERROR)
|
|
264
|
-
|
|
265
|
-
val viewId = call.data.getInt("viewId")
|
|
266
|
-
|
|
267
|
-
coreModule.viewQuadrilateralForFrameQuadrilateral(
|
|
268
|
-
viewId,
|
|
269
|
-
quadrilateralJson,
|
|
270
|
-
CapacitorResult(call)
|
|
271
|
-
)
|
|
272
|
-
}
|
|
273
|
-
//endregion
|
|
274
|
-
|
|
275
|
-
//region Feedback
|
|
276
|
-
@PluginMethod
|
|
277
|
-
fun emitFeedback(call: PluginCall) {
|
|
278
|
-
call.data.getString("feedbackJson")?.let {
|
|
279
|
-
coreModule.emitFeedback(it, CapacitorResult(call))
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
//endregion
|
|
283
|
-
|
|
284
|
-
@PluginMethod
|
|
285
|
-
fun getDefaults(call: PluginCall) {
|
|
286
|
-
val defaults = coreModule.getDefaults()
|
|
287
|
-
call.resolve(JSObject.fromJSONObject(JSONObject(defaults)))
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
@PluginMethod
|
|
291
|
-
fun subscribeContextListener(call: PluginCall) {
|
|
292
|
-
coreModule.registerDataCaptureContextListener()
|
|
293
|
-
call.resolve()
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
@PluginMethod
|
|
297
|
-
fun unsubscribeContextListener(call: PluginCall) {
|
|
298
|
-
coreModule.unregisterDataCaptureContextListener()
|
|
299
|
-
call.resolve()
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
@PluginMethod
|
|
303
|
-
fun registerListenerForViewEvents(call: PluginCall) {
|
|
304
|
-
val viewId = call.data.getInt("viewId")
|
|
305
|
-
coreModule.registerDataCaptureViewListener(viewId)
|
|
306
|
-
call.resolve()
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
@PluginMethod
|
|
310
|
-
fun unregisterListenerForViewEvents(call: PluginCall) {
|
|
311
|
-
val viewId = call.data.getInt("viewId")
|
|
312
|
-
coreModule.unregisterDataCaptureViewListener(viewId)
|
|
313
|
-
call.resolve()
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
@PluginMethod
|
|
317
|
-
fun getFrame(call: PluginCall) {
|
|
318
|
-
val frameId = call.data.getString("frameId") ?: run {
|
|
319
|
-
call.reject(missingParameter("frameId"))
|
|
320
|
-
return
|
|
321
|
-
}
|
|
322
|
-
coreModule.getLastFrameAsJson(frameId, CapacitorResult(call))
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
@PluginMethod
|
|
326
|
-
fun subscribeVolumeButtonObserver(call: PluginCall) = call.resolve()
|
|
327
|
-
|
|
328
|
-
@PluginMethod
|
|
329
|
-
fun unsubscribeVolumeButtonObserver(call: PluginCall) = call.resolve()
|
|
330
|
-
|
|
331
|
-
//endregion
|
|
332
|
-
|
|
333
|
-
@PluginMethod
|
|
334
|
-
fun addModeToContext(call: PluginCall) {
|
|
335
|
-
val modeJson = call.data.getString("modeJson")
|
|
336
|
-
?: return call.reject(EMPTY_STRING_ERROR)
|
|
337
|
-
coreModule.addModeToContext(modeJson, CapacitorResult(call))
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
@PluginMethod
|
|
341
|
-
fun removeModeFromContext(call: PluginCall) {
|
|
342
|
-
val modeJson = call.data.getString("modeJson")
|
|
343
|
-
?: return call.reject(EMPTY_STRING_ERROR)
|
|
344
|
-
coreModule.removeModeFromContext(modeJson, CapacitorResult(call))
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
@PluginMethod
|
|
348
|
-
fun removeAllModes(call: PluginCall) {
|
|
349
|
-
coreModule.removeAllModes(CapacitorResult(call))
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
@PluginMethod
|
|
353
|
-
fun createDataCaptureView(call: PluginCall) {
|
|
354
|
-
val viewJson = call.data.getString("viewJson")
|
|
355
|
-
?: return call.reject(EMPTY_STRING_ERROR)
|
|
356
|
-
val view = coreModule.createDataCaptureView(viewJson, CapacitorResult(call))
|
|
357
|
-
if (view != null) {
|
|
358
|
-
val existingView = captureViewHandler.dataCaptureView
|
|
359
|
-
if (existingView != null) {
|
|
360
|
-
// Remove existing view and add the new one.
|
|
361
|
-
coreModule.dataCaptureViewDisposed(existingView)
|
|
362
|
-
captureViewHandler.removeDataCaptureView(existingView)
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
captureViewHandler.addDataCaptureView(view, this.bridge)
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
@PluginMethod
|
|
370
|
-
fun removeDataCaptureView(call: PluginCall) {
|
|
371
|
-
val viewId = call.data.getInt("viewId")
|
|
372
|
-
// In capacitor we just show 1 datacapture view at a time
|
|
373
|
-
val dcViewToRemove = coreModule.getDataCaptureViewById(viewId)
|
|
374
|
-
dcViewToRemove?.post {
|
|
375
|
-
coreModule.dataCaptureViewDisposed(dcViewToRemove)
|
|
376
|
-
captureViewHandler.removeDataCaptureView(dcViewToRemove)
|
|
377
|
-
}
|
|
378
|
-
call.resolve()
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
@PluginMethod
|
|
382
|
-
fun updateDataCaptureView(call: PluginCall) {
|
|
383
|
-
val viewJson = call.data.getString("viewJson")
|
|
384
|
-
?: return call.reject(EMPTY_STRING_ERROR)
|
|
385
|
-
coreModule.updateDataCaptureView(viewJson, CapacitorResult(call))
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
override fun emit(eventName: String, payload: MutableMap<String, Any?>) {
|
|
389
|
-
val capacitorPayload = JSObject()
|
|
390
|
-
capacitorPayload.put("name", eventName)
|
|
391
|
-
capacitorPayload.put("data", JSONObject(payload).toString())
|
|
392
|
-
|
|
393
|
-
notifyListeners(eventName, capacitorPayload)
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
override fun hasListenersForEvent(eventName: String): Boolean = this.hasListeners(eventName)
|
|
397
|
-
|
|
398
|
-
@PluginMethod
|
|
399
|
-
fun getOpenSourceSoftwareLicenseInfo(call: PluginCall) {
|
|
400
|
-
coreModule.getOpenSourceSoftwareLicenseInfo(CapacitorResult(call))
|
|
401
|
-
}
|
|
402
|
-
}
|
package/android/src/main/java/com/scandit/capacitor/datacapture/core/data/ResizeAndMoveInfo.kt
DELETED
|
@@ -1,15 +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.data
|
|
8
|
-
|
|
9
|
-
data class ResizeAndMoveInfo(
|
|
10
|
-
val top: Float,
|
|
11
|
-
val left: Float,
|
|
12
|
-
val width: Float,
|
|
13
|
-
val height: Float,
|
|
14
|
-
val shouldBeUnderWebView: Boolean
|
|
15
|
-
)
|
|
@@ -1,34 +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.data
|
|
8
|
-
|
|
9
|
-
import org.json.JSONObject
|
|
10
|
-
|
|
11
|
-
class SerializableCallbackAction(
|
|
12
|
-
private val callbackName: String,
|
|
13
|
-
private val argument: JSONObject,
|
|
14
|
-
private val finishCallbackId: String? = null,
|
|
15
|
-
private val shouldNotifyWhenFinished: Boolean = false
|
|
16
|
-
) : SerializableData {
|
|
17
|
-
|
|
18
|
-
override fun toJson(): JSONObject = JSONObject(
|
|
19
|
-
mapOf(
|
|
20
|
-
FIELD_NAME to callbackName,
|
|
21
|
-
FIELD_ARGUMENT to argument,
|
|
22
|
-
FIELD_FINISH_CALLBACK_ID to finishCallbackId,
|
|
23
|
-
FIELD_SHOULD_NOTIFY_WHEN_FINISHED to shouldNotifyWhenFinished
|
|
24
|
-
)
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
companion object {
|
|
28
|
-
private const val FIELD_NAME = "name"
|
|
29
|
-
private const val FIELD_ARGUMENT = "argument"
|
|
30
|
-
private const val FIELD_SHOULD_NOTIFY_WHEN_FINISHED = "shouldNotifyWhenFinished"
|
|
31
|
-
|
|
32
|
-
const val FIELD_FINISH_CALLBACK_ID = "finishCallbackID"
|
|
33
|
-
}
|
|
34
|
-
}
|
package/android/src/main/java/com/scandit/capacitor/datacapture/core/data/SerializableData.kt
DELETED
|
@@ -1,13 +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.data
|
|
8
|
-
|
|
9
|
-
import org.json.JSONObject
|
|
10
|
-
|
|
11
|
-
interface SerializableData {
|
|
12
|
-
fun toJson(): JSONObject
|
|
13
|
-
}
|
|
@@ -1,20 +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
|
-
package com.scandit.capacitor.datacapture.core.data
|
|
7
|
-
|
|
8
|
-
import org.json.JSONObject
|
|
9
|
-
|
|
10
|
-
class SerializableFinishModeCallbackData(val enabled: Boolean) {
|
|
11
|
-
companion object {
|
|
12
|
-
private const val FIELD_ENABLED = "enabled"
|
|
13
|
-
|
|
14
|
-
fun fromJson(json: JSONObject?): SerializableFinishModeCallbackData? {
|
|
15
|
-
return json?.let {
|
|
16
|
-
SerializableFinishModeCallbackData(it.optBoolean(FIELD_ENABLED, false))
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,49 +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.data.defaults
|
|
8
|
-
|
|
9
|
-
import com.scandit.capacitor.datacapture.core.data.SerializableData
|
|
10
|
-
import com.scandit.datacapture.core.ui.style.Brush
|
|
11
|
-
import com.scandit.datacapture.frameworks.core.extensions.hexString
|
|
12
|
-
import org.json.JSONObject
|
|
13
|
-
|
|
14
|
-
data class SerializableBrushDefaults(
|
|
15
|
-
private val fillColor: String?,
|
|
16
|
-
private val strokeColor: String?,
|
|
17
|
-
private val strokeWidth: Float?
|
|
18
|
-
) : SerializableData {
|
|
19
|
-
|
|
20
|
-
constructor(brush: Brush?) : this(
|
|
21
|
-
fillColor = brush?.fillColor?.hexString,
|
|
22
|
-
strokeColor = brush?.strokeColor?.hexString,
|
|
23
|
-
strokeWidth = brush?.strokeWidth
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
override fun toJson(): JSONObject = JSONObject(
|
|
27
|
-
mapOf(
|
|
28
|
-
FIELD_FILL_COLOR to fillColor,
|
|
29
|
-
FIELD_STROKE_COLOR to strokeColor,
|
|
30
|
-
FIELD_STROKE_WIDTH to strokeWidth
|
|
31
|
-
)
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
fun toJSONObject(): JSONObject {
|
|
35
|
-
val data = JSONObject()
|
|
36
|
-
|
|
37
|
-
data.put(FIELD_FILL_COLOR, fillColor)
|
|
38
|
-
data.put(FIELD_STROKE_COLOR, strokeColor)
|
|
39
|
-
data.put(FIELD_STROKE_WIDTH, strokeWidth?.toDouble() ?: 0.0)
|
|
40
|
-
|
|
41
|
-
return data
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
companion object {
|
|
45
|
-
private const val FIELD_FILL_COLOR = "fillColor"
|
|
46
|
-
private const val FIELD_STROKE_COLOR = "strokeColor"
|
|
47
|
-
private const val FIELD_STROKE_WIDTH = "strokeWidth"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,51 +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.data.defaults
|
|
8
|
-
|
|
9
|
-
import com.scandit.capacitor.datacapture.core.data.SerializableData
|
|
10
|
-
import com.scandit.datacapture.core.source.CameraSettings
|
|
11
|
-
import com.scandit.datacapture.core.source.toJson
|
|
12
|
-
import org.json.JSONObject
|
|
13
|
-
|
|
14
|
-
data class SerializableCameraSettingsDefault(
|
|
15
|
-
private val prefResolution: String,
|
|
16
|
-
private val zoomFactor: Float,
|
|
17
|
-
private val focusRange: String,
|
|
18
|
-
private val zoomGestureZoomFactor: Float,
|
|
19
|
-
private val focusGestureStrategy: String,
|
|
20
|
-
private val shouldPreferSmoothAutoFocus: Boolean
|
|
21
|
-
) : SerializableData {
|
|
22
|
-
|
|
23
|
-
constructor(settings: CameraSettings) : this(
|
|
24
|
-
prefResolution = settings.preferredResolution.toJson(),
|
|
25
|
-
zoomFactor = settings.zoomFactor,
|
|
26
|
-
focusRange = "full",
|
|
27
|
-
zoomGestureZoomFactor = settings.zoomGestureZoomFactor,
|
|
28
|
-
focusGestureStrategy = settings.focusGestureStrategy.toJson(),
|
|
29
|
-
shouldPreferSmoothAutoFocus = settings.shouldPreferSmoothAutoFocus
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
override fun toJson(): JSONObject = JSONObject(
|
|
33
|
-
mapOf(
|
|
34
|
-
FIELD_PREFERRED_RESOLUTION to prefResolution,
|
|
35
|
-
FIELD_ZOOM_FACTOR to zoomFactor,
|
|
36
|
-
FIELD_FOCUS_RANGE to focusRange,
|
|
37
|
-
FIELD_ZOOM_GESTURE_ZOOM_FACTOR to zoomGestureZoomFactor,
|
|
38
|
-
FIELD_FOCUS_GESTURE_STRATEGY to focusGestureStrategy,
|
|
39
|
-
FIELD_FOCUS_SHOULD_PREFER_SMOOTH_AUTOFOCUS to shouldPreferSmoothAutoFocus
|
|
40
|
-
)
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
companion object {
|
|
44
|
-
private const val FIELD_PREFERRED_RESOLUTION = "preferredResolution"
|
|
45
|
-
private const val FIELD_ZOOM_FACTOR = "zoomFactor"
|
|
46
|
-
private const val FIELD_FOCUS_RANGE = "focusRange"
|
|
47
|
-
private const val FIELD_ZOOM_GESTURE_ZOOM_FACTOR = "zoomGestureZoomFactor"
|
|
48
|
-
private const val FIELD_FOCUS_GESTURE_STRATEGY = "focusGestureStrategy"
|
|
49
|
-
private const val FIELD_FOCUS_SHOULD_PREFER_SMOOTH_AUTOFOCUS = "shouldPreferSmoothAutoFocus"
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,27 +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.errors
|
|
8
|
-
|
|
9
|
-
import org.json.JSONObject
|
|
10
|
-
|
|
11
|
-
abstract class ActionError(
|
|
12
|
-
private val errorCode: Int,
|
|
13
|
-
private val errorMessage: String
|
|
14
|
-
) : Exception(errorMessage) {
|
|
15
|
-
|
|
16
|
-
companion object {
|
|
17
|
-
private const val KEY_CODE = "Code"
|
|
18
|
-
private const val KEY_MESSAGE = "Message"
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
fun serializeContent(): JSONObject = JSONObject(
|
|
22
|
-
mapOf(
|
|
23
|
-
KEY_CODE to errorCode,
|
|
24
|
-
KEY_MESSAGE to errorMessage
|
|
25
|
-
)
|
|
26
|
-
)
|
|
27
|
-
}
|
package/android/src/main/java/com/scandit/capacitor/datacapture/core/errors/JsonParseError.kt
DELETED
|
@@ -1,18 +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.errors
|
|
8
|
-
|
|
9
|
-
class JsonParseError(
|
|
10
|
-
error: String?
|
|
11
|
-
) : ActionError(
|
|
12
|
-
ERROR_CODE,
|
|
13
|
-
"Invalid or no JSON passed for command: ${error ?: "No additional info"}"
|
|
14
|
-
) {
|
|
15
|
-
companion object {
|
|
16
|
-
private const val ERROR_CODE = 10001
|
|
17
|
-
}
|
|
18
|
-
}
|