diff options
author | Nikita <nikich340@gmail.com> | 2016-02-23 15:19:23 +1000 |
---|---|---|
committer | Abhisek Devkota <ciwrl@cyanogenmod.com> | 2016-03-07 15:08:41 -0800 |
commit | 2bfa8aa638b8042277e2b9ec0506492ac3a55d32 (patch) | |
tree | 1460305602b1a0f60249fdebb90c56f37beb4cf8 | |
parent | 1e99d0c85a354d6b873e19ebe8947a1cc6fd94bd (diff) | |
download | android_packages_apps_Snap-2bfa8aa638b8042277e2b9ec0506492ac3a55d32.tar.gz android_packages_apps_Snap-2bfa8aa638b8042277e2b9ec0506492ac3a55d32.tar.bz2 android_packages_apps_Snap-2bfa8aa638b8042277e2b9ec0506492ac3a55d32.zip |
Snap: Fix incorrect preview layout surface size in landscape mode
If height is smaller than width it means that orientation sets to horizontal
and we should decrease width instead height to get normal preview size.
RM-208
Change-Id: Ifa211ad2604fb730fb85b01ae1d7c93c9b7aa2ce
(cherry picked from commit a301c539d76fe1905a286a4a15b1c59e26f64364)
-rw-r--r-- | src/com/android/camera/PhotoUI.java | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java index d2827fce4..5c13a7573 100644 --- a/src/com/android/camera/PhotoUI.java +++ b/src/com/android/camera/PhotoUI.java @@ -383,8 +383,13 @@ 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 (mScreenRatio == CameraUtil.RATIO_4_3) { + if (height > width) { + height -= (mTopMargin + mBottomMargin); + } else { + width -= (mTopMargin + mBottomMargin); + } + } if (mOrientationResize) { scaledTextureWidth = height * mAspectRatio; if (scaledTextureWidth > width) { @@ -403,7 +408,7 @@ public class PhotoUI implements PieListener, scaledTextureHeight = height; } } else { - if(Math.max(height, width * mAspectRatio) > height) { + if (Math.max(height, width * mAspectRatio) > height) { scaledTextureWidth = height / mAspectRatio; scaledTextureHeight = height; } else { @@ -424,7 +429,7 @@ public class PhotoUI implements PieListener, lp = new FrameLayout.LayoutParams((int) scaledTextureWidth, (int) scaledTextureHeight, Gravity.CENTER); } - if(mScreenRatio == CameraUtil.RATIO_4_3) { + if (mScreenRatio == CameraUtil.RATIO_4_3) { lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP; lp.setMargins(0, mTopMargin, 0, mBottomMargin); } |