Skip to content

Commit

Permalink
Fix documentation mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
DaSpood committed Jul 30, 2024
1 parent b8788c8 commit 19e13cf
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 63 deletions.
84 changes: 46 additions & 38 deletions docs/api/camera.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,33 @@ view refresh. You can force a refresh by pausing and resuming the camera.

:param AspectRatioMode mode: The mode to use for filling the camera preview. Can be one of the
following values:
- `0`: `fillWithCrop`: The preview will be scaled to fit the picture, cropping the sides if
needed. The aspect ratio of the preview will be kept.
- `1`: `fillWithBlackBars`: The preview will be scaled to fit the picture, with black bars on
the sides if needed. The aspect ratio of the preview will be kept.
- `2`: `fillWithStretch`: The preview will fill the available space, by squashing or stretching
the preview if needed. The aspect ratio of the preview can be altered.

.. image:: /pictures/crop.png
:width: 400
:alt: fillWithCrop
- `0`: `fillWithCrop`: The preview will be scaled to fit the picture, cropping the sides if
needed. The aspect ratio of the preview will be kept.
- `1`: `fillWithBlackBars`: The preview will be scaled to fit the picture, with black bars on
the sides if needed. The aspect ratio of the preview will be kept.
- `2`: `fillWithStretch`: The preview will fill the available space, by squashing or stretching
the preview if needed. The aspect ratio of the preview can be altered.
:::

Example of a preview with the `fillWithCrop` mode.
Example of a preview with the `fillWithCrop` mode:

.. image:: /pictures/black_bars.png
:::{image} /pictures/crop.png
:width: 400
:alt: fillWithBlackBars
:alt: Example of a preview with the `fillWithCrop` mode.
:::

Example of a preview with the `fillWithBlackBars` mode.
Example of a preview with the `fillWithBlackBars` mode:

.. image:: /pictures/stretch.png
:::{image} /pictures/black_bars.png
:width: 400
:alt: fillWithStretch
:alt: Example of a preview with the `fillWithBlackBars` mode.
:::

Example of a preview with the `fillWithStretch` mode.
Example of a preview with the `fillWithStretch` mode:

:::{image} /pictures/stretch.png
:width: 400
:alt: Example of a preview with the `fillWithStretch` mode.
:::

:::{method} setReaderMode(CameraReader readerMode) -> void
Expand Down Expand Up @@ -143,8 +145,8 @@ To use this view in your own layout, you can add the following block to its XML
the attributes to your needs:

```xml
<com.enioka.scanner.camera.CameraBarcodeScanView
android:id="@+id/camera_scan_view"
<com.enioka.scanner.sdk.camera.CameraBarcodeScanView
android:id="@+id/cameraScanView"
android:layout_width="0dp"
android:layout_height="0dp"
app:forceCameraApiVersion="Auto"
Expand All @@ -162,8 +164,7 @@ the attributes to your needs:
app:targetColorPaused="@color/defaultItemColor"
app:targetIsFixed="false"
app:targetStrokeWidth="5"
app:useAdaptiveResolution="true"
/>
app:useAdaptiveResolution="true" />
```

The main XML attributes are as follow:
Expand Down Expand Up @@ -194,12 +195,12 @@ The maximum vertical resolution of the camera preview, useful to limit performan
:::{method} app:previewRatioMode

The mode to use for filling the camera preview. Can be one of the following values:
- `0`: `fillWithCrop`: The preview will be scaled to fit the picture, cropping the sides if
needed. The aspect ratio of the preview will be kept.
- `1`: `fillWithBlackBars`: The preview will be scaled to fit the picture, with black bars on
the sides if needed. The aspect ratio of the preview will be kept.
- `2`: `fillWithStretch`: The preview will fill the available space, by squashing or stretching
the preview if needed. The aspect ratio of the preview can be altered.
- `0`: `fillWithCrop`: The preview will be scaled to fit the picture, cropping the sides if
needed. The aspect ratio of the preview will be kept.
- `1`: `fillWithBlackBars`: The preview will be scaled to fit the picture, with black bars on
the sides if needed. The aspect ratio of the preview will be kept.
- `2`: `fillWithStretch`: The preview will fill the available space, by squashing or stretching
the preview if needed. The aspect ratio of the preview can be altered.

If the value of this attribute is not recognized or defined, the preview ratio mode will be set
by default to `fillWithCrop`.
Expand Down Expand Up @@ -263,17 +264,24 @@ The mode to use for filling the camera preview. Can be one of the following valu
:returns: A map containing the IDs of the views used by the camera scanner. May be replaced with
your own.

Contains the following keys:
- layout_id_camera: The ID of the layout containing the camera view.
- camera_view_id: The ID of the camera view in the layout.
- scanner_toggle_view_id: The ID of the view that toggles the scanner library reader.
- scanner_toggle_pause_id: The ID of the view that toggles the pause of the scanner.
- card_last_scan_id: ID of the card view that displays the last scan.
- constraint_layout_id: The ID of the constraint layout inside the camera layout.
- scanner_flashlight_id: The ID of the optional ImageButton on which to press to toggle the
flashlight/illumination.
- scanner_bt_provider_logs: The ID of the optional ImageButton on which to press to manually access
available providers logs
It contains the following values:
- `layout_id_camera`: The ID of the layout containing the camera view.
Set to `R.layout.activity_main_alt`.
- `camera_view_id`: The ID of the
[`CameraBarcodeScanView`](camera.md#the-camerabarcodescanview-class) inside the `layout_id_camera`
layout. Set to `R.id.cameraScanView`.
- `scanner_toggle_view_id`: The ID of the optional ImageButton on which to press to toggle the
zxing/zbar camera scan library. Set to `R.id.scannerSwitchZxing`.
- `scanner_toggle_pause_id`: The ID of the optional toggle button on which to press to pause/unpause
the scanner. Set to `R.id.scannerSwitchPause`.
- `card_last_scan_id`: The ID of the card view that displays the last scan.
Set to `R.id.cardCameraLastScan`.
- `constraint_layout_id`: The ID of the constraint layout inside the camera layout.
Set to `R.id.constraintLayoutMainActivity`.
- `scanner_flashlight_id`: The ID of the optional ImageButton on which to press to toggle the
flashlight/illumination. Set to `R.id.scannerFlashlight`.
- `scanner_bt_provider_logs`: The ID of the optional ImageButton on which to press to manually access
available providers logs. Set to `R.id.scannerBtProviderLogs`.
:::

:::{method} getCameraScanner(Context ctx, ScannerConnectionHandler handler, ScannerSearchOptions options) -> void
Expand Down
35 changes: 17 additions & 18 deletions docs/api/scanner_activity.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,23 @@ The hashmap containing the IDs of the views used by the camera scanner. May be r
own.

If the camera SDK is included, it will be set to a map containing the following values:
- layout_id_camera: The ID of the layout containing the camera view
:::{cpp:var}R.layout.activity_main_alt:::.
- camera_view_id: The ID of the camera view in the layout :::{cpp:var}R.id.cameraScanView:::.
It is the ID of the [`CameraBarcodeScanView`](camera.md#the-camerabarcodescanview-class) inside the
`layout_id_camera` layout.
:::.
- scanner_toggle_view_id: It is the ID of the optional ImageButton on which to press to toggle the
zxing/zbar camera scan library :::{cpp:var}R.id.scannerSwitchZxing:::.
- scanner_toggle_pause_id: The ID of the optional toggle button on which to press to pause/unpause
the scanner :::{cpp:var}R.id.scannerSwitchPause:::.
- card_last_scan_id: ID of the card view that displays the last scan
:::{cpp:var}R.id.cardCameraLastScan:::.
- constraint_layout_id: The ID of the constraint layout inside the camera layout
:::{cpp:var}R.id.constraintLayoutMainActivity:::.
- scanner_flashlight_id: The ID of the optional ImageButton on which to press to toggle the
flashlight/illumination :::{cpp:var}R.id.scannerFlashlight:::.
- scanner_bt_provider_logs: The ID of the optional ImageButton on which to press to manually access
available providers logs :::{cpp:var}R.id.scannerBtProviderLogs:::.
- `layout_id_camera`: The ID of the layout containing the camera view.
Defaults to `R.layout.activity_main_alt`.
- `camera_view_id`: The ID of the
[`CameraBarcodeScanView`](camera.md#the-camerabarcodescanview-class) inside the `layout_id_camera`
layout. Defaults to `R.id.cameraScanView`.
- `scanner_toggle_view_id`: The ID of the optional ImageButton on which to press to toggle the
zxing/zbar camera scan library. Defaults to `R.id.scannerSwitchZxing`.
- `scanner_toggle_pause_id`: The ID of the optional toggle button on which to press to pause/unpause
the scanner. Defaults to `R.id.scannerSwitchPause`.
- `card_last_scan_id`: The ID of the card view that displays the last scan.
Defaults to `R.id.cardCameraLastScan`.
- `constraint_layout_id`: The ID of the constraint layout inside the camera layout.
Defaults to `R.id.constraintLayoutMainActivity`.
- `scanner_flashlight_id`: The ID of the optional ImageButton on which to press to toggle the
flashlight/illumination. Defaults to `R.id.scannerFlashlight`.
- `scanner_bt_provider_logs`: The ID of the optional ImageButton on which to press to manually access
available providers logs. Defaults to `R.id.scannerBtProviderLogs`.
:::

:::{cpp:var} int cameraToggleId = R.id.scannerBtCamera
Expand Down
17 changes: 12 additions & 5 deletions docs/guides/custom_layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,26 @@ To ensure activity is able to properly switch to the camera when needed, you sho
following view block in the `<layout>.xml` file used by `layoutIdCamera`:

```xml
<com.enioka.scanner.camera.CameraBarcodeScanView
android:id="@+id/camera_scan_view"
<com.enioka.scanner.sdk.camera.CameraBarcodeScanView
android:id="@+id/cameraScanView"
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:previewRatioMode="fillWithCrop"
app:readerMode="Auto"
app:storePreferredResolution="false"
app:targetColor="@color/colorRed"
app:targetColorActive="@color/colorRed"
app:targetColorPaused="@color/defaultItemColor"
app:targetIsFixed="false"
app:targetStrokeWidth="5"
app:useAdaptiveResolution="true" />
app:useAdaptiveResolution="true" />
```

Should you choose a different ID for this view, remember to also change the value of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public HashMap<String, Integer> getIdResources() {
idResources.put("scanner_toggle_view_id", R.id.scannerSwitchZxing);
idResources.put("scanner_toggle_pause_id", R.id.scannerSwitchPause);
idResources.put("card_last_scan_id", R.id.cardCameraLastScan);
idResources.put("constraint_layout_id", R.id.constraint_layout_main_activity);
idResources.put("constraint_layout_id", R.id.constraintLayoutMainActivity);
idResources.put("scanner_flashlight_id", R.id.scannerFlashlight);
idResources.put("scanner_bt_provider_logs", R.id.scannerBtProviderLogs);

Expand Down
2 changes: 1 addition & 1 deletion enioka_scan_camera/src/main/res/layout/activity_camera.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/constraint_layout_main_activity"
android:id="@+id/constraintLayoutMainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.enioka.scanner.activities.ScannerCompatActivity">
Expand Down

0 comments on commit 19e13cf

Please sign in to comment.