Merge "Make large task tile snap to position after scrolling" into main

This commit is contained in:
Treehugger Robot
2024-10-01 23:01:37 +00:00
committed by Android (Google) Code Review
2 changed files with 9 additions and 2 deletions
@@ -113,6 +113,12 @@ class RecentsViewUtils {
it.isVisibleInCarousel(runningTaskView, nonRunningTaskCarouselHidden)
}
/** Returns if any small tasks are fully visible */
fun isAnySmallTaskFullyVisible(
taskViews: Iterable<TaskView>,
isTaskViewFullyVisible: (TaskView) -> Boolean,
): Boolean = taskViews.any { !it.isLargeTile && isTaskViewFullyVisible(it) }
/** Returns the current list of [TaskView] children. */
fun getTaskViews(taskViewCount: Int, requireTaskViewAt: (Int) -> TaskView): Iterable<TaskView> =
(0 until taskViewCount).map(requireTaskViewAt)
@@ -1706,10 +1706,11 @@ public abstract class RecentsView<
return;
}
TaskView taskView = getTaskViewAt(mNextPage);
// Snap to fully visible focused task and clear all button.
boolean shouldSnapToLargeTask = taskView != null && taskView.isLargeTile()
&& isTaskViewFullyVisible(taskView);
&& !mUtils.isAnySmallTaskFullyVisible(getTaskViews(),
this::isTaskViewFullyVisible);
boolean shouldSnapToClearAll = mNextPage == indexOfChild(mClearAllButton);
// Snap to large tile when grid tasks aren't fully visible or the clear all button.
if (!shouldSnapToLargeTask && !shouldSnapToClearAll) {
return;
}