From 22c9b14239c5fd517f2ebff84d499e3b30a36551 Mon Sep 17 00:00:00 2001 From: Jack Yoo Date: Mon, 25 Jan 2016 11:12:46 -0800 Subject: SnapdragonCamera: Calculate in top bottom margin for the preview Subtract top and bottom margin from the max height of the preview Let it be aligned correctly to the top and center horizontally. Change-Id: I6c5b3fde57c1a514725a6316dbe8e0c799a928d0 CRs-Fixed: 965033 --- src/com/android/camera/PhotoUI.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java index 88cc2b856..19aa3a71b 100644 --- a/src/com/android/camera/PhotoUI.java +++ b/src/com/android/camera/PhotoUI.java @@ -344,6 +344,7 @@ public class PhotoUI implements PieListener, FrameLayout.LayoutParams lp; float scaledTextureWidth, scaledTextureHeight; int rotation = CameraUtil.getDisplayRotation(mActivity); + mScreenRatio = CameraUtil.determineRatio(ratio); if (mScreenRatio == CameraUtil.RATIO_16_9 && CameraUtil.determinCloseRatio(ratio) == CameraUtil.RATIO_4_3) { int l = (mTopMargin + mBottomMargin) * 4; @@ -377,7 +378,8 @@ public class PhotoUI implements PieListener, } else { float width = mMaxPreviewWidth, height = mMaxPreviewHeight; if (width == 0 || height == 0) return; - + if(mScreenRatio == CameraUtil.RATIO_4_3) + height -= (mTopMargin + mBottomMargin); if (mOrientationResize) { scaledTextureWidth = height * mAspectRatio; if (scaledTextureWidth > width) { @@ -408,7 +410,6 @@ public class PhotoUI implements PieListener, Log.v(TAG, "setTransformMatrix: scaledTextureWidth = " + scaledTextureWidth + ", scaledTextureHeight = " + scaledTextureHeight); - if (((rotation == 0 || rotation == 180) && scaledTextureWidth > scaledTextureHeight) || ((rotation == 90 || rotation == 270) && scaledTextureWidth < scaledTextureHeight)) { @@ -418,6 +419,10 @@ public class PhotoUI implements PieListener, lp = new FrameLayout.LayoutParams((int) scaledTextureWidth, (int) scaledTextureHeight, Gravity.CENTER); } + if(mScreenRatio == CameraUtil.RATIO_4_3) { + lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP; + lp.setMargins(0, mTopMargin, 0, mBottomMargin); + } } if (mSurfaceTextureUncroppedWidth != scaledTextureWidth || -- cgit v1.2.3