capacitor-community-multilens-camerapreview 0.0.1

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.
Files changed (37) hide show
  1. package/CapacitorCommunityMultilensCamerapreview.podspec +17 -0
  2. package/README.md +210 -0
  3. package/android/build.gradle +55 -0
  4. package/android/src/main/AndroidManifest.xml +5 -0
  5. package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraActivity.java +1005 -0
  6. package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraPreview.java +547 -0
  7. package/android/src/main/java/com/ahm/capacitor/camera/preview/CustomSurfaceView.java +23 -0
  8. package/android/src/main/java/com/ahm/capacitor/camera/preview/CustomTextureView.java +29 -0
  9. package/android/src/main/java/com/ahm/capacitor/camera/preview/Preview.java +386 -0
  10. package/android/src/main/java/com/ahm/capacitor/camera/preview/TapGestureDetector.java +24 -0
  11. package/android/src/main/res/layout/bridge_layout_main.xml +15 -0
  12. package/android/src/main/res/layout/camera_activity.xml +68 -0
  13. package/android/src/main/res/values/camera_ids.xml +4 -0
  14. package/android/src/main/res/values/camera_theme.xml +9 -0
  15. package/android/src/main/res/values/colors.xml +3 -0
  16. package/android/src/main/res/values/strings.xml +3 -0
  17. package/android/src/main/res/values/styles.xml +3 -0
  18. package/dist/docs.json +390 -0
  19. package/dist/esm/definitions.d.ts +79 -0
  20. package/dist/esm/definitions.js +2 -0
  21. package/dist/esm/definitions.js.map +1 -0
  22. package/dist/esm/index.d.ts +4 -0
  23. package/dist/esm/index.js +7 -0
  24. package/dist/esm/index.js.map +1 -0
  25. package/dist/esm/web.d.ts +27 -0
  26. package/dist/esm/web.js +153 -0
  27. package/dist/esm/web.js.map +1 -0
  28. package/dist/plugin.cjs.js +164 -0
  29. package/dist/plugin.cjs.js.map +1 -0
  30. package/dist/plugin.js +167 -0
  31. package/dist/plugin.js.map +1 -0
  32. package/ios/Plugin/CameraController.swift +667 -0
  33. package/ios/Plugin/Info.plist +24 -0
  34. package/ios/Plugin/Plugin.h +10 -0
  35. package/ios/Plugin/Plugin.m +17 -0
  36. package/ios/Plugin/Plugin.swift +300 -0
  37. package/package.json +78 -0
@@ -0,0 +1,547 @@
1
+ package com.ahm.capacitor.camera.preview;
2
+
3
+ import static android.Manifest.permission.CAMERA;
4
+
5
+ import android.app.FragmentManager;
6
+ import android.app.FragmentTransaction;
7
+ import android.content.pm.ActivityInfo;
8
+ import android.graphics.Color;
9
+ import android.graphics.Point;
10
+ import android.hardware.Camera;
11
+ import android.hardware.camera2.CameraAccessException;
12
+ import android.hardware.camera2.CameraManager;
13
+ import android.util.DisplayMetrics;
14
+ import android.util.TypedValue;
15
+ import android.view.Display;
16
+ import android.view.MotionEvent;
17
+ import android.view.View;
18
+ import android.view.ViewGroup;
19
+ import android.widget.FrameLayout;
20
+ import com.getcapacitor.JSObject;
21
+ import com.getcapacitor.Logger;
22
+ import com.getcapacitor.PermissionState;
23
+ import com.getcapacitor.Plugin;
24
+ import com.getcapacitor.PluginCall;
25
+ import com.getcapacitor.PluginMethod;
26
+ import com.getcapacitor.annotation.CapacitorPlugin;
27
+ import com.getcapacitor.annotation.Permission;
28
+ import com.getcapacitor.annotation.PermissionCallback;
29
+ import java.io.File;
30
+ import java.util.List;
31
+ import org.json.JSONArray;
32
+
33
+ @CapacitorPlugin(name = "CameraPreview", permissions = { @Permission(strings = { CAMERA }, alias = CameraPreview.CAMERA_PERMISSION_ALIAS) })
34
+ public class CameraPreview extends Plugin implements CameraActivity.CameraPreviewListener {
35
+
36
+ static final String CAMERA_PERMISSION_ALIAS = "camera";
37
+
38
+ private static String VIDEO_FILE_PATH = "";
39
+ private static String VIDEO_FILE_EXTENSION = ".mp4";
40
+
41
+ private String captureCallbackId = "";
42
+ private String snapshotCallbackId = "";
43
+ private String recordCallbackId = "";
44
+ private String cameraStartCallbackId = "";
45
+
46
+ // keep track of previously specified orientation to support locking orientation:
47
+ private int previousOrientationRequest = -1;
48
+
49
+ private static CameraActivity fragment;
50
+ private int containerViewId = 20;
51
+ private int zoomLevel = 0;
52
+
53
+ @PluginMethod
54
+ public void echo(PluginCall call) {
55
+ String value = call.getString("value");
56
+
57
+ JSObject ret = new JSObject();
58
+ ret.put("value", value);
59
+ call.resolve(ret);
60
+ }
61
+
62
+ @PluginMethod
63
+ public void start(PluginCall call) {
64
+ if (PermissionState.GRANTED.equals(getPermissionState(CAMERA_PERMISSION_ALIAS))) {
65
+ startCamera(call);
66
+ } else {
67
+ requestPermissionForAlias(CAMERA_PERMISSION_ALIAS, call, "handleCameraPermissionResult");
68
+ }
69
+ }
70
+
71
+ @PluginMethod
72
+ public void flip(PluginCall call) {
73
+ try {
74
+ fragment.switchCamera();
75
+ call.resolve();
76
+ } catch (Exception e) {
77
+ Logger.debug(getLogTag(), "Camera flip exception: " + e);
78
+ call.reject("failed to flip camera");
79
+ }
80
+ }
81
+
82
+ @PluginMethod
83
+ public void setOpacity(PluginCall call) {
84
+ if (this.hasCamera(call) == false) {
85
+ call.error("Camera is not running");
86
+ return;
87
+ }
88
+
89
+ bridge.saveCall(call);
90
+ Float opacity = call.getFloat("opacity", 1F);
91
+ fragment.setOpacity(opacity);
92
+ }
93
+
94
+ @PluginMethod
95
+ public void capture(PluginCall call) {
96
+ if (this.hasCamera(call) == false) {
97
+ call.reject("Camera is not running");
98
+ return;
99
+ }
100
+ bridge.saveCall(call);
101
+ captureCallbackId = call.getCallbackId();
102
+
103
+ Integer quality = call.getInt("quality", 85);
104
+ // Image Dimensions - Optional
105
+ Integer width = call.getInt("width", 0);
106
+ Integer height = call.getInt("height", 0);
107
+ fragment.takePicture(width, height, quality);
108
+ }
109
+
110
+ @PluginMethod
111
+ public void captureSample(PluginCall call) {
112
+ if (this.hasCamera(call) == false) {
113
+ call.reject("Camera is not running");
114
+ return;
115
+ }
116
+ bridge.saveCall(call);
117
+ snapshotCallbackId = call.getCallbackId();
118
+
119
+ Integer quality = call.getInt("quality", 85);
120
+ fragment.takeSnapshot(quality);
121
+ }
122
+
123
+ @PluginMethod
124
+ public void stop(final PluginCall call) {
125
+ bridge
126
+ .getActivity()
127
+ .runOnUiThread(
128
+ new Runnable() {
129
+ @Override
130
+ public void run() {
131
+ FrameLayout containerView = getBridge().getActivity().findViewById(containerViewId);
132
+
133
+ // allow orientation changes after closing camera:
134
+ getBridge().getActivity().setRequestedOrientation(previousOrientationRequest);
135
+
136
+ if (containerView != null) {
137
+ ((ViewGroup) getBridge().getWebView().getParent()).removeView(containerView);
138
+ getBridge().getWebView().setBackgroundColor(Color.WHITE);
139
+ FragmentManager fragmentManager = getActivity().getFragmentManager();
140
+ FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
141
+ fragmentTransaction.remove(fragment);
142
+ fragmentTransaction.commit();
143
+ fragment = null;
144
+
145
+ call.resolve();
146
+ } else {
147
+ call.reject("camera already stopped");
148
+ }
149
+ }
150
+ }
151
+ );
152
+ }
153
+
154
+ @PluginMethod
155
+ public void getSupportedFlashModes(PluginCall call) {
156
+ if (this.hasCamera(call) == false) {
157
+ call.reject("Camera is not running");
158
+ return;
159
+ }
160
+
161
+ Camera camera = fragment.getCamera();
162
+ Camera.Parameters params = camera.getParameters();
163
+ List<String> supportedFlashModes;
164
+ supportedFlashModes = params.getSupportedFlashModes();
165
+ JSONArray jsonFlashModes = new JSONArray();
166
+
167
+ if (supportedFlashModes != null) {
168
+ for (int i = 0; i < supportedFlashModes.size(); i++) {
169
+ jsonFlashModes.put(new String(supportedFlashModes.get(i)));
170
+ }
171
+ }
172
+
173
+ JSObject jsObject = new JSObject();
174
+ jsObject.put("result", jsonFlashModes);
175
+ call.resolve(jsObject);
176
+ }
177
+ @PluginMethod
178
+ public void getSupportedZoomLevels(PluginCall call) {
179
+ if (this.hasCamera(call) == false) {
180
+ call.reject("Camera is not running");
181
+ return;
182
+ }
183
+ Camera camera = fragment.getCamera();
184
+ Camera.Parameters params = camera.getParameters();
185
+ Boolean zoomSupported = params.isZoomSupported();
186
+ List<Integer> ZoomLevels;
187
+ JSONArray jsonZoomLevels = new JSONArray();
188
+ if(zoomSupported){
189
+ ZoomLevels = params.getZoomRatios();
190
+ for (int i = 0; i < ZoomLevels.size(); i++) {
191
+ if(i == 0){
192
+ zoomLevel = ZoomLevels.get(i);
193
+ }
194
+ jsonZoomLevels.put(new String(String.valueOf(ZoomLevels.get(i))));
195
+ }
196
+ }
197
+
198
+ JSObject jsObject = new JSObject();
199
+ jsObject.put("result", jsonZoomLevels);
200
+ call.resolve(jsObject);
201
+ }
202
+
203
+ @PluginMethod
204
+ public void setFlashMode(PluginCall call) {
205
+ if (this.hasCamera(call) == false) {
206
+ call.reject("Camera is not running");
207
+ return;
208
+ }
209
+
210
+ String flashMode = call.getString("flashMode");
211
+ if (flashMode == null || flashMode.isEmpty() == true) {
212
+ call.reject("flashMode required parameter is missing");
213
+ return;
214
+ }
215
+
216
+ Camera camera = fragment.getCamera();
217
+ Camera.Parameters params = camera.getParameters();
218
+
219
+ List<String> supportedFlashModes;
220
+ supportedFlashModes = camera.getParameters().getSupportedFlashModes();
221
+ if (supportedFlashModes.indexOf(flashMode) > -1) {
222
+ params.setFlashMode(flashMode);
223
+ } else {
224
+ call.reject("Flash mode not recognised: " + flashMode);
225
+ return;
226
+ }
227
+
228
+ fragment.setCameraParameters(params);
229
+
230
+ call.resolve();
231
+ }
232
+
233
+ @PluginMethod
234
+ public void startRecordVideo(final PluginCall call) {
235
+ if (this.hasCamera(call) == false) {
236
+ call.reject("Camera is not running");
237
+ return;
238
+ }
239
+ final String filename = "videoTmp";
240
+ VIDEO_FILE_PATH = getActivity().getCacheDir().toString() + "/";
241
+
242
+ final String position = call.getString("position", "front");
243
+ final Integer width = call.getInt("width", 0);
244
+ final Integer height = call.getInt("height", 0);
245
+ final Boolean withFlash = call.getBoolean("withFlash", false);
246
+ final Integer maxDuration = call.getInt("maxDuration", 0);
247
+ final String lens = call.getString("zoomFactor", "0");
248
+ // final Integer quality = call.getInt("quality", 0);
249
+ bridge.saveCall(call);
250
+ recordCallbackId = call.getCallbackId();
251
+
252
+ bridge
253
+ .getActivity()
254
+ .runOnUiThread(
255
+ new Runnable() {
256
+ @Override
257
+ public void run() {
258
+ // fragment.startRecord(getFilePath(filename), position, width, height, quality, withFlash);
259
+ fragment.startRecord(getFilePath(filename), position, width, height, 70, withFlash, maxDuration, lens);
260
+ }
261
+ }
262
+ );
263
+
264
+ call.resolve();
265
+ }
266
+
267
+ @PluginMethod
268
+ public void stopRecordVideo(PluginCall call) {
269
+ if (this.hasCamera(call) == false) {
270
+ call.reject("Camera is not running");
271
+ return;
272
+ }
273
+
274
+ System.out.println("stopRecordVideo - Callbackid=" + call.getCallbackId());
275
+
276
+ bridge.saveCall(call);
277
+ recordCallbackId = call.getCallbackId();
278
+
279
+ // bridge.getActivity().runOnUiThread(new Runnable() {
280
+ // @Override
281
+ // public void run() {
282
+ // fragment.stopRecord();
283
+ // }
284
+ // });
285
+
286
+ fragment.stopRecord();
287
+ // call.resolve();
288
+ }
289
+
290
+ @PermissionCallback
291
+ private void handleCameraPermissionResult(PluginCall call) {
292
+ if (PermissionState.GRANTED.equals(getPermissionState(CAMERA_PERMISSION_ALIAS))) {
293
+ startCamera(call);
294
+ } else {
295
+ Logger.debug(getLogTag(), "User denied camera permission: " + getPermissionState(CAMERA_PERMISSION_ALIAS).toString());
296
+ call.reject("Permission failed: user denied access to camera.");
297
+ }
298
+ }
299
+
300
+ public static void setZoom(int zoomLevel) {
301
+ Camera Cam = fragment.getCamera();
302
+ Camera.Parameters params = Cam.getParameters();
303
+ if(params.isZoomSupported()){
304
+ params.setZoom(zoomLevel);
305
+ }
306
+ }
307
+
308
+ private void startCamera(final PluginCall call) {
309
+ String position = call.getString("position");
310
+ int zoomFactor = call.getInt("zoomFactor", 100);
311
+
312
+ if (position == null || position.isEmpty() || "rear".equals(position)) {
313
+ position = "back";
314
+ } else {
315
+ position = "front";
316
+ }
317
+
318
+ final Integer x = call.getInt("x", 0);
319
+ final Integer y = call.getInt("y", 0);
320
+ final Integer width = call.getInt("width", 0);
321
+ final Integer height = call.getInt("height", 0);
322
+ final Integer paddingBottom = call.getInt("paddingBottom", 0);
323
+ final Boolean toBack = call.getBoolean("toBack", false);
324
+ final Boolean storeToFile = call.getBoolean("storeToFile", false);
325
+ final Boolean enableOpacity = call.getBoolean("enableOpacity", false);
326
+ final Boolean enableZoom = call.getBoolean("enableZoom", false);
327
+ final Boolean disableExifHeaderStripping = call.getBoolean("disableExifHeaderStripping", true);
328
+ final Boolean lockOrientation = call.getBoolean("lockAndroidOrientation", false);
329
+ previousOrientationRequest = getBridge().getActivity().getRequestedOrientation();
330
+
331
+ fragment = new CameraActivity();
332
+ fragment.setEventListener(this);
333
+ fragment.defaultCamera = position;
334
+ fragment.tapToTakePicture = false;
335
+ fragment.dragEnabled = false;
336
+ fragment.tapToFocus = true;
337
+ fragment.disableExifHeaderStripping = disableExifHeaderStripping;
338
+ fragment.storeToFile = storeToFile;
339
+ fragment.toBack = toBack;
340
+ fragment.enableOpacity = enableOpacity;
341
+ fragment.enableZoom = enableZoom;
342
+ zoomLevel = zoomFactor;
343
+ bridge
344
+ .getActivity()
345
+ .runOnUiThread(
346
+ new Runnable() {
347
+ @Override
348
+ public void run() {
349
+ DisplayMetrics metrics = getBridge().getActivity().getResources().getDisplayMetrics();
350
+ // lock orientation if specified in options:
351
+ if (lockOrientation) {
352
+ getBridge().getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
353
+ }
354
+
355
+ // offset
356
+ int computedX = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, x, metrics);
357
+ int computedY = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, y, metrics);
358
+
359
+ // size
360
+ int computedWidth;
361
+ int computedHeight;
362
+ int computedPaddingBottom;
363
+
364
+ if (paddingBottom != 0) {
365
+ computedPaddingBottom = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, paddingBottom, metrics);
366
+ } else {
367
+ computedPaddingBottom = 0;
368
+ }
369
+
370
+ if (width != 0) {
371
+ computedWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, width, metrics);
372
+ } else {
373
+ Display defaultDisplay = getBridge().getActivity().getWindowManager().getDefaultDisplay();
374
+ final Point size = new Point();
375
+ defaultDisplay.getSize(size);
376
+
377
+ computedWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, size.x, metrics);
378
+ }
379
+
380
+ if (height != 0) {
381
+ computedHeight =
382
+ (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, height, metrics) - computedPaddingBottom;
383
+ } else {
384
+ Display defaultDisplay = getBridge().getActivity().getWindowManager().getDefaultDisplay();
385
+ final Point size = new Point();
386
+ defaultDisplay.getSize(size);
387
+
388
+ computedHeight =
389
+ (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, size.y, metrics) - computedPaddingBottom;
390
+ }
391
+
392
+ fragment.setRect(computedX, computedY, computedWidth, computedHeight);
393
+
394
+ FrameLayout containerView = getBridge().getActivity().findViewById(containerViewId);
395
+ if (containerView == null) {
396
+ containerView = new FrameLayout(getActivity().getApplicationContext());
397
+ containerView.setId(containerViewId);
398
+
399
+ getBridge().getWebView().setBackgroundColor(Color.TRANSPARENT);
400
+ ((ViewGroup) getBridge().getWebView().getParent()).addView(containerView);
401
+ if (toBack == true) {
402
+ getBridge().getWebView().getParent().bringChildToFront(getBridge().getWebView());
403
+ setupBroadcast();
404
+ }
405
+
406
+ FragmentManager fragmentManager = getBridge().getActivity().getFragmentManager();
407
+ FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
408
+ fragmentTransaction.add(containerView.getId(), fragment);
409
+ fragmentTransaction.commit();
410
+
411
+ // NOTE: we don't return invoke call.resolve here because it must be invoked in onCameraStarted
412
+ // otherwise the plugin start method might resolve/return before the camera is actually set in CameraActivity
413
+ // onResume method (see this line mCamera = Camera.open(defaultCameraId);) and the next subsequent plugin
414
+ // method invocations (for example, getSupportedFlashModes) might fails with "Camera is not running" error
415
+ // because camera is not available yet and hasCamera method will return false
416
+ // Please also see https://developer.android.com/reference/android/hardware/Camera.html#open%28int%29
417
+ bridge.saveCall(call);
418
+ cameraStartCallbackId = call.getCallbackId();
419
+ } else {
420
+ call.reject("camera already started");
421
+ }
422
+ }
423
+ }
424
+ );
425
+ }
426
+
427
+ @Override
428
+ protected void handleOnResume() {
429
+ super.handleOnResume();
430
+ }
431
+
432
+ @Override
433
+ public void onPictureTaken(String originalPicture) {
434
+ JSObject jsObject = new JSObject();
435
+ jsObject.put("value", originalPicture);
436
+ bridge.getSavedCall(captureCallbackId).resolve(jsObject);
437
+ }
438
+
439
+ @Override
440
+ public void onPictureTakenError(String message) {
441
+ bridge.getSavedCall(captureCallbackId).reject(message);
442
+ }
443
+
444
+ @Override
445
+ public void onSnapshotTaken(String originalPicture) {
446
+ JSObject jsObject = new JSObject();
447
+ jsObject.put("value", originalPicture);
448
+ bridge.getSavedCall(snapshotCallbackId).resolve(jsObject);
449
+ }
450
+
451
+ @Override
452
+ public void onSnapshotTakenError(String message) {
453
+ bridge.getSavedCall(snapshotCallbackId).reject(message);
454
+ }
455
+
456
+ @Override
457
+ public void onFocusSet(int pointX, int pointY) {}
458
+
459
+ @Override
460
+ public void onFocusSetError(String message) {}
461
+
462
+ @Override
463
+ public void onBackButton() {}
464
+
465
+ @Override
466
+ public void onCameraStarted() {
467
+ PluginCall pluginCall = bridge.getSavedCall(cameraStartCallbackId);
468
+ pluginCall.resolve();
469
+ bridge.releaseCall(pluginCall);
470
+
471
+ setZoom(zoomLevel);
472
+ }
473
+
474
+ @Override
475
+ public void onStartRecordVideo() {}
476
+
477
+ @Override
478
+ public void onStartRecordVideoError(String message) {
479
+ bridge.getSavedCall(recordCallbackId).reject(message);
480
+ }
481
+
482
+ @Override
483
+ public void onStopRecordVideo(String file) {
484
+ PluginCall pluginCall = bridge.getSavedCall(recordCallbackId);
485
+ JSObject jsObject = new JSObject();
486
+ jsObject.put("videoFilePath", file);
487
+ pluginCall.resolve(jsObject);
488
+ }
489
+
490
+ @Override
491
+ public void onStopRecordVideoError(String error) {
492
+ bridge.getSavedCall(recordCallbackId).reject(error);
493
+ }
494
+
495
+ private boolean hasView(PluginCall call) {
496
+ if (fragment == null) {
497
+ return false;
498
+ }
499
+
500
+ return true;
501
+ }
502
+
503
+ private boolean hasCamera(PluginCall call) {
504
+ if (this.hasView(call) == false) {
505
+ return false;
506
+ }
507
+
508
+ if (fragment.getCamera() == null) {
509
+ return false;
510
+ }
511
+
512
+ return true;
513
+ }
514
+
515
+ private String getFilePath(String filename) {
516
+ String fileName = filename;
517
+
518
+ int i = 1;
519
+
520
+ while (new File(VIDEO_FILE_PATH + fileName + VIDEO_FILE_EXTENSION).exists()) {
521
+ // Add number suffix if file exists
522
+ fileName = filename + '_' + i;
523
+ i++;
524
+ }
525
+
526
+ return VIDEO_FILE_PATH + fileName + VIDEO_FILE_EXTENSION;
527
+ }
528
+
529
+ private void setupBroadcast() {
530
+ /** When touch event is triggered, relay it to camera view if needed so it can support pinch zoom */
531
+
532
+ getBridge().getWebView().setClickable(true);
533
+ getBridge()
534
+ .getWebView()
535
+ .setOnTouchListener(
536
+ new View.OnTouchListener() {
537
+ @Override
538
+ public boolean onTouch(View v, MotionEvent event) {
539
+ if ((null != fragment) && (fragment.toBack == true)) {
540
+ fragment.frameContainerLayout.dispatchTouchEvent(event);
541
+ }
542
+ return false;
543
+ }
544
+ }
545
+ );
546
+ }
547
+ }
@@ -0,0 +1,23 @@
1
+ package com.ahm.capacitor.camera.preview;
2
+
3
+ import android.content.Context;
4
+ import android.view.SurfaceHolder;
5
+ import android.view.SurfaceView;
6
+
7
+ class CustomSurfaceView extends SurfaceView implements SurfaceHolder.Callback {
8
+
9
+ private final String TAG = "CustomSurfaceView";
10
+
11
+ CustomSurfaceView(Context context) {
12
+ super(context);
13
+ }
14
+
15
+ @Override
16
+ public void surfaceCreated(SurfaceHolder holder) {}
17
+
18
+ @Override
19
+ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {}
20
+
21
+ @Override
22
+ public void surfaceDestroyed(SurfaceHolder holder) {}
23
+ }
@@ -0,0 +1,29 @@
1
+ package com.ahm.capacitor.camera.preview;
2
+
3
+ import android.content.Context;
4
+ import android.graphics.SurfaceTexture;
5
+ import android.view.SurfaceHolder;
6
+ import android.view.TextureView;
7
+
8
+ class CustomTextureView extends TextureView implements TextureView.SurfaceTextureListener {
9
+
10
+ private final String TAG = "CustomTextureView";
11
+
12
+ CustomTextureView(Context context) {
13
+ super(context);
14
+ }
15
+
16
+ @Override
17
+ public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {}
18
+
19
+ @Override
20
+ public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {}
21
+
22
+ @Override
23
+ public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
24
+ return true;
25
+ }
26
+
27
+ @Override
28
+ public void onSurfaceTextureUpdated(SurfaceTexture surface) {}
29
+ }