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

Commit 55ef24c2 authored by Alex Chau's avatar Alex Chau Committed by Android (Google) Code Review
Browse files

Merge "Add task menu item to move task to Desktop" into main

parents 887a88f1 3c0729c4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@
    <string name="recent_task_option_pin">Pin</string>
    <!-- Title for an option to enter freeform mode for a given app -->
    <string name="recent_task_option_freeform">Freeform</string>
    <!-- Title for an option to enter desktop windowing mode for a given app -->
    <string name="recent_task_option_desktop">Desktop</string>

    <!-- Recents: The empty recents string. [CHAR LIMIT=NONE] -->
    <string name="recents_empty_message">No recent items</string>
+6 −2
Original line number Diff line number Diff line
@@ -56,6 +56,11 @@ class DesktopRecentsTransitionController(
        systemUiProxy.showDesktopApps(desktopTaskView.display.displayId, transition)
    }

    /** Launch desktop tasks from recents view */
    fun moveToDesktop(taskId: Int) {
        systemUiProxy.moveToDesktop(taskId)
    }

    private class RemoteDesktopLaunchTransitionRunner(
        private val desktopTaskView: DesktopTaskView,
        private val stateManager: StateManager<*>,
@@ -99,8 +104,7 @@ class DesktopRecentsTransitionController(
            finishCallback: IRemoteTransitionFinishedCallback
        ) {}

        override fun onTransitionConsumed(transition: IBinder?, aborted: Boolean) {
        }
        override fun onTransitionConsumed(transition: IBinder?, aborted: Boolean) {}
    }

    companion object {
+1 −1
Original line number Diff line number Diff line
@@ -499,7 +499,7 @@ public class HotseatPredictionController implements DragController.DragListener,

        @Override
        public void onClick(View view) {
            dismissTaskMenuView(mTarget);
            dismissTaskMenuView();
            pinPrediction(mItemInfo);
        }
    }
+81 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.quickstep

import android.view.View
import com.android.launcher3.AbstractFloatingViewHelper
import com.android.launcher3.BaseDraggingActivity
import com.android.launcher3.R
import com.android.launcher3.logging.StatsLogManager.LauncherEvent
import com.android.launcher3.popup.SystemShortcut
import com.android.quickstep.views.RecentsView
import com.android.quickstep.views.TaskView.TaskIdAttributeContainer
import com.android.window.flags.Flags

/** A menu item, "Desktop", that allows the user to bring the current app into Desktop Windowing. */
class DesktopSystemShortcut(
    activity: BaseDraggingActivity,
    private val mTaskContainer: TaskIdAttributeContainer,
    abstractFloatingViewHelper: AbstractFloatingViewHelper
) :
    SystemShortcut<BaseDraggingActivity>(
        R.drawable.ic_caption_desktop_button_foreground,
        R.string.recent_task_option_desktop,
        activity,
        mTaskContainer.itemInfo,
        mTaskContainer.taskView,
        abstractFloatingViewHelper
    ) {
    override fun onClick(view: View) {
        dismissTaskMenuView()
        val recentsView = mTarget!!.getOverviewPanel<RecentsView<*, *>>()
        recentsView.moveTaskToDesktop(mTaskContainer) {
            mTarget.statsLogManager
                .logger()
                .withItemInfo(mTaskContainer.itemInfo)
                .log(LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_DESKTOP_TAP)
        }
    }

    companion object {
        /** Creates a factory for creating Desktop system shorcuts. */
        @JvmOverloads
        fun createFactory(
            abstractFloatingViewHelper: AbstractFloatingViewHelper = AbstractFloatingViewHelper()
        ): TaskShortcutFactory {
            return object : TaskShortcutFactory {
                override fun getShortcuts(
                    activity: BaseDraggingActivity,
                    taskContainer: TaskIdAttributeContainer
                ): List<DesktopSystemShortcut>? {
                    return if (!Flags.enableDesktopWindowingMode()) null
                    else if (!taskContainer.task.isDockable) null
                    else
                        listOf(
                            DesktopSystemShortcut(
                                activity,
                                taskContainer,
                                abstractFloatingViewHelper
                            )
                        )
                }

                override fun showForSplitscreen() = true
            }
        }
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -1475,6 +1475,17 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle {
        }
    }

    /** Call shell to move a task with given `taskId` to desktop  */
    public void moveToDesktop(int taskId) {
        if (mDesktopMode != null) {
            try {
                mDesktopMode.moveToDesktop(taskId);
            } catch (RemoteException e) {
                Log.w(TAG, "Failed call moveToDesktop", e);
            }
        }
    }

    //
    // Unfold transition
    //
Loading