Force Grid-based Recents to show at most 8 tasks.
Bug: 32101881
Bug: 33975969
Change-Id: Icbadaa3ca12f53e57e06dd19d7809a23e0efa88c
(cherry picked from commit 883887eac908b4b0145f06c52de00f76e8c833df)
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java
index 5877440..5c7496d 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java
@@ -38,6 +38,7 @@
import com.android.systemui.recents.RecentsDebugFlags;
import com.android.systemui.recents.misc.SystemServicesProxy;
+import com.android.systemui.recents.views.grid.TaskGridLayoutAlgorithm;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -150,11 +151,19 @@
Task.TaskKey taskKey = new Task.TaskKey(t.persistentId, t.stackId, t.baseIntent,
t.userId, t.firstActiveTime, t.lastActiveTime);
- // This task is only shown in the stack if it statisfies the historical time or min
+ // This task is only shown in the stack if it satisfies the historical time or min
// number of tasks constraints. Freeform tasks are also always shown.
boolean isFreeformTask = SystemServicesProxy.isFreeformStack(t.stackId);
- boolean isStackTask = isFreeformTask || !isHistoricalTask(t) ||
+ boolean isStackTask;
+ if (Recents.getConfiguration().isGridEnabled) {
+ // When grid layout is enabled, we only show the first
+ // TaskGridLayoutAlgorithm.MAX_LAYOUT_TASK_COUNT} tasks.
+ isStackTask = t.lastActiveTime >= lastStackActiveTime &&
+ i >= taskCount - TaskGridLayoutAlgorithm.MAX_LAYOUT_TASK_COUNT;
+ } else {
+ isStackTask = isFreeformTask || !isHistoricalTask(t) ||
(t.lastActiveTime >= lastStackActiveTime && i >= (taskCount - MIN_NUM_TASKS));
+ }
boolean isLaunchTarget = taskKey.id == runningTaskId;
// The last stack active time is the baseline for which we show visible tasks. Since
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/grid/TaskGridLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/grid/TaskGridLayoutAlgorithm.java
index be3af040..046ced4 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/grid/TaskGridLayoutAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/grid/TaskGridLayoutAlgorithm.java
@@ -30,7 +30,7 @@
public class TaskGridLayoutAlgorithm {
private final String TAG = "TaskGridLayoutAlgorithm";
- private final int MAX_LAYOUT_TASK_COUNT = 8;
+ public static final int MAX_LAYOUT_TASK_COUNT = 8;
/** The horizontal padding around the whole recents view. */
private int mPaddingLeftRight;
@@ -135,6 +135,16 @@
updateAppAspectRatio();
}
+ /**
+ * Returns the proper task view transform of a certain task view, according to its index and the
+ * amount of task views.
+ * @param taskIndex The index of the task view whose transform we want. It's never greater
+ * than {@link MAX_LAYOUT_TASK_COUNT}.
+ * @param taskCount The current amount of task views.
+ * @param transformOut The result transform that this method returns.
+ * @param stackLayout The base stack layout algorithm.
+ * @return The expected transform of the (taskIndex)th task view.
+ */
public TaskViewTransform getTransform(int taskIndex, int taskCount,
TaskViewTransform transformOut, TaskStackLayoutAlgorithm stackLayout) {