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

Commit 21d4253c authored by Jon Miranda's avatar Jon Miranda
Browse files

Fix home/overview threshold.

Fixes: 258836670
Test: Enable I06e16d78c179b7c3281f423ed8c7dd6cfc42229a to visually show
      thresholds on screen
      Swipe up to overview where taskbar not showing
      and also with taskbar already showing

Change-Id: Ie7487a5f869c0718d9ee08209dee8331a01d5989
parent 193f8992
Loading
Loading
Loading
Loading
+26 −8
Original line number Diff line number Diff line
@@ -317,6 +317,9 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
    private final int mTaskbarAppWindowThreshold;
    private final int mTaskbarCatchUpThreshold;
    private boolean mTaskbarAlreadyOpen;
    private final boolean mIsTransientTaskbar;
    // Only used when mIsTransientTaskbar is true.
    private boolean mHasReachedHomeOverviewThreshold;

    public AbsSwipeUpHandler(Context context, RecentsAnimationDeviceState deviceState,
            TaskAnimationManager taskAnimationManager, GestureState gestureState,
@@ -343,6 +346,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
        mTaskbarAppWindowThreshold = res
                .getDimensionPixelSize(R.dimen.taskbar_app_window_threshold);
        mTaskbarCatchUpThreshold = res.getDimensionPixelSize(R.dimen.taskbar_catch_up_threshold);
        mIsTransientTaskbar = DisplayController.isTransientTaskbar(mActivity);

        mQuickSwitchScaleScrollThreshold = res
                .getDimension(R.dimen.quick_switch_scaling_scroll_threshold);
@@ -819,7 +823,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
    @UiThread
    @Override
    public void updateFinalShift() {
        final boolean passed = mCurrentShift.value >= MIN_PROGRESS_FOR_OVERVIEW;
        final boolean passed = hasReachedHomeOverviewThreshold();
        if (passed != mPassedOverviewThreshold) {
            mPassedOverviewThreshold = passed;
            if (mDeviceState.isTwoButtonNavMode() && !mGestureState.isHandlingAtomicEvent()) {
@@ -1145,16 +1149,16 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
        }

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

    private GestureEndTarget calculateEndTargetForNonFling(PointF velocity) {
        final boolean isScrollingToNewTask = isScrollingToNewTask();
        final boolean reachedOverviewThreshold = hasReachedOverviewThreshold();
        final boolean reachedHomeOverviewThreshold = hasReachedHomeOverviewThreshold();
        if (!mDeviceState.isFullyGesturalNavMode()) {
            return reachedOverviewThreshold && mGestureStarted
            return reachedHomeOverviewThreshold && mGestureStarted
                    ? RECENTS
                    : (isScrollingToNewTask ? NEW_TASK : LAST_TASK);
        }
@@ -1170,7 +1174,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
            return RECENTS;
        } else if (isScrollingToNewTask) {
            return NEW_TASK;
        } else if (reachedOverviewThreshold) {
        } else if (reachedHomeOverviewThreshold) {
            return HOME;
        }
        return LAST_TASK;
@@ -1189,8 +1193,22 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
        return runningTaskIndex >= 0 && mRecentsView.getNextPage() != runningTaskIndex;
    }

    private boolean hasReachedOverviewThreshold() {
        return getTaskbarProgress() > MIN_PROGRESS_FOR_OVERVIEW;
    /**
     * Sets whether the current swipe has reached the threshold where if user lets go they would
     * go to either the home state or overview state.
     */
    public void setHasReachedHomeOverviewThreshold(boolean hasReachedHomeOverviewThreshold) {
        mHasReachedHomeOverviewThreshold = hasReachedHomeOverviewThreshold;
    }

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

    @UiThread
@@ -2267,7 +2285,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
     * There is also a catch up period so that the window can start moving 1:1 with the swipe.
     */
    private float getTaskbarProgress() {
        if (!DisplayController.isTransientTaskbar(mContext)) {
        if (!mIsTransientTaskbar) {
            return mCurrentShift.value;
        }

+7 −11
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ import android.annotation.TargetApi;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.PointF;
import android.os.Build;
import android.util.Log;
@@ -151,10 +150,6 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
        mHandlerFactory = handlerFactory;
        mActivityInterface = mGestureState.getActivityInterface();

        Resources res = base.getResources();
        mTaskbarHomeOverviewThreshold = res
                .getDimensionPixelSize(R.dimen.taskbar_home_overview_threshold);

        mMotionPauseDetector = new MotionPauseDetector(base, false,
                mNavBarPosition.isLeftEdge() || mNavBarPosition.isRightEdge()
                        ? MotionEvent.AXIS_X : MotionEvent.AXIS_Y);
@@ -168,6 +163,8 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
        TaskbarUIController controller = mActivityInterface.getTaskbarController();
        mTaskbarAlreadyOpen = controller != null && !controller.isTaskbarStashed();
        mIsTransientTaskbar = DisplayController.isTransientTaskbar(base);
        mTaskbarHomeOverviewThreshold = base.getResources()
                .getDimensionPixelSize(R.dimen.taskbar_home_overview_threshold);

        boolean continuingPreviousGesture = mTaskAnimationManager.isRecentsAnimationRunning();
        mIsDeferredDownTarget = !continuingPreviousGesture && isDeferredDownTarget;
@@ -340,13 +337,12 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
                    }

                    if (mDeviceState.isFullyGesturalNavMode()) {
                        float minDisplacement = mMotionPauseMinDisplacement;

                        if (mIsTransientTaskbar && !mTaskbarAlreadyOpen) {
                            minDisplacement += mTaskbarHomeOverviewThreshold;
                        boolean minSwipeMet = upDist >= mMotionPauseMinDisplacement;
                        if (mIsTransientTaskbar) {
                            minSwipeMet = upDist >= mTaskbarHomeOverviewThreshold;
                            mInteractionHandler.setHasReachedHomeOverviewThreshold(minSwipeMet);
                        }

                        mMotionPauseDetector.setDisallowPause(upDist < minDisplacement
                        mMotionPauseDetector.setDisallowPause(!minSwipeMet
                                || isLikelyToStartNewTask);
                        mMotionPauseDetector.addPosition(ev);
                        mInteractionHandler.setIsLikelyToStartNewTask(isLikelyToStartNewTask);