@xbone-3/cordova-plugin-mlkit-barcodescanner 4.0.0

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,51 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file. The format is
4
+ based on [Keep a Changelog](https://keepachangelog.com/), and this project
5
+ adheres to [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [4.0.0] - 2026-06-13
8
+
9
+ ### Added
10
+
11
+ - `continuous` option — keep the camera open and stream every newly detected
12
+ barcode (deduplicated) until the user closes the scanner.
13
+ - `multiple` option — detect every barcode in a frame; the success callback then
14
+ receives an array of results.
15
+ - `drawDetectionBorder` option (Android) — draw a border around each detected
16
+ barcode in the preview, tracing its corner points (follows rotated and 2D
17
+ codes).
18
+ - `confirmation` option (Android) — freeze the preview on detection with the
19
+ decoded value and Confirm/Retry buttons; the result is returned only on
20
+ Confirm.
21
+ - TypeScript `types` entry so consumers resolve the bundled `.d.ts` declarations
22
+ on `import`.
23
+
24
+ ### Changed
25
+
26
+ - **Breaking:** `detectorSize` is now the fraction of the **screen** that is
27
+ scanned — a centred rectangle covering that percentage of both the width and
28
+ the height, where `1` scans the whole screen and draws no focus box.
29
+ Previously it was a fixed centred square of the smaller dimension that could
30
+ never cover the full screen.
31
+
32
+ ### Fixed
33
+
34
+ - Android: corrected the Cordova service name, which caused every scan to fail
35
+ immediately with a single-character `"C"` message (Cordova's
36
+ `"Class not found"` error).
37
+ - Android: scans after the first were cancelled before the camera opened, caused
38
+ by a duplicate `setActivityResultCallback` that aborted the in-flight scan.
39
+ Each scan now opens and reads correctly.
40
+ - Android: back-press / permission-denied is now reported as a cancellation
41
+ (`{ cancelled: true }`) instead of being silently swallowed, and no longer
42
+ risks a crash on a null result intent.
43
+ - Normalised the error callback so Cordova framework errors surface their full
44
+ message rather than just the first character.
45
+
46
+ ### Chore
47
+
48
+ - Made the `clean` build script cross-platform (`rimraf`) so the build runs on
49
+ Windows as well as POSIX shells.
50
+
51
+ [4.0.0]: https://github.com/XBone-3/cordova-plugin-mlkit-barcodescanner/releases/tag/v4.0.0
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Dealr, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,260 @@
1
+ # :camera: cordova-plugin-mlkit-barcode-scanner
2
+
3
+ ## Purpose of this Project
4
+
5
+ The purpose of this project is to provide a barcode scanner utilizing the Google ML Kit Vision library for the Cordova framework on iOS and Android.
6
+ The MLKit library is incredibly performant and fast in comparison to any other barcode reader that I have used that are free.
7
+
8
+ ## Plugin Dependencies
9
+
10
+ | Dependency | Version | Info |
11
+ | --------------------------------- | --------- | -------------------------- |
12
+ | `cordova-android` | `>=8.0.0` | |
13
+ | `cordova-ios` | `>=4.5.0` | |
14
+ | `cordova-plugin-androidx` | ` ^3.0.0` | If cordova-android < 9.0.0 |
15
+ | `cordova-plugin-androidx-adapter` | ` ^1.1.3` | |
16
+
17
+ ## Prerequisites
18
+
19
+ If your `cordova-android` version is below `9.0.0`, you have to install `cordova-plugin-androidx` first before installing this plugin.
20
+ Execute this command in your terminal:
21
+
22
+ ```bash
23
+ npx cordova plugin add cordova-plugin-androidx
24
+ ```
25
+
26
+ ## Installation
27
+
28
+ Run this command in your project root:
29
+
30
+ ```bash
31
+ npx cordova plugin add cordova-plugin-mlkit-barcode-scanner
32
+ ```
33
+
34
+ ## Supported Platforms
35
+
36
+ - Android
37
+ - iOS/iPadOS
38
+
39
+ ## Barcode Support
40
+
41
+ | 1d formats | Android | iOS |
42
+ | ------------ | ------- | --- |
43
+ | Codabar | ✓ | ✓ |
44
+ | Code 39 | ✓ | ✓ |
45
+ | Code 93 | ✓ | ✓ |
46
+ | Code 128 | ✓ | ✓ |
47
+ | EAN-8. | ✓ | ✓ |
48
+ | EAN-13 | ✓ | ✓ |
49
+ | ITF | ✓ | ✓ |
50
+ | MSI | ✗ | ✗ |
51
+ | RSS Expanded | ✗ | ✗ |
52
+ | RSS-14 | ✗ | ✗ |
53
+ | UPC-A | ✓ | ✓ |
54
+ | UPC-E | ✓ | ✓ |
55
+
56
+ | 2d formats | Android | iOS |
57
+ | ----------- | ------- | --- |
58
+ | Aztec | ✓ | ✓ |
59
+ | Codablock | ✗ | ✗ |
60
+ | Data Matrix | ✓ | ✓ |
61
+ | MaxiCode | ✗ | ✗ |
62
+ | PDF417 | ✓ | ✓ |
63
+ | QR Code | ✓ | ✓ |
64
+
65
+ :information_source: Note that this API does not recognize barcodes in these forms:
66
+
67
+ - 1D Barcodes with only one character
68
+ - Barcodes in ITF format with fewer than six characters
69
+ - Barcodes encoded with FNC2, FNC3 or FNC4
70
+ - QR codes generated in the ECI mode
71
+
72
+ ## Usage
73
+
74
+ To use the plugin simply call `cordova.plugins.mlkit.barcodeScanner.scan(options, sucessCallback, failureCallback)`. See the sample below.
75
+
76
+ ```javascript
77
+ cordova.plugins.mlkit.barcodeScanner.scan(
78
+ options,
79
+ (result) => {
80
+ // Do something with the data
81
+ alert(result);
82
+ },
83
+ (error) => {
84
+ // Error handling
85
+ },
86
+ );
87
+ ```
88
+
89
+ ### Plugin Options
90
+
91
+ The default options are shown below.
92
+ All values are optional.
93
+
94
+ `detectorSize` is the fraction of the **screen** that is scanned (a value in the
95
+ range `(0, 1]`). It is a centred rectangle covering that percentage of both the
96
+ width and the height, so only barcodes the user sees inside the focus box are
97
+ detected. A value of `1` scans the **whole screen** and draws no focus box.
98
+ Values outside `(0, 1]` fall back to the default. (Android.)
99
+
100
+ ```javascript
101
+ const defaultOptions = {
102
+ barcodeFormats: {
103
+ Code128: true,
104
+ Code39: true,
105
+ Code93: true,
106
+ CodaBar: true,
107
+ DataMatrix: true,
108
+ EAN13: true,
109
+ EAN8: true,
110
+ ITF: true,
111
+ QRCode: true,
112
+ UPCA: true,
113
+ UPCE: true,
114
+ PDF417: true,
115
+ Aztec: true,
116
+ },
117
+ beepOnSuccess: false,
118
+ vibrateOnSuccess: false,
119
+ detectorSize: 0.6,
120
+ rotateCamera: false,
121
+ continuous: false,
122
+ multiple: false,
123
+ drawDetectionBorder: false,
124
+ confirmation: false,
125
+ };
126
+ ```
127
+
128
+ #### `continuous`
129
+
130
+ When `true`, the camera stays open and every newly detected barcode is streamed
131
+ back to the success callback (which may therefore be called many times). Each
132
+ distinct barcode is reported only once. The scanner stays open until the user
133
+ presses back, at which point the error callback is invoked with
134
+ `{ cancelled: true }`. Default: `false` (the camera closes after the first
135
+ result).
136
+
137
+ #### `multiple`
138
+
139
+ When `true`, every barcode visible in a frame is detected and the success
140
+ callback receives an **array** of results instead of a single result. Can be
141
+ combined with `continuous`. Default: `false`.
142
+
143
+ #### `drawDetectionBorder`
144
+
145
+ When `true`, a border is drawn around each barcode in the camera preview as it
146
+ is detected, tracing the code's corner points (so it follows rotated and 2D
147
+ codes). Default: `false`. (Android only.)
148
+
149
+ #### `confirmation`
150
+
151
+ When `true`, a detected barcode is not returned immediately. The preview
152
+ freezes on the detected frame with the decoded value and **Confirm** / **Retry**
153
+ buttons; the result is returned only when the user taps Confirm. Combine with
154
+ `multiple` to confirm a whole frame of codes at once. Ignored in `continuous`
155
+ mode. Default: `false`. (Android only.)
156
+
157
+ ### Output/Return value
158
+
159
+ With the default options the success callback receives a single result:
160
+
161
+ ```javascript
162
+ result: {
163
+ text: string;
164
+ format: string;
165
+ type: string;
166
+ }
167
+ ```
168
+
169
+ When `multiple: true`, it instead receives an array of such results:
170
+
171
+ ```javascript
172
+ result: Array<{
173
+ text: string;
174
+ format: string;
175
+ type: string;
176
+ }>;
177
+ ```
178
+
179
+ ## Known Issues
180
+
181
+ On some devices the camera may be upside down.
182
+
183
+ Here is a list of devices with this problem:
184
+
185
+ - Zebra MC330K (Manufacturer: Zebra Technologies, Model: MC33)
186
+
187
+ Current Solution:
188
+ if your device has this problem, you can call the plugin with the option `rotateCamera` set to `true`.
189
+ This will rotate the camera stream by 180 degrees.
190
+
191
+ ## Development
192
+
193
+ ### Build Process
194
+
195
+ This project uses npm scripts for building:
196
+
197
+ ```shell
198
+ # lint the project using eslint
199
+ npm run lint
200
+
201
+ # removes the generated folders
202
+ npm run clean
203
+
204
+ # build the project
205
+ # (includes clean and lint)
206
+ npm run build
207
+
208
+ # publish the project
209
+ # (includes build)
210
+ npm publish
211
+ ```
212
+
213
+ A VS Code task for `build` is also included.
214
+
215
+ ## Run the test app
216
+
217
+ Install cordova:
218
+
219
+ ```
220
+ npm i -g cordova
221
+ ```
222
+
223
+ Go to test app:
224
+
225
+ ```
226
+ cd test/scan-test-app
227
+ ```
228
+
229
+ Install node modules:
230
+
231
+ ```
232
+ npm i
233
+ ```
234
+
235
+ Prepare Cordova:
236
+
237
+ ```
238
+ cordova prepare && cordova plugin add ../../ --link --force
239
+ ```
240
+
241
+ Build and run the project Android:
242
+
243
+ ```
244
+ cordova build android && cordova run android
245
+ ```
246
+
247
+ and iOS:
248
+
249
+ ```
250
+ cordova build ios && cordova run ios
251
+ ```
252
+
253
+ ### Versioning
254
+
255
+ ⚠️ Before incrementing the version in `package.json`, remember to increment the version in `plugin.xml` by hand.
256
+
257
+ ### VS Code Extensions
258
+
259
+ This project is intended to be used with Visual Studio Code and the recommended extensions can be found in [`.vscode/extensions.json`](.vscode/extensions.json).
260
+ When you open this repository for the first time in Visual Studio Code you should get a prompt asking you to install the recommended extensions.
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@xbone-3/cordova-plugin-mlkit-barcodescanner",
3
+ "version": "4.0.0",
4
+ "description": "Google MLKit Vision Barcode Scanner Plugin for Cordova",
5
+ "cordova": {
6
+ "id": "@xbone-3/cordova-plugin-mlkit-barcodescanner",
7
+ "platforms": [
8
+ "android",
9
+ "ios"
10
+ ]
11
+ },
12
+ "keywords": [
13
+ "ecosystem:cordova",
14
+ "cordova-ios",
15
+ "cordova-android"
16
+ ],
17
+ "author": "XBone-3",
18
+ "license": "MIT",
19
+ "main": "www/BarcodeScanner.contract.js",
20
+ "types": "www/BarcodeScanner.contract.d.ts",
21
+ "engines": {
22
+ "node": ">=10.0.0"
23
+ },
24
+ "scripts": {
25
+ "build": "npm run lint && npm run clean && npm run transpile",
26
+ "clean": "rimraf www",
27
+ "lint": "eslint . --ext .js,.ts --cache && tsc -p tsconfig.lint.json",
28
+ "test": "npm run test:android:build",
29
+ "test:android:deps": "cd test/scan-test-app && npm install",
30
+ "test:android:prepare": "cd test/scan-test-app && npx cordova prepare android && npx cordova plugin add ../../ --link --force",
31
+ "test:android:build": "cd test/scan-test-app && npx cordova build android",
32
+ "test:android:run": "cd test/scan-test-app && npx cordova run android",
33
+ "test:android": "npm run test:android:deps && npm run test:android:prepare && npm run test:android:build && npm run test:android:run",
34
+ "transpile": "rollup --config --silent",
35
+ "prepublishOnly": "npm run build"
36
+ },
37
+ "files": [
38
+ "/src/",
39
+ "/www/**/*.{js,js.map,d.ts}",
40
+ "/plugin.xml",
41
+ "/CHANGELOG.md"
42
+ ],
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/XBone-3/cordova-plugin-mlkit-barcodescanner.git"
46
+ },
47
+ "homepage": "https://github.com/XBone-3/cordova-plugin-mlkit-barcodescanner#readme",
48
+ "devDependencies": {
49
+ "@rollup/plugin-node-resolve": "13.0.4",
50
+ "@rollup/plugin-typescript": "8.3.0",
51
+ "@typescript-eslint/eslint-plugin": "5.62.0",
52
+ "@typescript-eslint/parser": "5.62.0",
53
+ "@types/cordova": "0.0.34",
54
+ "@types/node": "16.7.1",
55
+ "eslint": "7.32.0",
56
+ "rollup": "2.56.3",
57
+ "typescript": "4.4.4",
58
+ "tslib": "2.3.1"
59
+ },
60
+ "bugs": {
61
+ "url": "https://github.com/XBone-3/cordova-plugin-mlkit-barcodescanner/issues"
62
+ },
63
+ "directories": {
64
+ "test": "test"
65
+ },
66
+ "dependencies": {}
67
+ }
package/plugin.xml ADDED
@@ -0,0 +1,133 @@
1
+ <?xml version='1.0' encoding='utf-8'?>
2
+ <plugin id="@xbone-3/cordova-plugin-mlkit-barcodescanner"
3
+ version="4.0.0"
4
+ xmlns="http://apache.org/cordova/ns/plugins/1.0"
5
+ xmlns:android="http://schemas.android.com/apk/res/android">
6
+ <name>@xbone-3/cordova-plugin-mlkit-barcodescanner</name>
7
+ <js-module name="cordova-plugin-mlkit-barcodescanner"
8
+ src="www/BarcodeScanner.plugin.js">
9
+ <clobbers target="cordova.plugins.mlkit.barcodeScanner" />
10
+ </js-module>
11
+
12
+ <engines>
13
+ <engine name="cordova"
14
+ version=">=7.1.0" />
15
+ <engine name="cordova-android"
16
+ version=">=8.0.0" />
17
+ <engine name="cordova-ios"
18
+ version=">=4.5.0" />
19
+ </engines>
20
+ <platform name="ios">
21
+ <config-file parent="/*"
22
+ target="config.xml">
23
+ <feature name="cordova-plugin-mlkit-barcodescanner">
24
+ <param name="ios-package"
25
+ value="CDViOSScanner" />
26
+ </feature>
27
+ </config-file>
28
+ <config-file target="*-Info.plist"
29
+ parent="CFBundleDevelopmentRegion">
30
+ <string>de_DE</string>
31
+ </config-file>
32
+ <config-file target="*-Info.plist"
33
+ parent="CFBundleLocalizations">
34
+ <array>
35
+ <string>en</string>
36
+ <string>de</string>
37
+ </array>
38
+ </config-file>
39
+
40
+ <framework src="Foundation.framework" />
41
+ <framework src="AVFoundation.framework" />
42
+ <framework src="UIKit.framework" />
43
+ <podspec>
44
+ <config>
45
+ <source url="https://cdn.cocoapods.org/" />
46
+ </config>
47
+ <pods use-frameworks="true">
48
+ <pod name="GoogleMLKit/BarcodeScanning"
49
+ spec="~> 2.5.0" />
50
+ </pods>
51
+ </podspec>
52
+ <header-file src="src/ios/CDViOSScanner.h" />
53
+ <source-file src="src/ios/CDViOSScanner.m" />
54
+ <header-file src="src/ios/CameraViewController.h" />
55
+ <source-file src="src/ios/CameraViewController.m" />
56
+ <resource-file src="src/ios/Sounds/beep.caf" />
57
+ <resource-file src="src/ios/de.lproj/Localizable.strings"
58
+ target="de.lproj/Localizable.strings" />
59
+ <resource-file src="src/ios/en.lproj/Localizable.strings"
60
+ target="en.lproj/Localizable.strings" />
61
+ </platform>
62
+ <platform name="android">
63
+ <dependency id="cordova-plugin-androidx-adapter"
64
+ version="^1.1.3" />
65
+
66
+ <config-file parent="/*"
67
+ target="res/xml/config.xml">
68
+ <feature name="cordova-plugin-mlkit-barcodescanner">
69
+ <param name="android-package"
70
+ value="com.mobisys.cordova.plugins.mlkit.barcode.scanner.MLKitBarcodeScanner" />
71
+ </feature>
72
+ </config-file>
73
+
74
+ <config-file parent="/*"
75
+ target="AndroidManifest.xml">
76
+ <uses-permission android:name="android.permission.CAMERA" />
77
+ <uses-permission android:name="android.permission.VIBRATE" />
78
+ <uses-feature android:name="android.hardware.camera"
79
+ android:required="false" />
80
+ </config-file>
81
+
82
+ <config-file parent="application"
83
+ target="AndroidManifest.xml">
84
+ <meta-data android:name="com.google.android.gms.version"
85
+ android:value="@integer/google_play_services_version" />
86
+ <meta-data android:name="com.google.android.gms.vision.DEPENDENCIES"
87
+ android:value="barcode" />
88
+ <activity android:label="Read Barcode"
89
+ android:name="com.mobisys.cordova.plugins.mlkit.barcode.scanner.CaptureActivity"
90
+ android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
91
+ </config-file>
92
+
93
+ <source-file src="src/android/src/CaptureActivity.java"
94
+ target-dir="src/com/mobisys/cordova/plugins/mlkit/barcode/scanner" />
95
+ <source-file src="src/android/src/MLKitBarcodeScanner.java"
96
+ target-dir="src/com/mobisys/cordova/plugins/mlkit/barcode/scanner" />
97
+ <source-file src="src/android/src/utils/BitmapUtils.java"
98
+ target-dir="src/com/mobisys/cordova/plugins/mlkit/barcode/scanner/utils" />
99
+ <source-file src="src/android/src/utils/FrameMetadata.java"
100
+ target-dir="src/com/mobisys/cordova/plugins/mlkit/barcode/scanner/utils" />
101
+
102
+ <resource-file src="src/android/res/assets/beep.ogg"
103
+ target="assets/beep.ogg" />
104
+ <resource-file src="src/android/res/values/strings-en.xml"
105
+ target="res/values/strings.xml" />
106
+ <resource-file src="src/android/res/values/strings-de.xml"
107
+ target="res/values-de/strings.xml" />
108
+ <resource-file src="src/android/res/layout/capture_activity.xml"
109
+ target="res/layout/capture_activity.xml" />
110
+ <resource-file src="src/android/res/drawable/flashlight.png"
111
+ target="res/drawable/flashlight.png" />
112
+ <resource-file src="src/android/res/drawable/torch_active.xml"
113
+ target="res/drawable/torch_active.xml" />
114
+ <resource-file src="src/android/res/drawable/torch_inactive.xml"
115
+ target="res/drawable/torch_inactive.xml" />
116
+
117
+ <framework src="com.android.support:support-v4:27.1.0" />
118
+ <framework src="com.android.support:design:27.1.0" />
119
+
120
+ <framework src="com.google.android.gms:play-services-vision:17.0.2" />
121
+ <framework src="com.google.mlkit:barcode-scanning:16.2.0" />
122
+
123
+ <framework src="androidx.camera:camera-core:1.0.0-beta05" />
124
+ <framework src="androidx.camera:camera-camera2:1.0.0-beta05" />
125
+ <framework src="androidx.camera:camera-lifecycle:1.0.0-beta05" />
126
+ <framework src="androidx.camera:camera-view:1.0.0-alpha12" />
127
+ <framework src="androidx.constraintlayout:constraintlayout:2.0.4" />
128
+
129
+ <framework src="src/android/build-extras.gradle"
130
+ custom="true"
131
+ type="gradleReference" />
132
+ </platform>
133
+ </plugin>
@@ -0,0 +1,14 @@
1
+ ext.postBuildExtras = {
2
+ android {
3
+ compileOptions {
4
+ sourceCompatibility JavaVersion.VERSION_1_8
5
+ targetCompatibility JavaVersion.VERSION_1_8
6
+ }
7
+ allprojects {
8
+ compileOptions {
9
+ sourceCompatibility = JavaVersion.VERSION_1_8
10
+ targetCompatibility = JavaVersion.VERSION_1_8
11
+ }
12
+ }
13
+ }
14
+ }
Binary file
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+
3
+ <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
4
+ <item>
5
+ <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
6
+ <solid android:color="#FFFFFF" />
7
+ </shape>
8
+ </item>
9
+ <item android:drawable="@drawable/flashlight" android:bottom="10dp" android:top="10dp" android:left="10dp" android:right="10dp" >
10
+
11
+ </item>
12
+ </layer-list>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+
3
+ <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
4
+ <item>
5
+ <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
6
+ <solid android:color="#40FFFFFF" />
7
+ </shape>
8
+ </item>
9
+ <item android:drawable="@drawable/flashlight" android:bottom="10dp" android:top="10dp" android:left="10dp" android:right="10dp" >
10
+
11
+ </item>
12
+ </layer-list>
@@ -0,0 +1,97 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+ xmlns:app="http://schemas.android.com/apk/res-auto"
4
+ xmlns:tools="http://schemas.android.com/tools"
5
+ android:id="@+id/topLayout"
6
+ android:layout_width="match_parent"
7
+ android:layout_height="match_parent">
8
+
9
+ <SurfaceView
10
+ android:id="@+id/overlay"
11
+ android:layout_width="0dp"
12
+ android:layout_height="0dp"
13
+ app:layout_constraintBottom_toBottomOf="parent"
14
+ app:layout_constraintEnd_toEndOf="parent"
15
+ app:layout_constraintStart_toStartOf="parent"
16
+ app:layout_constraintTop_toTopOf="parent" />
17
+
18
+ <androidx.camera.view.PreviewView
19
+ android:id="@+id/previewView"
20
+ android:layout_width="0dp"
21
+ android:layout_height="0dp"
22
+ app:layout_constraintBottom_toBottomOf="parent"
23
+ app:layout_constraintEnd_toEndOf="parent"
24
+ app:layout_constraintHorizontal_bias="0.0"
25
+ app:layout_constraintStart_toStartOf="parent"
26
+ app:layout_constraintTop_toTopOf="@+id/overlay"
27
+ app:layout_constraintVertical_bias="0.0">
28
+
29
+ </androidx.camera.view.PreviewView>
30
+
31
+ <!-- Frozen camera frame shown while awaiting scan confirmation. -->
32
+ <ImageView
33
+ android:id="@+id/freeze_frame"
34
+ android:layout_width="0dp"
35
+ android:layout_height="0dp"
36
+ android:visibility="gone"
37
+ android:scaleType="fitCenter"
38
+ app:layout_constraintBottom_toBottomOf="parent"
39
+ app:layout_constraintEnd_toEndOf="parent"
40
+ app:layout_constraintStart_toStartOf="parent"
41
+ app:layout_constraintTop_toTopOf="parent" />
42
+
43
+ <ImageButton
44
+ android:id="@+id/torch_button"
45
+ android:layout_width="50dp"
46
+ android:layout_height="50dp"
47
+ app:layout_constraintBottom_toBottomOf="parent"
48
+ app:layout_constraintEnd_toEndOf="parent"
49
+ android:layout_margin="20dp"
50
+ android:background="@drawable/torch_inactive"
51
+ />
52
+
53
+ <!-- Confirmation prompt shown on detection when `confirmation` is enabled. -->
54
+ <LinearLayout
55
+ android:id="@+id/confirm_panel"
56
+ android:layout_width="0dp"
57
+ android:layout_height="wrap_content"
58
+ android:orientation="vertical"
59
+ android:padding="16dp"
60
+ android:background="#CC000000"
61
+ android:visibility="gone"
62
+ app:layout_constraintBottom_toBottomOf="parent"
63
+ app:layout_constraintEnd_toEndOf="parent"
64
+ app:layout_constraintStart_toStartOf="parent">
65
+
66
+ <TextView
67
+ android:id="@+id/confirm_text"
68
+ android:layout_width="match_parent"
69
+ android:layout_height="wrap_content"
70
+ android:textColor="#FFFFFF"
71
+ android:textSize="16sp"
72
+ android:maxLines="3"
73
+ android:ellipsize="end"
74
+ android:paddingBottom="12dp" />
75
+
76
+ <LinearLayout
77
+ android:layout_width="match_parent"
78
+ android:layout_height="wrap_content"
79
+ android:orientation="horizontal"
80
+ android:gravity="end">
81
+
82
+ <Button
83
+ android:id="@+id/retry_button"
84
+ android:layout_width="wrap_content"
85
+ android:layout_height="wrap_content"
86
+ android:layout_marginEnd="12dp" />
87
+
88
+ <Button
89
+ android:id="@+id/confirm_button"
90
+ android:layout_width="wrap_content"
91
+ android:layout_height="wrap_content" />
92
+
93
+ </LinearLayout>
94
+
95
+ </LinearLayout>
96
+
97
+ </androidx.constraintlayout.widget.ConstraintLayout>