Remove `GroupTask.mSplitBounds`
See go/refactor-group-task for details. This CL removes `mSplitBounds`
from `GroupTask` and adds `splitBounds` to `SplitTask`. This makes its
usages more intentional.
Bug: 388593902
Test: m
Flag: EXEMPT pure refactor with no behavior change.
Change-Id: I9a3e8ee2e96d46f9eb79a58ffcf5efc257615aac
diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java
index 73f9bea..4581119 100644
--- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java
@@ -275,7 +275,7 @@
task2,
updateTasks ? mViewCallbacks::updateThumbnailInBackground : null,
updateTasks ? mViewCallbacks::updateIconInBackground : null,
- groupTask.mSplitBounds);
+ groupTask instanceof SplitTask splitTask ? splitTask.getSplitBounds() : null);
previousTaskView = currentTaskView;
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
index c880aa9..690dec4 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
@@ -65,7 +65,6 @@
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 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);
}
diff --git a/quickstep/src/com/android/quickstep/util/DesktopTask.kt b/quickstep/src/com/android/quickstep/util/DesktopTask.kt
index 0669185..5d61dd4 100644
--- a/quickstep/src/com/android/quickstep/util/DesktopTask.kt
+++ b/quickstep/src/com/android/quickstep/util/DesktopTask.kt
@@ -23,7 +23,7 @@
* tasks list.
*/
class DesktopTask(override val tasks: List<Task>) :
- GroupTask(tasks[0], null, null, TaskViewType.DESKTOP) {
+ GroupTask(tasks[0], task2 = null, TaskViewType.DESKTOP) {
override fun containsTask(taskId: Int) = tasks.any { it.key.id == taskId }
diff --git a/quickstep/src/com/android/quickstep/util/GroupTask.kt b/quickstep/src/com/android/quickstep/util/GroupTask.kt
index 8237d2e..9ab9633 100644
--- a/quickstep/src/com/android/quickstep/util/GroupTask.kt
+++ b/quickstep/src/com/android/quickstep/util/GroupTask.kt
@@ -30,19 +30,12 @@
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,
- )
+ ) : this(task1, task2, if (task2 != null) TaskViewType.GROUPED else TaskViewType.SINGLE)
open fun containsTask(taskId: Int) =
task1.key.id == taskId || (task2 != null && task2.key.id == taskId)
@@ -83,8 +76,7 @@
}
/** 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(task, task2 = null, TaskViewType.SINGLE) {
val task: Task
get() = task1
@@ -104,25 +96,25 @@
* 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(task1, task2, TaskViewType.GROUPED) {
val topLeftTask: Task
- get() = if (mSplitBounds!!.leftTopTaskId == task1.key.id) task1!! else task2!!
+ get() = if (splitBounds.leftTopTaskId == task1.key.id) task1!! else task2!!
val bottomRightTask: Task
get() = if (topLeftTask == task1) task2!! else task1!!
- override fun copy() = SplitTask(task1, task2!!, mSplitBounds!!)
+ override fun copy() = SplitTask(task1, task2!!, splitBounds)
override fun toString() = "type=$taskViewType task1=$task1 task2=$task2"
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)
}
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index c6db576..5e59a06 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -1988,7 +1988,7 @@
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 =