summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne Coucheron <arco68@gmail.com>2017-08-14 17:02:03 +0200
committerChippa-a <vusal1372@gmail.com>2019-10-25 15:55:25 +0300
commit40a51e69340846445723c935757512c984d0e69d (patch)
tree0ad3faa53051dcd2e67a56c31a12c3d47030b937
parentacaa9e05bdb2b5ced973cbabec22f00d3bbefdae (diff)
downloadandroid_packages_apps_Snap-40a51e69340846445723c935757512c984d0e69d.zip
android_packages_apps_Snap-40a51e69340846445723c935757512c984d0e69d.tar.gz
android_packages_apps_Snap-40a51e69340846445723c935757512c984d0e69d.tar.bz2
Snap: Fix panorama layout
Loosely based on old cyngn patches. Change-Id: I7fdb6ba82243f2f28e8ea655f83f0339d49de5ad
-rw-r--r--res/layout/pano_module_capture.xml2
-rw-r--r--src/com/android/camera/WideAnglePanoramaModule.java1
-rw-r--r--src/com/android/camera/WideAnglePanoramaUI.java45
-rw-r--r--src/com/android/camera/ui/CameraControls.java2
4 files changed, 40 insertions, 10 deletions
diff --git a/res/layout/pano_module_capture.xml b/res/layout/pano_module_capture.xml
index 4e84187..c6ea2b2 100644
--- a/res/layout/pano_module_capture.xml
+++ b/res/layout/pano_module_capture.xml
@@ -24,7 +24,7 @@
android:id="@+id/pano_preview_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_gravity="center" >
+ android:layout_gravity="center_vertical|center_horizontal" >
<TextureView
android:id="@+id/pano_preview_textureview"
diff --git a/src/com/android/camera/WideAnglePanoramaModule.java b/src/com/android/camera/WideAnglePanoramaModule.java
index 58e6e67..364e815 100644
--- a/src/com/android/camera/WideAnglePanoramaModule.java
+++ b/src/com/android/camera/WideAnglePanoramaModule.java
@@ -458,6 +458,7 @@ public class WideAnglePanoramaModule
Log.d(TAG, "camera preview h = "
+ mCameraPreviewHeight + " , w = " + mCameraPreviewWidth);
parameters.setPreviewSize(mCameraPreviewWidth, mCameraPreviewHeight);
+ mUI.setPreviewSize(mCameraPreviewWidth, mCameraPreviewHeight);
List<int[]> frameRates = parameters.getSupportedPreviewFpsRange();
int last = frameRates.size() - 1;
diff --git a/src/com/android/camera/WideAnglePanoramaUI.java b/src/com/android/camera/WideAnglePanoramaUI.java
index 99b08b9..f3b30db 100644
--- a/src/com/android/camera/WideAnglePanoramaUI.java
+++ b/src/com/android/camera/WideAnglePanoramaUI.java
@@ -108,6 +108,10 @@ public class WideAnglePanoramaUI implements
private RotateLayout mPanoFailedDialog;
private Button mPanoFailedButton;
+ private int mTopMargin = 0;
+ private int mBottomMargin = 0;
+ private float mAspectRatio = 1.0f;
+
/** Constructor. */
public WideAnglePanoramaUI(
CameraActivity activity,
@@ -144,6 +148,14 @@ public class WideAnglePanoramaUI implements
muteButton.setVisibility(View.GONE);
}
+ private void calculateMargins(Point size) {
+ int l = size.x > size.y ? size.x : size.y;
+ int tm = mActivity.getResources().getDimensionPixelSize(R.dimen.preview_top_margin);
+ int bm = mActivity.getResources().getDimensionPixelSize(R.dimen.preview_bottom_margin);
+ mTopMargin = l / 4 * tm / (tm + bm);
+ mBottomMargin = l / 4 - mTopMargin;
+ }
+
public void onStartCapture() {
hideSwitcher();
mShutterButton.setImageResource(R.drawable.shutter_button_stop);
@@ -363,16 +375,19 @@ public class WideAnglePanoramaUI implements
Display display = mActivity.getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
+ mActivity.getWindowManager().getDefaultDisplay().getRealSize(size);
+ calculateMargins(size);
+ mCameraControls.setMargins(mTopMargin, mBottomMargin);
int width = size.x;
- int height = size.y;
+ int height = size.y - mTopMargin - mBottomMargin;
int xOffset = 0;
int yOffset = 0;
int w = width;
int h = height;
h = w * 4 / 3;
- yOffset = (height - h) / 2;
+ yOffset = (height - h) / 2 + mTopMargin;
FrameLayout.LayoutParams param = new FrameLayout.LayoutParams(w, h);
mTextureView.setLayoutParams(param);
@@ -383,12 +398,7 @@ public class WideAnglePanoramaUI implements
mPreviewBorder.setY(yOffset);
mPreviewYOffset = yOffset;
- int t = mPreviewYOffset;
- int b1 = mTextureView.getBottom() - mPreviewYOffset;
- int r = mTextureView.getRight();
- int b2 = mTextureView.getBottom();
-
- mCameraControls.setPreviewRatio(1.0f, true);
+ mTextureView.layout(0, mPreviewYOffset, mTextureView.getRight(), mTextureView.getBottom());
}
public void resetSavingProgress() {
@@ -711,4 +721,23 @@ public class WideAnglePanoramaUI implements
mPreviewCover.setVisibility(View.GONE);
}
}
+
+ public void setPreviewSize(int width, int height) {
+ if (width == 0 || height == 0) {
+ Log.w(TAG, "Preview size should not be 0.");
+ return;
+ }
+ float ratio;
+ if (width > height) {
+ ratio = (float) width / height;
+ } else {
+ ratio = (float) height / width;
+ }
+
+ if (ratio != mAspectRatio) {
+ mAspectRatio = ratio;
+ }
+
+ mCameraControls.setPreviewRatio(mAspectRatio, false);
+ }
}
diff --git a/src/com/android/camera/ui/CameraControls.java b/src/com/android/camera/ui/CameraControls.java
index 6484790..26a4057 100644
--- a/src/com/android/camera/ui/CameraControls.java
+++ b/src/com/android/camera/ui/CameraControls.java
@@ -991,7 +991,7 @@ public class CameraControls extends RotatableLayout {
mPaint.setColor(getResources().getColor(R.color.camera_control_bg_transparent));
}
}
- invalidate();
+ requestLayout();
}
public void showRefocusToast(boolean show) {