Merge "Update dismiss length for tasks to bring them off screen." into main

This commit is contained in:
Treehugger Robot
2025-02-14 12:30:46 -08:00
committed by Android (Google) Code Review
4 changed files with 28 additions and 4 deletions
@@ -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
@@ -52,6 +53,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
@@ -112,7 +114,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
}
@@ -336,8 +336,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 ->
@@ -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();
@@ -129,7 +129,7 @@ public final class OverviewTask {
return mTask.getVisibleCenter().x;
}
int getTaskCenterY() {
public int getTaskCenterY() {
return mTask.getVisibleCenter().y;
}