scandit-capacitor-datacapture-core 6.28.0-beta.1 → 6.28.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.
@@ -16,5 +16,5 @@ Pod::Spec.new do |s|
16
16
  s.swift_version = "5.7"
17
17
 
18
18
  s.dependency "Capacitor"
19
- s.dependency "scandit-datacapture-frameworks-core", '= 6.28.0-beta.1'
19
+ s.dependency "scandit-datacapture-frameworks-core", '= 6.28.0-beta.2'
20
20
  end
@@ -56,7 +56,7 @@ repositories {
56
56
  }
57
57
 
58
58
  dependencies {
59
- def sdk_version = "6.28.0-beta.1"
59
+ def sdk_version = "6.28.0-beta.2"
60
60
 
61
61
  implementation fileTree(dir: 'libs', include: ['*.jar'])
62
62
 
@@ -10,13 +10,13 @@ import com.getcapacitor.PluginMethod
10
10
  import com.getcapacitor.annotation.CapacitorPlugin
11
11
  import com.getcapacitor.annotation.Permission
12
12
  import com.getcapacitor.annotation.PermissionCallback
13
- import com.scandit.capacitor.datacapture.core.communication.CameraPermissionGrantedListener
14
13
  import com.scandit.capacitor.datacapture.core.data.ResizeAndMoveInfo
15
14
  import com.scandit.capacitor.datacapture.core.errors.JsonParseError
16
15
  import com.scandit.capacitor.datacapture.core.errors.NullFrameError
17
16
  import com.scandit.capacitor.datacapture.core.handlers.DataCaptureViewHandler
18
17
  import com.scandit.capacitor.datacapture.core.utils.CapacitorResult
19
18
  import com.scandit.datacapture.core.source.FrameSourceState
19
+ import com.scandit.datacapture.core.source.FrameSourceStateDeserializer
20
20
  import com.scandit.datacapture.frameworks.core.CoreModule
21
21
  import com.scandit.datacapture.frameworks.core.events.Emitter
22
22
  import com.scandit.datacapture.frameworks.core.listeners.FrameworksDataCaptureContextListener
@@ -116,45 +116,26 @@ class ScanditCaptureCoreNative :
116
116
  private fun checkCameraPermission(): Boolean =
117
117
  getPermissionState("camera") == PermissionState.GRANTED
118
118
 
119
- private fun checkOrRequestInitialCameraPermission(call: PluginCall) {
120
- if (getPermissionState("camera") != PermissionState.GRANTED) {
121
- requestPermissionForAlias("camera", call, "initialCameraPermsCallback")
119
+ private fun checkOrRequestCameraPermissions(call: PluginCall) {
120
+ if (!checkCameraPermission()) {
121
+ requestPermissionForAlias("camera", call, "onCameraPermissionResult")
122
122
  } else {
123
- updateContext(call)
124
- }
125
- }
126
-
127
- private fun checkOrRequestUpdateCameraPermission(call: PluginCall) {
128
- if (getPermissionState("camera") != PermissionState.GRANTED) {
129
- requestPermissionForAlias("camera", call, "updateCameraPermsCallback")
130
- } else {
131
- updateContext(call)
123
+ onCameraPermissionResult(call)
132
124
  }
133
125
  }
134
126
 
135
127
  @Suppress("unused")
136
128
  @PermissionCallback
137
- private fun initialCameraPermsCallback(call: PluginCall) {
138
- if (getPermissionState("camera") == PermissionState.GRANTED) {
139
- notifyCameraPermissionGrantedToPlugins()
129
+ private fun onCameraPermissionResult(call: PluginCall) {
130
+ if (checkCameraPermission()) {
131
+ coreModule.switchToDesiredCameraState(lastFrameSourceState)
132
+ call.resolve()
133
+ return
140
134
  }
141
- updateContext(call)
142
- }
143
135
 
144
- @Suppress("unused")
145
- @PermissionCallback
146
- private fun updateCameraPermsCallback(call: PluginCall) {
147
- if (getPermissionState("camera") == PermissionState.GRANTED) {
148
- notifyCameraPermissionGrantedToPlugins()
149
- }
150
- updateContext(call)
136
+ call.reject("Camera permissions not granted.")
151
137
  }
152
138
 
153
- private fun notifyCameraPermissionGrantedToPlugins() =
154
- plugins.filterIsInstance<CameraPermissionGrantedListener>().forEach {
155
- it.onCameraPermissionGranted()
156
- }
157
-
158
139
  //region CameraProxy
159
140
  @PluginMethod
160
141
  fun getCurrentCameraState(call: PluginCall) =
@@ -180,19 +161,27 @@ class ScanditCaptureCoreNative :
180
161
 
181
162
  @PluginMethod
182
163
  fun switchCameraToDesiredState(call: PluginCall) {
183
- val desiredStateJson = call.data.getString("desiredState") ?: return
184
- coreModule.switchCameraToDesiredState(desiredStateJson, CapacitorResult(call))
164
+ val desiredStateJson = call.data.getString("desiredState") ?: run {
165
+ call.reject(
166
+ "Missing desiredState argument in switchCameraToDesiredState."
167
+ )
168
+ return
169
+ }
170
+
171
+ if (checkCameraPermission()) {
172
+ coreModule.switchCameraToDesiredState(desiredStateJson, CapacitorResult(call))
173
+ lastFrameSourceState = coreModule.getCurrentCameraDesiredState() ?: FrameSourceState.OFF
174
+ return
175
+ }
176
+
177
+ lastFrameSourceState = FrameSourceStateDeserializer.fromJson(desiredStateJson)
178
+ checkOrRequestCameraPermissions(call)
185
179
  }
186
180
  //endregion
187
181
 
188
182
  //region DataCaptureContextProxy
189
183
  @PluginMethod
190
184
  fun contextFromJSON(call: PluginCall) {
191
- initializeContextFromJson(call)
192
- checkOrRequestInitialCameraPermission(call)
193
- }
194
-
195
- private fun initializeContextFromJson(call: PluginCall) {
196
185
  val jsonString = call.data.getString("context")
197
186
  ?: return call.reject(EMPTY_STRING_ERROR)
198
187
  coreModule.createContextFromJson(jsonString, CapacitorResult(call))
@@ -208,9 +197,7 @@ class ScanditCaptureCoreNative :
208
197
  }
209
198
 
210
199
  @PluginMethod
211
- fun updateContextFromJSON(call: PluginCall) = checkOrRequestUpdateCameraPermission(call)
212
-
213
- private fun updateContext(call: PluginCall) {
200
+ fun updateContextFromJSON(call: PluginCall) {
214
201
  val jsonString = call.data.getString("context")
215
202
  ?: return call.reject(EMPTY_STRING_ERROR)
216
203
 
package/dist/index.js CHANGED
@@ -271,7 +271,7 @@ __decorate([
271
271
 
272
272
  class DataCaptureVersion {
273
273
  static get pluginVersion() {
274
- return '6.28.0-beta.1';
274
+ return '6.28.0-beta.2';
275
275
  }
276
276
  }
277
277
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scandit-capacitor-datacapture-core",
3
- "version": "6.28.0-beta.1",
3
+ "version": "6.28.0-beta.2",
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.28.0-beta.1"
76
+ "scandit-datacapture-frameworks-core": "6.28.0-beta.2"
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
- }