From 21d4253c01366187e184c2b867ae5882d0168d17 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Thu, 17 Nov 2022 18:09:31 -0800 Subject: [PATCH] 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 --- .../android/quickstep/AbsSwipeUpHandler.java | 34 ++++++++++++++----- .../OtherActivityInputConsumer.java | 18 ++++------ 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index b09e531fab..28e783f327 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -317,6 +317,9 @@ public abstract class AbsSwipeUpHandler, 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, 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, @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, } 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, 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, 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, * 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; } diff --git a/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java index b3d3c3dbf6..503644a606 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java @@ -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);