From 8bda4f6b5f8c6e6d64136b94c6200787d7ea4ba4 Mon Sep 17 00:00:00 2001 From: Pat Manning Date: Wed, 12 Feb 2025 15:34:05 +0000 Subject: [PATCH] Update dismiss length for tasks to bring them off screen. Fix: 393553524 Test: TaplTestsQuickstep#testDismissBottomRow Flag: com.android.launcher3.enable_expressive_dismiss_task_motion Change-Id: I959bcc86ad986abfe4546add62146e99f3707cc4 --- .../TaskViewDismissTouchController.kt | 6 ++++- .../quickstep/views/RecentsViewUtils.kt | 2 -- .../android/quickstep/TaplTestsQuickstep.java | 22 +++++++++++++++++++ .../android/launcher3/tapl/OverviewTask.java | 2 +- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewDismissTouchController.kt b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewDismissTouchController.kt index 98737a5568..4ecf409415 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewDismissTouchController.kt +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewDismissTouchController.kt @@ -16,6 +16,7 @@ package com.android.launcher3.uioverrides.touchcontrollers import android.content.Context +import android.graphics.Rect import android.view.MotionEvent import androidx.dynamicanimation.animation.SpringAnimation import com.android.app.animation.Interpolators.DECELERATE @@ -50,6 +51,7 @@ CONTAINER : RecentsViewContainer { recentsView.pagedOrientationHandler.upDownSwipeDirection, ) private val isRtl = isRtl(container.resources) + private val tempTaskThumbnailBounds = Rect() private var taskBeingDragged: TaskView? = null private var springAnimation: SpringAnimation? = null @@ -108,7 +110,9 @@ CONTAINER : RecentsViewContainer { recentsView.isTaskViewVisible(it) && container.dragLayer.isEventOverView(it, ev) } ?.also { - dismissLength = recentsView.pagedOrientationHandler.getSecondaryDimension(it) + // Dismiss length as bottom of task so it is fully off screen when dismissed. + it.getThumbnailBounds(tempTaskThumbnailBounds, relativeToDragLayer = true) + dismissLength = tempTaskThumbnailBounds.bottom verticalFactor = recentsView.pagedOrientationHandler.secondaryTranslationDirectionFactor } diff --git a/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt b/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt index d18a5f7fe8..7b4f4eef5b 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt +++ b/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt @@ -335,8 +335,6 @@ class RecentsViewUtils(private val recentsView: RecentsView<*, *>) { .setStartVelocity(if (detector.isFling(velocity)) velocity else 0f) .addUpdateListener { animation, value, _ -> if (isDismissing && abs(value) >= abs(dismissLength)) { - // TODO(b/393553524): Remove 0 alpha, instead animate task fully off screen. - draggedTaskView.alpha = 0f animation.cancel() } else if (draggedTaskView.isRunningTask && recentsView.enableDrawingLiveTile) { recentsView.runActionOnRemoteHandles { remoteTargetHandle -> diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java index 79d3c19a0f..aaaa0e45da 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java @@ -62,6 +62,7 @@ import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; +import java.util.Comparator; import java.util.function.Consumer; import java.util.function.Function; @@ -557,6 +558,27 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { numTasks == null ? 0 : numTasks, recentsView.getTaskViewCount())); } + @Test + @PortraitLandscape + public void testDismissBottomRow() throws Exception { + assumeTrue(mLauncher.isTablet()); + mLauncher.goHome().switchToOverview().dismissAllTasks(); + startTestAppsWithCheck(); + Overview overview = mLauncher.goHome().switchToOverview(); + assertIsInState("Launcher internal state didn't switch to Overview", + ExpectedState.OVERVIEW); + final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount); + OverviewTask bottomTask = overview.getCurrentTasksForTablet().stream().max( + Comparator.comparingInt(OverviewTask::getTaskCenterY)).get(); + assertNotNull("bottomTask null", bottomTask); + + bottomTask.dismiss(); + + runOnRecentsView(recentsView -> assertEquals( + "Dismissing a bottomTask didn't remove 1 bottomTask from Overview", + numTasks - 1, recentsView.getTaskViewCount())); + } + private void startTestAppsWithCheck() throws Exception { startTestApps(); expectLaunchedAppState(); diff --git a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java index 1158521db2..4e94e1e7c6 100644 --- a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java +++ b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java @@ -129,7 +129,7 @@ public final class OverviewTask { return mTask.getVisibleCenter().x; } - int getTaskCenterY() { + public int getTaskCenterY() { return mTask.getVisibleCenter().y; }