Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7555925 authored by Alex Chau's avatar Alex Chau Committed by Cherrypicker Worker
Browse files

Add stub task when matching TaskView is grouped while runningTasks is not grouped

- Completely rewrote shouldAddStubTaskView to simplify the logic

Fix: 333844287
Test: With 2 split tasks, unsplit one, go to Overview, launch the other split, unsplit, go to Overview
Flag: None
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:492965326e7391c8427b6fca7875508e7a957b49)
Merged-In: I2f33f91956d485957cedf43ccd684f16d42803be
Change-Id: I2f33f91956d485957cedf43ccd684f16d42803be
parent 0db4a1aa
Loading
Loading
Loading
Loading
+13 −11
Original line number Original line Diff line number Diff line
@@ -2759,18 +2759,20 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
     * Returns true if we should add a stub taskView for the running task id
     * Returns true if we should add a stub taskView for the running task id
     */
     */
    protected boolean shouldAddStubTaskView(Task[] runningTasks) {
    protected boolean shouldAddStubTaskView(Task[] runningTasks) {
        TaskView taskView = getTaskViewByTaskId(runningTasks[0].key.id);
        if (taskView == null) {
            // No TaskView found, add a stub task.
            return true;
        }

        if (runningTasks.length > 1) {
        if (runningTasks.length > 1) {
            TaskView primaryTaskView = getTaskViewByTaskId(runningTasks[0].key.id);
            // Ensure all taskIds matches the TaskView, otherwise add a stub task.
            TaskView secondaryTaskView = getTaskViewByTaskId(runningTasks[1].key.id);
            return Arrays.stream(runningTasks).anyMatch(
            int leftTopTaskViewId =
                    runningTask -> !taskView.containsTaskId(runningTask.key.id));
                    (primaryTaskView == null) ? -1 : primaryTaskView.getTaskViewId();
        } else {
            int rightBottomTaskViewId =
            // Ensure the TaskView only contains a single taskId, otherwise add a stub task.
                    (secondaryTaskView == null) ? -1 : secondaryTaskView.getTaskViewId();
            return taskView.containsMultipleTasks();
            // Add a new stub view if both taskIds don't match any taskViews
        }
            return leftTopTaskViewId != rightBottomTaskViewId || leftTopTaskViewId == -1;
        }
        Task runningTaskInfo = runningTasks[0];
        return runningTaskInfo != null && getTaskViewByTaskId(runningTaskInfo.key.id) == null;
    }
    }


    /**
    /**