diff options
author | Jeremy Sim <jeremysim@google.com> | 2023-02-01 15:22:23 +0800 |
---|---|---|
committer | Jeremy Sim <jeremysim@google.com> | 2023-02-01 15:40:06 +0800 |
commit | 0b4b89bdcf8a3460acaba44a11e62a0f5b10589f (patch) | |
tree | c609035ebc0277cf5b604f568bfc6981fbcbdd1b | |
parent | 1a4eb297ee726c3b69d1364743bc47049a903746 (diff) | |
download | Launcher3-0b4b89bdcf8a3460acaba44a11e62a0f5b10589f.tar.gz |
Fix bug with selecting a secondary task as second splitscreen app via Taskbar
This patch makes it so that the correct task will be chosen when selecting a second splitscreen app via Taskbar.
Prior to this patch, the Taskbar app selection function -- which attempts to match the tapped icon to a running TaskView -- assumed that the TaskView in question was always a solo (non-grouped) Task. This resulted in the wrong app being selected for split when the desired Task happened to be the secondary app in a pair.
Fixed by checking to see if the desired app is primary or secondary, and returning the correct Task, IconView, and ThumbnailView for the split operation.
Fixes: 265244769
Test: Manual
Change-Id: Ie1122d1b49151d70dec9711fe558fba7752b7d8e
-rw-r--r-- | quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java | 13 | ||||
-rw-r--r-- | quickstep/src/com/android/quickstep/views/TaskView.java | 13 |
2 files changed, 22 insertions, 4 deletions
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java index b680a1536e..87fa6f318f 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java @@ -31,6 +31,7 @@ import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.SplitConfigurationOptions; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; +import com.android.quickstep.views.TaskView.TaskIdAttributeContainer; import com.android.systemui.shared.recents.model.Task; import java.io.PrintWriter; @@ -202,12 +203,16 @@ public class TaskbarUIController { // null checks as much. See comments at ag/21152798. if (foundTaskView != null) { // There is already a running app of this type, use that as second app. + // Get index of task (0 or 1), in case it's a GroupedTaskView + int indexOfTask = foundTaskView.getIndexOfTask(foundTask.key.id); + TaskIdAttributeContainer taskAttributes = + foundTaskView.getTaskIdAttributeContainers()[indexOfTask]; recents.confirmSplitSelect( foundTaskView, - foundTaskView.getTask(), - foundTaskView.getIconView().getDrawable(), - foundTaskView.getThumbnail(), - foundTaskView.getThumbnail().getThumbnail(), + taskAttributes.getTask(), + taskAttributes.getIconView().getDrawable(), + taskAttributes.getThumbnailView(), + taskAttributes.getThumbnailView().getThumbnail(), null /* intent */); return; } diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index aa37fddb8b..b23c87349c 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -600,6 +600,19 @@ public class TaskView extends FrameLayout implements Reusable { return mTaskIdContainer[1] != -1; } + /** + * Finds the index of a given taskId within this TaskView, or -1 if the TaskView does not + * contain it. For grouped tasks (of two), this is 0 or 1; for solo tasks, it is 0. + */ + public int getIndexOfTask(int taskId) { + for (int i = 0; i < mTaskIdContainer.length; i++) { + if (mTaskIdContainer[i] == taskId) { + return i; + } + } + return -1; + } + public TaskThumbnailView getThumbnail() { return mSnapshotView; } |