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

Commit f9551e4c authored by Jeremy Sim's avatar Jeremy Sim Committed by Automerger Merge Worker
Browse files

Merge "Fix bug with Taskbar launches in Overview" into tm-qpr-dev am: bc1fa1e6

parents 768e60af bc1fa1e6
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -101,7 +101,7 @@ public interface QuickstepSystemShortcut {
            RecentsView recentsView = mTarget.getOverviewPanel();
            RecentsView recentsView = mTarget.getOverviewPanel();
            // Check if there is already an instance of this app running, if so, initiate the split
            // Check if there is already an instance of this app running, if so, initiate the split
            // using that.
            // using that.
            recentsView.findLastActiveTaskAndDoSplitOperation(
            recentsView.findLastActiveTaskAndRunCallback(
                    intent.getComponent(),
                    intent.getComponent(),
                    (Consumer<Task>) foundTask -> {
                    (Consumer<Task>) foundTask -> {
                        SplitSelectSource source = new SplitSelectSource(mOriginalView,
                        SplitSelectSource source = new SplitSelectSource(mOriginalView,
+33 −6
Original line number Original line Diff line number Diff line
@@ -94,6 +94,7 @@ import com.android.launcher3.util.TraceHelper;
import com.android.launcher3.util.ViewCache;
import com.android.launcher3.util.ViewCache;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.ActivityContext;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.rotation.RotationButtonController;
import com.android.systemui.shared.rotation.RotationButtonController;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.ActivityManagerWrapper;
@@ -101,6 +102,7 @@ import com.android.systemui.unfold.updates.RotationChangeProvider;
import com.android.systemui.unfold.util.ScopedUnfoldTransitionProgressProvider;
import com.android.systemui.unfold.util.ScopedUnfoldTransitionProgressProvider;


import java.io.PrintWriter;
import java.io.PrintWriter;
import java.util.function.Consumer;


/**
/**
 * The {@link ActivityContext} with which we inflate Taskbar-related Views. This allows UI elements
 * The {@link ActivityContext} with which we inflate Taskbar-related Views. This allows UI elements
@@ -778,12 +780,12 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
                });
                });
            });
            });
        } else if (tag instanceof WorkspaceItemInfo) {
        } else if (tag instanceof WorkspaceItemInfo) {
            // Tapping a launchable icon on Taskbar
            WorkspaceItemInfo info = (WorkspaceItemInfo) tag;
            WorkspaceItemInfo info = (WorkspaceItemInfo) tag;
            if (!info.isDisabled() || !ItemClickHandler.handleDisabledItemClicked(info, this)) {
            if (!info.isDisabled() || !ItemClickHandler.handleDisabledItemClicked(info, this)) {
                TaskbarUIController taskbarUIController = mControllers.uiController;
                TaskbarUIController taskbarUIController = mControllers.uiController;
                RecentsView recents = taskbarUIController.getRecentsView();
                RecentsView recents = taskbarUIController.getRecentsView();
                if (recents != null
                if (recents != null && recents.isSplitSelectionActive()) {
                        && taskbarUIController.getRecentsView().isSplitSelectionActive()) {
                    // If we are selecting a second app for split, launch the split tasks
                    // If we are selecting a second app for split, launch the split tasks
                    taskbarUIController.triggerSecondAppForSplit(info, info.intent, view);
                    taskbarUIController.triggerSecondAppForSplit(info, info.intent, view);
                } else {
                } else {
@@ -810,7 +812,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
                            getSystemService(LauncherApps.class)
                            getSystemService(LauncherApps.class)
                                    .startShortcut(packageName, id, null, null, info.user);
                                    .startShortcut(packageName, id, null, null, info.user);
                        } else {
                        } else {
                            startItemInfoActivity(info);
                            launchFromTaskbarPreservingSplitIfVisible(recents, info);
                        }
                        }


                        mControllers.uiController.onTaskbarIconLaunched(info);
                        mControllers.uiController.onTaskbarIconLaunched(info);
@@ -825,6 +827,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
                mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
                mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
            }
            }
        } else if (tag instanceof AppInfo) {
        } else if (tag instanceof AppInfo) {
            // Tapping an item in AllApps
            AppInfo info = (AppInfo) tag;
            AppInfo info = (AppInfo) tag;
            TaskbarUIController taskbarUIController = mControllers.uiController;
            TaskbarUIController taskbarUIController = mControllers.uiController;
            RecentsView recents = taskbarUIController.getRecentsView();
            RecentsView recents = taskbarUIController.getRecentsView();
@@ -833,9 +836,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
                // If we are selecting a second app for split, launch the split tasks
                // If we are selecting a second app for split, launch the split tasks
                taskbarUIController.triggerSecondAppForSplit(info, info.intent, view);
                taskbarUIController.triggerSecondAppForSplit(info, info.intent, view);
            } else {
            } else {
                // Else launch the selected task
                launchFromTaskbarPreservingSplitIfVisible(recents, info);
                startItemInfoActivity((AppInfo) tag);
                mControllers.uiController.onTaskbarIconLaunched(info);
                mControllers.uiController.onTaskbarIconLaunched((AppInfo) tag);
            }
            }
            mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
            mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
        } else if (tag instanceof ItemClickProxy) {
        } else if (tag instanceof ItemClickProxy) {
@@ -847,6 +849,31 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
        AbstractFloatingView.closeAllOpenViews(this);
        AbstractFloatingView.closeAllOpenViews(this);
    }
    }


    /**
     * Run when the user taps a Taskbar icon while in Overview. If the tapped app is currently
     * visible to the user in Overview, or is part of a visible split pair, we expand the TaskView
     * as if the user tapped on it (preserving the split pair). Otherwise, launch it normally
     * (potentially breaking a split pair).
     */
    private void launchFromTaskbarPreservingSplitIfVisible(RecentsView recents, ItemInfo info) {
        recents.findLastActiveTaskAndRunCallback(
                info.getTargetComponent(),
                (Consumer<Task>) foundTask -> {
                    if (foundTask != null) {
                        TaskView foundTaskView =
                                recents.getTaskViewByTaskId(foundTask.key.id);
                        if (foundTaskView != null
                                && foundTaskView.isVisibleToUser()) {
                            TestLogging.recordEvent(
                                    TestProtocol.SEQUENCE_MAIN, "start: taskbarAppIcon");
                            foundTaskView.launchTasks();
                            return;
                        }
                    }
                    startItemInfoActivity(info);
                });
    }

    private void startItemInfoActivity(ItemInfo info) {
    private void startItemInfoActivity(ItemInfo info) {
        Intent intent = new Intent(info.getIntent())
        Intent intent = new Intent(info.getIntent())
                .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+1 −1
Original line number Original line Diff line number Diff line
@@ -170,7 +170,7 @@ public class TaskbarUIController {
     */
     */
    public void triggerSecondAppForSplit(ItemInfoWithIcon info, Intent intent, View startingView) {
    public void triggerSecondAppForSplit(ItemInfoWithIcon info, Intent intent, View startingView) {
        RecentsView recents = getRecentsView();
        RecentsView recents = getRecentsView();
        recents.findLastActiveTaskAndDoSplitOperation(
        recents.findLastActiveTaskAndRunCallback(
                info.getTargetComponent(),
                info.getTargetComponent(),
                (Consumer<Task>) foundTask -> {
                (Consumer<Task>) foundTask -> {
                    if (foundTask != null) {
                    if (foundTask != null) {
+4 −4
Original line number Original line Diff line number Diff line
@@ -1275,14 +1275,14 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
    }
    }


    /**
    /**
     * Pulls the list of active Tasks from RecentModel, and finds the most recently active Task
     * Pulls the list of active Tasks from RecentsModel, and finds the most recently active Task
     * matching a given ComponentName. Then uses that Task (which could be null) with the given
     * matching a given ComponentName. Then uses that Task (which could be null) with the given
     * callback.
     * callback.
     *
     *
     * Used in various splitscreen operations when we need to check if there is a currently running
     * Used in various task-switching or splitscreen operations when we need to check if there is a
     * Task of a certain type and use the most recent one.
     * currently running Task of a certain type and use the most recent one.
     */
     */
    public void findLastActiveTaskAndDoSplitOperation(ComponentName componentName,
    public void findLastActiveTaskAndRunCallback(ComponentName componentName,
            Consumer<Task> callback) {
            Consumer<Task> callback) {
        mModel.getTasks(taskGroups -> {
        mModel.getTasks(taskGroups -> {
            Task lastActiveTask = null;
            Task lastActiveTask = null;