From ded650084861f7c410e8b17b916d1dcc2072a111 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Fri, 27 Sep 2024 12:04:17 +0100 Subject: [PATCH] Make large task tile snap to position after scrolling - There's an edge case when there are only 2 grid tasks, mNextPage will still be on the grid tasks when they're not fully visible, so the new isAnySmallTaskFullyVisible check can't kick in. This only happens when grid tasks are barely out of screen. Fix: 370733696 Test: Scroll betwene large tiles, it should always snap after scrolling Test: Scroll from focus task to grid task, it should only snap if grid tasks aren't fully visible Flag: com.android.launcher3.enable_large_desktop_windowing_tile Change-Id: I3b0a80ceffb1caae57aa53b1c949c5e51336231a --- .../src/com/android/quickstep/util/RecentsViewUtils.kt | 6 ++++++ quickstep/src/com/android/quickstep/views/RecentsView.java | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt b/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt index 68690d2f43..c3b072deac 100644 --- a/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt +++ b/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt @@ -113,6 +113,12 @@ class RecentsViewUtils { it.isVisibleInCarousel(runningTaskView, nonRunningTaskCarouselHidden) } + /** Returns if any small tasks are fully visible */ + fun isAnySmallTaskFullyVisible( + taskViews: Iterable, + 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 = (0 until taskViewCount).map(requireTaskViewAt) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 0d2acf0dab..458a0d0b1c 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -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; }