Merge "Swipe up from excludeFromRecents task should be shown left of desktop tasks" into main

This commit is contained in:
Alex Chau
2024-11-22 11:59:12 +00:00
committed by Android (Google) Code Review
2 changed files with 29 additions and 19 deletions
@@ -784,7 +784,7 @@ public abstract class AbsSwipeUpHandler<
&& recentsAttachedToAppWindow) {
// Only move running task if RecentsView has never been attached before, to avoid
// TaskView jumping to new position as we move the tasks.
mRecentsView.moveRunningTaskToFront();
mRecentsView.moveRunningTaskToExpectedPosition();
}
mAnimationFactory.setRecentsAttachedToAppWindow(
recentsAttachedToAppWindow, animate, updateRunningTaskAlpha);
@@ -1768,26 +1768,17 @@ public abstract class RecentsView<
}
/**
* Moves the running task to the front of the carousel in tablets, to minimize animation
* required to move the running task in grid.
* Moves the running task to the expected position in the carousel. In tablets, this minimize
* animation required to move the running task into focused task position.
*/
public void moveRunningTaskToFront() {
if (!mContainer.getDeviceProfile().isTablet) {
return;
}
public void moveRunningTaskToExpectedPosition() {
TaskView runningTaskView = getRunningTaskView();
if (runningTaskView == null) {
if (runningTaskView == null || mCurrentPage != indexOfChild(runningTaskView)) {
return;
}
if (indexOfChild(runningTaskView) != mCurrentPage) {
return;
}
int frontIndex = enableLargeDesktopWindowingTile() ? getDesktopTaskViewCount() : 0;
if (mCurrentPage <= frontIndex) {
int runningTaskExpectedIndex = getRunningTaskExpectedIndex(runningTaskView);
if (mCurrentPage == runningTaskExpectedIndex) {
return;
}
@@ -1800,12 +1791,31 @@ public abstract class RecentsView<
mMovingTaskView = null;
runningTaskView.resetPersistentViewTransforms();
addView(runningTaskView, frontIndex);
setCurrentPage(frontIndex);
addView(runningTaskView, runningTaskExpectedIndex);
setCurrentPage(runningTaskExpectedIndex);
updateTaskSize();
}
private int getRunningTaskExpectedIndex(TaskView runningTaskView) {
if (mContainer.getDeviceProfile().isTablet) {
if (runningTaskView instanceof DesktopTaskView) {
return 0; // Desktop running task is always in front.
} else if (enableLargeDesktopWindowingTile()) {
return getDesktopTaskViewCount(); // Other running task is behind desktop tasks.
} else {
return 0;
}
} else {
int currentIndex = indexOfChild(runningTaskView);
if (currentIndex != -1) {
return currentIndex; // Keep the position if running task already in layout.
} else {
return 0; // New running task are added to the front to begin with.
}
}
}
@Override
protected void onScrollerAnimationAborted() {
ActiveGestureProtoLogProxy.logOnScrollerAnimationAborted();
@@ -2971,7 +2981,7 @@ public abstract class RecentsView<
taskView = getTaskViewFromPool(TaskViewType.SINGLE);
taskView.bind(runningTasks[0], mOrientationState, mTaskOverlayFactory);
}
addView(taskView, 0);
addView(taskView, getRunningTaskExpectedIndex(taskView));
runningTaskViewId = taskView.getTaskViewId();
if (wasEmpty) {
addView(mClearAllButton);