summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/ui/PhotoView.java
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2012-06-18 17:24:58 +0800
committerChih-Chung Chang <chihchung@google.com>2012-06-18 18:00:00 +0800
commit2ce59cbd4368eaf0f30cfea28891bd47155182cb (patch)
tree602540119732b5418401ce05de7a4e74edd19db2 /src/com/android/gallery3d/ui/PhotoView.java
parent6b891c6a3739f8c49d42f9db6fc76cb92c7c5f25 (diff)
downloadandroid_packages_apps_Gallery2-2ce59cbd4368eaf0f30cfea28891bd47155182cb.tar.gz
android_packages_apps_Gallery2-2ce59cbd4368eaf0f30cfea28891bd47155182cb.tar.bz2
android_packages_apps_Gallery2-2ce59cbd4368eaf0f30cfea28891bd47155182cb.zip
Fix scaling gesture responsiveness.
Bug: 6632011 Change-Id: I9cfeafa4365354a631565f8ee4a9b53df76d06e9
Diffstat (limited to 'src/com/android/gallery3d/ui/PhotoView.java')
-rw-r--r--src/com/android/gallery3d/ui/PhotoView.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java
index 6aace393f..3fba261fb 100644
--- a/src/com/android/gallery3d/ui/PhotoView.java
+++ b/src/com/android/gallery3d/ui/PhotoView.java
@@ -885,6 +885,8 @@ public class PhotoView extends GLView {
private boolean mModeChanged;
// If this scaling gesture should be ignored.
private boolean mIgnoreScalingGesture;
+ // If we have seen a scaling gesture.
+ private boolean mSeenScaling;
// whether the down action happened while the view is scrolling.
private boolean mDownInScrolling;
// If we should ignore all gestures other than onSingleTapUp.
@@ -897,6 +899,8 @@ public class PhotoView extends GLView {
private boolean mFirstScrollX;
// The accumulated Y delta that has been sent to mPositionController.
private int mDeltaY;
+ // The accumulated scaling change from a scaling gesture.
+ private float mAccScale;
@Override
public boolean onSingleTapUp(float x, float y) {
@@ -987,6 +991,7 @@ public class PhotoView extends GLView {
@Override
public boolean onFling(float velocityX, float velocityY) {
if (mIgnoreSwipingGesture) return true;
+ if (mSeenScaling) return true;
if (swipeImages(velocityX, velocityY)) {
mIgnoreUpEvent = true;
} else {
@@ -1057,6 +1062,8 @@ public class PhotoView extends GLView {
mCanChangeMode = mFilmMode
|| mPositionController.isAtMinimalScale();
mModeChanged = false;
+ mSeenScaling = true;
+ mAccScale = 1f;
return true;
}
@@ -1067,15 +1074,16 @@ public class PhotoView extends GLView {
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);
+ // We wait for a large enough scale change before changing mode.
+ // Otherwise we may mistakenly treat a zoom-in gesture as zoom-out
+ // or vice versa.
+ mAccScale *= scale;
+ boolean largeEnough = (mAccScale < 0.97f || mAccScale > 1.03f);
+
// If mode changes, we treat this scaling gesture has ended.
- if (mCanChangeMode) {
+ if (mCanChangeMode && largeEnough) {
if ((outOfRange < 0 && !mFilmMode) ||
(outOfRange > 0 && mFilmMode)) {
stopExtraScalingIfNeeded();
@@ -1129,6 +1137,7 @@ public class PhotoView extends GLView {
@Override
public void onDown(float x, float y) {
mDeltaY = 0;
+ mSeenScaling = false;
mListener.onCommitDeleteImage();
if (mIgnoreSwipingGesture) return;