summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2012-06-18 10:35:57 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-06-18 10:35:57 -0700
commit3772856152d4e404f4f9486d6026adb9fc66bf76 (patch)
treec2132a525ebb41dbe481a210e004f3725b127f8c /src
parent01244eaf188a7f02954b7b269a3efd9330dbc69b (diff)
parent8d84cc6d45b956b3ed52ba2a1c5ea49105f047cc (diff)
downloadandroid_packages_apps_Snap-3772856152d4e404f4f9486d6026adb9fc66bf76.tar.gz
android_packages_apps_Snap-3772856152d4e404f4f9486d6026adb9fc66bf76.tar.bz2
android_packages_apps_Snap-3772856152d4e404f4f9486d6026adb9fc66bf76.zip
am 2ce59cbd: Fix scaling gesture responsiveness.
* commit '2ce59cbd4368eaf0f30cfea28891bd47155182cb': Fix scaling gesture responsiveness.
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/ui/PhotoView.java21
-rw-r--r--src/com/android/gallery3d/ui/PositionController.java2
2 files changed, 16 insertions, 7 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;
diff --git a/src/com/android/gallery3d/ui/PositionController.java b/src/com/android/gallery3d/ui/PositionController.java
index 2b91fcbfe..d556cafdc 100644
--- a/src/com/android/gallery3d/ui/PositionController.java
+++ b/src/com/android/gallery3d/ui/PositionController.java
@@ -62,7 +62,7 @@ class PositionController {
// (always 1).
private static final int ANIM_TIME[] = {
0, // ANIM_KIND_SCROLL
- 50, // ANIM_KIND_SCALE
+ 0, // ANIM_KIND_SCALE
SNAPBACK_ANIMATION_TIME, // ANIM_KIND_SNAPBACK
400, // ANIM_KIND_SLIDE
300, // ANIM_KIND_ZOOM