diff options
author | Chih-Chung Chang <chihchung@google.com> | 2012-05-22 11:35:46 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-05-22 19:36:28 -0700 |
commit | b9e6e7f1dffe3d4e4736ed67a323f11a174afbb1 (patch) | |
tree | e0efc6b433d4e440d3dc6212a94a792fc95ae548 /src/com/android/gallery3d/ui | |
parent | 048ca675a9e659fb0d3b150880d71cd42770023d (diff) | |
download | android_packages_apps_Snap-b9e6e7f1dffe3d4e4736ed67a323f11a174afbb1.tar.gz android_packages_apps_Snap-b9e6e7f1dffe3d4e4736ed67a323f11a174afbb1.tar.bz2 android_packages_apps_Snap-b9e6e7f1dffe3d4e4736ed67a323f11a174afbb1.zip |
Unlock orientation only when action bar is needed.
Bug: 6482079
Change-Id: I75d96ca7957f80e9c52f35edf74127f82f194f63
Diffstat (limited to 'src/com/android/gallery3d/ui')
-rw-r--r-- | src/com/android/gallery3d/ui/PhotoView.java | 63 | ||||
-rw-r--r-- | src/com/android/gallery3d/ui/PositionController.java | 17 |
2 files changed, 34 insertions, 46 deletions
diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java index a15dd612c..4490569bb 100644 --- a/src/com/android/gallery3d/ui/PhotoView.java +++ b/src/com/android/gallery3d/ui/PhotoView.java @@ -90,33 +90,25 @@ public class PhotoView extends GLView { public void unlockOrientation(); public void onFullScreenChanged(boolean full); public void onActionBarAllowed(boolean allowed); + public void onActionBarWanted(); public void onCurrentImageUpdated(); } - // Here is a graph showing the places we need to lock/unlock device - // orientation: + // The rules about orientation locking: // - // +------------+ A +------------+ - // Page mode | Camera |<---| Photo | - // | [locked] |--->| [unlocked] | - // +------------+ B +------------+ - // ^ ^ - // | C | D - // +------------+ +------------+ - // | Camera | | Photo | - // Film mode | [*] | | [*] | - // +------------+ +------------+ + // (1) We need to lock the orientation if we are in page mode camera + // preview, so there is no (unwanted) rotation animation when the user + // rotates the device. // - // In Page mode, we want to lock in Camera because we don't want the system - // rotation animation. We also want to unlock in Photo because we want to - // show the system action bar in the right place. + // (2) We need to unlock the orientation if we want to show the action bar + // because the action bar follows the system orientation. // - // We don't show action bar in Film mode, so it's fine for it to be locked - // or unlocked in Film mode. + // The rules about action bar: // - // There are four transitions we need to check if we need to - // lock/unlock. Marked as A to D above and in the code. - + // (1) If we are in film mode, we don't show action bar. + // + // (2) If we go from camera to gallery with capture animation, we show + // action bar. private static final int MSG_CANCEL_EXTRA_SCALING = 2; private static final int MSG_SWITCH_FOCUS = 3; private static final int MSG_CAPTURE_ANIMATION_DONE = 4; @@ -457,14 +449,9 @@ public class PhotoView extends GLView { setFilmMode(false); } - if (isCenter && !mFilmMode) { - if (mIsCamera) { - // move into camera, lock - mListener.lockOrientation(); // Transition A - } else { - // move out of camera, unlock - mListener.unlockOrientation(); // Transition B - } + if (isCenter && !mFilmMode && mIsCamera) { + // Move into camera in page mode, lock + mListener.lockOrientation(); } mWasCameraCenter = isCameraCenter; @@ -931,13 +918,9 @@ public class PhotoView extends GLView { mModel.setNeedFullImage(!enabled); mListener.onActionBarAllowed(!enabled); - // If we leave filmstrip mode, we should lock/unlock - if (!enabled) { - if (mPictures.get(0).isCamera()) { - mListener.lockOrientation(); // Transition C - } else { - mListener.unlockOrientation(); // Transition D - } + // Move into camera in page mode, lock + if (!enabled && mPictures.get(0).isCamera()) { + mListener.lockOrientation(); } } @@ -1209,12 +1192,10 @@ public class PhotoView extends GLView { private void captureAnimationDone(int offset) { mHolding &= ~HOLD_CAPTURE_ANIMATION; - if (offset == 1) { - // move out of camera, unlock - if (!mFilmMode) { - // Now the capture animation is done, enable the action bar. - mListener.onActionBarAllowed(true); - } + if (offset == 1 && !mFilmMode) { + // Now the capture animation is done, enable the action bar. + mListener.onActionBarAllowed(true); + mListener.onActionBarWanted(); } snapback(); } diff --git a/src/com/android/gallery3d/ui/PositionController.java b/src/com/android/gallery3d/ui/PositionController.java index bb2b83ecb..d085c4d49 100644 --- a/src/com/android/gallery3d/ui/PositionController.java +++ b/src/com/android/gallery3d/ui/PositionController.java @@ -209,8 +209,13 @@ class PositionController { } updateScaleAndGapLimit(); - startOpeningAnimationIfNeeded(); - snapAndRedraw(); + + // If we have the opening animation, do it. Otherwise go directly to the + // right position. + if (!startOpeningAnimationIfNeeded()) { + snapAndRedraw(); + skipAnimation(); + } } public void setConstrainedFrame(Rect f) { @@ -280,10 +285,10 @@ class PositionController { return true; } - private void startOpeningAnimationIfNeeded() { - if (mOpenAnimationRect == null) return; + private boolean startOpeningAnimationIfNeeded() { + if (mOpenAnimationRect == null) return false; Box b = mBoxes.get(0); - if (b.mUseViewSize) return; + if (b.mUseViewSize) return false; // Start animation from the saved rectangle if we have one. Rect r = mOpenAnimationRect; @@ -303,6 +308,8 @@ class PositionController { g.mCurrentGap = mViewW; g.doAnimation(g.mDefaultSize, ANIM_KIND_OPENING); } + + return true; } public void setFilmMode(boolean enabled) { |