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

Commit b6ac8b2a authored by vinayjoglekar's avatar vinayjoglekar
Browse files

Fix for recents button quick switch with only focus and desktop task

This CL also fixes : Home -> Recents -> Recents opens the last large tile (Which was broken when there is desktop window tile in recents.)

Test: Manual
BUG: 365756337
Fix: 365756337
Flag: com.android.launcher3.enable_large_desktop_windowing_tile
Change-Id: I0b8fe3a0a7074355f14ced23ae282fe2943d8ce9
parent cbe8f8f7
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
@@ -4567,6 +4567,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());