diff options
author | Doris Liu <tianliu@google.com> | 2013-05-06 17:23:09 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-05-06 17:23:09 +0000 |
commit | 93240535cafe2b1a7630f8350963a3d84cbb9937 (patch) | |
tree | 232d76013f0ddbd68c74bde8cd5e412eb0687e77 /src/com/android/camera/ui/CameraControls.java | |
parent | 712cc2f5add2fb78fbb723ecbca5f576a91fb54f (diff) | |
parent | fa1c3a528de2ec357b8f43aa133feae444899668 (diff) | |
download | android_packages_apps_Snap-93240535cafe2b1a7630f8350963a3d84cbb9937.tar.gz android_packages_apps_Snap-93240535cafe2b1a7630f8350963a3d84cbb9937.tar.bz2 android_packages_apps_Snap-93240535cafe2b1a7630f8350963a3d84cbb9937.zip |
Merge "Restrict checking for device flip" into gb-ub-photos-bryce
Diffstat (limited to 'src/com/android/camera/ui/CameraControls.java')
-rw-r--r-- | src/com/android/camera/ui/CameraControls.java | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/com/android/camera/ui/CameraControls.java b/src/com/android/camera/ui/CameraControls.java index 5d2f12360..1fc83fdf4 100644 --- a/src/com/android/camera/ui/CameraControls.java +++ b/src/com/android/camera/ui/CameraControls.java @@ -62,12 +62,7 @@ public class CameraControls extends RotatableLayout { @Override public void onDisplayChanged(int arg0) { - int currentRotation = Util.getDisplayRotation((Activity) getContext()); - if ((currentRotation - mLastRotation) % 180 == 0) { - flipChildren(); - getParent().requestLayout(); - } - mLastRotation = currentRotation; + checkLayoutFlip(); } @Override @@ -76,6 +71,15 @@ public class CameraControls extends RotatableLayout { } } + private void checkLayoutFlip() { + int currentRotation = Util.getDisplayRotation((Activity) getContext()); + if ((currentRotation - mLastRotation + 360) % 360 == 180) { + mLastRotation = currentRotation; + flipChildren(); + getParent().requestLayout(); + } + } + @Override public void onFinishInflate() { super.onFinishInflate(); @@ -99,6 +103,14 @@ public class CameraControls extends RotatableLayout { } @Override + public void onWindowVisibilityChanged(int visibility) { + if (visibility == View.VISIBLE) { + // Make sure when coming back from onPause, the layout is rotated correctly + checkLayoutFlip(); + } + } + + @Override public void onDetachedFromWindow () { super.onDetachedFromWindow(); if (ApiHelper.HAS_DISPLAY_LISTENER) { @@ -109,6 +121,7 @@ public class CameraControls extends RotatableLayout { @Override public void onLayout(boolean changed, int l, int t, int r, int b) { + mLastRotation = Util.getDisplayRotation((Activity) getContext()); int orientation = getResources().getConfiguration().orientation; int size = getResources().getDimensionPixelSize(R.dimen.camera_controls_size); int rotation = getUnifiedRotation(); |