diff options
author | Mindy Pereira <mindyp@google.com> | 2013-09-09 15:56:23 -0700 |
---|---|---|
committer | Mindy Pereira <mindyp@google.com> | 2013-09-09 18:06:19 -0700 |
commit | 24870ce4f222fec664a24e47cf6b12db36dbdff2 (patch) | |
tree | fc4cac8cd579058eec354ef2f3d33cf9c6885b02 /core | |
parent | 0c58bd97384498be14aa9795be9188ca93110e00 (diff) | |
download | frameworks_base-24870ce4f222fec664a24e47cf6b12db36dbdff2.zip frameworks_base-24870ce4f222fec664a24e47cf6b12db36dbdff2.tar.gz frameworks_base-24870ce4f222fec664a24e47cf6b12db36dbdff2.tar.bz2 |
Scale feels too quick in relation to movement
Reduce scale factor in relation to amount of y movement
Change-Id: Iaf351edb2eb1a67f542aa9b3aa3587fc231f8c5c
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/view/ScaleGestureDetector.java | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/core/java/android/view/ScaleGestureDetector.java b/core/java/android/view/ScaleGestureDetector.java index 0bebc04..a0d39ca 100644 --- a/core/java/android/view/ScaleGestureDetector.java +++ b/core/java/android/view/ScaleGestureDetector.java @@ -159,6 +159,7 @@ public class ScaleGestureDetector { private static final long TOUCH_STABILIZE_TIME = 128; // ms private static final int DOUBLE_TAP_MODE_NONE = 0; private static final int DOUBLE_TAP_MODE_IN_PROGRESS = 1; + private static final float SCALE_FACTOR = .5f; /** @@ -197,7 +198,7 @@ public class ScaleGestureDetector { * @throws NullPointerException if {@code listener} is null. */ public ScaleGestureDetector(Context context, OnScaleGestureListener listener, - Handler handler) { + Handler handler) { mContext = context; mListener = listener; mSpanSlop = ViewConfiguration.get(context).getScaledTouchSlop() * 2; @@ -409,7 +410,9 @@ public class ScaleGestureDetector { mPrevSpanY = mCurrSpanY = spanY; mInitialSpan = mPrevSpan = mCurrSpan = span; } - if (!mInProgress && span >= mMinSpan && + + final int minSpan = inDoubleTapMode() ? mSpanSlop : mMinSpan; + if (!mInProgress && span >= minSpan && (wasInProgress || Math.abs(span - mInitialSpan) > mSpanSlop)) { mPrevSpanX = mCurrSpanX = spanX; mPrevSpanY = mCurrSpanY = spanY; @@ -464,7 +467,7 @@ public class ScaleGestureDetector { mDoubleTapMode = DOUBLE_TAP_MODE_IN_PROGRESS; return true; } - }; + }; mGestureDetector = new GestureDetector(mContext, gestureListener, mHandler); } } @@ -572,11 +575,15 @@ public class ScaleGestureDetector { * @return The current scaling factor. */ public float getScaleFactor() { - if (inDoubleTapMode() && mEventBeforeOrAboveStartingGestureEvent) { + if (inDoubleTapMode()) { // Drag is moving up; the further away from the gesture // start, the smaller the span should be, the closer, // the larger the span, and therefore the larger the scale - return (1 / mCurrSpan) / (1 / mPrevSpan); + final boolean scaleUp = + (mEventBeforeOrAboveStartingGestureEvent && (mCurrSpan < mPrevSpan)) || + (!mEventBeforeOrAboveStartingGestureEvent && (mCurrSpan > mPrevSpan)); + final float spanDiff = (Math.abs(1 - (mCurrSpan / mPrevSpan)) * SCALE_FACTOR); + return mPrevSpan <= 0 ? 1 : scaleUp ? (1 + spanDiff) : (1 - spanDiff); } return mPrevSpan > 0 ? mCurrSpan / mPrevSpan : 1; } |