diff options
author | Chih-Chung Chang <chihchung@google.com> | 2012-05-02 05:55:48 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-05-02 05:55:48 -0700 |
commit | 81de7b34f669073ccfbe96504d16c74d6467eecb (patch) | |
tree | fb164a31af0789b5e8d4368f192c226920883930 | |
parent | f9c34e21b209b2dda131a26a4dd09096eaeb4277 (diff) | |
parent | b0c6de54e6555c6be9f13c362aaeae63dc18023d (diff) | |
download | android_packages_apps_Gallery2-81de7b34f669073ccfbe96504d16c74d6467eecb.tar.gz android_packages_apps_Gallery2-81de7b34f669073ccfbe96504d16c74d6467eecb.tar.bz2 android_packages_apps_Gallery2-81de7b34f669073ccfbe96504d16c74d6467eecb.zip |
am b0c6de54: am 33f8567d: Fix the Camera controls disappearing after zooming problem.
* commit 'b0c6de54e6555c6be9f13c362aaeae63dc18023d':
Fix the Camera controls disappearing after zooming problem.
-rw-r--r-- | src/com/android/gallery3d/app/PhotoPage.java | 2 | ||||
-rw-r--r-- | src/com/android/gallery3d/ui/PhotoView.java | 38 |
2 files changed, 32 insertions, 8 deletions
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index d7936e24f..1851b976c 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -712,7 +712,7 @@ public class PhotoPage extends ActivityState implements onUserInteraction(); if (mAppBridge != null) { mAppBridge.setServer(this); - mModel.moveTo(0); // move to the camera preview after resume + mPhotoView.resetToFirstPicture(); } } diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java index b54a685d4..c6b370d74 100644 --- a/src/com/android/gallery3d/ui/PhotoView.java +++ b/src/com/android/gallery3d/ui/PhotoView.java @@ -737,6 +737,8 @@ public class PhotoView extends GLView { private boolean mCanChangeMode; // If we have changed the film mode in this scaling gesture. private boolean mModeChanged; + // If this scaling gesture should be ignored. + private boolean mIgnoreScalingGesture; @Override public boolean onSingleTapUp(float x, float y) { @@ -784,6 +786,11 @@ public class PhotoView extends GLView { @Override public boolean onScaleBegin(float focusX, float focusY) { + // We ignore the scaling gesture if it is a camera preview. + mIgnoreScalingGesture = mPictures.get(0).isCamera(); + if (mIgnoreScalingGesture) { + return true; + } mPositionController.beginScale(focusX, focusY); // We can change mode if we are in film mode, or we are in page // mode and at minimal scale. @@ -795,9 +802,17 @@ public class PhotoView extends GLView { @Override public boolean onScale(float focusX, float focusY, float scale) { + if (mIgnoreScalingGesture) { + return true; + } if (mModeChanged) return true; if (Float.isNaN(scale) || Float.isInfinite(scale)) return false; + + // We wait for the scale change accumulated to a large enough change + // before reacting to it. Otherwise we may mistakenly treat a + // zoom-in gesture as zoom-out or vice versa. if (scale > 0.99f && scale < 1.01f) return false; + int outOfRange = mPositionController.scaleBy(scale, focusX, focusY); // If mode changes, we treat this scaling gesture has ended. @@ -807,7 +822,7 @@ public class PhotoView extends GLView { stopExtraScalingIfNeeded(); // Removing the touch down flag allows snapback to happen - // for file mode change. + // for film mode change. mHolding &= ~HOLD_TOUCH_DOWN; setFilmMode(!mFilmMode); @@ -827,6 +842,15 @@ public class PhotoView extends GLView { return true; } + @Override + public void onScaleEnd() { + if (mIgnoreScalingGesture) { + return; + } + if (mModeChanged) return; + mPositionController.endScale(); + } + private void startExtraScalingIfNeeded() { if (!mCancelExtraScalingPending) { mHandler.sendEmptyMessageDelayed( @@ -845,12 +869,6 @@ public class PhotoView extends GLView { } @Override - public void onScaleEnd() { - if (mModeChanged) return; - mPositionController.endScale(); - } - - @Override public void onDown() { mHolding |= HOLD_TOUCH_DOWN; } @@ -905,6 +923,12 @@ public class PhotoView extends GLView { mTileView.prepareTextures(); } + // move to the camera preview and show controls after resume + public void resetToFirstPicture() { + mModel.moveTo(0); + setFilmMode(false); + } + //////////////////////////////////////////////////////////////////////////// // Rendering //////////////////////////////////////////////////////////////////////////// |