Handle running task launch properly in desktop mode
- Move logic from KeyboardQuickSwitchViewController to handle bringing desktop tasks to front, and still support recent tasks for non-desktop mode. Flag: com.android.launcher3.enable_recents_in_taskbar Test: manually launch tasks from the Recents section in both Desktop mode and full screen mode (running vs recent) Bug: 315354060 Change-Id: I0520351b4d0095a3538c6165acd82a7b4c45a5e2
This commit is contained in:
@@ -67,6 +67,7 @@ import android.view.View;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
import android.window.RemoteTransition;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -131,6 +132,9 @@ import com.android.launcher3.views.ActivityContext;
|
||||
import com.android.quickstep.LauncherActivityInterface;
|
||||
import com.android.quickstep.NavHandle;
|
||||
import com.android.quickstep.RecentsModel;
|
||||
import com.android.quickstep.SystemUiProxy;
|
||||
import com.android.quickstep.util.DesktopTask;
|
||||
import com.android.quickstep.util.GroupTask;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
import com.android.quickstep.views.TaskView;
|
||||
import com.android.systemui.shared.recents.model.Task;
|
||||
@@ -298,7 +302,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
TaskbarEduTooltipController.newInstance(this),
|
||||
new KeyboardQuickSwitchController(),
|
||||
new TaskbarPinningController(this, () ->
|
||||
DisplayController.INSTANCE.get(this).getInfo().isInDesktopMode()),
|
||||
DisplayController.isInDesktopMode(this)),
|
||||
bubbleControllersOptional);
|
||||
|
||||
mLauncherPrefs = LauncherPrefs.get(this);
|
||||
@@ -1081,10 +1085,9 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
RecentsView recents = taskbarUIController.getRecentsView();
|
||||
boolean shouldCloseAllOpenViews = true;
|
||||
Object tag = view.getTag();
|
||||
if (tag instanceof Task) {
|
||||
Task task = (Task) tag;
|
||||
ActivityManagerWrapper.getInstance().startActivityFromRecents(task.key,
|
||||
ActivityOptions.makeBasic());
|
||||
if (tag instanceof GroupTask groupTask) {
|
||||
handleGroupTaskLaunch(groupTask, /* remoteTransition = */ null,
|
||||
DisplayController.isInDesktopMode(this));
|
||||
mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
|
||||
} else if (tag instanceof FolderInfo) {
|
||||
// Tapping an expandable folder icon on Taskbar
|
||||
@@ -1184,6 +1187,36 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Launches the given GroupTask with the following behavior:
|
||||
* - If the GroupTask is a DesktopTask, launch the tasks in that Desktop.
|
||||
* - If {@code onDesktop}, bring the given GroupTask to the front.
|
||||
* - If the GroupTask is a single task, launch it via startActivityFromRecents.
|
||||
* - Otherwise, we assume the GroupTask is a Split pair and launch them together.
|
||||
*/
|
||||
public void handleGroupTaskLaunch(GroupTask task, @Nullable RemoteTransition remoteTransition,
|
||||
boolean onDesktop) {
|
||||
if (task instanceof DesktopTask) {
|
||||
UI_HELPER_EXECUTOR.execute(() ->
|
||||
SystemUiProxy.INSTANCE.get(this).showDesktopApps(getDisplay().getDisplayId(),
|
||||
remoteTransition));
|
||||
} else if (onDesktop) {
|
||||
UI_HELPER_EXECUTOR.execute(() ->
|
||||
SystemUiProxy.INSTANCE.get(this).showDesktopApp(task.task1.key.id));
|
||||
} else if (task.task2 == null) {
|
||||
UI_HELPER_EXECUTOR.execute(() -> {
|
||||
ActivityOptions activityOptions =
|
||||
makeDefaultActivityOptions(SPLASH_SCREEN_STYLE_UNDEFINED).options;
|
||||
activityOptions.setRemoteTransition(remoteTransition);
|
||||
|
||||
ActivityManagerWrapper.getInstance().startActivityFromRecents(
|
||||
task.task1.key, activityOptions);
|
||||
});
|
||||
} else {
|
||||
mControllers.uiController.launchSplitTasks(task, remoteTransition);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs when the user taps a Taskbar icon in TaskbarActivityContext (Overview or inside an app),
|
||||
* and calls the appropriate method to animate and launch.
|
||||
|
||||
Reference in New Issue
Block a user