summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne Coucheron <arco68@gmail.com>2017-08-14 17:02:03 +0200
committerArne Coucheron <arco68@gmail.com>2018-01-27 00:41:45 +0100
commit690481663272ee4cce5dd7670edfe7b0b33a5f85 (patch)
tree60bd56bc07ccf1b0321fbb9f06ec9c4f04374c61
parent395fe6019b4ecc9159cbde3742d1035f3b7de3ca (diff)
downloadandroid_packages_apps_Snap-690481663272ee4cce5dd7670edfe7b0b33a5f85.tar.gz
android_packages_apps_Snap-690481663272ee4cce5dd7670edfe7b0b33a5f85.tar.bz2
android_packages_apps_Snap-690481663272ee4cce5dd7670edfe7b0b33a5f85.zip
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
-rwxr-xr-xsrc/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 4e841878b..c6ea2b22a 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 c257661ca..0e7d0805d 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 99b08b9b5..f3b30db1c 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 db93c0edb..54355078c 100755
--- a/src/com/android/camera/ui/CameraControls.java
+++ b/src/com/android/camera/ui/CameraControls.java
@@ -1066,7 +1066,7 @@ public class CameraControls extends RotatableLayout {
mPaint.setColor(getResources().getColor(R.color.camera_control_bg_transparent));
}
}
- invalidate();
+ requestLayout();
}
public void showRefocusToast(boolean show) {