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