Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3878b786 authored by Mindy Pereira's avatar Mindy Pereira Committed by Android Git Automerger
Browse files

am 21497c5f: am af2d8bbd: Merge "Scale feels too quick in relation to movement" into klp-dev

* commit '21497c5f':
  Scale feels too quick in relation to movement
parents b203dc13 21497c5f
Loading
Loading
Loading
Loading
+12 −5
Original line number Original line Diff line number Diff line
@@ -159,6 +159,7 @@ public class ScaleGestureDetector {
    private static final long TOUCH_STABILIZE_TIME = 128; // ms
    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_NONE = 0;
    private static final int DOUBLE_TAP_MODE_IN_PROGRESS = 1;
    private static final int DOUBLE_TAP_MODE_IN_PROGRESS = 1;
    private static final float SCALE_FACTOR = .5f;




    /**
    /**
@@ -409,7 +410,9 @@ public class ScaleGestureDetector {
            mPrevSpanY = mCurrSpanY = spanY;
            mPrevSpanY = mCurrSpanY = spanY;
            mInitialSpan = mPrevSpan = mCurrSpan = span;
            mInitialSpan = mPrevSpan = mCurrSpan = span;
        }
        }
        if (!mInProgress && span >= mMinSpan &&

        final int minSpan = inDoubleTapMode() ? mSpanSlop : mMinSpan;
        if (!mInProgress && span >=  minSpan &&
                (wasInProgress || Math.abs(span - mInitialSpan) > mSpanSlop)) {
                (wasInProgress || Math.abs(span - mInitialSpan) > mSpanSlop)) {
            mPrevSpanX = mCurrSpanX = spanX;
            mPrevSpanX = mCurrSpanX = spanX;
            mPrevSpanY = mCurrSpanY = spanY;
            mPrevSpanY = mCurrSpanY = spanY;
@@ -572,11 +575,15 @@ public class ScaleGestureDetector {
     * @return The current scaling factor.
     * @return The current scaling factor.
     */
     */
    public float getScaleFactor() {
    public float getScaleFactor() {
        if (inDoubleTapMode() && mEventBeforeOrAboveStartingGestureEvent) {
        if (inDoubleTapMode()) {
            // Drag is moving up; the further away from the gesture
            // Drag is moving up; the further away from the gesture
            // start, the smaller the span should be, the closer,
            // start, the smaller the span should be, the closer,
            // the larger the span, and therefore the larger the scale
            // 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;
        return mPrevSpan > 0 ? mCurrSpan / mPrevSpan : 1;
    }
    }