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

Commit 5a90a5ab authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix for recents button quick switch with only focus and desktop task" into main

parents d0ce1d3c b6ac8b2a
Loading
Loading
Loading
Loading
+28 −7
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import androidx.annotation.BinderThread
import androidx.annotation.UiThread
import androidx.annotation.VisibleForTesting
import com.android.internal.jank.Cuj
import com.android.launcher3.Flags.enableLargeDesktopWindowingTile
import com.android.launcher3.Flags.enableOverviewCommandHelperTimeout
import com.android.launcher3.PagedView
import com.android.launcher3.logger.LauncherAtom
@@ -215,13 +216,12 @@ constructor(
                }
            }
            TOGGLE -> {
                val taskView =
                    if (recentsView.runningTaskView == null) {
                        recentsView.getTaskViewAt(0)
                    } else {
                        recentsView.nextTaskView ?: recentsView.runningTaskView
                    }
                launchTask(recentsView, taskView, command, onCallbackResult)
                launchTask(
                    recentsView,
                    getNextToggledTaskView(recentsView),
                    command,
                    onCallbackResult,
                )
            }
            HOME -> {
                recentsView.startHome()
@@ -229,6 +229,27 @@ constructor(
            }
        }

    private fun getNextToggledTaskView(recentsView: RecentsView<*, *>): TaskView? {
        // When running task view is null we return last large taskView - typically focusView when
        // grid only is not enabled else last desktop task view.
        return if (recentsView.runningTaskView == null) {
            recentsView.lastLargeTaskView ?: recentsView.getTaskViewAt(0)
        } else {
            if (
                enableLargeDesktopWindowingTile() &&
                    recentsView.getTaskViewCount() == recentsView.largeTilesCount &&
                    recentsView.runningTaskView === recentsView.lastLargeTaskView
            ) {
                // Enables the toggle when only large tiles are in recents view.
                // We return previous because unlike small tiles, large tiles are always
                // on the right hand side.
                recentsView.previousTaskView ?: recentsView.runningTaskView
            } else {
                recentsView.nextTaskView ?: recentsView.runningTaskView
            }
        }
    }

    private fun launchTask(
        recents: RecentsView<*, *>,
        taskView: TaskView?,
+14 −0
Original line number Diff line number Diff line
@@ -4571,6 +4571,20 @@ public abstract class RecentsView<
        return getTaskViewAt(getRunningTaskIndex() + 1);
    }

    @Nullable
    public TaskView getPreviousTaskView() {
        return getTaskViewAt(getRunningTaskIndex() - 1);
    }

    @Nullable
    public TaskView getLastLargeTaskView() {
        return mUtils.getLastLargeTaskView(getTaskViews());
    }

    public int getLargeTilesCount() {
        return mUtils.getLargeTileCount(getTaskViews());
    }

    @Nullable
    public TaskView getCurrentPageTaskView() {
        return getTaskViewAt(getCurrentPage());