Merge changes I8af39b58,I9a3e8ee2 into main

* changes:
  Finally remove `task1` and `task2` from `GroupTask`
  Remove `GroupTask.mSplitBounds`
This commit is contained in:
Treehugger Robot
2025-01-31 11:51:02 -08:00
committed by Android (Google) Code Review
6 changed files with 23 additions and 63 deletions
@@ -275,7 +275,7 @@ public class KeyboardQuickSwitchView extends ConstraintLayout {
task2,
updateTasks ? mViewCallbacks::updateThumbnailInBackground : null,
updateTasks ? mViewCallbacks::updateIconInBackground : null,
groupTask.mSplitBounds);
groupTask instanceof SplitTask splitTask ? splitTask.getSplitBounds() : null);
previousTaskView = currentTaskView;
}
@@ -26,8 +26,6 @@ import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_FOLDER;
import static com.android.launcher3.config.FeatureFlags.enableTaskbarPinning;
import static com.android.launcher3.icons.IconNormalizer.ICON_VISIBLE_AREA_FACTOR;
import static java.util.function.Predicate.not;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
@@ -399,7 +397,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
.filter(Objects::nonNull)
.toArray(ItemInfo[]::new);
// TODO(b/343289567 and b/316004172): support app pairs and desktop mode.
recentTasks = recentTasks.stream().filter(not(GroupTask::supportsMultipleTasks)).toList();
recentTasks = recentTasks.stream().filter(it -> it instanceof SingleTask).toList();
if (taskbarRecentsLayoutTransition()) {
updateItemsWithLayoutTransition(hotseatItemInfos, recentTasks);
@@ -650,7 +648,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
// Replace any Recent views with the appropriate type if it's not already that type.
final int expectedLayoutResId;
boolean isCollection = false;
if (task.supportsMultipleTasks()) {
if (!(task instanceof SingleTask)) {
if (task.taskViewType == TaskViewType.DESKTOP) {
// TODO(b/316004172): use Desktop tile layout.
expectedLayoutResId = -1;
@@ -65,7 +65,6 @@ import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import static com.android.quickstep.util.AnimUtils.completeRunnableListCallback;
import static com.android.quickstep.util.SplitAnimationTimings.TABLET_HOME_TO_SPLIT;
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_HOME_KEY;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_50_50;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -1390,16 +1389,13 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer,
*/
public void launchSplitTasks(
@NonNull SplitTask splitTask, @Nullable RemoteTransition remoteTransition) {
mSplitSelectStateController.launchExistingSplitPair(
null /* launchingTaskView */,
mSplitSelectStateController.launchExistingSplitPair(null /* launchingTaskView */,
splitTask.getTopLeftTask().key.id,
splitTask.getBottomRightTask().key.id,
SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT,
/* callback= */ success -> mSplitSelectStateController.resetState(),
/* freezeTaskList= */ false,
splitTask.mSplitBounds == null
? SNAP_TO_2_50_50
: splitTask.mSplitBounds.snapPosition,
splitTask.getSplitBounds().snapPosition,
remoteTransition);
}
@@ -20,14 +20,9 @@ import com.android.systemui.shared.recents.model.Task
/**
* A [Task] container that can contain N number of tasks that are part of the desktop in recent
* tasks list.
* tasks list. Note that desktops can be empty with no tasks in them.
*/
class DesktopTask(override val tasks: List<Task>) :
GroupTask(tasks[0], null, null, TaskViewType.DESKTOP) {
override fun containsTask(taskId: Int) = tasks.any { it.key.id == taskId }
override fun supportsMultipleTasks() = true
class DesktopTask(tasks: List<Task>) : GroupTask(tasks, TaskViewType.DESKTOP) {
override fun copy() = DesktopTask(tasks)
@@ -15,7 +15,6 @@
*/
package com.android.quickstep.util
import androidx.annotation.VisibleForTesting
import com.android.launcher3.util.SplitConfigurationOptions
import com.android.quickstep.views.TaskViewType
import com.android.systemui.shared.recents.model.Task
@@ -25,27 +24,8 @@ import java.util.Objects
* An abstract class for creating [Task] containers that can be [SingleTask]s, [SplitTask]s, or
* [DesktopTask]s in the recent tasks list.
*/
abstract class GroupTask
@VisibleForTesting(otherwise = VisibleForTesting.PROTECTED)
constructor(
@Deprecated("Prefer using `getTasks()` instead") @JvmField val task1: Task,
@Deprecated("Prefer using `getTasks()` instead") @JvmField val task2: Task?,
@JvmField val mSplitBounds: SplitConfigurationOptions.SplitBounds?,
@JvmField val taskViewType: TaskViewType,
) {
protected constructor(
task1: Task,
task2: Task?,
splitBounds: SplitConfigurationOptions.SplitBounds?,
) : this(
task1,
task2,
splitBounds,
if (task2 != null) TaskViewType.GROUPED else TaskViewType.SINGLE,
)
open fun containsTask(taskId: Int) =
task1.key.id == taskId || (task2 != null && task2.key.id == taskId)
abstract class GroupTask(val tasks: List<Task>, @JvmField val taskViewType: TaskViewType) {
fun containsTask(taskId: Int) = tasks.any { it.key.id == taskId }
/**
* Returns true if a task in this group has a package name that matches the given `packageName`.
@@ -61,18 +41,9 @@ constructor(
fun isEmpty() = tasks.isEmpty()
/** Returns whether this task supports multiple tasks or not. */
open fun supportsMultipleTasks() = taskViewType == TaskViewType.GROUPED
/** Returns a List of all the Tasks in this GroupTask */
open val tasks: List<Task>
get() = listOfNotNull(task1, task2)
/** Creates a copy of this instance */
abstract fun copy(): GroupTask
override fun toString() = "type=$taskViewType task1=$task1 task2=$task2"
override fun equals(o: Any?): Boolean {
if (this === o) return true
if (o !is GroupTask) return false
@@ -83,15 +54,14 @@ constructor(
}
/** A [Task] container that must contain exactly one task in the recent tasks list. */
class SingleTask(task: Task) :
GroupTask(task, task2 = null, mSplitBounds = null, TaskViewType.SINGLE) {
class SingleTask(task: Task) : GroupTask(listOf(task), TaskViewType.SINGLE) {
val task: Task
get() = task1
get() = tasks[0]
override fun copy() = SingleTask(task1)
override fun copy() = SingleTask(task)
override fun toString() = "type=$taskViewType task=$task1"
override fun toString() = "type=$taskViewType task=$task"
override fun equals(o: Any?): Boolean {
if (this === o) return true
@@ -104,25 +74,26 @@ class SingleTask(task: Task) :
* A [Task] container that must contain exactly two tasks and split bounds to represent an app-pair
* in the recent tasks list.
*/
class SplitTask(task1: Task, task2: Task, splitBounds: SplitConfigurationOptions.SplitBounds) :
GroupTask(task1, task2, splitBounds, TaskViewType.GROUPED) {
class SplitTask(task1: Task, task2: Task, val splitBounds: SplitConfigurationOptions.SplitBounds) :
GroupTask(listOf(task1, task2), TaskViewType.GROUPED) {
val topLeftTask: Task
get() = if (mSplitBounds!!.leftTopTaskId == task1.key.id) task1!! else task2!!
get() = if (splitBounds.leftTopTaskId == tasks[0].key.id) tasks[0] else tasks[1]
val bottomRightTask: Task
get() = if (topLeftTask == task1) task2!! else task1!!
get() = if (topLeftTask == tasks[0]) tasks[1] else tasks[0]
override fun copy() = SplitTask(task1, task2!!, mSplitBounds!!)
override fun copy() = SplitTask(tasks[0], tasks[1], splitBounds)
override fun toString() = "type=$taskViewType task1=$task1 task2=$task2"
override fun toString() =
"type=$taskViewType topLeftTask=$topLeftTask bottomRightTask=$bottomRightTask"
override fun equals(o: Any?): Boolean {
if (this === o) return true
if (o !is SplitTask) return false
if (mSplitBounds!! != o.mSplitBounds!!) return false
if (splitBounds != o.splitBounds) return false
return super.equals(o)
}
override fun hashCode() = Objects.hash(super.hashCode(), mSplitBounds)
override fun hashCode() = Objects.hash(super.hashCode(), splitBounds)
}
@@ -1972,7 +1972,7 @@ public abstract class RecentsView<
var splitTask = (SplitTask) groupTask;
groupedTaskView.bind(splitTask.getTopLeftTask(),
splitTask.getBottomRightTask(), mOrientationState,
mTaskOverlayFactory, splitTask.mSplitBounds);
mTaskOverlayFactory, splitTask.getSplitBounds());
} else if (taskView instanceof DesktopTaskView desktopTaskView) {
// Minimized tasks should not be shown in Overview
List<Task> nonMinimizedTasks =