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

Commit 24870ce4 authored by Mindy Pereira's avatar Mindy Pereira
Browse files

Scale feels too quick in relation to movement

Reduce scale factor in relation to amount of y movement

Change-Id: Iaf351edb2eb1a67f542aa9b3aa3587fc231f8c5c
parent 0c58bd97
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -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;


    /**
@@ -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;
@@ -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;
    }