From 6f50ca34c45d79847765d9802f39466ea7b0d62e Mon Sep 17 00:00:00 2001 From: Ats Jenk Date: Mon, 30 Jan 2023 17:32:30 -0800 Subject: [PATCH] Pin desktop tile to the right in overview When desktop windowing prototype is enabled, pin desktop tile to the right of the focused tile. Also making desktop tile persistent so it will always show up, regardless whether there are tasks added to the desktop or not. Fixing some nullpointer issues that stem from that. Bug: 261234155 Test: no recent tasks, go to overview, shows empty view Test: only desktop tasks, go to overview from home, desktop tile focused Test: only desktop tasks, desktop open, go to overview, desktop tile focused Test: 1 fullscreen task and some desktop tasks, go to overview from home screen, fullscreen tile focused Test: fullscreen task open and no desktop tasks, go to overview, fullscreen task focused and empty desktop tile on the right Test: fullscreen task open and some desktop tasks in background, go to overview, fullscreen tile focused, desktop tile on the right Test: some desktop tasks focused, some fullscreen tasks in background, go to overview, desktop tile focused, fullscreen tasks on the left Change-Id: Ib28185b40f639d36b82b6d0e3c61026ec84e245c --- quickstep/res/layout/task_desktop.xml | 3 +- .../quickstep/views/DesktopTaskView.java | 18 ++--- .../android/quickstep/views/RecentsView.java | 65 ++++++++++++++++--- .../com/android/quickstep/views/TaskView.java | 7 +- 4 files changed, 74 insertions(+), 19 deletions(-) diff --git a/quickstep/res/layout/task_desktop.xml b/quickstep/res/layout/task_desktop.xml index 0c8543f414..2a9674f90b 100644 --- a/quickstep/res/layout/task_desktop.xml +++ b/quickstep/res/layout/task_desktop.xml @@ -33,7 +33,8 @@ + android:layout_height="wrap_content" + android:visibility="gone" /> mTasks; + @NonNull + private List mTasks = new ArrayList<>(); private final ArrayList mSnapshotViews = new ArrayList<>(); @@ -108,8 +109,6 @@ public class DesktopTaskView extends TaskView { getContext().getTheme())); // TODO(b/244348395): this should be wallpaper setBackground(mBackground); - - mSnapshotViews.add(mSnapshotView); } @Override @@ -129,12 +128,9 @@ public class DesktopTaskView extends TaskView { } Log.d(TAG, sb.toString()); } - if (tasks.isEmpty()) { - return; - } cancelPendingLoadTasks(); - mTasks = tasks; + mTasks = new ArrayList<>(tasks); mSnapshotViewMap.clear(); // Ensure there are equal number of snapshot views and tasks. @@ -207,7 +203,8 @@ public class DesktopTaskView extends TaskView { if (task != null) { return mSnapshotViewMap.get(task.key.id); } - return null; + // Return the place holder snapshot views. Callers expect this to be non-null + return mSnapshotView; } @Override @@ -313,6 +310,11 @@ public class DesktopTaskView extends TaskView { callback.accept(true); } + @Override + public boolean isDesktopTask() { + return true; + } + @Override void refreshThumbnails(@Nullable HashMap thumbnailDatas) { // Sets new thumbnails based on the incoming data and refreshes the rest. diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 8facb0a35e..d8ecd872fb 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -1548,8 +1548,14 @@ public abstract class RecentsView= 0; i--) { @@ -1622,6 +1630,12 @@ public abstract class RecentsView tasks = desktopTask != null ? desktopTask.tasks : new ArrayList<>(); + ((DesktopTaskView) taskView).bind(tasks, mOrientationState); + } } // Keep same previous focused task @@ -1674,6 +1693,12 @@ public abstract class RecentsView 0) { newFocusedTaskView = getTaskViewAt(0); + // Check if the first task is the desktop. + // If first task is desktop, try to find another task to set as the focused task + if (newFocusedTaskView != null && newFocusedTaskView.isDesktopTask() + && getTaskViewCount() > 1) { + newFocusedTaskView = getTaskViewAt(1); + } } mFocusedTaskViewId = newFocusedTaskView != null ? newFocusedTaskView.getTaskViewId() : -1; @@ -1707,7 +1732,12 @@ public abstract class RecentsView 0) { - targetPage = indexOfChild(requireTaskViewAt(0)); + TaskView taskView = requireTaskViewAt(0); + // If first task id desktop, try to find another task to set the target page + if (taskView.isDesktopTask() && getTaskViewCount() > 1) { + taskView = requireTaskViewAt(1); + } + targetPage = indexOfChild(taskView); } } if (targetPage != -1 && mCurrentPage != targetPage) { @@ -2136,6 +2166,9 @@ public abstract class RecentsView focusedTaskIndex) { // For tasks after the focused task, shift by focused task's width and spacing. @@ -2776,7 +2819,7 @@ public abstract class RecentsView= 0; j--) { - if (j == focusedTaskIndex) { + if (j == focusedTaskIndex || j == desktopTaskIndex) { continue; } widthOffset += requireTaskViewAt(j).getLayoutParams().width + mPageSpacing; @@ -2795,7 +2838,7 @@ public abstract class RecentsView= 0; j--) { - if (j == focusedTaskIndex) { + if (j == focusedTaskIndex || j == desktopTaskIndex) { continue; } widthOffset += requireTaskViewAt(j).getLayoutParams().width + mPageSpacing; @@ -5096,6 +5139,10 @@ public abstract class RecentsView