From 3a06568d8bcfb8a28eb0c5f631bf1b9c79084956 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Thu, 11 Feb 2021 13:54:27 +0000 Subject: [PATCH] Use PersistedTaskSnapshotData to calculate TaskView size - Disabled variable width for running task, as PersistedTaskSnapshotData is not always up to date for current task after rotating the device Bug: 174464656 Test: Test tablet overview with different comination of portrait/landscape wide/narrow thumbnails in portrait/landscape Change-Id: Ifa01e72020ccaf422e3975b092462de85fa19efd --- .../android/quickstep/RecentTasksList.java | 5 ++-- .../android/quickstep/views/RecentsView.java | 11 +++++--- .../quickstep/views/TaskThumbnailView.java | 28 ------------------- .../com/android/quickstep/views/TaskView.java | 13 ++++++--- 4 files changed, 18 insertions(+), 39 deletions(-) diff --git a/quickstep/src/com/android/quickstep/RecentTasksList.java b/quickstep/src/com/android/quickstep/RecentTasksList.java index 70b4f20c2b..1c5dc4c829 100644 --- a/quickstep/src/com/android/quickstep/RecentTasksList.java +++ b/quickstep/src/com/android/quickstep/RecentTasksList.java @@ -191,6 +191,7 @@ public class RecentTasksList extends TaskStackChangeListener { } else { task = new Task(taskKey); } + task.setLastSnapshotData(rawTask); allTasks.add(task); } @@ -200,9 +201,7 @@ public class RecentTasksList extends TaskStackChangeListener { private ArrayList copyOf(ArrayList tasks) { ArrayList newTasks = new ArrayList<>(); for (int i = 0; i < tasks.size(); i++) { - Task t = tasks.get(i); - newTasks.add(new Task(t.key, t.colorPrimary, t.colorBackground, t.isDockable, - t.isLocked, t.taskDescription, t.topActivity)); + newTasks.add(new Task(tasks.get(i))); } return newTasks; } diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 5d492acf84..deb1388e96 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -646,9 +646,9 @@ public abstract class RecentsView extends PagedView public TaskView getTaskView(int taskId) { for (int i = 0; i < getTaskViewCount(); i++) { - TaskView tv = getTaskViewAt(i); - if (tv.getTask() != null && tv.getTask().key != null && tv.getTask().key.id == taskId) { - return tv; + TaskView taskView = getTaskViewAt(i); + if (taskView.hasTaskId(taskId)) { + return taskView; } } return null; @@ -808,6 +808,7 @@ public abstract class RecentsView extends PagedView final Task task = tasks.get(i); final TaskView taskView = (TaskView) getChildAt(pageIndex); taskView.bind(task, mOrientationState); + taskView.updateTaskSize(!taskView.hasTaskId(mRunningTaskId)); } if (mNextPage == INVALID_PAGE) { @@ -942,7 +943,8 @@ public abstract class RecentsView extends PagedView // Force TaskView to update size from thumbnail final int taskCount = getTaskViewCount(); for (int i = 0; i < taskCount; i++) { - getTaskViewAt(i).updateTaskSize(); + TaskView taskView = getTaskViewAt(i); + taskView.updateTaskSize(!taskView.hasTaskId(mRunningTaskId)); } } @@ -1252,6 +1254,7 @@ public abstract class RecentsView extends PagedView // gesture and the task list is loaded and applied mTmpRunningTask = Task.from(new TaskKey(runningTaskInfo), runningTaskInfo, false); taskView.bind(mTmpRunningTask, mOrientationState); + taskView.updateTaskSize(false); // Measure and layout immediately so that the scroll values is updated instantly // as the user might be quick-switching diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java index 3bd883ddc4..f2f4bc1238 100644 --- a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java +++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java @@ -111,9 +111,6 @@ public class TaskThumbnailView extends View implements PluginListener