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.
Files changed (33) hide show
  1. package/ScanditCapacitorDatacaptureCore.podspec +1 -1
  2. package/android/build.gradle +76 -24
  3. package/android/src/main/java/com/scandit/capacitor/datacapture/core/ScanditCaptureCoreNative.java +311 -0
  4. package/android/src/main/java/com/scandit/capacitor/datacapture/core/data/ResizeAndMoveInfo.java +44 -0
  5. package/android/src/main/java/com/scandit/capacitor/datacapture/core/errors/ActionError.java +33 -0
  6. package/android/src/main/java/com/scandit/capacitor/datacapture/core/errors/JsonParseError.java +18 -0
  7. package/android/src/main/java/com/scandit/capacitor/datacapture/core/handlers/DataCaptureViewHandler.java +422 -0
  8. package/android/src/main/java/com/scandit/capacitor/datacapture/core/utils/{Callback.kt → Callback.java} +7 -8
  9. package/android/src/main/java/com/scandit/capacitor/datacapture/core/utils/CapacitorExtensions.java +31 -0
  10. package/android/src/main/java/com/scandit/capacitor/datacapture/core/utils/CapacitorMethodCall.java +57 -0
  11. package/android/src/main/java/com/scandit/capacitor/datacapture/core/utils/CapacitorResult.java +129 -0
  12. package/dist/core.js +473 -102
  13. package/dist/core.js.map +1 -1
  14. package/dist/dts/definitions.d.ts +6 -0
  15. package/dist/index.js +16 -4
  16. package/dist/index.js.map +1 -1
  17. package/ios/Sources/ScanditCapacitorCore/CapacitorMethodCall.swift +24 -1
  18. package/ios/Sources/ScanditCapacitorCore/CapacitorResult.swift +4 -0
  19. package/ios/Sources/ScanditCapacitorCore/ScanditCaptureCore.swift +21 -229
  20. package/package.json +7 -7
  21. package/android/src/main/java/com/scandit/capacitor/datacapture/core/ScanditCaptureCoreNative.kt +0 -402
  22. package/android/src/main/java/com/scandit/capacitor/datacapture/core/data/ResizeAndMoveInfo.kt +0 -15
  23. package/android/src/main/java/com/scandit/capacitor/datacapture/core/data/SerializableCallbackAction.kt +0 -34
  24. package/android/src/main/java/com/scandit/capacitor/datacapture/core/data/SerializableData.kt +0 -13
  25. package/android/src/main/java/com/scandit/capacitor/datacapture/core/data/SerializableFinishModeCallbackData.kt +0 -20
  26. package/android/src/main/java/com/scandit/capacitor/datacapture/core/data/defaults/SerializableBrushDefaults.kt +0 -49
  27. package/android/src/main/java/com/scandit/capacitor/datacapture/core/data/defaults/SerializableCameraSettingsDefault.kt +0 -51
  28. package/android/src/main/java/com/scandit/capacitor/datacapture/core/errors/ActionError.kt +0 -27
  29. package/android/src/main/java/com/scandit/capacitor/datacapture/core/errors/JsonParseError.kt +0 -18
  30. package/android/src/main/java/com/scandit/capacitor/datacapture/core/handlers/DataCaptureViewHandler.kt +0 -363
  31. package/android/src/main/java/com/scandit/capacitor/datacapture/core/utils/CapacitorMethodCall.kt +0 -22
  32. package/android/src/main/java/com/scandit/capacitor/datacapture/core/utils/CapacitorResult.kt +0 -40
  33. package/android/src/main/java/com/scandit/capacitor/datacapture/core/utils/Extensions.kt +0 -28
@@ -17,5 +17,5 @@ Pod::Spec.new do |s|
17
17
  s.swift_version = "5.7"
18
18
 
19
19
  s.dependency "Capacitor"
20
- s.dependency "scandit-datacapture-frameworks-core", '= 8.1.1'
20
+ s.dependency "scandit-datacapture-frameworks-core", '= 8.2.0'
21
21
  end
@@ -1,6 +1,6 @@
1
1
  ext {
2
- androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
3
- androidxCoreVersion = project.hasProperty('androidxCoreVersion') ? rootProject.ext.androidxCoreVersion : '1.10.1'
2
+ androidxCoreVersion = project.hasProperty('androidxCoreVersion') ? rootProject.ext.androidxCoreVersion : '1.10.0'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
4
4
  cordovaAndroidVersion = project.hasProperty('cordovaAndroidVersion') ? rootProject.ext.cordovaAndroidVersion : '10.1.1'
5
5
  }
6
6
 
@@ -9,8 +9,47 @@ def safeExtGet(prop, fallback) {
9
9
  }
10
10
 
11
11
  buildscript {
12
+ def getFrameworksFile = { String rootDir ->
13
+ def currentDir = new File(rootDir)
14
+
15
+ while (currentDir != null) {
16
+ def frameworksFile = new File(currentDir, "common/frameworks.gradle")
17
+ if (frameworksFile.exists()) {
18
+ return frameworksFile.absolutePath
19
+ }
20
+ currentDir = currentDir.getParentFile()
21
+ }
22
+
23
+ return null
24
+ }
25
+
26
+ def getCapacitorMajorVersion = {
27
+ try {
28
+ def capacitorAndroidDir = new File(rootProject.projectDir, "node_modules/@capacitor/android")
29
+ if (capacitorAndroidDir.exists()) {
30
+ def packageJson = new File(capacitorAndroidDir, "package.json")
31
+ if (packageJson.exists()) {
32
+ def json = new groovy.json.JsonSlurper().parseText(packageJson.text)
33
+ def version = json.version
34
+ if (version) {
35
+ def majorVersion = version.tokenize('.')[0] as Integer
36
+ return majorVersion
37
+ }
38
+ }
39
+ }
40
+ } catch (Exception e) {
41
+ // Fallback if detection fails
42
+ }
43
+ return 7 // Default to Capacitor 7 if detection fails
44
+ }
45
+
12
46
  def retrieveCapacitorCompatibility = {
13
- def file = project(":app").file("capacitor.build.gradle")
47
+ def appModule = rootProject.findProject(":app")
48
+ if (appModule == null) {
49
+ return
50
+ }
51
+
52
+ def file = appModule.file("capacitor.build.gradle")
14
53
  if (file.exists()) {
15
54
  def content = file.text
16
55
 
@@ -28,42 +67,51 @@ buildscript {
28
67
  } else {
29
68
  ext.rootTargetCompatibility = JavaVersion.VERSION_17
30
69
  }
31
-
32
- if (ext.rootTargetCompatibility == JavaVersion.VERSION_21) {
33
- ext.kotlin_version = "1.9.25"
34
- ext.agp_version = "8.7.2"
35
- }
36
70
  }
37
71
  }
38
72
 
39
73
  ext {
40
- kotlin_version = "1.9.25"
41
- agp_version = "8.5.2"
42
74
  rootSourceCompatibility = JavaVersion.VERSION_17
43
75
  rootTargetCompatibility = JavaVersion.VERSION_17
44
76
  }
45
77
 
78
+ // Check for monorepo frameworks.gradle
79
+ def common_gradle_script = getFrameworksFile(rootProject.projectDir.path)
80
+ if (common_gradle_script != null) {
81
+ apply from: common_gradle_script
82
+ }
83
+
46
84
  retrieveCapacitorCompatibility()
47
85
 
48
- repositories {
49
- google()
50
- mavenCentral()
86
+ // Set AGP version if not already defined by frameworks.gradle or root project
87
+ if (!ext.has('agpVersion') && !rootProject.ext.has('agpVersion')) {
88
+ def capacitorMajorVersion = getCapacitorMajorVersion()
89
+ ext.agpVersion = capacitorMajorVersion >= 8 ? '8.13.0' : '8.7.2'
90
+ }
91
+
92
+ // Use repos from frameworks.gradle if available, otherwise explicit repos
93
+ if (ext.has('repos')) {
94
+ repositories ext.repos
95
+ } else {
96
+ repositories {
97
+ google()
98
+ mavenCentral()
99
+ }
51
100
  }
101
+
52
102
  dependencies {
53
- classpath "com.android.tools.build:gradle:$agp_version"
54
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
103
+ classpath "com.android.tools.build:gradle:$agpVersion"
55
104
  }
56
105
  }
57
106
 
58
107
  apply plugin: 'com.android.library'
59
- apply plugin: 'kotlin-android'
60
108
 
61
109
  android {
62
110
  namespace "com.scandit.capacitor.datacapture.core"
63
- compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
111
+ compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
64
112
  defaultConfig {
65
- minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
66
- targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
113
+ minSdk project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
114
+ targetSdk project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
67
115
  versionCode 1
68
116
  versionName "1.0"
69
117
  }
@@ -82,17 +130,21 @@ android {
82
130
  }
83
131
  }
84
132
 
85
- repositories {
86
- google()
87
- mavenCentral()
133
+ // Use repos from frameworks.gradle if available, otherwise explicit repos
134
+ if (ext.has('repos')) {
135
+ repositories ext.repos
136
+ } else {
137
+ repositories {
138
+ google()
139
+ mavenCentral()
140
+ }
88
141
  }
89
142
 
90
143
  dependencies {
91
- def sdk_version = "8.1.1"
144
+ def sdk_version = "8.2.0"
92
145
 
93
146
  implementation fileTree(dir: 'libs', include: ['*.jar'])
94
147
 
95
- println("Version of the native sdk used in this build: ${safeExtGet('global_sdk_version', sdk_version)}")
96
148
  if (findProject(':scandit-datacapture-frameworks-core') != null) {
97
149
  api project(":scandit-datacapture-frameworks-core")
98
150
  } else {
@@ -0,0 +1,311 @@
1
+ package com.scandit.capacitor.datacapture.core;
2
+
3
+ import android.Manifest;
4
+ import android.util.Log;
5
+ import androidx.annotation.NonNull;
6
+ import com.getcapacitor.JSObject;
7
+ import com.getcapacitor.PermissionState;
8
+ import com.getcapacitor.Plugin;
9
+ import com.getcapacitor.PluginCall;
10
+ import com.getcapacitor.PluginMethod;
11
+ import com.getcapacitor.annotation.CapacitorPlugin;
12
+ import com.getcapacitor.annotation.Permission;
13
+ import com.getcapacitor.annotation.PermissionCallback;
14
+ import com.scandit.capacitor.datacapture.core.data.ResizeAndMoveInfo;
15
+ import com.scandit.capacitor.datacapture.core.errors.JsonParseError;
16
+ import com.scandit.capacitor.datacapture.core.handlers.DataCaptureViewHandler;
17
+ import com.scandit.capacitor.datacapture.core.utils.CapacitorMethodCall;
18
+ import com.scandit.capacitor.datacapture.core.utils.CapacitorResult;
19
+ import com.scandit.datacapture.core.source.FrameSourceState;
20
+ import com.scandit.datacapture.core.source.FrameSourceStateDeserializer;
21
+ import com.scandit.datacapture.core.ui.DataCaptureView;
22
+ import com.scandit.datacapture.frameworks.core.CoreModule;
23
+ import com.scandit.datacapture.frameworks.core.errors.ParameterNullError;
24
+ import com.scandit.datacapture.frameworks.core.events.Emitter;
25
+ import com.scandit.datacapture.frameworks.core.lifecycle.ActivityLifecycleDispatcher;
26
+ import com.scandit.datacapture.frameworks.core.lifecycle.DefaultActivityLifecycle;
27
+ import com.scandit.datacapture.frameworks.core.locator.DefaultServiceLocator;
28
+ import com.scandit.datacapture.frameworks.core.result.NoopFrameworksResult;
29
+ import java.util.ArrayList;
30
+ import java.util.Arrays;
31
+ import java.util.List;
32
+ import java.util.Map;
33
+ import org.jetbrains.annotations.NotNull;
34
+ import org.json.JSONException;
35
+ import org.json.JSONObject;
36
+
37
+ @CapacitorPlugin(
38
+ name = "ScanditCaptureCoreNative",
39
+ permissions = {
40
+ @Permission(
41
+ strings = {Manifest.permission.CAMERA},
42
+ alias = "camera")
43
+ })
44
+ public class ScanditCaptureCoreNative extends Plugin implements Emitter {
45
+
46
+ private static final List<String> SCANDIT_PLUGINS =
47
+ Arrays.asList(
48
+ "ScanditBarcodeNative", "ScanditParserNative", "ScanditIdNative", "ScanditTextNative");
49
+
50
+ private final ActivityLifecycleDispatcher lifecycleDispatcher;
51
+ private final DataCaptureViewHandler captureViewHandler;
52
+ private final CoreModule coreModule;
53
+ private final List<Plugin> plugins;
54
+ private FrameSourceState lastFrameSourceState;
55
+
56
+ public ScanditCaptureCoreNative() {
57
+ this.lifecycleDispatcher = DefaultActivityLifecycle.Companion.getInstance();
58
+ this.captureViewHandler = new DataCaptureViewHandler();
59
+ this.coreModule = CoreModule.create(this);
60
+ this.lastFrameSourceState = FrameSourceState.OFF;
61
+ this.plugins = new ArrayList<>();
62
+
63
+ DefaultServiceLocator.getInstance().register(coreModule);
64
+ }
65
+
66
+ public void registerPluginInstance(Plugin instance) {
67
+ plugins.add(instance);
68
+ }
69
+
70
+ @Override
71
+ public void load() {
72
+ super.load();
73
+
74
+ List<String> registeredPlugins = new ArrayList<>();
75
+ for (Plugin plugin : plugins) {
76
+ registeredPlugins.add(plugin.getPluginHandle().getId());
77
+ }
78
+
79
+ for (String pluginName : SCANDIT_PLUGINS) {
80
+ if (!registeredPlugins.contains(pluginName)) {
81
+ com.getcapacitor.PluginHandle unregisteredPlugin = getBridge().getPlugin(pluginName);
82
+
83
+ if (unregisteredPlugin != null) {
84
+ registerPluginInstance(unregisteredPlugin.getInstance());
85
+ } else {
86
+ Log.e("Registering:", pluginName + " not found");
87
+ }
88
+ }
89
+ }
90
+ coreModule.onCreate(getContext());
91
+ }
92
+
93
+ @Override
94
+ protected void handleOnStart() {
95
+ if (checkCameraPermission()) {
96
+ coreModule.switchToDesiredCameraState(lastFrameSourceState);
97
+ }
98
+ coreModule.subscribeContextListener(new NoopFrameworksResult());
99
+ coreModule.registerTopmostDataCaptureViewListener();
100
+ coreModule.registerFrameSourceListener(new NoopFrameworksResult());
101
+ lifecycleDispatcher.dispatchOnStart();
102
+ }
103
+
104
+ @Override
105
+ protected void handleOnStop() {
106
+ lifecycleDispatcher.dispatchOnStop();
107
+ FrameSourceState currentState = coreModule.getCurrentCameraDesiredState();
108
+ lastFrameSourceState = currentState != null ? currentState : FrameSourceState.OFF;
109
+ coreModule.switchToDesiredCameraState(FrameSourceState.OFF);
110
+ coreModule.unsubscribeContextListener(new NoopFrameworksResult());
111
+ coreModule.unregisterTopmostDataCaptureViewListener();
112
+ coreModule.unregisterFrameSourceListener(new NoopFrameworksResult());
113
+ }
114
+
115
+ @Override
116
+ protected void handleOnDestroy() {
117
+ lifecycleDispatcher.dispatchOnDestroy();
118
+ coreModule.onDestroy();
119
+ captureViewHandler.disposeCurrentWebView();
120
+ }
121
+
122
+ @Override
123
+ protected void handleOnResume() {
124
+ lifecycleDispatcher.dispatchOnResume();
125
+ }
126
+
127
+ @Override
128
+ protected void handleOnPause() {
129
+ lifecycleDispatcher.dispatchOnPause();
130
+ }
131
+
132
+ private boolean checkCameraPermission() {
133
+ return getPermissionState("camera") == PermissionState.GRANTED;
134
+ }
135
+
136
+ private void checkOrRequestCameraPermissions(PluginCall call) {
137
+ if (!checkCameraPermission()) {
138
+ requestPermissionForAlias("camera", call, "onCameraPermissionResult");
139
+ } else {
140
+ onCameraPermissionResult(call);
141
+ }
142
+ }
143
+
144
+ @SuppressWarnings("unused")
145
+ @PermissionCallback
146
+ private void onCameraPermissionResult(PluginCall call) {
147
+ if (checkCameraPermission()) {
148
+ coreModule.switchToDesiredCameraState(lastFrameSourceState);
149
+ call.resolve();
150
+ return;
151
+ }
152
+
153
+ call.reject("Camera permissions not granted.");
154
+ }
155
+
156
+ // region DataCaptureViewProxy
157
+ @PluginMethod
158
+ public void setDataCaptureViewPositionAndSize(PluginCall call) {
159
+ try {
160
+ double top = call.getData().getDouble("top");
161
+ double left = call.getData().getDouble("left");
162
+ double width = call.getData().getDouble("width");
163
+ double height = call.getData().getDouble("height");
164
+ boolean shouldBeUnderWebView = call.getData().getBoolean("shouldBeUnderWebView");
165
+
166
+ captureViewHandler.setResizeAndMoveInfo(
167
+ new ResizeAndMoveInfo(
168
+ (float) top, (float) left, (float) width, (float) height, shouldBeUnderWebView));
169
+ call.resolve();
170
+ } catch (JSONException e) {
171
+ call.reject(new JsonParseError(e.getMessage()).toString());
172
+ }
173
+ }
174
+
175
+ @PluginMethod
176
+ public void showDataCaptureView(PluginCall call) {
177
+ captureViewHandler.setVisible();
178
+ call.resolve();
179
+ }
180
+
181
+ @PluginMethod
182
+ public void hideDataCaptureView(PluginCall call) {
183
+ captureViewHandler.setInvisible();
184
+ call.resolve();
185
+ }
186
+
187
+ // endregion
188
+
189
+ @PluginMethod
190
+ public void getDefaults(PluginCall call) {
191
+ try {
192
+ Map<String, Object> defaults = coreModule.getDefaults();
193
+ call.resolve(JSObject.fromJSONObject(new JSONObject(defaults)));
194
+ } catch (JSONException e) {
195
+ call.reject("Failed to get defaults: " + e.getMessage());
196
+ }
197
+ }
198
+
199
+ @PluginMethod
200
+ public void subscribeVolumeButtonObserver(PluginCall call) {
201
+ call.resolve();
202
+ }
203
+
204
+ @PluginMethod
205
+ public void unsubscribeVolumeButtonObserver(PluginCall call) {
206
+ call.resolve();
207
+ }
208
+
209
+ @PluginMethod
210
+ public void createDataCaptureView(PluginCall call) {
211
+ String viewJson = call.getData().getString("viewJson");
212
+ if (viewJson == null) {
213
+ call.reject(new ParameterNullError("viewJson").getMessage());
214
+ return;
215
+ }
216
+
217
+ DataCaptureView view = coreModule.createDataCaptureView(viewJson, new CapacitorResult(call));
218
+ if (view != null) {
219
+ DataCaptureView existingView = captureViewHandler.getDataCaptureView();
220
+ if (existingView != null) {
221
+ // Remove existing view and add the new one.
222
+ coreModule.dataCaptureViewDisposed(existingView);
223
+ captureViewHandler.removeDataCaptureView(existingView);
224
+ }
225
+
226
+ captureViewHandler.addDataCaptureView(view, getBridge());
227
+ }
228
+ }
229
+
230
+ @PluginMethod
231
+ public void removeDataCaptureView(PluginCall call) {
232
+ try {
233
+ int viewId = call.getData().getInt("viewId");
234
+ // In capacitor we just show 1 datacapture view at a time
235
+ DataCaptureView dcViewToRemove = coreModule.getDataCaptureViewById(viewId);
236
+ if (dcViewToRemove != null) {
237
+ dcViewToRemove.post(
238
+ () -> {
239
+ coreModule.dataCaptureViewDisposed(dcViewToRemove);
240
+ captureViewHandler.removeDataCaptureView(dcViewToRemove);
241
+ });
242
+ }
243
+ call.resolve();
244
+ } catch (JSONException e) {
245
+ call.reject("Failed to remove view: " + e.getMessage());
246
+ }
247
+ }
248
+
249
+ @Override
250
+ public void emit(@NotNull String eventName, @NotNull Map<String, Object> payload) {
251
+ JSObject capacitorPayload = new JSObject();
252
+ capacitorPayload.put("name", eventName);
253
+ capacitorPayload.put("data", new JSONObject(payload).toString());
254
+
255
+ notifyListeners(eventName, capacitorPayload);
256
+ }
257
+
258
+ @Override
259
+ public boolean hasListenersForEvent(@NonNull String eventName) {
260
+ return this.hasListeners(eventName);
261
+ }
262
+
263
+ @Override
264
+ public boolean hasViewSpecificListenersForEvent(int viewId, @NonNull String eventName) {
265
+ return this.hasListenersForEvent(eventName);
266
+ }
267
+
268
+ @Override
269
+ public boolean hasModeSpecificListenersForEvent(int modeId, @NonNull String eventName) {
270
+ return this.hasListenersForEvent(eventName);
271
+ }
272
+
273
+ /**
274
+ * Single entry point for all Core operations. Routes method calls to the appropriate command via
275
+ * the shared command factory.
276
+ */
277
+ @PluginMethod
278
+ public void executeCore(PluginCall call) {
279
+ String methodName = call.getData().getString("methodName");
280
+
281
+ // Special handling for switchCameraToDesiredState: check camera permissions
282
+ if ("switchCameraToDesiredState".equals(methodName)) {
283
+ handleSwitchCameraToDesiredState(call);
284
+ return;
285
+ }
286
+
287
+ boolean handled =
288
+ coreModule.execute(new CapacitorMethodCall(call), new CapacitorResult(call), coreModule);
289
+ if (!handled) {
290
+ call.reject("Unknown Core method: " + (methodName != null ? methodName : "unknown"));
291
+ }
292
+ }
293
+
294
+ private void handleSwitchCameraToDesiredState(PluginCall call) {
295
+ String stateJson = call.getData().getString("stateJson");
296
+ if (stateJson == null) {
297
+ call.reject(new ParameterNullError("stateJson").getMessage());
298
+ return;
299
+ }
300
+
301
+ if (checkCameraPermission()) {
302
+ coreModule.execute(new CapacitorMethodCall(call), new CapacitorResult(call), coreModule);
303
+ FrameSourceState currentState = coreModule.getCurrentCameraDesiredState();
304
+ lastFrameSourceState = currentState != null ? currentState : FrameSourceState.OFF;
305
+ return;
306
+ }
307
+
308
+ lastFrameSourceState = FrameSourceStateDeserializer.fromJson(stateJson);
309
+ checkOrRequestCameraPermissions(call);
310
+ }
311
+ }
@@ -0,0 +1,44 @@
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
+ public class ResizeAndMoveInfo {
10
+ private final float top;
11
+ private final float left;
12
+ private final float width;
13
+ private final float height;
14
+ private final boolean shouldBeUnderWebView;
15
+
16
+ public ResizeAndMoveInfo(
17
+ float top, float left, float width, float height, boolean shouldBeUnderWebView) {
18
+ this.top = top;
19
+ this.left = left;
20
+ this.width = width;
21
+ this.height = height;
22
+ this.shouldBeUnderWebView = shouldBeUnderWebView;
23
+ }
24
+
25
+ public float getTop() {
26
+ return top;
27
+ }
28
+
29
+ public float getLeft() {
30
+ return left;
31
+ }
32
+
33
+ public float getWidth() {
34
+ return width;
35
+ }
36
+
37
+ public float getHeight() {
38
+ return height;
39
+ }
40
+
41
+ public boolean getShouldBeUnderWebView() {
42
+ return shouldBeUnderWebView;
43
+ }
44
+ }
@@ -0,0 +1,33 @@
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 java.util.HashMap;
10
+ import java.util.Map;
11
+ import org.json.JSONObject;
12
+
13
+ public abstract class ActionError extends Exception {
14
+
15
+ private static final String KEY_CODE = "Code";
16
+ private static final String KEY_MESSAGE = "Message";
17
+
18
+ private final int errorCode;
19
+ private final String errorMessage;
20
+
21
+ public ActionError(int errorCode, String errorMessage) {
22
+ super(errorMessage);
23
+ this.errorCode = errorCode;
24
+ this.errorMessage = errorMessage;
25
+ }
26
+
27
+ public JSONObject serializeContent() {
28
+ Map<String, Object> data = new HashMap<>();
29
+ data.put(KEY_CODE, errorCode);
30
+ data.put(KEY_MESSAGE, errorMessage);
31
+ return new JSONObject(data);
32
+ }
33
+ }
@@ -0,0 +1,18 @@
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
+ public class JsonParseError extends ActionError {
10
+
11
+ private static final int ERROR_CODE = 10001;
12
+
13
+ public JsonParseError(String error) {
14
+ super(
15
+ ERROR_CODE,
16
+ "Invalid or no JSON passed for command: " + (error != null ? error : "No additional info"));
17
+ }
18
+ }