diff --git a/enioka_scan/src/main/java/com/enioka/scanner/activities/ScannerCompatActivity.java b/enioka_scan/src/main/java/com/enioka/scanner/activities/ScannerCompatActivity.java index d3972585..0709f7a8 100644 --- a/enioka_scan/src/main/java/com/enioka/scanner/activities/ScannerCompatActivity.java +++ b/enioka_scan/src/main/java/com/enioka/scanner/activities/ScannerCompatActivity.java @@ -35,6 +35,7 @@ import com.enioka.scanner.camera.CameraBarcodeScanView; import com.enioka.scanner.camera.CameraReader; import com.enioka.scanner.data.Barcode; +import com.enioka.scanner.data.BarcodeType; import com.enioka.scanner.helpers.Common; import com.enioka.scanner.sdk.camera.CameraBarcodeScanViewScanner; import com.enioka.scanner.service.ScannerClient; @@ -43,7 +44,10 @@ import com.enioka.scanner.service.ScannerServiceBinderHelper; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Objects; +import java.util.Set; /** * A helper activity which implements all scan functions: laser, camera, HID.

Basic usage is trivial : just inherit this class, and that's all.
@@ -370,7 +374,16 @@ private void initCameraScanner() { return; } - cameraScanner = new CameraBarcodeScanViewScanner(cameraView, new ScannerDataCallbackProxy((s, data) -> ScannerCompatActivity.this.onData(data)), new ScannerStatusCallbackProxy(this)); + final Set symbologies = new HashSet<>(); + if (getIntent().getExtras() != null && getIntent().getExtras().getStringArray(ScannerServiceApi.EXTRA_SYMBOLOGY_SELECTION) != null) { + for (final String symbology : Objects.requireNonNull(getIntent().getExtras().getStringArray(ScannerServiceApi.EXTRA_SYMBOLOGY_SELECTION))) { + symbologies.add(BarcodeType.valueOf(symbology)); + } + } + if (symbologies.isEmpty()) { + symbologies.add(BarcodeType.CODE128); + } + cameraScanner = new CameraBarcodeScanViewScanner(cameraView, new ScannerDataCallbackProxy((s, data) -> ScannerCompatActivity.this.onData(data)), new ScannerStatusCallbackProxy(this), symbologies); if (findViewById(R.id.scanner_text_last_scan) != null) { ((TextView) findViewById(R.id.scanner_text_last_scan)).setText(null); diff --git a/enioka_scan/src/main/java/com/enioka/scanner/sdk/camera/CameraBarcodeScanViewScanner.java b/enioka_scan/src/main/java/com/enioka/scanner/sdk/camera/CameraBarcodeScanViewScanner.java index 079a986d..b8f09aee 100644 --- a/enioka_scan/src/main/java/com/enioka/scanner/sdk/camera/CameraBarcodeScanViewScanner.java +++ b/enioka_scan/src/main/java/com/enioka/scanner/sdk/camera/CameraBarcodeScanViewScanner.java @@ -29,13 +29,15 @@ public class CameraBarcodeScanViewScanner implements Scanner, Scanner.WithBeepSu private ScannerDataCallbackProxy dataDb; private final ScannerStatusCallback statusCallback; - public CameraBarcodeScanViewScanner(CameraBarcodeScanView cameraBarcodeScanView, ScannerDataCallbackProxy mHandler, final ScannerStatusCallbackProxy statusCallback) { + public CameraBarcodeScanViewScanner(CameraBarcodeScanView cameraBarcodeScanView, ScannerDataCallbackProxy mHandler, final ScannerStatusCallbackProxy statusCallback, final Set symbologySelection) { this.dataDb = mHandler; - this.scanner = cameraBarcodeScanView; scanner.setResultHandler(this); scanner.setTorch(false); + for(BarcodeType symbology: symbologySelection) { + scanner.addSymbology(symbology); + } this.statusCallback = statusCallback; this.statusCallback.onStatusChanged(this, ScannerStatusCallback.Status.CONNECTED); @@ -60,9 +62,6 @@ public void handleScanResult(String code, BarcodeType barcodeType) { @Override public void initialize(final Context applicationContext, final ScannerInitCallbackProxy initCallback, final ScannerDataCallbackProxy dataCallback, final ScannerStatusCallbackProxy statusCallback, final Mode mode, final Set symbologySelection) { // Do nothing. The camera view implementation is special, as it is built directly and not through the LaserScanner. - for (BarcodeType symbology : symbologySelection) { - scanner.addSymbology(symbology); - } initCallback.onConnectionSuccessful(this); }