From 7d4767989272539bb8eb42956d369bab076ab434 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Tue, 18 Feb 2025 18:07:34 +0000 Subject: [PATCH] Fix jump when dismissing last grid task View - Calcualte the scroll diff to bring large tile to middle of screen - Additional compensate for scroll diff between last task and ClearAllButton if ClearAllButton is visible Fix: 395883390 Test: manual, not adding e2e because animation jump cannot be caught by e2e test Flag: com.android.launcher3.enable_grid_only_overview Change-Id: I6a506f2af46ded4daf21fe49329ab71b59e3f19d --- .../com/android/quickstep/views/RecentsView.java | 16 ++++++++++++++++ .../android/quickstep/views/RecentsViewUtils.kt | 3 +++ 2 files changed, 19 insertions(+) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 1ca14a5dae..d719fd96a5 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -3901,6 +3901,22 @@ public abstract class RecentsView< // the only invariant point in landscape split screen. snapToLastTask = true; } + if (mUtils.getGridTaskCount() == 1 && dismissedTaskView.isGridTask()) { + TaskView lastLargeTile = mUtils.getLastLargeTaskView(); + if (lastLargeTile != null) { + // Calculate the distance to put last large tile back to middle of the screen. + int primaryScroll = getPagedOrientationHandler().getPrimaryScroll(this); + int lastLargeTileScroll = getScrollForPage(indexOfChild(lastLargeTile)); + longGridRowWidthDiff = primaryScroll - lastLargeTileScroll; + + if (!isClearAllHidden) { + // If ClearAllButton is visible, reduce the distance by scroll difference + // between ClearAllButton and the last task. + longGridRowWidthDiff += getLastTaskScroll(/*clearAllScroll=*/0, + getPagedOrientationHandler().getPrimarySize(mClearAllButton)); + } + } + } // If we need to animate the grid to compensate the clear all gap, we split the second // half of the dismiss pending animation (in which the non-dismissed tasks slide into diff --git a/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt b/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt index f742ec3898..c62b804f7d 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt +++ b/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt @@ -84,6 +84,9 @@ class RecentsViewUtils(private val recentsView: RecentsView<*, *>) { /** Counts [TaskView]s that are large tiles. */ fun getLargeTileCount(): Int = taskViews.count { it.isLargeTile } + /** Counts [TaskView]s that are grid tasks. */ + fun getGridTaskCount(): Int = taskViews.count { it.isGridTask } + /** Returns the first TaskView that should be displayed as a large tile. */ fun getFirstLargeTaskView(): TaskView? = taskViews.firstOrNull {