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

Commit 3a89e422 authored by Tony Wickham's avatar Tony Wickham
Browse files

Don't detach recents from app window after motion pause

- Update MotionPauseListener to have 2 methods: the existing
  onMotionPauseChanged(isPaused) and onMotionPauseDetected()
  - onMotionPauseDetected is the default as most listeners only
    care about the first detected pause
  - AbsSwipeUpHandler still listens to pause changes, to help
    determine the end target at the end of the gesture

Bug: 159089437
Change-Id: I6d14f106cdcbe4e07d8dddba1cee909a963615b1
parent 1aee9da5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch
        mMotionPauseDetector.clear();

        if (handlingOverviewAnim()) {
            mMotionPauseDetector.setOnMotionPauseListener(this::onMotionPauseChanged);
            mMotionPauseDetector.setOnMotionPauseListener(this::onMotionPauseDetected);
        }

        if (mFromState == NORMAL && mToState == HINT_STATE) {
@@ -185,7 +185,7 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch
        }
    }

    private void onMotionPauseChanged(boolean isPaused) {
    private void onMotionPauseDetected() {
        if (mCurrentAnimation == null) {
            return;
        }
+3 −4
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ import com.android.quickstep.views.LauncherRecentsView;
 * the user as possible, also handles swipe up and hold to go to overview and swiping back home.
 */
public class NoButtonQuickSwitchTouchController implements TouchController,
        BothAxesSwipeDetector.Listener, MotionPauseDetector.OnMotionPauseListener {
        BothAxesSwipeDetector.Listener {

    /** The minimum progress of the scale/translationY animation until drag end. */
    private static final float Y_ANIM_MIN_PROGRESS = 0.25f;
@@ -167,7 +167,7 @@ public class NoButtonQuickSwitchTouchController implements TouchController,
        if (start) {
            mStartState = mLauncher.getStateManager().getState();

            mMotionPauseDetector.setOnMotionPauseListener(this);
            mMotionPauseDetector.setOnMotionPauseListener(this::onMotionPauseDetected);

            // We have detected horizontal drag start, now allow swipe up as well.
            mSwipeDetector.setDetectableScrollConditions(DIRECTION_RIGHT | DIRECTION_UP,
@@ -177,8 +177,7 @@ public class NoButtonQuickSwitchTouchController implements TouchController,
        }
    }

    @Override
    public void onMotionPauseChanged(boolean isPaused) {
    private void onMotionPauseDetected() {
        VibratorWrapper.INSTANCE.get(mLauncher).vibrate(OVERVIEW_HAPTIC);
    }

+17 −8
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ import com.android.quickstep.util.ActiveGestureLog;
import com.android.quickstep.util.ActivityInitListener;
import com.android.quickstep.util.AnimatorControllerWithResistance;
import com.android.quickstep.util.InputConsumerProxy;
import com.android.quickstep.util.MotionPauseDetector;
import com.android.quickstep.util.RectFSpringAnim;
import com.android.quickstep.util.SurfaceTransactionApplier;
import com.android.quickstep.util.TransformParams;
@@ -201,6 +202,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<?>, Q extends
    // Either RectFSpringAnim (if animating home) or ObjectAnimator (from mCurrentShift) otherwise
    private RunningWindowAnim mRunningWindowAnim;
    private boolean mIsMotionPaused;
    private boolean mHasMotionEverBeenPaused;

    private boolean mContinuingLastGesture;

@@ -482,15 +484,22 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<?>, Q extends
                .getHighResLoadingState().setVisible(true);
    }

    /**
     * Called when motion pause is detected
     */
    public void onMotionPauseChanged(boolean isPaused) {
        mIsMotionPaused = isPaused;
    public MotionPauseDetector.OnMotionPauseListener getMotionPauseListener() {
        return new MotionPauseDetector.OnMotionPauseListener() {
            @Override
            public void onMotionPauseDetected() {
                mHasMotionEverBeenPaused = true;
                maybeUpdateRecentsAttachedState();
                performHapticFeedback();
            }

            @Override
            public void onMotionPauseChanged(boolean isPaused) {
                mIsMotionPaused = isPaused;
            }
        };
    }

    public void maybeUpdateRecentsAttachedState() {
        maybeUpdateRecentsAttachedState(true /* animate */);
    }
@@ -519,7 +528,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<?>, Q extends
            // The window is going away so make sure recents is always visible in this case.
            recentsAttachedToAppWindow = true;
        } else {
            recentsAttachedToAppWindow = mIsMotionPaused || mIsLikelyToStartNewTask;
            recentsAttachedToAppWindow = mHasMotionEverBeenPaused || mIsLikelyToStartNewTask;
        }
        mAnimationFactory.setRecentsAttachedToAppWindow(recentsAttachedToAppWindow, animate);

+2 −2
Original line number Diff line number Diff line
@@ -52,9 +52,9 @@ import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.TraceHelper;
import com.android.quickstep.BaseActivityInterface;
import com.android.quickstep.AbsSwipeUpHandler;
import com.android.quickstep.AbsSwipeUpHandler.Factory;
import com.android.quickstep.BaseActivityInterface;
import com.android.quickstep.GestureState;
import com.android.quickstep.InputConsumer;
import com.android.quickstep.RecentsAnimationCallbacks;
@@ -365,7 +365,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
        mInteractionHandler = mHandlerFactory.newHandler(mGestureState, touchTimeMs,
                mTaskAnimationManager.isRecentsAnimationRunning());
        mInteractionHandler.setGestureEndCallback(this::onInteractionGestureFinished);
        mMotionPauseDetector.setOnMotionPauseListener(mInteractionHandler::onMotionPauseChanged);
        mMotionPauseDetector.setOnMotionPauseListener(mInteractionHandler.getMotionPauseListener());
        Intent intent = new Intent(mInteractionHandler.getLaunchIntent());
        mInteractionHandler.initWhenReady(intent);

+9 −11
Original line number Diff line number Diff line
@@ -42,8 +42,7 @@ public class ScreenPinnedInputConsumer implements InputConsumer {
        mMotionPauseMinDisplacement = context.getResources().getDimension(
                R.dimen.motion_pause_detector_min_displacement_from_app);
        mMotionPauseDetector = new MotionPauseDetector(context, true /* makePauseHarderToTrigger*/);
        mMotionPauseDetector.setOnMotionPauseListener(isPaused -> {
            if (isPaused) {
        mMotionPauseDetector.setOnMotionPauseListener(() -> {
            SystemUiProxy.INSTANCE.get(context).stopScreenPinning();
            BaseDraggingActivity launcherActivity = gestureState.getActivityInterface()
                    .getCreatedActivity();
@@ -53,7 +52,6 @@ public class ScreenPinnedInputConsumer implements InputConsumer {
                        HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
            }
            mMotionPauseDetector.clear();
            }
        });
    }

Loading