scandit-capacitor-datacapture-barcode 8.3.1 → 8.4.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.
@@ -17,5 +17,5 @@ Pod::Spec.new do |s|
17
17
 
18
18
  s.dependency "Capacitor"
19
19
  s.dependency "ScanditCapacitorDatacaptureCore", "= #{version}"
20
- s.dependency "scandit-datacapture-frameworks-barcode", '= 8.3.1'
20
+ s.dependency "scandit-datacapture-frameworks-barcode", '= 8.4.0'
21
21
  end
@@ -143,7 +143,7 @@ if (ext.has('repos')) {
143
143
  }
144
144
 
145
145
  dependencies {
146
- def sdk_version = "8.3.1"
146
+ def sdk_version = "8.4.0"
147
147
 
148
148
  implementation fileTree(dir: 'libs', include: ['*.jar'])
149
149
  implementation fileTree(dir: 'library', include: ['*.aar'])
@@ -153,7 +153,7 @@ dependencies {
153
153
  if (findProject(':scandit-datacapture-frameworks-barcode') != null) {
154
154
  api project(":scandit-datacapture-frameworks-barcode")
155
155
  } else {
156
- api "com.scandit.datacapture.frameworks:barcode:${safeExtGet('global_sdk_version', sdk_version)}"
156
+ api "com.scandit.datacapture.frameworks:barcode:${safeExtGet('frameworks_sdk_version', sdk_version)}"
157
157
  }
158
158
 
159
159
  implementation "androidx.core:core-ktx:$androidxCoreVersion"
@@ -42,6 +42,7 @@ import com.scandit.datacapture.frameworks.core.FrameworkModule;
42
42
  import com.scandit.datacapture.frameworks.core.errors.ParameterNullError;
43
43
  import com.scandit.datacapture.frameworks.core.events.Emitter;
44
44
  import com.scandit.datacapture.frameworks.core.locator.DefaultServiceLocator;
45
+ import com.scandit.datacapture.frameworks.core.result.NoopFrameworksResult;
45
46
  import com.scandit.datacapture.frameworks.core.utils.DefaultFrameworksLog;
46
47
  import com.scandit.datacapture.frameworks.core.utils.DefaultMainThread;
47
48
  import com.scandit.datacapture.frameworks.core.utils.FrameworksLog;
@@ -472,7 +473,30 @@ public class ScanditBarcodeNative extends Plugin implements Emitter {
472
473
  return;
473
474
  }
474
475
 
475
- final String finalViewJson = viewJson;
476
+ // BarcodeAr manages its own camera (like SparkScan) and the JS sample fires
477
+ // camera.switchToDesiredState(On) immediately after connectToElement resolves,
478
+ // so the view must only be created (and the call only resolved) once the user
479
+ // has granted the camera permission — otherwise the camera-on call races the
480
+ // OS dialog and the user sees a black preview on first launch.
481
+ if (!checkCameraPermission()) {
482
+ requestPermissionForAlias("camera", call, "onBarcodeArCameraPermissionResult");
483
+ return;
484
+ }
485
+ attachBarcodeArView(call);
486
+ }
487
+
488
+ @SuppressWarnings("unused")
489
+ @PermissionCallback
490
+ private void onBarcodeArCameraPermissionResult(PluginCall call) {
491
+ if (!checkCameraPermission()) {
492
+ call.reject("Camera permissions not granted.");
493
+ return;
494
+ }
495
+ attachBarcodeArView(call);
496
+ }
497
+
498
+ private void attachBarcodeArView(PluginCall call) {
499
+ final String finalViewJson = call.getData().getString("viewJson");
476
500
  mainThread.runOnMainThread(
477
501
  () -> {
478
502
  FrameLayout container = new FrameLayout(getBridge().getContext());
@@ -480,20 +504,20 @@ public class ScanditBarcodeNative extends Plugin implements Emitter {
480
504
  container.setMinimumWidth(getBridge().getWebView().getWidth());
481
505
  container.setBackgroundColor(Color.TRANSPARENT);
482
506
 
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());
507
+ barcodeArModule.addViewToContainer(container, finalViewJson, new NoopFrameworksResult());
492
508
 
493
- call.resolve();
494
- } else {
509
+ if (container.getChildCount() == 0) {
495
510
  call.reject("Unable to create the native BarcodeArModule");
511
+ return;
496
512
  }
513
+
514
+ android.view.View nativeView = container.getChildAt(0);
515
+ Object tag = nativeView.getTag();
516
+ int viewId = (tag instanceof Integer) ? (Integer) tag : 0;
517
+
518
+ barcodeArViewHandler.addBarcodeArViewContainer(viewId, container, getBridge());
519
+
520
+ call.resolve();
497
521
  });
498
522
  }
499
523