Stay in the current task when a new desk is created

Bug: 401002178
Flag: com.android.window.flags.enable_multiple_desktops_frontend
Flag: com.android.window.flags.enable_multiple_desktops_backend
Test: manual create new desks
Change-Id: Iaa29c557a421d5c51b90aa808188d3cabec89143
This commit is contained in:
Suhua Lei
2025-03-21 17:33:31 +00:00
parent 376885f8ba
commit 77481d611b
@@ -7038,6 +7038,8 @@ public abstract class RecentsView<
return;
}
TaskView currentTaskView = getTaskViewAt(mCurrentPage);
// We assume that a newly added desk is always empty and gets added to the left of the
// `AddNewDesktopButton`.
DesktopTaskView desktopTaskView =
@@ -7051,9 +7053,12 @@ public abstract class RecentsView<
updateTaskSize();
mUtils.updateChildTaskOrientations();
updateScrollSynchronously();
// TODO: b/401002178 - Recalculate the new current page such that the addition of the new
// desk does not result in a change in the current scroll page.
// Set Current Page based on the stored TaskView.
if (currentTaskView != null) {
setCurrentPage(indexOfChild(currentTaskView));
}
}
@Override