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
This commit is contained in:
Pat Manning committed 2025-02-20 18:06:52 +00:00
1 parent e0221f0c8b
commit 2caae623a6
4 files changed
+50 -8

No files matched your search

@@ -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.
@@ -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();
@@ -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.
*/
@@ -125,7 +125,7 @@ public final class OverviewTask {
return right - left;
}
int getTaskCenterX() {
public int getTaskCenterX() {
return mTask.getVisibleCenter().x;
}