Skip to content

Commit

Permalink
ReadTheDocs documentation #130 (#146)
Browse files Browse the repository at this point in the history
* Add quickstart #130

* Add dependencies doc #130

* Add development doc #130

* Add scanner api ref #130

* Add scannerProvider api ref #130

* Fix scanner search options inconsistencies

* Add scanner service api ref #130

* Add scanner callbacks ref #130

* Add scanner activity ref #130

* Fix ScannerCompatActivity inconsistencies

* Add camera ref #130

* Fix CameraBarcodeScanView inconsistencies

* Add camera layout ref #130

* Add BarcodeType ref #130

* Add lazerscanner ref #130

* Cleanup for first merge #130
  • Loading branch information
DaSpood authored Mar 29, 2024
1 parent 98355be commit a101e26
Show file tree
Hide file tree
Showing 23 changed files with 1,896 additions and 266 deletions.
254 changes: 29 additions & 225 deletions README.md

Large diffs are not rendered by default.

167 changes: 167 additions & 0 deletions docs/api/camera.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# The camera scanner

**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` instance](scanner.md#the-scanner-interface).

:::{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` implementation](scanner_callbacks.md#the-camerabarcodescanviewresulthandler-interface)
:::

:::{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.
:::

## Use `CameraBarcodeScanView` in your custom layout

To use this view in your own layout, you can add the following block to its XML definition and adapt
the attributes to your needs:

```xml
<com.enioka.scanner.camera.CameraBarcodeScanView
android:id="@+id/camera_scan_view"
android:layout_width="0dp"
android:layout_height="0dp"
app:forceCameraApiVersion="Auto"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:maxDistortionRatio="0.3"
app:minResolutionY="720"
app:maxResolutionY="1080"
app:previewRatioMode="fillAvailableSpace"
app:readerMode="Auto"
app:storePreferredResolution="false"
app:targetColorActive="@color/colorRed"
app:targetColorPaused="@color/defaultItemColor"
app:targetIsFixed="false"
app:targetStrokeWidth="5"
app:useAdaptiveResolution="true"
/>
```

The main XML attributes are as follow:

:::{method} app:forceCameraApiVersion

"1" for the old camera API, "2" for the Camera2 API, any other value to let the library detect the
appropriate camera API for this device.
:::

:::{method} app:useAdaptiveResolution

If true, the resolution of the camera preview may be decreased if performances are deemed too low
by the frame analyzer.
:::

:::{method} app:minResolutionY

The minimum vertical resolution of the camera preview, after which resolution can no longer be
decreased by adaptive resolution when trying to improve performance.
:::

:::{method} app:maxResolutionY

The maximum vertical resolution of the camera preview, useful to limit performance costs.
:::

:::{method} app:readerMode

"1" for ZXING, any other value for ZBAR.
:::

:::{method} app:storePreferredResolution

If true, the app will persists the most used preview resolution to the application's preference.
:::

:::{method} app:targetColorActive

The default color of the "target" indicating where barcodes are expected to be.
:::

:::{method} app:targetColorPaused

The color of the "target" indicating where barcodes are expected to be, used whenever the scanning
is paused.
:::

:::{method} app:targetIsFixed

If true, the target cannot be moved by the user. If false, the user can drag the target up and down
on the preview.
:::

:::{method} app:targetStrokeWidth

The thickness of the target's lines.
:::
32 changes: 32 additions & 0 deletions docs/api/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# API reference

% Notes:

% Due to the limitations of Sphinx and MyST, documentation formatting was 'hacked' a bit by using
% python and cpp directives as Java is not natively supported and has no proper third-party option.

% API guides for the BluetoothScanner API may be helpful for provider developers but is not a
% priority. A full bluetooth guide may be needed, as well as a detailed overview of the library's
% workflow from service startup to scanner availability.

This section contains more in-depth info about important classes and interfaces of **enioka Scan**.

:::{toctree}
:caption: For most users
:maxdepth: 2

scanner
scanner_service
scanner_callbacks
scanner_activity
camera
others
:::

:::{toctree}
:caption: For advanced users and enioka Scan developpers
:maxdepth: 2

lazerscanner
scanner_provider
:::
40 changes: 40 additions & 0 deletions docs/api/lazerscanner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# The LazerScanner class

`LazerScanner` is the main scanner factory and the core of the library. It is in charge of finding
scanner providers and scanner devices. Most users will let the
[`ScannerService`](scanner_service.md#the-scannerserviceapi-interface)
handle its own instance of `LazerScanner`, but should you need it, you can use its static methods
directly.

:::{method} discoverProviders(Context ctx, ProviderDiscoveredCallback cb) -> void

Discovers scanner providers through service intent and retrieves them through reflection.
The providers are cached and do not need to be discovered again unless new entries are expected, it
is a costly operation.

:param Context ctx: a context used to retrieve a `PackageManager`
:param ProviderDiscoveredCallback cb: The callback used whenever a provider is found.
Automatically wrapped by a `ProviderDiscoveredCallbackProxy`, for which a public overload exists
:::

:::{method} getProviderCache() -> List<String>

:returns: the list of provider keys from the current provider cache, including bluetooth ones if
available (the cache needs to have been initialized first).
:::

:::{method} getLaserScanner(Context ctx, ScannerConnectionHandler handler, ScannerSearchOptions options) -> void

Search for new laser scanners with available providers. The scanner is provided through a callback.
There is a specific callback when no scanner is available.

:param Context ctx: a context used to retrieve a `PackageManager`
:param ScannerConnectionHandler handler: The callback used whenever a scanner is found.
Automatically wrapped by a `ScannerConnectionHandlerProxy`, for which a public overload exists.
:param ScannerSearchOptions options: The options used to refine the search.
:::

:::{seealso}

* The [Callbacks](scanner_callbacks.md) documentation
:::
24 changes: 24 additions & 0 deletions docs/api/others.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Other useful classes

The library contains a lot of other smaller classes you may need to interact with. This page will
regroup most of them.

## The `BarcodeType` enum

This enum contains every barcode symbology officially supported by **enioka Scan**. Whenever a
scanner reads data, it will try to match its symbology with one of these. This list is not final and
will likely be extended in the future to include other symbologies. This is also the enum to use
when configuring a scanner.

:::{cpp:enum} BarcodeType

:CODE128: The Code 128 symbology
:CODE39: The Code 39 symbology
:DIS25: The Discrete-2-of-5 symbology
:INT25: The Interleaved-2-Of-5 symbology
:EAN13: The EAN 13 symbology
:QRCODE: The regular QR Code symbology
:AZTEC: The Aztec 2D symbology
:UNKNOWN: Any other symbology not currently part of the enum. When used during symbology
configuration, means the scanner should allow all symbologies.
:::
Loading

0 comments on commit a101e26

Please sign in to comment.