summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDoris Liu <tianliu@google.com>2013-05-03 14:33:57 -0700
committerDoris Liu <tianliu@google.com>2013-05-03 17:28:08 -0700
commit9ee99847b28e9a282cf0732fa659f62a9d24f3eb (patch)
tree0be2ddd6c9128629c84c250487a94abaae395820 /src
parent4b9dea3a1496271b73a7b5a4f62ad3bb3b5cdadc (diff)
downloadandroid_packages_apps_Gallery2-9ee99847b28e9a282cf0732fa659f62a9d24f3eb.tar.gz
android_packages_apps_Gallery2-9ee99847b28e9a282cf0732fa659f62a9d24f3eb.tar.bz2
android_packages_apps_Gallery2-9ee99847b28e9a282cf0732fa659f62a9d24f3eb.zip
Restrict checking for device flip
Bug: 8714114 Change-Id: Ic12627fe5b7512c8d5739ed801130d52f33407cc
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/ui/CameraControls.java25
-rw-r--r--src/com/android/camera/ui/RotatableLayout.java2
2 files changed, 20 insertions, 7 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();
diff --git a/src/com/android/camera/ui/RotatableLayout.java b/src/com/android/camera/ui/RotatableLayout.java
index 2dea58d9d..8355c8826 100644
--- a/src/com/android/camera/ui/RotatableLayout.java
+++ b/src/com/android/camera/ui/RotatableLayout.java
@@ -82,7 +82,7 @@ public class RotatableLayout extends FrameLayout {
super.onConfigurationChanged(config);
int rotation = Util.getDisplayRotation((Activity) getContext());
if ((rotation - mPrevRotation + 360) % 180 == 0) {
- flipChildren();
+ mPrevRotation = rotation;
return;
}
boolean clockwise = isClockWiseRotation(mPrevRotation, rotation);