@capacitor-community/camera-preview 7.0.4 → 7.0.5
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.
|
@@ -2,6 +2,7 @@ package com.ahm.capacitor.camera.preview;
|
|
|
2
2
|
|
|
3
3
|
import static android.Manifest.permission.CAMERA;
|
|
4
4
|
|
|
5
|
+
import android.annotation.SuppressLint;
|
|
5
6
|
import android.app.FragmentManager;
|
|
6
7
|
import android.app.FragmentTransaction;
|
|
7
8
|
import android.content.pm.ActivityInfo;
|
|
@@ -108,6 +109,7 @@ public class CameraPreview extends Plugin implements CameraActivity.CameraPrevie
|
|
|
108
109
|
fragment.takeSnapshot(quality);
|
|
109
110
|
}
|
|
110
111
|
|
|
112
|
+
@SuppressLint("WrongConstant")
|
|
111
113
|
@PluginMethod
|
|
112
114
|
public void stop(final PluginCall call) {
|
|
113
115
|
bridge
|
|
@@ -120,13 +122,16 @@ public class CameraPreview extends Plugin implements CameraActivity.CameraPrevie
|
|
|
120
122
|
|
|
121
123
|
// allow orientation changes after closing camera:
|
|
122
124
|
getBridge().getActivity().setRequestedOrientation(previousOrientationRequest);
|
|
125
|
+
getBridge().getWebView().setOnTouchListener(null);
|
|
123
126
|
|
|
124
127
|
if (containerView != null) {
|
|
125
128
|
((ViewGroup) getBridge().getWebView().getParent()).removeView(containerView);
|
|
126
129
|
getBridge().getWebView().setBackgroundColor(Color.WHITE);
|
|
127
130
|
FragmentManager fragmentManager = getActivity().getFragmentManager();
|
|
128
131
|
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
|
129
|
-
|
|
132
|
+
if (fragment != null) {
|
|
133
|
+
fragmentTransaction.remove(fragment);
|
|
134
|
+
}
|
|
130
135
|
fragmentTransaction.commit();
|
|
131
136
|
fragment = null;
|
|
132
137
|
|
|
@@ -346,7 +351,6 @@ public class CameraPreview extends Plugin implements CameraActivity.CameraPrevie
|
|
|
346
351
|
((ViewGroup) getBridge().getWebView().getParent()).addView(containerView);
|
|
347
352
|
if (toBack == true) {
|
|
348
353
|
getBridge().getWebView().getParent().bringChildToFront(getBridge().getWebView());
|
|
349
|
-
setupBroadcast();
|
|
350
354
|
}
|
|
351
355
|
|
|
352
356
|
FragmentManager fragmentManager = getBridge().getActivity().getFragmentManager();
|
|
@@ -410,9 +414,17 @@ public class CameraPreview extends Plugin implements CameraActivity.CameraPrevie
|
|
|
410
414
|
|
|
411
415
|
@Override
|
|
412
416
|
public void onCameraStarted() {
|
|
417
|
+
if (fragment != null && fragment.toBack) {
|
|
418
|
+
setupBroadcast();
|
|
419
|
+
}
|
|
420
|
+
|
|
413
421
|
PluginCall pluginCall = bridge.getSavedCall(cameraStartCallbackId);
|
|
414
|
-
pluginCall
|
|
415
|
-
|
|
422
|
+
if (pluginCall != null) {
|
|
423
|
+
pluginCall.resolve();
|
|
424
|
+
bridge.releaseCall(pluginCall);
|
|
425
|
+
} else {
|
|
426
|
+
Logger.warn(getLogTag(), "onCameraStarted but no saved start call (cameraStartCallbackId=" + cameraStartCallbackId + ")");
|
|
427
|
+
}
|
|
416
428
|
}
|
|
417
429
|
|
|
418
430
|
@Override
|
|
@@ -480,7 +492,7 @@ public class CameraPreview extends Plugin implements CameraActivity.CameraPrevie
|
|
|
480
492
|
new View.OnTouchListener() {
|
|
481
493
|
@Override
|
|
482
494
|
public boolean onTouch(View v, MotionEvent event) {
|
|
483
|
-
if (
|
|
495
|
+
if (fragment != null && fragment.toBack && fragment.frameContainerLayout != null) {
|
|
484
496
|
fragment.frameContainerLayout.dispatchTouchEvent(event);
|
|
485
497
|
}
|
|
486
498
|
return false;
|