From 54ff015a41ce07c32cac962d2eaeb02293c3077b Mon Sep 17 00:00:00 2001 From: "antoine.gonzalez" Date: Tue, 5 Dec 2023 18:34:47 +0100 Subject: [PATCH] Add camera ref #130 --- docs/api/camera.md | 81 +++++++++++++++++++++++++++++++++++ docs/api/scanner_activity.md | 6 ++- docs/api/scanner_callbacks.md | 10 +++++ docs/dependencies.md | 2 +- 4 files changed, 96 insertions(+), 3 deletions(-) diff --git a/docs/api/camera.md b/docs/api/camera.md index 87a0ebe6..a72d8aab 100644 --- a/docs/api/camera.md +++ b/docs/api/camera.md @@ -4,4 +4,85 @@ :class: attention This documentation is a work in progress. +::: + +**enioka Scan** can still be used to manage barcodes scanned using the Android camera. For that, it +exposes the `CameraBarcodeScanView` and a series of helper classes to handle compatibility with both +Camera 1 and Camera 2 hardware APIs. + +This page regroups all information needed to control this special scanner at a deeper level. + +## The `CameraBarcodeScanView` class + +This is the base Android `FrameLayout` used by the activity to display the camera. This view wraps +the API-specific `CameraBarcodeScanViewBase` implementation and handles the API selection based on +the device's properties. + +For most users, this is the class they will interact with if they need to interact with the Camera +hardware and not just the [`Scanner`](scanner) instance. + +:::{method} setReaderMode(CameraReader readerMode) -> void + +Change the library used to read barcodes from the camera feed. + +:param CameraReader readerMode: The library to use, between `CameraReader.ZBAR` and + `CameraReader.ZXing` +::: + +:::{method} addSymbology(BarcodeType barcodeType) -> void + +Add a symbology to detect. By default, only `CODE_128` is used. + +:param BarcodeType barcodeType: The symbology to add. +::: + +:::{method} setResultHandler(ResultHandler handler) -> void + +Change the callback used when a barcode is read. + +Used by `CameraBarcodeScanViewScanner` to register itself with the view and correctly propagate +barcodes read by the camera as any regular scanner reads. + +:param ResultHandler handler: the + [`ResultHandler`](scanner_callbacks.md#the-camerabarcodescanviewresulthandler-interface) + implementation +::: + +:::{method} setTorch(boolean value) -> void + +Switch the camera's torch on or off. + +:param boolean value: Indicate if the torch should be turned on (true) or off (false) +::: + +:::{method} getSupportTorch() -> boolean + +:returns: true if the camera supports torch activation. false otherwise. +::: + +:::{method} getTorchOn() -> boolean + +:returns: true if the camera's torch is on, false otherwise. +::: + +:::{method} cleanUp() -> void + +Unhooks all camera callbacks and closes it. After this method is called, the camera becomes unusable +and the view needs to be reinitialized. +::: + +:::{method} pauseCamera() -> void + +Pauses the camera's capture. +::: + +:::{method} resumeCamera() -> void + +Resumes the camera's capture. +::: + +:::{method} getLatestSuccessfulScanJpeg() -> byte[] + +:returns: The JPEG data of the image used in the latest successful scan, or null if there is no + previous scan data. ::: \ No newline at end of file diff --git a/docs/api/scanner_activity.md b/docs/api/scanner_activity.md index 02e882d2..7d78961e 100644 --- a/docs/api/scanner_activity.md +++ b/docs/api/scanner_activity.md @@ -62,8 +62,8 @@ The layout used by the activity when using the camera as a scanner. May be repla :::{cpp:var} int cameraViewId = R.id.camera_scan_view -The ID of the [`CameraBarcodeScanView`](camera.md#cameraBarcodeScanView) inside the `layoutIdCamera` -layout. +The ID of the [`CameraBarcodeScanView`](camera.md#the-camerabarcodescanview-class) inside the +`layoutIdCamera` layout. ::: :::{cpp:var} int cameraToggleId = R.id.scanner_bt_camera @@ -120,6 +120,8 @@ Initialized by the [`onStart()`](#onStart) and [`onResume()`](#onResume) methods :::{cpp:var} CameraBarcodeScanViewScanner cameraScanner; The instance of the camera scanner, can be used to access camera methods but should not be replaced. +`CameraBarcodeScanViewScanner` is a simple provider-less implementation of the [`Scanner`](scanner) +API. Initialized by the [`initCamera()`](#initCamera) method. ::: diff --git a/docs/api/scanner_callbacks.md b/docs/api/scanner_callbacks.md index 75a1b8f4..fe6a0fe2 100644 --- a/docs/api/scanner_callbacks.md +++ b/docs/api/scanner_callbacks.md @@ -201,4 +201,14 @@ Called if the provider can manage the device. :::{method} cannotManage() -> void Called if the provider can not manage the device. +::: + +## The `CameraBarcodeScanView.ResultHandler` interface + +Callback used by the camera reader when a barcode is read from the camera feed. + +:::{method} handleScanResult(String result, BarcodeType type) -> void + +:param String result: The barcode data +:param BarcodeType type: The barcode symbology ::: \ No newline at end of file diff --git a/docs/dependencies.md b/docs/dependencies.md index 3818fdda..23749b89 100644 --- a/docs/dependencies.md +++ b/docs/dependencies.md @@ -115,7 +115,7 @@ devices. | Artefact | Provider name | Supported devices | Tested devices | Device type | External requirements | Device compatible if | |-------------------------|----------------------------------|-----------------------------------------------------|------------------------------------|---------------|----------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------| -| `scanner` | Android camera (default) | Any device with a camera | Smartphones, integrated devices... | Camera | | Device has a camera | +| `scanner` | `CAMERA_SCANNER` (no provider) | Any device with a camera | Smartphones, integrated devices... | Camera | | Device has a camera | | `scanner` | `AthesiE5LProvider` | Athesi E5L | Athesi E5L | Integrated | | Device name is strictly `RD50TE` | | `scanner` | `AthesiHHTProvider` | Athesi SPA43 | Athesi SPA43 | Integrated | | Device name is strictly `SPA43LTE` | | `scanner` | `BluebirdProvider` | Bluebird integrated scanners | Bluebird EF500 | Integrated | Bluebird service (should be preinstalled on device) | Intent `kr.co.bluebird.android.bbapi.action.BARCODE_OPEN` has a listener |