From 2caae623a6f59bb216a49ffcb55ab0f81c209598 Mon Sep 17 00:00:00 2001 From: Pat Manning Date: Thu, 20 Feb 2025 15:18:10 +0000 Subject: [PATCH] Close gap between grid and clear all for expressive dismiss. Fix: 397891454 Test: TaplTestsQuickstep#testDismissLastGridRow Flag: com.android.launcher3.enable_expressive_dismiss_task_motion Change-Id: Id49447819c38f307f05cd4ecc3d501bd51766443 --- .../android/quickstep/views/RecentsView.java | 4 ++- .../android/quickstep/TaplTestsQuickstep.java | 34 +++++++++++++++++++ .../android/launcher3/tapl/BaseOverview.java | 18 ++++++---- .../android/launcher3/tapl/OverviewTask.java | 2 +- 4 files changed, 50 insertions(+), 8 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index a29d3028bc..16ce2bd3f8 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -38,6 +38,7 @@ import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAG import static com.android.launcher3.Flags.enableAdditionalHomeAnimations; import static com.android.launcher3.Flags.enableDesktopExplodedView; import static com.android.launcher3.Flags.enableDesktopTaskAlphaAnimation; +import static com.android.launcher3.Flags.enableExpressiveDismissTaskMotion; import static com.android.launcher3.Flags.enableGridOnlyOverview; import static com.android.launcher3.Flags.enableLargeDesktopWindowingTile; import static com.android.launcher3.Flags.enableRefactorTaskThumbnail; @@ -3840,7 +3841,8 @@ public abstract class RecentsView< newClearAllShortTotalWidthTranslation = expectedFirstTaskStart - firstTaskStart; } } - if (lastGridTaskView != null && lastGridTaskView.isVisibleToUser()) { + if (lastGridTaskView != null && (lastGridTaskView.isVisibleToUser() || ( + enableExpressiveDismissTaskMotion() && lastGridTaskView == dismissedTaskView))) { // After dismissal, animate translation of the remaining tasks to fill any gap left // between the end of the grid and the clear all button. Only animate if the clear // all button is visible or would become visible after dismissal. diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java index aaaa0e45da..6761e9b85e 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java @@ -23,6 +23,7 @@ import static com.android.quickstep.TaskbarModeSwitchRule.Mode.TRANSIENT; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeFalse; @@ -579,6 +580,39 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { numTasks - 1, recentsView.getTaskViewCount())); } + @Test + @PortraitLandscape + public void testDismissLastGridRow() throws Exception { + assumeTrue(mLauncher.isTablet()); + mLauncher.goHome().switchToOverview().dismissAllTasks(); + startTestAppsWithCheck(); + startTestActivity(3); + startTestActivity(4); + runOnRecentsView( + recentsView -> assertNotEquals("Grid overview should have unequal row counts", + recentsView.getTopRowTaskCountForTablet(), + recentsView.getBottomRowTaskCountForTablet())); + Overview overview = mLauncher.goHome().switchToOverview(); + assertIsInState("Launcher internal state didn't switch to Overview", + ExpectedState.OVERVIEW); + overview.flingForwardUntilClearAllVisible(); + assertTrue("Clear All not visible.", overview.isClearAllVisible()); + final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount); + OverviewTask lastGridTask = overview.getCurrentTasksForTablet().stream().min( + Comparator.comparingInt(OverviewTask::getTaskCenterX)).get(); + assertNotNull("lastGridTask null.", lastGridTask); + + lastGridTask.dismiss(); + + runOnRecentsView(recentsView -> assertEquals( + "Dismissing a lastGridTask didn't remove 1 lastGridTask from Overview", + numTasks - 1, recentsView.getTaskViewCount())); + runOnRecentsView(recentsView -> assertEquals("Grid overview should have equal row counts.", + recentsView.getTopRowTaskCountForTablet(), + recentsView.getBottomRowTaskCountForTablet())); + assertTrue("Clear All not visible.", overview.isClearAllVisible()); + } + private void startTestAppsWithCheck() throws Exception { startTestApps(); expectLaunchedAppState(); diff --git a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java index ef72a0f6f1..f633d48363 100644 --- a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java +++ b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java @@ -157,12 +157,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "dismissing all tasks")) { final BySelector clearAllSelector = mLauncher.getOverviewObjectSelector("clear_all"); - for (int i = 0; - i < FLINGS_FOR_DISMISS_LIMIT - && !verifyActiveContainer().hasObject(clearAllSelector); - ++i) { - flingForwardImpl(); - } + flingForwardUntilClearAllVisible(); final Runnable clickClearAll = () -> mLauncher.clickLauncherObject( mLauncher.waitForObjectInContainer(verifyActiveContainer(), @@ -182,6 +177,17 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { } } + /** + * Scrolls until Clear-all button is visible. + */ + public void flingForwardUntilClearAllVisible() { + final BySelector clearAllSelector = mLauncher.getOverviewObjectSelector("clear_all"); + for (int i = 0; i < FLINGS_FOR_DISMISS_LIMIT + && !verifyActiveContainer().hasObject(clearAllSelector); ++i) { + flingForwardImpl(); + } + } + /** * Touch to the right of current task. This should dismiss overview and go back to Workspace. */ diff --git a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java index 4e94e1e7c6..8fbb5e3172 100644 --- a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java +++ b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java @@ -125,7 +125,7 @@ public final class OverviewTask { return right - left; } - int getTaskCenterX() { + public int getTaskCenterX() { return mTask.getVisibleCenter().x; }