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

Commit c3d2e928 authored by nift4's avatar nift4 Committed by Bruno Martins
Browse files

Trebuchet: Let's keep 2-button nav alive for a little longer

* Refactor to avoid breaking gesture nav

This partially reverts commit 9cddf413.
This partially reverts commit 0130252c.

Change-Id: I1823de2a911f8a17c3716bc0b1b8e6c9c55d37cd
parent cfc74263
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -305,6 +305,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,

    private boolean mWasLauncherAlreadyVisible;

    private boolean mPassedOverviewThreshold;
    private boolean mGestureStarted;
    private boolean mLogDirectionUpOrLeft = true;
    private boolean mIsLikelyToStartNewTask;
@@ -883,6 +884,14 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
    @UiThread
    @Override
    public void onCurrentShiftUpdated() {
        final boolean passed = hasReachedHomeOverviewThreshold();
        if (passed != mPassedOverviewThreshold) {
            mPassedOverviewThreshold = passed;
            if (mDeviceState.isTwoButtonNavMode() && !mGestureState.isHandlingAtomicEvent()) {
                performHapticFeedback();
            }
        }

        float threshold = LauncherPrefs.get(mContext).get(ALL_APPS_OVERVIEW_THRESHOLD) / 100f;
        setIsInAllAppsRegion(mCurrentShift.value >= threshold);
        updateSysUiFlags(mCurrentShift.value);
@@ -981,6 +990,8 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
        mStateCallback.runOnceAtState(STATE_APP_CONTROLLER_RECEIVED | STATE_GESTURE_STARTED,
                this::startInterceptingTouchesForGesture);
        mStateCallback.setStateOnUiThread(STATE_APP_CONTROLLER_RECEIVED);

        mPassedOverviewThreshold = false;
    }

    @Override
@@ -1260,11 +1271,19 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
            return willGoToNewTask || isCenteredOnNewTask ? NEW_TASK : LAST_TASK;
        }

        if (!mDeviceState.isFullyGesturalNavMode()) {
            return (!hasReachedHomeOverviewThreshold() && willGoToNewTask) ? NEW_TASK : RECENTS;
        }
        return willGoToNewTask ? NEW_TASK : HOME;
    }

    private GestureEndTarget calculateEndTargetForNonFling(PointF velocity) {
        final boolean isScrollingToNewTask = isScrollingToNewTask();
        if (!mDeviceState.isFullyGesturalNavMode()) {
            return hasReachedHomeOverviewThreshold() && mGestureStarted
                    ? RECENTS
                    : (isScrollingToNewTask ? NEW_TASK : LAST_TASK);
        }

        // Fully gestural mode.
        final boolean isFlingX = Math.abs(velocity.x) > mContext.getResources()
@@ -1308,6 +1327,16 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
        mCanSlowSwipeGoHome = canSlowSwipeGoHome;
    }

    /**
     * Returns true if swipe has reached the overview threshold.
     */
    private boolean hasReachedHomeOverviewThreshold() {
        if (mIsTransientTaskbar) {
            return mCanSlowSwipeGoHome;
        }
        return mCurrentShift.value > MIN_PROGRESS_FOR_OVERVIEW;
    }

    @UiThread
    private void handleNormalGestureEnd(
            float endVelocityPxPerMs, boolean isFling, PointF velocityPxPerMs, boolean isCancel) {
+20 −0
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ import android.content.ContextWrapper;
import android.content.Intent;
import android.graphics.PointF;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.MotionEvent;
import android.view.VelocityTracker;
@@ -64,6 +66,7 @@ import com.android.quickstep.TaskAnimationManager;
import com.android.quickstep.util.CachedEventDispatcher;
import com.android.quickstep.util.MotionPauseDetector;
import com.android.quickstep.util.NavBarPosition;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.InputChannelCompat.InputEventReceiver;
import com.android.systemui.shared.system.InputMonitorCompat;

@@ -125,6 +128,12 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
    // Might be displacement in X or Y, depending on the direction we are swiping from the nav bar.
    private float mStartDisplacement;

    private Handler mMainThreadHandler;
    private Runnable mCancelRecentsAnimationRunnable = () -> {
        ActivityManagerWrapper.getInstance().cancelRecentsAnimation(
                true /* restoreHomeStackPosition */);
    };

    public OtherActivityInputConsumer(Context base, RecentsAnimationDeviceState deviceState,
            TaskAnimationManager taskAnimationManager, GestureState gestureState,
            boolean isDeferredDownTarget, Consumer<OtherActivityInputConsumer> onCompleteCallback,
@@ -135,6 +144,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
        mNavBarPosition = mDeviceState.getNavBarPosition();
        mTaskAnimationManager = taskAnimationManager;
        mGestureState = gestureState;
        mMainThreadHandler = new Handler(Looper.getMainLooper());
        mHandlerFactory = handlerFactory;
        mActivityInterface = mGestureState.getActivityInterface();

@@ -453,6 +463,15 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
            }
            onConsumerAboutToBeSwitched();
            onInteractionGestureFinished();

            // Cancel the recents animation if SysUI happens to handle UP before we have a chance
            // to start the recents animation. In addition, workaround for b/126336729 by delaying
            // the cancel of the animation for a period, in case SysUI is slow to handle UP and we
            // handle DOWN & UP and move the home stack before SysUI can start the activity
            mMainThreadHandler.removeCallbacks(mCancelRecentsAnimationRunnable);
            if (!mDeviceState.isFullyGesturalNavMode()) {
                mMainThreadHandler.postDelayed(mCancelRecentsAnimationRunnable, 100);
            }
        }
        cleanupAfterGesture();
        TraceHelper.INSTANCE.endSection();
@@ -474,6 +493,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
    @Override
    public void onConsumerAboutToBeSwitched() {
        Preconditions.assertUIThread();
        mMainThreadHandler.removeCallbacks(mCancelRecentsAnimationRunnable);
        if (mInteractionHandler != null) {
            // The consumer is being switched while we are active. Set up the shared state to be
            // used by the next animation