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

Commit 6a550f26 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Using FallbackSwipeHandler in 2-button mode" into ub-launcher3-master

parents 0abe8199 fa617d89
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ public abstract class BaseSwipeUpHandler<T extends BaseDraggingActivity, Q exten
    private static final String TAG = "BaseSwipeUpHandler";
    protected static final Rect TEMP_RECT = new Rect();

    public static final float MIN_PROGRESS_FOR_OVERVIEW = 0.7f;
    private static final Interpolator PULLBACK_INTERPOLATOR = DEACCEL;

    // The distance needed to drag to reach the task size in recents.
+35 −14
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import static com.android.quickstep.GestureState.GestureEndTarget.HOME;
import static com.android.quickstep.GestureState.GestureEndTarget.LAST_TASK;
import static com.android.quickstep.GestureState.GestureEndTarget.NEW_TASK;
import static com.android.quickstep.GestureState.GestureEndTarget.RECENTS;
import static com.android.quickstep.LauncherSwipeHandler.MIN_PROGRESS_FOR_OVERVIEW;
import static com.android.quickstep.MultiStateCallback.DEBUG_STATES;
import static com.android.quickstep.RecentsActivity.EXTRA_TASK_ID;
import static com.android.quickstep.RecentsActivity.EXTRA_THUMBNAIL;
@@ -97,7 +96,7 @@ public class FallbackSwipeHandler extends BaseSwipeUpHandler<RecentsActivity, Fa

    private final AnimatedFloat mLauncherAlpha = new AnimatedFloat(this::onLauncherAlphaChanged);

    private boolean mIsMotionPaused = false;
    private boolean mOverviewThresholdPassed = false;

    private final boolean mInQuickSwitchMode;
    private final boolean mContinuingLastGesture;
@@ -222,10 +221,16 @@ public class FallbackSwipeHandler extends BaseSwipeUpHandler<RecentsActivity, Fa

    @Override
    public void onMotionPauseChanged(boolean isPaused) {
        if (!mInQuickSwitchMode) {
            mIsMotionPaused = isPaused;
        if (!mInQuickSwitchMode && mDeviceState.isFullyGesturalNavMode()) {
            updateOverviewThresholdPassed(isPaused);
        }
    }

    private void updateOverviewThresholdPassed(boolean passed) {
        if (passed != mOverviewThresholdPassed) {
            mOverviewThresholdPassed = passed;
            if (mSwipeUpOverHome) {
                mLauncherAlpha.animateToValue(mLauncherAlpha.value, isPaused ? 0 : 1)
                mLauncherAlpha.animateToValue(mLauncherAlpha.value, passed ? 0 : 1)
                        .setDuration(150).start();
            }
            performHapticFeedback();
@@ -234,7 +239,7 @@ public class FallbackSwipeHandler extends BaseSwipeUpHandler<RecentsActivity, Fa

    @Override
    public Intent getLaunchIntent() {
        if (mInQuickSwitchMode || mSwipeUpOverHome) {
        if (mInQuickSwitchMode || mSwipeUpOverHome || !mDeviceState.isFullyGesturalNavMode()) {
            return mGestureState.getOverviewIntent();
        } else {
            return mGestureState.getHomeIntent();
@@ -248,6 +253,11 @@ public class FallbackSwipeHandler extends BaseSwipeUpHandler<RecentsActivity, Fa
            mRecentsAnimationController.setWindowThresholdCrossed(!mInQuickSwitchMode
                    && (mCurrentShift.value > 1 - UPDATE_SYSUI_FLAGS_THRESHOLD));
        }

        if (!mInQuickSwitchMode && !mDeviceState.isFullyGesturalNavMode()) {
            updateOverviewThresholdPassed(mCurrentShift.value >= MIN_PROGRESS_FOR_OVERVIEW);
        }

        if (mRecentsAnimationTargets != null) {
            applyTransformUnchecked();
        }
@@ -271,15 +281,26 @@ public class FallbackSwipeHandler extends BaseSwipeUpHandler<RecentsActivity, Fa
                    .getDimension(R.dimen.quickstep_fling_threshold_velocity);
            boolean isFling = Math.abs(endVelocity) > flingThreshold;

            if (mDeviceState.isFullyGesturalNavMode()) {
                if (isFling) {
                    mGestureState.setEndTarget(endVelocity < 0 ? HOME : LAST_TASK);
            } else if (mIsMotionPaused) {
                } else if (mOverviewThresholdPassed) {
                    mGestureState.setEndTarget(RECENTS);
                } else {
                    mGestureState.setEndTarget(mCurrentShift.value >= MIN_PROGRESS_FOR_OVERVIEW
                            ? HOME
                            : LAST_TASK);
                }
            } else {
                GestureEndTarget startState = mSwipeUpOverHome ? HOME : LAST_TASK;
                if (isFling) {
                    mGestureState.setEndTarget(endVelocity < 0 ? RECENTS : startState);
                } else {
                    mGestureState.setEndTarget(mCurrentShift.value >= MIN_PROGRESS_FOR_OVERVIEW
                            ? RECENTS
                            : startState);
                }
            }
        }
        mStateCallback.setStateOnUiThread(STATE_GESTURE_COMPLETED);
    }
@@ -353,7 +374,7 @@ public class FallbackSwipeHandler extends BaseSwipeUpHandler<RecentsActivity, Fa
                mRecentsAnimationController.finish(false, null, false);
                break;
            case RECENTS: {
                if (mSwipeUpOverHome) {
                if (mSwipeUpOverHome || !mDeviceState.isFullyGesturalNavMode()) {
                    mRecentsAnimationController.finish(true, null, true);
                    break;
                }
+1 −22
Original line number Diff line number Diff line
@@ -616,11 +616,7 @@ public class TouchInteractionService extends Service implements PluginListener<O

        if (!mOverviewComponentObserver.isHomeAndOverviewSame()) {
            shouldDefer = previousGestureState.getFinishingRecentsAnimationTaskId() < 0;
            if (mDeviceState.isFullyGesturalNavMode()) {
            factory = mFallbackSwipeHandlerFactory;
            } else {
                factory = this::determineFallbackTwoButtonSwipeHandler;
            }
        } else {
            shouldDefer = gestureState.getActivityInterface().deferStartingActivity(mDeviceState,
                    event);
@@ -633,23 +629,6 @@ public class TouchInteractionService extends Service implements PluginListener<O
                mInputMonitorCompat, disableHorizontalSwipe, factory);
    }

    /**
     * Determines whether to use the LauncherSwipeHandler or FallbackSwipeHandler at runtime.
     * We need to use the FallbackSwipeHandler to handle quick switch from home, otherwise the
     * normal LauncherSwipeHandler works.
     */
    private BaseSwipeUpHandler determineFallbackTwoButtonSwipeHandler(GestureState gestureState,
            long touchTimeMs, boolean continuingLastGesture, boolean isLikelyToStartNewTask) {
        boolean runningOverHome = gestureState.getRunningTask() == null
                || ActivityManagerWrapper.isHomeTask(gestureState.getRunningTask());
        boolean isQuickSwitchMode = isLikelyToStartNewTask || continuingLastGesture;
        BaseSwipeUpHandler.Factory factory = runningOverHome && isQuickSwitchMode
                ? mFallbackSwipeHandlerFactory
                : mLauncherSwipeHandlerFactory;
        return factory.newHandler(gestureState, touchTimeMs, continuingLastGesture,
                isLikelyToStartNewTask);
    }

    private InputConsumer createDeviceLockedInputConsumer(GestureState gestureState) {
        if (mDeviceState.isFullyGesturalNavMode() && gestureState.getRunningTask() != null) {
            return new DeviceLockedInputConsumer(this, mDeviceState, mTaskAnimationManager,