@capacitor-community/camera-preview 3.1.1 → 3.1.2
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.
|
@@ -4,6 +4,7 @@ import android.app.Activity;
|
|
|
4
4
|
import android.app.Fragment;
|
|
5
5
|
import android.content.Context;
|
|
6
6
|
import android.content.pm.PackageManager;
|
|
7
|
+
import android.content.res.Configuration;
|
|
7
8
|
import android.graphics.Bitmap;
|
|
8
9
|
import android.graphics.Bitmap.CompressFormat;
|
|
9
10
|
import android.graphics.BitmapFactory;
|
|
@@ -390,6 +391,40 @@ public class CameraActivity extends Fragment {
|
|
|
390
391
|
}
|
|
391
392
|
}
|
|
392
393
|
|
|
394
|
+
@Override
|
|
395
|
+
public void onConfigurationChanged(Configuration newConfig) {
|
|
396
|
+
super.onConfigurationChanged(newConfig);
|
|
397
|
+
|
|
398
|
+
final FrameLayout frameContainerLayout = (FrameLayout) view.findViewById(
|
|
399
|
+
getResources().getIdentifier("frame_container", "id", appResourcesPackage)
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
final int previousOrientation = frameContainerLayout.getHeight() > frameContainerLayout.getWidth() ? Configuration.ORIENTATION_PORTRAIT : Configuration.ORIENTATION_LANDSCAPE;
|
|
403
|
+
// Checks if the orientation of the screen has changed
|
|
404
|
+
if (newConfig.orientation != previousOrientation) {
|
|
405
|
+
|
|
406
|
+
final RelativeLayout frameCamContainerLayout = (RelativeLayout) view.findViewById(
|
|
407
|
+
getResources().getIdentifier("frame_camera_cont", "id", appResourcesPackage)
|
|
408
|
+
);
|
|
409
|
+
|
|
410
|
+
frameContainerLayout.getLayoutParams().width = frameCamContainerLayout.getHeight();
|
|
411
|
+
frameContainerLayout.getLayoutParams().height = frameCamContainerLayout.getWidth();
|
|
412
|
+
|
|
413
|
+
frameCamContainerLayout.getLayoutParams().width = frameCamContainerLayout.getHeight();
|
|
414
|
+
frameCamContainerLayout.getLayoutParams().height = frameCamContainerLayout.getWidth();
|
|
415
|
+
|
|
416
|
+
frameContainerLayout.invalidate();
|
|
417
|
+
frameContainerLayout.requestLayout();
|
|
418
|
+
|
|
419
|
+
frameCamContainerLayout.forceLayout();
|
|
420
|
+
|
|
421
|
+
mPreview.setCameraDisplayOrientation();
|
|
422
|
+
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
|
|
393
428
|
public Camera getCamera() {
|
|
394
429
|
return mCamera;
|
|
395
430
|
}
|
|
@@ -102,7 +102,7 @@ class Preview extends RelativeLayout implements SurfaceHolder.Callback, TextureV
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
public void setCameraDisplayOrientation() {
|
|
106
106
|
Camera.CameraInfo info = new Camera.CameraInfo();
|
|
107
107
|
int rotation = ((Activity) getContext()).getWindowManager().getDefaultDisplay().getRotation();
|
|
108
108
|
int degrees = 0;
|