@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.
@@ -0,0 +1,221 @@
1
+ package com.mobisys.cordova.plugins.mlkit.barcode.scanner;
2
+
3
+ import android.app.Activity;
4
+ import android.app.AlertDialog;
5
+ import android.content.Context;
6
+ import android.content.DialogInterface;
7
+ import android.content.Intent;
8
+ import android.content.pm.PackageManager;
9
+ import android.content.res.AssetFileDescriptor;
10
+ import android.hardware.camera2.CameraManager;
11
+ import android.media.MediaPlayer;
12
+ import android.os.Build;
13
+ import android.os.Bundle;
14
+ import android.os.VibrationEffect;
15
+ import android.os.Vibrator;
16
+ import android.util.Log;
17
+
18
+ import com.google.android.gms.common.api.CommonStatusCodes;
19
+
20
+ import org.apache.cordova.CallbackContext;
21
+ import org.apache.cordova.CordovaInterface;
22
+ import org.apache.cordova.CordovaPlugin;
23
+ import org.apache.cordova.CordovaWebView;
24
+ import org.apache.cordova.PluginResult;
25
+ import org.json.JSONArray;
26
+ import org.json.JSONException;
27
+ import org.json.JSONObject;
28
+
29
+ import java.io.IOException;
30
+
31
+ /**
32
+ * This class echoes a string called from JavaScript.
33
+ */
34
+ public class MLKitBarcodeScanner extends CordovaPlugin {
35
+
36
+ private static final String TAG = "MLKitBarcodeScanner";
37
+ private static final int RC_BARCODE_CAPTURE = 9001;
38
+
39
+ // Active plugin instance, used by CaptureActivity to stream results back
40
+ // while the camera stays open in continuous mode.
41
+ private static MLKitBarcodeScanner _Instance;
42
+
43
+ private CallbackContext _CallbackContext;
44
+ private Boolean _BeepOnSuccess;
45
+ private Boolean _VibrateOnSuccess;
46
+ private MediaPlayer _MediaPlayer;
47
+ private Vibrator _Vibrator;
48
+
49
+ public void initialize(CordovaInterface cordova, CordovaWebView webView) {
50
+ super.initialize(cordova, webView);
51
+
52
+ _Instance = this;
53
+
54
+ Context context = cordova.getContext();
55
+
56
+ _Vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
57
+ _MediaPlayer = new MediaPlayer();
58
+
59
+ try {
60
+ AssetFileDescriptor descriptor = context.getAssets().openFd("beep.ogg");
61
+ _MediaPlayer.setDataSource(descriptor.getFileDescriptor(), descriptor.getStartOffset(), descriptor.getLength());
62
+ descriptor.close();
63
+ _MediaPlayer.prepare();
64
+ } catch (IOException e) {
65
+ e.printStackTrace();
66
+ }
67
+ }
68
+
69
+ @Override
70
+ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
71
+ Activity activity = cordova.getActivity();
72
+ Boolean hasCamera = activity.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY);
73
+ CameraManager cameraManager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE);
74
+
75
+ _CallbackContext = callbackContext;
76
+
77
+ int numberOfCameras = 0;
78
+
79
+ try {
80
+ numberOfCameras = cameraManager.getCameraIdList().length;
81
+ } catch (Exception e) {
82
+ e.printStackTrace();
83
+ }
84
+
85
+ if (!hasCamera || numberOfCameras == 0) {
86
+ AlertDialog alertDialog = new AlertDialog.Builder(activity).create();
87
+ alertDialog.setMessage(activity.getString(activity.getResources()
88
+ .getIdentifier("no_cameras_found", "string", activity.getPackageName())));
89
+ alertDialog.setButton(
90
+ AlertDialog.BUTTON_POSITIVE, activity.getString(activity.getResources()
91
+ .getIdentifier("ok", "string", activity.getPackageName())),
92
+ new DialogInterface.OnClickListener() {
93
+ public void onClick(DialogInterface dialog, int which) {
94
+ dialog.dismiss();
95
+ }
96
+ });
97
+ alertDialog.show();
98
+ return false;
99
+ }
100
+
101
+ if (action.equals("startScan")) {
102
+ class OneShotTask implements Runnable {
103
+ private final Context context;
104
+ private final JSONArray args;
105
+
106
+ private OneShotTask(Context ctx, JSONArray as) {
107
+ context = ctx;
108
+ args = as;
109
+ }
110
+
111
+ public void run() {
112
+ try {
113
+ openNewActivity(context, args);
114
+ } catch (JSONException e) {
115
+ _CallbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, e.toString()));
116
+ }
117
+ }
118
+ }
119
+ Thread t = new Thread(new OneShotTask(cordova.getContext(), args));
120
+ t.start();
121
+ return true;
122
+ }
123
+ return false;
124
+ }
125
+
126
+ private void openNewActivity(Context context, JSONArray args) throws JSONException {
127
+ JSONObject config = args.getJSONObject(0);
128
+ Intent intent = new Intent(context, CaptureActivity.class);
129
+ intent.putExtra("BarcodeFormats", config.optInt("barcodeFormats", 1234));
130
+ intent.putExtra("DetectorSize", config.optDouble("detectorSize", 0.5));
131
+ intent.putExtra("RotateCamera", config.optBoolean("rotateCamera", false));
132
+ intent.putExtra("Continuous", config.optBoolean("continuous", false));
133
+ intent.putExtra("Multiple", config.optBoolean("multiple", false));
134
+ intent.putExtra("DrawDetectionBorder", config.optBoolean("drawDetectionBorder", false));
135
+ intent.putExtra("Confirmation", config.optBoolean("confirmation", false));
136
+
137
+ _BeepOnSuccess = config.optBoolean("beepOnSuccess", false);
138
+ _VibrateOnSuccess = config.optBoolean("vibrateOnSuccess", false);
139
+
140
+ // NOTE: do not call setActivityResultCallback(this) here.
141
+ // startActivityForResult() already registers this plugin as the result
142
+ // callback. Calling it twice makes the second registration treat the first
143
+ // as a still-pending activity and cancel it via a synthetic
144
+ // onActivityResult(activityResultRequestCode, RESULT_CANCELED, null). Once
145
+ // activityResultRequestCode has been set to RC_BARCODE_CAPTURE by an
146
+ // earlier scan, that synthetic cancel passes our guard and aborts every
147
+ // subsequent scan before the camera opens.
148
+ this.cordova.startActivityForResult(this, intent, RC_BARCODE_CAPTURE);
149
+ }
150
+
151
+ @Override
152
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
153
+ super.onActivityResult(requestCode, resultCode, data);
154
+
155
+ if (requestCode == RC_BARCODE_CAPTURE) {
156
+ // CommonStatusCodes.SUCCESS and Activity.RESULT_CANCELED are both 0, so a
157
+ // successful scan can only be distinguished from a cancellation (back
158
+ // press / permission denied) by the presence of result data.
159
+ if (resultCode == CommonStatusCodes.SUCCESS && data != null) {
160
+ String payload = data.getStringExtra(CaptureActivity.BarcodePayload);
161
+ try {
162
+ // The payload is an array of [text, format, type] triples (one per
163
+ // detected barcode).
164
+ JSONArray result = new JSONArray(payload);
165
+ _CallbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
166
+ notifyScan();
167
+ Log.d(TAG, "Barcodes read: " + payload);
168
+ } catch (JSONException e) {
169
+ _CallbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, e.toString()));
170
+ }
171
+ } else {
172
+ // No result data means the user cancelled (back press / permission
173
+ // denied). Report it as a cancellation rather than crashing on a null
174
+ // intent. A null first element is mapped to USER_CANCELLED in JS.
175
+ String err = (data != null) ? data.getStringExtra("err") : null;
176
+ JSONArray result = new JSONArray();
177
+ result.put(err);
178
+ result.put("");
179
+ result.put("");
180
+ _CallbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, result));
181
+ }
182
+ }
183
+ }
184
+
185
+ /**
186
+ * Streams a batch of barcodes back to JS while keeping the callback (and the
187
+ * camera) alive. Called from CaptureActivity in continuous mode.
188
+ */
189
+ static void sendContinuousResult(JSONArray barcodes) {
190
+ MLKitBarcodeScanner self = _Instance;
191
+ if (self == null || self._CallbackContext == null) {
192
+ return;
193
+ }
194
+ PluginResult result = new PluginResult(PluginResult.Status.OK, barcodes);
195
+ result.setKeepCallback(true);
196
+ self._CallbackContext.sendPluginResult(result);
197
+ self.notifyScan();
198
+ }
199
+
200
+ /** Plays the success beep and/or vibrates, honouring the scan options. */
201
+ private void notifyScan() {
202
+ if (_BeepOnSuccess) {
203
+ _MediaPlayer.start();
204
+ }
205
+
206
+ if (_VibrateOnSuccess) {
207
+ int duration = 200;
208
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
209
+ _Vibrator.vibrate(VibrationEffect.createOneShot(duration, VibrationEffect.DEFAULT_AMPLITUDE));
210
+ } else {
211
+ // deprecated in API 26 aka Oreo
212
+ _Vibrator.vibrate(duration);
213
+ }
214
+ }
215
+ }
216
+
217
+ @Override
218
+ public void onRestoreStateForActivityResult(Bundle state, CallbackContext callbackContext) {
219
+ _CallbackContext = callbackContext;
220
+ }
221
+ }
@@ -0,0 +1,286 @@
1
+ /*
2
+ * Copyright 2020 Google LLC. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package com.mobisys.cordova.plugins.mlkit.barcode.scanner.utils;
18
+
19
+ import android.annotation.TargetApi;
20
+ import android.content.ContentResolver;
21
+ import android.graphics.Bitmap;
22
+ import android.graphics.BitmapFactory;
23
+ import android.graphics.ImageFormat;
24
+ import android.graphics.Matrix;
25
+ import android.graphics.Rect;
26
+ import android.graphics.YuvImage;
27
+ import android.media.Image;
28
+ import android.media.Image.Plane;
29
+ import android.net.Uri;
30
+ import android.os.Build.VERSION_CODES;
31
+ import android.provider.MediaStore;
32
+ import android.util.Log;
33
+
34
+ import androidx.annotation.Nullable;
35
+ import androidx.annotation.RequiresApi;
36
+ import androidx.camera.core.ExperimentalGetImage;
37
+ import androidx.camera.core.ImageProxy;
38
+ import androidx.exifinterface.media.ExifInterface;
39
+
40
+ import java.io.ByteArrayOutputStream;
41
+ import java.io.IOException;
42
+ import java.io.InputStream;
43
+ import java.nio.ByteBuffer;
44
+
45
+ /** Utils functions for bitmap conversions. */
46
+ public class BitmapUtils {
47
+ private static final String TAG = "BitmapUtils";
48
+
49
+ /** Converts NV21 format byte buffer to bitmap. */
50
+ @Nullable
51
+ public static Bitmap getBitmap(ByteBuffer data, FrameMetadata metadata) {
52
+ data.rewind();
53
+ byte[] imageInBuffer = new byte[data.limit()];
54
+ data.get(imageInBuffer, 0, imageInBuffer.length);
55
+ try {
56
+ YuvImage image = new YuvImage(imageInBuffer, ImageFormat.NV21, metadata.getWidth(), metadata.getHeight(), null);
57
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
58
+ image.compressToJpeg(new Rect(0, 0, metadata.getWidth(), metadata.getHeight()), 80, stream);
59
+
60
+ Bitmap bmp = BitmapFactory.decodeByteArray(stream.toByteArray(), 0, stream.size());
61
+
62
+ stream.close();
63
+ return rotateBitmap(bmp, metadata.getRotation(), false, false);
64
+ } catch (Exception e) {
65
+ Log.e("VisionProcessorBase", "Error: " + e.getMessage());
66
+ }
67
+ return null;
68
+ }
69
+
70
+ /** Converts a YUV_420_888 image from CameraX API to a bitmap. */
71
+ @RequiresApi(VERSION_CODES.KITKAT)
72
+ @Nullable
73
+ @ExperimentalGetImage
74
+ public static Bitmap getBitmap(ImageProxy image) {
75
+ FrameMetadata frameMetadata = new FrameMetadata.Builder().setWidth(image.getWidth()).setHeight(image.getHeight())
76
+ .setRotation(image.getImageInfo().getRotationDegrees()).build();
77
+
78
+ ByteBuffer nv21Buffer = yuv420ThreePlanesToNV21(image.getImage().getPlanes(), image.getWidth(), image.getHeight());
79
+ return getBitmap(nv21Buffer, frameMetadata);
80
+ }
81
+
82
+ /** Rotates a bitmap if it is converted from a bytebuffer. */
83
+ private static Bitmap rotateBitmap(Bitmap bitmap, int rotationDegrees, boolean flipX, boolean flipY) {
84
+ Matrix matrix = new Matrix();
85
+
86
+ // Rotate the image back to straight.
87
+ matrix.postRotate(rotationDegrees);
88
+
89
+ // Mirror the image along the X or Y axis.
90
+ matrix.postScale(flipX ? -1.0f : 1.0f, flipY ? -1.0f : 1.0f);
91
+ Bitmap rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
92
+
93
+ // Recycle the old bitmap if it has changed.
94
+ if (rotatedBitmap != bitmap) {
95
+ bitmap.recycle();
96
+ }
97
+ return rotatedBitmap;
98
+ }
99
+
100
+ @Nullable
101
+ public static Bitmap getBitmapFromContentUri(ContentResolver contentResolver, Uri imageUri) throws IOException {
102
+ Bitmap decodedBitmap = MediaStore.Images.Media.getBitmap(contentResolver, imageUri);
103
+ if (decodedBitmap == null) {
104
+ return null;
105
+ }
106
+ int orientation = getExifOrientationTag(contentResolver, imageUri);
107
+
108
+ int rotationDegrees = 0;
109
+ boolean flipX = false;
110
+ boolean flipY = false;
111
+ // See e.g. https://magnushoff.com/articles/jpeg-orientation/ for a detailed
112
+ // explanation on each
113
+ // orientation.
114
+ switch (orientation) {
115
+ case ExifInterface.ORIENTATION_FLIP_HORIZONTAL:
116
+ flipX = true;
117
+ break;
118
+ case ExifInterface.ORIENTATION_ROTATE_90:
119
+ rotationDegrees = 90;
120
+ break;
121
+ case ExifInterface.ORIENTATION_TRANSPOSE:
122
+ rotationDegrees = 90;
123
+ flipX = true;
124
+ break;
125
+ case ExifInterface.ORIENTATION_ROTATE_180:
126
+ rotationDegrees = 180;
127
+ break;
128
+ case ExifInterface.ORIENTATION_FLIP_VERTICAL:
129
+ flipY = true;
130
+ break;
131
+ case ExifInterface.ORIENTATION_ROTATE_270:
132
+ rotationDegrees = -90;
133
+ break;
134
+ case ExifInterface.ORIENTATION_TRANSVERSE:
135
+ rotationDegrees = -90;
136
+ flipX = true;
137
+ break;
138
+ case ExifInterface.ORIENTATION_UNDEFINED:
139
+ case ExifInterface.ORIENTATION_NORMAL:
140
+ default:
141
+ // No transformations necessary in this case.
142
+ }
143
+
144
+ return rotateBitmap(decodedBitmap, rotationDegrees, flipX, flipY);
145
+ }
146
+
147
+ private static int getExifOrientationTag(ContentResolver resolver, Uri imageUri) {
148
+ // We only support parsing EXIF orientation tag from local file on the device.
149
+ // See also:
150
+ // https://android-developers.googleblog.com/2016/12/introducing-the-exifinterface-support-library.html
151
+ if (!ContentResolver.SCHEME_CONTENT.equals(imageUri.getScheme())
152
+ && !ContentResolver.SCHEME_FILE.equals(imageUri.getScheme())) {
153
+ return 0;
154
+ }
155
+
156
+ ExifInterface exif;
157
+ try (InputStream inputStream = resolver.openInputStream(imageUri)) {
158
+ if (inputStream == null) {
159
+ return 0;
160
+ }
161
+
162
+ exif = new ExifInterface(inputStream);
163
+ } catch (IOException e) {
164
+ Log.e(TAG, "failed to open file to read rotation meta data: " + imageUri, e);
165
+ return 0;
166
+ }
167
+
168
+ return exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
169
+ }
170
+
171
+ /**
172
+ * Converts YUV_420_888 to NV21 bytebuffer.
173
+ *
174
+ * <p>
175
+ * The NV21 format consists of a single byte array containing the Y, U and V
176
+ * values. For an image of size S, the first S positions of the array contain
177
+ * all the Y values. The remaining positions contain interleaved V and U values.
178
+ * U and V are subsampled by a factor of 2 in both dimensions, so there are S/4
179
+ * U values and S/4 V values. In summary, the NV21 array will contain S Y values
180
+ * followed by S/4 VU values: YYYYYYYYYYYYYY(...)YVUVUVUVU(...)VU
181
+ *
182
+ * <p>
183
+ * YUV_420_888 is a generic format that can describe any YUV image where U and V
184
+ * are subsampled by a factor of 2 in both dimensions. {@link Image#getPlanes}
185
+ * returns an array with the Y, U and V planes. The Y plane is guaranteed not to
186
+ * be interleaved, so we can just copy its values into the first part of the
187
+ * NV21 array. The U and V planes may already have the representation in the
188
+ * NV21 format. This happens if the planes share the same buffer, the V buffer
189
+ * is one position before the U buffer and the planes have a pixelStride of 2.
190
+ * If this is case, we can just copy them to the NV21 array.
191
+ */
192
+ @RequiresApi(VERSION_CODES.KITKAT)
193
+ private static ByteBuffer yuv420ThreePlanesToNV21(Plane[] yuv420888planes, int width, int height) {
194
+ int imageSize = width * height;
195
+ byte[] out = new byte[imageSize + 2 * (imageSize / 4)];
196
+
197
+ if (areUVPlanesNV21(yuv420888planes, width, height)) {
198
+ // Copy the Y values.
199
+ yuv420888planes[0].getBuffer().get(out, 0, imageSize);
200
+
201
+ ByteBuffer uBuffer = yuv420888planes[1].getBuffer();
202
+ ByteBuffer vBuffer = yuv420888planes[2].getBuffer();
203
+ // Get the first V value from the V buffer, since the U buffer does not contain
204
+ // it.
205
+ vBuffer.get(out, imageSize, 1);
206
+ // Copy the first U value and the remaining VU values from the U buffer.
207
+ uBuffer.get(out, imageSize + 1, 2 * imageSize / 4 - 1);
208
+ } else {
209
+ // Fallback to copying the UV values one by one, which is slower but also works.
210
+ // Unpack Y.
211
+ unpackPlane(yuv420888planes[0], width, height, out, 0, 1);
212
+ // Unpack U.
213
+ unpackPlane(yuv420888planes[1], width, height, out, imageSize + 1, 2);
214
+ // Unpack V.
215
+ unpackPlane(yuv420888planes[2], width, height, out, imageSize, 2);
216
+ }
217
+
218
+ return ByteBuffer.wrap(out);
219
+ }
220
+
221
+ /**
222
+ * Checks if the UV plane buffers of a YUV_420_888 image are in the NV21 format.
223
+ */
224
+ @RequiresApi(VERSION_CODES.KITKAT)
225
+ private static boolean areUVPlanesNV21(Plane[] planes, int width, int height) {
226
+ int imageSize = width * height;
227
+
228
+ ByteBuffer uBuffer = planes[1].getBuffer();
229
+ ByteBuffer vBuffer = planes[2].getBuffer();
230
+
231
+ // Backup buffer properties.
232
+ int vBufferPosition = vBuffer.position();
233
+ int uBufferLimit = uBuffer.limit();
234
+
235
+ // Advance the V buffer by 1 byte, since the U buffer will not contain the first
236
+ // V value.
237
+ vBuffer.position(vBufferPosition + 1);
238
+ // Chop off the last byte of the U buffer, since the V buffer will not contain
239
+ // the last U value.
240
+ uBuffer.limit(uBufferLimit - 1);
241
+
242
+ // Check that the buffers are equal and have the expected number of elements.
243
+ boolean areNV21 = (vBuffer.remaining() == (2 * imageSize / 4 - 2)) && (vBuffer.compareTo(uBuffer) == 0);
244
+
245
+ // Restore buffers to their initial state.
246
+ vBuffer.position(vBufferPosition);
247
+ uBuffer.limit(uBufferLimit);
248
+
249
+ return areNV21;
250
+ }
251
+
252
+ /**
253
+ * Unpack an image plane into a byte array.
254
+ *
255
+ * The input plane data will be copied in 'out', starting at 'offset' and every
256
+ * pixel will be spaced by 'pixelStride'. Note that there is no row padding on
257
+ * the output.
258
+ */
259
+ @TargetApi(VERSION_CODES.KITKAT)
260
+ private static void unpackPlane(Plane plane, int width, int height, byte[] out, int offset, int pixelStride) {
261
+ ByteBuffer buffer = plane.getBuffer();
262
+ buffer.rewind();
263
+
264
+ // Compute the size of the current plane.
265
+ // We assume that it has the aspect ratio as the original image.
266
+ int numRow = (buffer.limit() + plane.getRowStride() - 1) / plane.getRowStride();
267
+ if (numRow == 0) {
268
+ return;
269
+ }
270
+ int scaleFactor = height / numRow;
271
+ int numCol = width / scaleFactor;
272
+
273
+ // Extract the data in the output buffer.
274
+ int outputPos = offset;
275
+ int rowStart = 0;
276
+ for (int row = 0; row < numRow; row++) {
277
+ int inputPos = rowStart;
278
+ for (int col = 0; col < numCol; col++) {
279
+ out[outputPos] = buffer.get(inputPos);
280
+ outputPos += pixelStride;
281
+ inputPos += plane.getPixelStride();
282
+ }
283
+ rowStart += plane.getRowStride();
284
+ }
285
+ }
286
+ }
@@ -0,0 +1,69 @@
1
+ /*
2
+ * Copyright 2020 Google LLC. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package com.mobisys.cordova.plugins.mlkit.barcode.scanner.utils;
18
+
19
+ /** Describing a frame info. */
20
+ public class FrameMetadata {
21
+
22
+ private final int width;
23
+ private final int height;
24
+ private final int rotation;
25
+
26
+ public int getWidth() {
27
+ return width;
28
+ }
29
+
30
+ public int getHeight() {
31
+ return height;
32
+ }
33
+
34
+ public int getRotation() {
35
+ return rotation;
36
+ }
37
+
38
+ private FrameMetadata(int width, int height, int rotation) {
39
+ this.width = width;
40
+ this.height = height;
41
+ this.rotation = rotation;
42
+ }
43
+
44
+ public static class Builder {
45
+
46
+ private int width;
47
+ private int height;
48
+ private int rotation;
49
+
50
+ public Builder setWidth(int width) {
51
+ this.width = width;
52
+ return this;
53
+ }
54
+
55
+ public Builder setHeight(int height) {
56
+ this.height = height;
57
+ return this;
58
+ }
59
+
60
+ public Builder setRotation(int rotation) {
61
+ this.rotation = rotation;
62
+ return this;
63
+ }
64
+
65
+ public FrameMetadata build() {
66
+ return new FrameMetadata(width, height, rotation);
67
+ }
68
+ }
69
+ }
@@ -0,0 +1,21 @@
1
+ #import <AVFoundation/AVFoundation.h>
2
+ #import <Foundation/Foundation.h>
3
+ #import <Cordova/CDV.h>
4
+ #import <UIKit/UIKit.h>
5
+ #import "CameraViewController.h"
6
+
7
+ @class UIViewController;
8
+
9
+ @interface CDViOSScanner : CDVPlugin {
10
+ NSString *_callback;
11
+ Boolean _scannerOpen;
12
+ AVAudioPlayer* _player;
13
+ Boolean _beepOnSuccess;
14
+ Boolean _vibrateOnSuccess;
15
+ }
16
+
17
+ @property (nonatomic, retain) CameraViewController* cameraViewController;
18
+
19
+ - (void) startScan:(CDVInvokedUrlCommand *)command;
20
+
21
+ @end