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

Commit 17312c35 authored by Tony Wickham's avatar Tony Wickham
Browse files

Keep recents attached to app window on continued switching

- LAST_TASK now has recentsAttachedToAppWindow = true, to match
  NEW_TASK. Though this does mean there's a small chance of
  seeing recents translating in if you swipe up and back down,
  this is preferable to seeing recents translate away if you
  swipe right and back left in two consecutive gestures.
- Until passing the touch slop for a new gesture, keep recents
  attached to the app window. This avoids cases where you
  could have recents view translate away mid-gesture, such as
  in the following case: swipe from A to B, swipe from B back
  to A, touch down during the transition back to A. Before this
  change, you would see recents translate away; with this
  change, recents instead stays in place until we get another
  signal indicating it should detach, such as swiping to home.

Bug: 157153404
Change-Id: I63a3a8b988af1aac5177f101b0b75e73e56b1ceb
parent 517cec53
Loading
Loading
Loading
Loading
+15 −3
Original line number Original line Diff line number Diff line
@@ -112,6 +112,9 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
    private boolean mPassedWindowMoveSlop;
    private boolean mPassedWindowMoveSlop;
    // Slop used to determine when we say that the gesture has started.
    // Slop used to determine when we say that the gesture has started.
    private boolean mPassedPilferInputSlop;
    private boolean mPassedPilferInputSlop;
    // Same as mPassedPilferInputSlop, except when continuing a gesture mPassedPilferInputSlop is
    // initially true while this one is false.
    private boolean mPassedSlopOnThisGesture;


    // Might be displacement in X or Y, depending on the direction we are swiping from the nav bar.
    // Might be displacement in X or Y, depending on the direction we are swiping from the nav bar.
    private float mStartDisplacement;
    private float mStartDisplacement;
@@ -244,6 +247,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
                mLastPos.set(ev.getX(pointerIndex), ev.getY(pointerIndex));
                mLastPos.set(ev.getX(pointerIndex), ev.getY(pointerIndex));
                float displacement = getDisplacement(ev);
                float displacement = getDisplacement(ev);
                float displacementX = mLastPos.x - mDownPos.x;
                float displacementX = mLastPos.x - mDownPos.x;
                float displacementY = mLastPos.y - mDownPos.y;


                if (!mPassedWindowMoveSlop) {
                if (!mPassedWindowMoveSlop) {
                    if (!mIsDeferredDownTarget) {
                    if (!mIsDeferredDownTarget) {
@@ -258,11 +262,18 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC


                float horizontalDist = Math.abs(displacementX);
                float horizontalDist = Math.abs(displacementX);
                float upDist = -displacement;
                float upDist = -displacement;
                boolean isLikelyToStartNewTask = horizontalDist > upDist;
                boolean passedSlop = squaredHypot(displacementX, displacementY)
                        >= mSquaredTouchSlop;
                if (!mPassedSlopOnThisGesture && passedSlop) {
                    mPassedSlopOnThisGesture = true;
                }
                // Until passing slop, we don't know what direction we're going, so assume we might
                // be quick switching to avoid translating recents away when continuing the gesture.
                boolean isLikelyToStartNewTask = !mPassedSlopOnThisGesture
                        || horizontalDist > upDist;


                if (!mPassedPilferInputSlop) {
                if (!mPassedPilferInputSlop) {
                    float displacementY = mLastPos.y - mDownPos.y;
                    if (passedSlop) {
                    if (squaredHypot(displacementX, displacementY) >= mSquaredTouchSlop) {
                        if (mDisableHorizontalSwipe
                        if (mDisableHorizontalSwipe
                                && Math.abs(displacementX) > Math.abs(displacementY)) {
                                && Math.abs(displacementX) > Math.abs(displacementY)) {
                            // Horizontal gesture is not allowed in this region
                            // Horizontal gesture is not allowed in this region
@@ -339,6 +350,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
            mActiveCallbacks = mTaskAnimationManager.continueRecentsAnimation(mGestureState);
            mActiveCallbacks = mTaskAnimationManager.continueRecentsAnimation(mGestureState);
            mActiveCallbacks.addListener(mInteractionHandler);
            mActiveCallbacks.addListener(mInteractionHandler);
            mTaskAnimationManager.notifyRecentsAnimationState(mInteractionHandler);
            mTaskAnimationManager.notifyRecentsAnimationState(mInteractionHandler);
            mInteractionHandler.setIsLikelyToStartNewTask(true);
            notifyGestureStarted();
            notifyGestureStarted();
        } else {
        } else {
            intent.putExtra(INTENT_EXTRA_LOG_TRACE_ID, mGestureState.getGestureId());
            intent.putExtra(INTENT_EXTRA_LOG_TRACE_ID, mGestureState.getGestureId());
+1 −1
Original line number Original line Diff line number Diff line
@@ -47,7 +47,7 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL


        NEW_TASK(false, ContainerType.APP, true),
        NEW_TASK(false, ContainerType.APP, true),


        LAST_TASK(false, ContainerType.APP, false);
        LAST_TASK(false, ContainerType.APP, true);


        GestureEndTarget(boolean isLauncher, int containerType,
        GestureEndTarget(boolean isLauncher, int containerType,
                boolean recentsAttachedToAppWindow) {
                boolean recentsAttachedToAppWindow) {