scandit-capacitor-datacapture-barcode 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 (31) hide show
  1. package/ScanditCapacitorDatacaptureBarcode.podspec +1 -1
  2. package/android/build.gradle +71 -23
  3. package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/ScanditBarcodeNative.java +593 -0
  4. package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/ar/BarcodeArViewHandler.java +146 -0
  5. package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/count/BarcodeCountViewHandler.java +143 -0
  6. package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/find/BarcodeFindViewHandler.java +181 -0
  7. package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/pick/BarcodePickViewHandler.java +152 -0
  8. package/dist/barcode.js +5271 -1377
  9. package/dist/barcode.js.map +1 -1
  10. package/dist/dts/definitions.d.ts +35 -8
  11. package/dist/dts/ts/BarcodeArView.d.ts +57 -0
  12. package/dist/dts/ts/BarcodeBatchAdvancedOverlay.d.ts +1 -0
  13. package/dist/dts/ts/BarcodeFindView.d.ts +1 -0
  14. package/dist/dts/web.d.ts +1 -3
  15. package/dist/index.js +562 -316
  16. package/dist/index.js.map +1 -1
  17. package/ios/Sources/ScanditCapacitorBarcode/BarcodeArViewHandler.swift +146 -0
  18. package/ios/Sources/ScanditCapacitorBarcode/BarcodeCountViewHandler.swift +11 -0
  19. package/ios/Sources/ScanditCapacitorBarcode/BarcodeFindViewHandler.swift +43 -25
  20. package/ios/Sources/ScanditCapacitorBarcode/BarcodePickViewHandler.swift +11 -8
  21. package/ios/Sources/ScanditCapacitorBarcode/ScanditBarcodeCapture.swift +293 -1910
  22. package/package.json +7 -7
  23. package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/ScanditBarcodeNative.kt +0 -1569
  24. package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/count/BarcodeCountViewHandler.kt +0 -137
  25. package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/factories/BarcodeCaptureActionFactory.kt +0 -13
  26. package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/find/BarcodeFindViewHandler.kt +0 -166
  27. package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/pick/BarcodePickViewHandler.kt +0 -136
  28. package/android/src/main/java/com/scandit/capacitor/datacapture/barcode/utils/AdvancedOverlayViewSerialization.kt +0 -89
  29. package/ios/Sources/ScanditCapacitorBarcode/BlockingCallbackResults.swift +0 -73
  30. package/ios/Sources/ScanditCapacitorBarcode/CommandJSONArgument+ScanditBarcodeCapture.swift +0 -70
  31. package/ios/Sources/ScanditCapacitorBarcode/TappableBase64ImageView.swift +0 -63
@@ -0,0 +1,593 @@
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.barcode;
7
+
8
+ import android.Manifest;
9
+ import android.graphics.Color;
10
+ import android.webkit.WebView;
11
+ import android.widget.FrameLayout;
12
+ import androidx.annotation.NonNull;
13
+ import com.getcapacitor.JSObject;
14
+ import com.getcapacitor.PermissionState;
15
+ import com.getcapacitor.Plugin;
16
+ import com.getcapacitor.PluginCall;
17
+ import com.getcapacitor.PluginHandle;
18
+ import com.getcapacitor.PluginMethod;
19
+ import com.getcapacitor.annotation.CapacitorPlugin;
20
+ import com.getcapacitor.annotation.Permission;
21
+ import com.getcapacitor.annotation.PermissionCallback;
22
+ import com.scandit.capacitor.datacapture.barcode.ar.BarcodeArViewHandler;
23
+ import com.scandit.capacitor.datacapture.barcode.count.BarcodeCountViewHandler;
24
+ import com.scandit.capacitor.datacapture.barcode.find.BarcodeFindViewHandler;
25
+ import com.scandit.capacitor.datacapture.barcode.pick.BarcodePickViewHandler;
26
+ import com.scandit.capacitor.datacapture.core.ScanditCaptureCoreNative;
27
+ import com.scandit.capacitor.datacapture.core.data.ResizeAndMoveInfo;
28
+ import com.scandit.capacitor.datacapture.core.utils.CapacitorMethodCall;
29
+ import com.scandit.capacitor.datacapture.core.utils.CapacitorResult;
30
+ import com.scandit.datacapture.frameworks.barcode.BarcodeModule;
31
+ import com.scandit.datacapture.frameworks.barcode.ar.BarcodeArModule;
32
+ import com.scandit.datacapture.frameworks.barcode.batch.BarcodeBatchModule;
33
+ import com.scandit.datacapture.frameworks.barcode.capture.BarcodeCaptureModule;
34
+ import com.scandit.datacapture.frameworks.barcode.count.BarcodeCountModule;
35
+ import com.scandit.datacapture.frameworks.barcode.find.BarcodeFindModule;
36
+ import com.scandit.datacapture.frameworks.barcode.generator.BarcodeGeneratorModule;
37
+ import com.scandit.datacapture.frameworks.barcode.pick.BarcodePickModule;
38
+ import com.scandit.datacapture.frameworks.barcode.selection.BarcodeSelectionModule;
39
+ import com.scandit.datacapture.frameworks.barcode.spark.SparkScanModule;
40
+ import com.scandit.datacapture.frameworks.core.CoreModule;
41
+ import com.scandit.datacapture.frameworks.core.FrameworkModule;
42
+ import com.scandit.datacapture.frameworks.core.errors.ParameterNullError;
43
+ import com.scandit.datacapture.frameworks.core.events.Emitter;
44
+ import com.scandit.datacapture.frameworks.core.locator.DefaultServiceLocator;
45
+ import com.scandit.datacapture.frameworks.core.utils.DefaultFrameworksLog;
46
+ import com.scandit.datacapture.frameworks.core.utils.DefaultMainThread;
47
+ import com.scandit.datacapture.frameworks.core.utils.FrameworksLog;
48
+ import com.scandit.datacapture.frameworks.core.utils.MainThread;
49
+ import java.util.Map;
50
+ import org.json.JSONException;
51
+ import org.json.JSONObject;
52
+
53
+ @CapacitorPlugin(
54
+ name = "ScanditBarcodeNative",
55
+ permissions = {
56
+ @Permission(
57
+ strings = {Manifest.permission.CAMERA},
58
+ alias = "camera")
59
+ })
60
+ public class ScanditBarcodeNative extends Plugin implements Emitter {
61
+
62
+ private static final String CORE_PLUGIN_NAME = "ScanditCaptureCoreNative";
63
+ private static final String WRONG_INPUT = "Wrong input parameter";
64
+ private static final String WEB_VIEW_NOT_ATTACHED = "WebView not attached yet";
65
+
66
+ private final BarcodeModule barcodeModule;
67
+ private final BarcodeCaptureModule barcodeCaptureModule;
68
+ private final BarcodeBatchModule barcodeBatchModule;
69
+ private final BarcodeSelectionModule barcodeSelectionModule;
70
+ private final BarcodeCountModule barcodeCountModule;
71
+ private final BarcodeFindModule barcodeFindModule;
72
+ private final BarcodePickModule barcodePickModule;
73
+ private final SparkScanModule sparkScanModule;
74
+ private final BarcodeArModule barcodeArModule;
75
+ private final BarcodeGeneratorModule barcodeGeneratorModule;
76
+
77
+ private final BarcodeCountViewHandler barcodeCountViewHandler;
78
+ private final BarcodeFindViewHandler barcodeFindViewHandler;
79
+ private final BarcodePickViewHandler barcodePickViewHandler;
80
+ private final BarcodeArViewHandler barcodeArViewHandler;
81
+
82
+ private final FrameworksLog logger;
83
+ private final MainThread mainThread;
84
+ private final DefaultServiceLocator serviceLocator;
85
+
86
+ public ScanditBarcodeNative() {
87
+ this.barcodeModule = new BarcodeModule();
88
+ this.barcodeCaptureModule = BarcodeCaptureModule.create(this);
89
+ this.barcodeBatchModule = BarcodeBatchModule.create(this, null);
90
+ this.barcodeSelectionModule = BarcodeSelectionModule.create(this);
91
+ this.barcodeCountModule = BarcodeCountModule.create(this);
92
+ this.barcodeFindModule = BarcodeFindModule.create(this);
93
+ this.barcodePickModule = BarcodePickModule.create(this);
94
+ this.sparkScanModule = SparkScanModule.create(this);
95
+ this.barcodeArModule = BarcodeArModule.create(this);
96
+ this.barcodeGeneratorModule = new BarcodeGeneratorModule();
97
+
98
+ this.barcodeCountViewHandler = new BarcodeCountViewHandler();
99
+ this.barcodeFindViewHandler = new BarcodeFindViewHandler();
100
+ this.barcodePickViewHandler = new BarcodePickViewHandler();
101
+ this.barcodeArViewHandler = new BarcodeArViewHandler();
102
+
103
+ this.logger = DefaultFrameworksLog.getInstance();
104
+ this.mainThread = DefaultMainThread.getInstance();
105
+ this.serviceLocator = DefaultServiceLocator.getInstance();
106
+
107
+ // Register modules with service locator
108
+ serviceLocator.register(barcodeModule);
109
+ serviceLocator.register(barcodeCaptureModule);
110
+ serviceLocator.register(barcodeBatchModule);
111
+ serviceLocator.register(barcodeSelectionModule);
112
+ serviceLocator.register(barcodeCountModule);
113
+ serviceLocator.register(barcodeFindModule);
114
+ serviceLocator.register(barcodePickModule);
115
+ serviceLocator.register(sparkScanModule);
116
+ serviceLocator.register(barcodeGeneratorModule);
117
+ serviceLocator.register(barcodeArModule);
118
+ }
119
+
120
+ @Override
121
+ public void load() {
122
+ super.load();
123
+
124
+ // We need to register the plugin with its Core dependency for serializers to load.
125
+ PluginHandle corePlugin = getBridge().getPlugin(CORE_PLUGIN_NAME);
126
+ if (corePlugin != null) {
127
+ ((ScanditCaptureCoreNative) corePlugin.getInstance())
128
+ .registerPluginInstance(getPluginHandle().getInstance());
129
+ } else {
130
+ logger.error("Core not found");
131
+ }
132
+
133
+ mainThread.runOnMainThread(
134
+ () -> {
135
+ barcodeCountViewHandler.attachWebView(getBridge().getWebView());
136
+ barcodeFindViewHandler.attachWebView(getBridge().getWebView());
137
+ barcodePickViewHandler.attachWebView(getBridge().getWebView(), getBridge().getActivity());
138
+ });
139
+
140
+ barcodeModule.onCreate(getContext());
141
+ barcodeCaptureModule.onCreate(getContext());
142
+ barcodeBatchModule.onCreate(getContext());
143
+ barcodeSelectionModule.onCreate(getContext());
144
+ barcodeCountModule.onCreate(getContext());
145
+ barcodeFindModule.onCreate(getContext());
146
+ barcodePickModule.onCreate(getContext());
147
+ sparkScanModule.onCreate(getContext());
148
+ barcodeGeneratorModule.onCreate(getContext());
149
+ barcodeArModule.onCreate(getContext());
150
+ }
151
+
152
+ @Override
153
+ protected void handleOnDestroy() {
154
+ barcodeModule.onDestroy();
155
+ barcodeCaptureModule.onDestroy();
156
+ barcodeBatchModule.onDestroy();
157
+ barcodeSelectionModule.onDestroy();
158
+ barcodeCountModule.onDestroy();
159
+ barcodeFindModule.onDestroy();
160
+ barcodePickModule.onDestroy();
161
+ sparkScanModule.onDestroy();
162
+ barcodeGeneratorModule.onDestroy();
163
+ barcodeArModule.onDestroy();
164
+ }
165
+
166
+ private boolean checkCameraPermission() {
167
+ return getPermissionState("camera") == PermissionState.GRANTED;
168
+ }
169
+
170
+ private void checkOrRequestCameraPermissions(PluginCall call) {
171
+ if (!checkCameraPermission()) {
172
+ requestPermissionForAlias("camera", call, "onCameraPermissionResult");
173
+ } else {
174
+ onCameraPermissionResult(call);
175
+ }
176
+ }
177
+
178
+ @SuppressWarnings("unused")
179
+ @PermissionCallback
180
+ private void onCameraPermissionResult(PluginCall call) {
181
+ if (checkCameraPermission()) {
182
+ call.resolve();
183
+ return;
184
+ }
185
+
186
+ call.reject("Camera permissions not granted.");
187
+ }
188
+
189
+ @Override
190
+ public void emit(@NonNull String eventName, @NonNull Map<String, Object> payload) {
191
+ JSObject capacitorPayload = new JSObject();
192
+ capacitorPayload.put("name", eventName);
193
+ capacitorPayload.put("data", new JSONObject(payload).toString());
194
+
195
+ notifyListeners(eventName, capacitorPayload);
196
+ }
197
+
198
+ @Override
199
+ public boolean hasListenersForEvent(@NonNull String eventName) {
200
+ return this.hasListeners(eventName);
201
+ }
202
+
203
+ @Override
204
+ public boolean hasViewSpecificListenersForEvent(int viewId, @NonNull String eventName) {
205
+ return this.hasListenersForEvent(eventName);
206
+ }
207
+
208
+ @Override
209
+ public boolean hasModeSpecificListenersForEvent(int modeId, @NonNull String eventName) {
210
+ return this.hasListenersForEvent(eventName);
211
+ }
212
+
213
+ @PluginMethod
214
+ public void getDefaults(PluginCall call) {
215
+ try {
216
+ JSObject defaults = JSObject.fromJSONObject(new JSONObject(barcodeModule.getDefaults()));
217
+ call.resolve(defaults);
218
+ } catch (JSONException e) {
219
+ call.reject("Failed to get defaults: " + e.getMessage());
220
+ }
221
+ }
222
+
223
+ // region BarcodeCount
224
+
225
+ @PluginMethod
226
+ public void createBarcodeCountView(PluginCall call) {
227
+ String viewJson = call.getData().getString("viewJson");
228
+ if (viewJson == null) {
229
+ call.reject(WRONG_INPUT, "Missing or invalid viewJson");
230
+ return;
231
+ }
232
+
233
+ Object barcodeCountView = barcodeCountModule.getViewFromJson(viewJson);
234
+ if (barcodeCountView == null) {
235
+ call.reject("Unable to create the BarcodeCountView from the given json=" + viewJson);
236
+ return;
237
+ }
238
+
239
+ mainThread.runOnMainThread(
240
+ () -> {
241
+ barcodeCountViewHandler.attachBarcodeCountView(
242
+ barcodeCountView, getBridge().getActivity());
243
+ barcodeCountViewHandler.render();
244
+ call.resolve();
245
+ });
246
+ }
247
+
248
+ @PluginMethod
249
+ public void removeBarcodeCountView(PluginCall call) {
250
+ mainThread.runOnMainThread(
251
+ () -> {
252
+ barcodeCountModule.viewDisposed(getViewId(call));
253
+ barcodeCountViewHandler.disposeCurrentView();
254
+ });
255
+ call.resolve();
256
+ }
257
+
258
+ @PluginMethod
259
+ public void setBarcodeCountViewPositionAndSize(PluginCall call) {
260
+ Double top = call.getDouble("top");
261
+ if (top == null) {
262
+ call.reject("Missing top position");
263
+ return;
264
+ }
265
+
266
+ Double left = call.getDouble("left");
267
+ if (left == null) {
268
+ call.reject("Missing left position");
269
+ return;
270
+ }
271
+
272
+ Double width = call.getDouble("width");
273
+ if (width == null) {
274
+ call.reject("Missing width");
275
+ return;
276
+ }
277
+
278
+ Double height = call.getDouble("height");
279
+ if (height == null) {
280
+ call.reject("Missing height");
281
+ return;
282
+ }
283
+
284
+ Boolean shouldBeUnderWebView = call.getBoolean("shouldBeUnderWebView");
285
+ if (shouldBeUnderWebView == null) {
286
+ shouldBeUnderWebView = false;
287
+ }
288
+
289
+ barcodeCountViewHandler.setResizeAndMoveInfo(
290
+ new ResizeAndMoveInfo(
291
+ top.floatValue(),
292
+ left.floatValue(),
293
+ width.floatValue(),
294
+ height.floatValue(),
295
+ shouldBeUnderWebView));
296
+ call.resolve();
297
+ }
298
+
299
+ // endregion
300
+
301
+ // region Barcode Find
302
+
303
+ @PluginMethod
304
+ public void createFindView(PluginCall call) {
305
+ String viewJson = call.getData().getString("json");
306
+ if (viewJson == null) {
307
+ call.reject("missing parameter for createFindView()");
308
+ return;
309
+ }
310
+
311
+ FrameLayout container = barcodeFindViewHandler.prepareContainer(getContext());
312
+
313
+ mainThread.runOnMainThread(
314
+ () -> {
315
+ barcodeFindModule.addViewToContainer(container, viewJson, new CapacitorResult(call));
316
+ barcodeFindViewHandler.addBarcodeFindViewContainer(
317
+ getViewId(call), container, getBridge().getActivity());
318
+ });
319
+ }
320
+
321
+ @PluginMethod
322
+ public void removeFindView(PluginCall call) {
323
+ int viewId = getViewId(call);
324
+ barcodeFindModule.viewDisposed(viewId);
325
+ barcodeFindViewHandler.disposeContainer(viewId);
326
+ call.resolve();
327
+ }
328
+
329
+ @PluginMethod
330
+ public void setFindViewPositionAndSize(PluginCall call) {
331
+ Double top = call.getDouble("top");
332
+ if (top == null) {
333
+ call.reject("Missing top position");
334
+ return;
335
+ }
336
+
337
+ Double left = call.getDouble("left");
338
+ if (left == null) {
339
+ call.reject("Missing left position");
340
+ return;
341
+ }
342
+
343
+ Double width = call.getDouble("width");
344
+ if (width == null) {
345
+ call.reject("Missing width");
346
+ return;
347
+ }
348
+
349
+ Double height = call.getDouble("height");
350
+ if (height == null) {
351
+ call.reject("Missing height");
352
+ return;
353
+ }
354
+
355
+ Boolean shouldBeUnderWebView = call.getBoolean("shouldBeUnderWebView");
356
+ if (shouldBeUnderWebView == null) {
357
+ shouldBeUnderWebView = false;
358
+ }
359
+
360
+ barcodeFindViewHandler.setResizeAndMoveInfo(
361
+ new ResizeAndMoveInfo(
362
+ top.floatValue(),
363
+ left.floatValue(),
364
+ width.floatValue(),
365
+ height.floatValue(),
366
+ shouldBeUnderWebView));
367
+ call.resolve();
368
+ }
369
+
370
+ // endregion
371
+
372
+ // region BarcodePick
373
+
374
+ @PluginMethod
375
+ public void createPickView(PluginCall call) {
376
+ String viewJson = call.getString("json");
377
+
378
+ if (viewJson != null) {
379
+ FrameLayout container = barcodePickViewHandler.prepareContainer(getContext());
380
+
381
+ mainThread.runOnMainThread(
382
+ () -> {
383
+ barcodePickModule.addViewToContainer(container, viewJson, new CapacitorResult(call));
384
+ barcodePickViewHandler.addBarcodePickViewContainer(
385
+ container, getBridge().getActivity());
386
+ barcodePickViewHandler.render();
387
+ });
388
+ call.resolve();
389
+ } else {
390
+ call.reject("missing parameter for createPickView()");
391
+ }
392
+ }
393
+
394
+ @PluginMethod
395
+ public void removePickView(PluginCall call) {
396
+ barcodePickModule.pickViewRelease(getViewId(call), new CapacitorResult(call));
397
+ barcodePickViewHandler.disposeCurrentView();
398
+ }
399
+
400
+ @PluginMethod
401
+ public void setPickViewPositionAndSize(PluginCall call) {
402
+ Double top = call.getDouble("top");
403
+ if (top == null) {
404
+ call.reject("Missing top position");
405
+ return;
406
+ }
407
+
408
+ Double left = call.getDouble("left");
409
+ if (left == null) {
410
+ call.reject("Missing left position");
411
+ return;
412
+ }
413
+
414
+ Double width = call.getDouble("width");
415
+ if (width == null) {
416
+ call.reject("Missing width");
417
+ return;
418
+ }
419
+
420
+ Double height = call.getDouble("height");
421
+ if (height == null) {
422
+ call.reject("Missing height");
423
+ return;
424
+ }
425
+
426
+ Boolean shouldBeUnderWebView = call.getBoolean("shouldBeUnderWebView");
427
+ if (shouldBeUnderWebView == null) {
428
+ shouldBeUnderWebView = false;
429
+ }
430
+
431
+ barcodePickViewHandler.setResizeAndMoveInfo(
432
+ new ResizeAndMoveInfo(
433
+ top.floatValue(),
434
+ left.floatValue(),
435
+ width.floatValue(),
436
+ height.floatValue(),
437
+ shouldBeUnderWebView));
438
+ call.resolve();
439
+ }
440
+
441
+ // endregion
442
+
443
+ @PluginMethod
444
+ public void createSparkScanView(PluginCall call) {
445
+ WebView container = getBridge().getWebView();
446
+ if (container == null) {
447
+ call.reject(WEB_VIEW_NOT_ATTACHED);
448
+ return;
449
+ }
450
+
451
+ String viewJson = call.getData().getString("viewJson");
452
+ if (viewJson == null) {
453
+ viewJson = "";
454
+ }
455
+
456
+ final String finalViewJson = viewJson;
457
+ container.post(
458
+ () ->
459
+ sparkScanModule.addViewToContainer(
460
+ container, finalViewJson, new CapacitorResult(call)));
461
+
462
+ checkOrRequestCameraPermissions(call);
463
+ }
464
+
465
+ // region BarcodeAr
466
+
467
+ @PluginMethod
468
+ public void createBarcodeArView(PluginCall call) {
469
+ String viewJson = call.getData().getString("viewJson");
470
+ if (viewJson == null) {
471
+ call.reject(WRONG_INPUT, "Missing or invalid viewJson");
472
+ return;
473
+ }
474
+
475
+ final String finalViewJson = viewJson;
476
+ mainThread.runOnMainThread(
477
+ () -> {
478
+ FrameLayout container = new FrameLayout(getBridge().getContext());
479
+ container.setMinimumHeight(getBridge().getWebView().getHeight());
480
+ container.setMinimumWidth(getBridge().getWebView().getWidth());
481
+ container.setBackgroundColor(Color.TRANSPARENT);
482
+
483
+ barcodeArModule.addViewToContainer(container, finalViewJson, new CapacitorResult(call));
484
+
485
+ // Assume the view was added successfully - the container should have children now
486
+ if (container.getChildCount() > 0) {
487
+ android.view.View nativeView = container.getChildAt(0);
488
+ Object tag = nativeView.getTag();
489
+ int viewId = (tag instanceof Integer) ? (Integer) tag : 0;
490
+
491
+ barcodeArViewHandler.addBarcodeArViewContainer(viewId, container, getBridge());
492
+
493
+ call.resolve();
494
+ } else {
495
+ call.reject("Unable to create the native BarcodeArModule");
496
+ }
497
+ });
498
+ }
499
+
500
+ @PluginMethod
501
+ public void removeBarcodeArView(PluginCall call) {
502
+ int viewId = getViewId(call);
503
+ mainThread.runOnMainThread(
504
+ () -> {
505
+ barcodeArModule.viewDisposed(viewId);
506
+ barcodeArViewHandler.disposeContainer(viewId);
507
+ });
508
+ call.resolve();
509
+ }
510
+
511
+ @PluginMethod
512
+ public void setArViewPositionAndSize(PluginCall call) {
513
+ Double top = call.getDouble("top");
514
+ if (top == null) {
515
+ call.reject("Missing top position");
516
+ return;
517
+ }
518
+
519
+ Double left = call.getDouble("left");
520
+ if (left == null) {
521
+ call.reject("Missing left position");
522
+ return;
523
+ }
524
+
525
+ Double width = call.getDouble("width");
526
+ if (width == null) {
527
+ call.reject("Missing width");
528
+ return;
529
+ }
530
+
531
+ Double height = call.getDouble("height");
532
+ if (height == null) {
533
+ call.reject("Missing height");
534
+ return;
535
+ }
536
+
537
+ Boolean shouldBeUnderWebView = call.getBoolean("shouldBeUnderWebView");
538
+ if (shouldBeUnderWebView == null) {
539
+ shouldBeUnderWebView = false;
540
+ }
541
+
542
+ barcodeArViewHandler.setResizeAndMoveInfo(
543
+ new ResizeAndMoveInfo(
544
+ top.floatValue(),
545
+ left.floatValue(),
546
+ width.floatValue(),
547
+ height.floatValue(),
548
+ shouldBeUnderWebView));
549
+ call.resolve();
550
+ }
551
+
552
+ // endregion
553
+
554
+ private int getViewId(PluginCall call) {
555
+ try {
556
+ return call.getData().getInt("viewId");
557
+ } catch (JSONException e) {
558
+ return 0;
559
+ }
560
+ }
561
+
562
+ @PluginMethod
563
+ public void executeBarcode(PluginCall call) {
564
+ String moduleName = call.getData().getString("moduleName");
565
+ if (moduleName == null) {
566
+ call.reject(new ParameterNullError("moduleName").getMessage());
567
+ return;
568
+ }
569
+
570
+ CoreModule coreModule = (CoreModule) serviceLocator.resolve(CoreModule.class.getSimpleName());
571
+ if (coreModule == null) {
572
+ call.reject("Unable to retrieve the CoreModule from the locator.");
573
+ return;
574
+ }
575
+
576
+ FrameworkModule targetModule = serviceLocator.resolve(moduleName);
577
+ if (targetModule == null) {
578
+ call.reject("Unable to retrieve the " + moduleName + " from the locator.");
579
+ return;
580
+ }
581
+
582
+ boolean result =
583
+ coreModule.execute(new CapacitorMethodCall(call), new CapacitorResult(call), targetModule);
584
+
585
+ if (!result) {
586
+ String methodName = call.getData().getString("methodName");
587
+ if (methodName == null) {
588
+ methodName = "unknown";
589
+ }
590
+ call.reject("Unknown method: " + methodName);
591
+ }
592
+ }
593
+ }