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

Commit bbe2f4aa authored by Winson's avatar Winson Committed by android-build-merger
Browse files

Merge "Preventing users from over scrolling too far." into nyc-dev

am: fbc32f15

* commit 'fbc32f15':
  Preventing users from over scrolling too far.
parents 6efbd973 fbc32f15
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -916,11 +916,11 @@ public class TaskStackLayoutAlgorithm {
        float peekHeightPct = (float) mFocusedTopPeekHeight / mStackRect.height();
        float slope = ((1f - peekHeightPct) - cpoint1Y) / (0.5f - cpoint1X);
        float b = 1f - slope * cpoint1X;
        float cpoint2X = 0.75f;
        float cpoint2X = 0.65f;
        float cpoint2Y = slope * cpoint2X + b;
        Path p = new Path();
        p.moveTo(0f, 1f);
        p.cubicTo(0f, 1f, cpoint1X, 1f, 0.5f, 1f - peekHeightPct);
        p.cubicTo(0f, 1f, cpoint1X, cpoint1Y, 0.5f, 1f - peekHeightPct);
        p.cubicTo(0.5f, 1f - peekHeightPct, cpoint2X, cpoint2Y, 1f, 0f);
        return p;
    }
+24 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.animation.Animator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Path;
import android.graphics.Rect;
import android.util.ArrayMap;
import android.util.MutableBoolean;
@@ -44,6 +45,7 @@ import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.HideRecentsEvent;
import com.android.systemui.recents.events.ui.StackViewScrolledEvent;
import com.android.systemui.recents.events.ui.TaskViewDismissedEvent;
import com.android.systemui.recents.misc.FreePathInterpolator;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.misc.Utilities;
import com.android.systemui.recents.model.Task;
@@ -60,6 +62,16 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
    private static final int INACTIVE_POINTER_ID = -1;
    private static final Interpolator STACK_TRANSFORM_INTERPOLATOR =
            new PathInterpolator(0.73f, 0.33f, 0.42f, 0.85f);
    // The min overscroll is the amount of task progress overscroll we want / the max overscroll
    // curve value below
    private static final float MAX_OVERSCROLL = 0.7f / 0.3f;
    private static final Interpolator OVERSCROLL_INTERP;
    static {
        Path OVERSCROLL_PATH = new Path();
        OVERSCROLL_PATH.moveTo(0, 0);
        OVERSCROLL_PATH.cubicTo(0.2f, 0.175f, 0.25f, 0.3f, 1f, 0.3f);
        OVERSCROLL_INTERP = new FreePathInterpolator(OVERSCROLL_PATH);
    }

    Context mContext;
    TaskStackView mSv;
@@ -245,6 +257,18 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
                    // of the curve, so just move the scroll proportional to that
                    float deltaP = layoutAlgorithm.getDeltaPForY(mDownY, y);
                    float curScrollP = mDownScrollP + deltaP;

                    // Modulate the overscroll to prevent users from pulling the stack too far
                    float minScrollP = layoutAlgorithm.mMinScrollP;
                    float maxScrollP = layoutAlgorithm.mMaxScrollP;
                    if (curScrollP < minScrollP || curScrollP > maxScrollP) {
                        float clampedScrollP = Utilities.clamp(curScrollP, minScrollP, maxScrollP);
                        float overscrollP = (curScrollP - clampedScrollP);
                        float overscrollX = Math.abs(overscrollP) / MAX_OVERSCROLL;
                        curScrollP = clampedScrollP + (Math.signum(overscrollP) *
                                (OVERSCROLL_INTERP.getInterpolation(overscrollX) * MAX_OVERSCROLL));
                    }

                    mScroller.setStackScroll(curScrollP);
                    mStackViewScrolledEvent.updateY(y - mLastY);
                    EventBus.getDefault().send(mStackViewScrolledEvent);