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
This commit is contained in:
Jon Miranda
2022-11-17 18:09:31 -08:00
parent 193f8992f1
commit 21d4253c01
2 changed files with 33 additions and 19 deletions
@@ -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;
}