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

Commit ee8c73b7 authored by Thales Lima's avatar Thales Lima
Browse files

Move focused task when using taskId 0

This is a quality of life improvement when moving tasks to desks. Using -1 is not permitted because the command interprets it as a flag.

Fixes: 336268819
Test: adb shell dumpsys activity service SystemUIService WMShell desktopmode moveTaskToDesk 0
Flag: EXEMPT small refactor
Change-Id: Id36bcbbc91c7200e14f95b040d8380a42c0aa710
parent f72d2dc9
Loading
Loading
Loading
Loading
+21 −5
Original line number Diff line number Diff line
@@ -54,13 +54,23 @@ class DesktopModeShellCommandHandler(
            pw.println("Error: task id should be provided as arguments")
            return false
        }
        val taskId =
        var taskId =
            try {
                args[1].toInt()
            } catch (e: NumberFormatException) {
                pw.println("Error: task id should be an integer")
                return false
            }

        if (taskId == 0) {
            taskId = focusTransitionObserver.globallyFocusedTaskId
        }

        if (taskId == INVALID_TASK_ID) {
            pw.println("Error: no appropriate task found")
            return false
        }

        if (!DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue) {
            return controller.moveTaskToDefaultDeskAndActivate(taskId, transitionSource = UNKNOWN)
        }
@@ -257,14 +267,20 @@ class DesktopModeShellCommandHandler(

    override fun printShellCommandHelp(pw: PrintWriter, prefix: String) {
        if (!DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue) {
            pw.println("$prefix moveTaskToDesk <taskId> ")
            pw.println("$prefix  Move a task with given id to desktop mode.")
            pw.println("$prefix moveTaskToDesk <taskId|0>")
            pw.println(
                "$prefix  Move a task with given id to desktop mode. " +
                    "TaskId 0 means focused task on the default display."
            )
            pw.println("$prefix moveToNextDisplay <taskId> ")
            pw.println("$prefix  Move a task with given id to next display.")
            return
        }
        pw.println("$prefix moveTaskToDesk <taskId> <deskId>")
        pw.println("$prefix  Move a task with given id to the given desk and activate it.")
        pw.println("$prefix moveTaskToDesk <taskId|0> <deskId>")
        pw.println(
            "$prefix  Move a task with given id to the given desk and activate it. " +
                "TaskId 0 means focused task on the default display."
        )
        pw.println("$prefix moveToNextDisplay <taskId>")
        pw.println("$prefix  Move a task with given id to next display.")
        pw.println("$prefix createDesk <displayId>")
+5 −1
Original line number Diff line number Diff line
@@ -370,7 +370,11 @@ class DesktopTasksController(
    /** Returns whether the given display has an active desk. */
    fun isAnyDeskActive(displayId: Int): Boolean = taskRepository.isAnyDeskActive(displayId)

    /** Moves focused task to desktop mode for given [displayId]. */
    /**
     * Moves focused task to desktop mode for given [displayId].
     *
     * TODO(b/405381458): use focusTransitionObserver to get the focused task on a certain display
     */
    fun moveFocusedTaskToDesktop(displayId: Int, transitionSource: DesktopModeTransitionSource) {
        val allFocusedTasks = getAllFocusedTasks(displayId)
        when (allFocusedTasks.size) {