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<>(); @@ -111,8 +112,6 @@ public class DesktopTaskView extends TaskView { getContext().getTheme())); // TODO(b/244348395): this should be wallpaper setBackground(mBackground); - - mSnapshotViews.add(mSnapshotView); } @Override @@ -132,12 +131,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. @@ -210,7 +206,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 @@ -316,6 +313,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 61d6179a43..2505d9192a 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -1550,8 +1550,14 @@ public abstract class RecentsView= 0; i--) { @@ -1624,6 +1632,12 @@ public abstract class RecentsView tasks = desktopTask != null ? desktopTask.tasks : new ArrayList<>(); + ((DesktopTaskView) taskView).bind(tasks, mOrientationState); + } } // Keep same previous focused task @@ -1676,6 +1695,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; @@ -1709,7 +1734,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) { @@ -2141,6 +2171,9 @@ public abstract class RecentsView focusedTaskIndex) { // For tasks after the focused task, shift by focused task's width and spacing. @@ -2781,7 +2824,7 @@ public abstract class RecentsView= 0; j--) { - if (j == focusedTaskIndex) { + if (j == focusedTaskIndex || j == desktopTaskIndex) { continue; } widthOffset += requireTaskViewAt(j).getLayoutParams().width + mPageSpacing; @@ -2800,7 +2843,7 @@ public abstract class RecentsView= 0; j--) { - if (j == focusedTaskIndex) { + if (j == focusedTaskIndex || j == desktopTaskIndex) { continue; } widthOffset += requireTaskViewAt(j).getLayoutParams().width + mPageSpacing; @@ -5101,6 +5144,10 @@ public abstract class RecentsView