capacitor-camera-module 0.0.37 → 0.0.39
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.
|
@@ -643,70 +643,68 @@ public class CameraModulePlugin extends Plugin {
|
|
|
643
643
|
@PluginMethod
|
|
644
644
|
public void startBarcodeScan(PluginCall call) {
|
|
645
645
|
|
|
646
|
-
|
|
647
|
-
call.reject("Preview not started");
|
|
648
|
-
return;
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
if (getPermissionState("camera") != PermissionState.GRANTED) {
|
|
652
|
-
call.reject("Camera permission not granted");
|
|
653
|
-
return;
|
|
654
|
-
}
|
|
646
|
+
getActivity().runOnUiThread(() -> {
|
|
655
647
|
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
648
|
+
if (previewView == null) {
|
|
649
|
+
call.reject("Preview not started");
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
660
652
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
653
|
+
if (getPermissionState("camera") != PermissionState.GRANTED) {
|
|
654
|
+
call.reject("Camera permission not granted");
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
665
657
|
|
|
666
|
-
|
|
658
|
+
if (cameraProvider == null) {
|
|
659
|
+
call.reject("Camera not initialized");
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
667
662
|
|
|
668
|
-
|
|
663
|
+
if (isScanning) {
|
|
664
|
+
call.reject("Already scanning");
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
669
667
|
|
|
670
|
-
|
|
671
|
-
isScanning = true;
|
|
668
|
+
barcodeScanner = BarcodeScanning.getClient();
|
|
672
669
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST
|
|
677
|
-
)
|
|
678
|
-
.build();
|
|
670
|
+
call.setKeepAlive(true);
|
|
671
|
+
scanCall = call;
|
|
672
|
+
isScanning = true;
|
|
679
673
|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
674
|
+
imageAnalysis =
|
|
675
|
+
new ImageAnalysis.Builder()
|
|
676
|
+
.setBackpressureStrategy(
|
|
677
|
+
ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST
|
|
678
|
+
)
|
|
679
|
+
.build();
|
|
684
680
|
|
|
685
|
-
|
|
681
|
+
imageAnalysis.setAnalyzer(
|
|
682
|
+
barcodeExecutor,
|
|
683
|
+
this::processBarcode
|
|
684
|
+
);
|
|
686
685
|
|
|
687
|
-
|
|
688
|
-
preview.setSurfaceProvider(previewView.getSurfaceProvider());
|
|
686
|
+
cameraProvider.unbindAll();
|
|
689
687
|
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
.setCaptureMode(ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY)
|
|
693
|
-
.build();
|
|
688
|
+
Preview preview = new Preview.Builder().build();
|
|
689
|
+
preview.setSurfaceProvider(previewView.getSurfaceProvider());
|
|
694
690
|
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
691
|
+
imageCapture =
|
|
692
|
+
new ImageCapture.Builder()
|
|
693
|
+
.setCaptureMode(ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY)
|
|
694
|
+
.build();
|
|
698
695
|
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
696
|
+
camera = cameraProvider.bindToLifecycle(
|
|
697
|
+
getActivity(),
|
|
698
|
+
cameraSelector,
|
|
699
|
+
preview,
|
|
700
|
+
imageCapture,
|
|
701
|
+
imageAnalysis
|
|
702
|
+
);
|
|
703
|
+
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
706
|
|
|
707
|
-
call.resolve();
|
|
708
707
|
|
|
709
|
-
}
|
|
710
708
|
|
|
711
709
|
private void processBarcode(ImageProxy imageProxy) {
|
|
712
710
|
|