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

Commit 57e261ce authored by Vinit Nayak's avatar Vinit Nayak
Browse files

Quickswitch with staged split

* UI polish/animations needed.
* One known bug (b/198310766), temp work around is to
swipe up to home.

Bug: 181704764
Test:
* Open apps in staged split and quickswitch
between GroupedTaskView and fullscreen apps.
* QS to fullscreen app and then go into overview
and re-launch split screen tasks
* QS to fullscreen app, wait 5 seconds,
swipe into overview, no GroupedTaskView shown

Change-Id: I0ce10a944d86be5c927eeaaef922559a40f39923
parent 667bda84
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -297,7 +297,7 @@ public abstract class BaseQuickstepLauncher extends Launcher
        mActionsView = findViewById(R.id.overview_actions_view);
        RecentsView overviewPanel = (RecentsView) getOverviewPanel();
        SplitSelectStateController controller =
                new SplitSelectStateController(mHandler, SystemUiProxy.INSTANCE.get(this));
                new SplitSelectStateController(SystemUiProxy.INSTANCE.get(this));
        overviewPanel.init(mActionsView, controller);
        mActionsView.setDp(getDeviceProfile());
        mActionsView.updateVerticalMargin(SysUINavigationMode.getMode(this));
+1 −1
Original line number Diff line number Diff line
@@ -531,7 +531,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
        ActivityManager.RunningTaskInfo[] runningTasks;
        if (mIsSwipeForStagedSplit) {
            int[] splitTaskIds =
                    LauncherSplitScreenListener.INSTANCE.getNoCreate().getSplitTaskIds();
                    LauncherSplitScreenListener.INSTANCE.getNoCreate().getRunningSplitTaskIds();
            runningTasks = new ActivityManager.RunningTaskInfo[splitTaskIds.length];
            for (int i = 0; i < splitTaskIds.length; i++) {
                int taskId = splitTaskIds[i];
+1 −1
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ public final class RecentsActivity extends StatefulActivity<RecentsState> {
        SYSUI_PROGRESS.set(getRootView().getSysUiScrim(), 0f);

        SplitSelectStateController controller =
                new SplitSelectStateController(mHandler, SystemUiProxy.INSTANCE.get(this));
                new SplitSelectStateController(SystemUiProxy.INSTANCE.get(this));
        mDragLayer.recreateControllers();
        mFallbackRecentsView.init(mActionsView, controller);
    }
+2 −1
Original line number Diff line number Diff line
@@ -90,7 +90,8 @@ public abstract class SwipeUpAnimationLogic implements
        mGestureState = gestureState;

        mIsSwipeForStagedSplit = ENABLE_SPLIT_SELECT.get() &&
                LauncherSplitScreenListener.INSTANCE.getNoCreate().getSplitTaskIds().length > 1;
                LauncherSplitScreenListener.INSTANCE.getNoCreate()
                        .getRunningSplitTaskIds().length > 1;

        TaskViewSimulator primaryTVS = new TaskViewSimulator(context,
                gestureState.getActivityInterface());
+49 −2
Original line number Diff line number Diff line
@@ -11,20 +11,54 @@ import com.android.launcher3.util.SplitConfigurationOptions.StagePosition;
import com.android.launcher3.util.SplitConfigurationOptions.StageType;
import com.android.launcher3.util.SplitConfigurationOptions.StagedSplitTaskPosition;
import com.android.quickstep.SystemUiProxy;
import com.android.systemui.shared.system.TaskStackChangeListener;
import com.android.systemui.shared.system.TaskStackChangeListeners;
import com.android.wm.shell.splitscreen.ISplitScreenListener;

/**
 * Listeners for system wide split screen position and stage changes.
 * Use {@link #getSplitTaskIds()} to determine which tasks, if any, are in staged split.
 *
 * Use {@link #getRunningSplitTaskIds()} to determine which tasks, if any, are actively in
 * staged split.
 *
 * Use {@link #getPersistentSplitIds()} to know if tasks were in split screen before a quickswitch
 * gesture happened.
 */
public class LauncherSplitScreenListener extends ISplitScreenListener.Stub {

    public static final MainThreadInitializedObject<LauncherSplitScreenListener> INSTANCE =
            new MainThreadInitializedObject<>(LauncherSplitScreenListener::new);

    private static final int[] EMPTY_ARRAY = {};

    private final StagedSplitTaskPosition mMainStagePosition = new StagedSplitTaskPosition();
    private final StagedSplitTaskPosition mSideStagePosition = new StagedSplitTaskPosition();

    private boolean mIsRecentsListFrozen = false;
    private final TaskStackChangeListener mTaskStackListener = new TaskStackChangeListener() {
        @Override
        public void onRecentTaskListFrozenChanged(boolean frozen) {
            super.onRecentTaskListFrozenChanged(frozen);
            mIsRecentsListFrozen = frozen;

            if (frozen) {
                mPersistentGroupedIds = getRunningSplitTaskIds();
            } else {
                // TODO(b/198310766) Need to also explicitly exit split screen if
                //  we're not currently viewing split screened apps
                mPersistentGroupedIds = EMPTY_ARRAY;
            }
        }
    };

    /**
     * Gets set to current split taskIDs whenever the task list is frozen, and set to empty array
     * whenever task list unfreezes.
     * When not null, this indicates that we need to load a GroupedTaskView as the most recent
     * page, so user can quickswitch back to a grouped task.
     */
    private int[] mPersistentGroupedIds;

    public LauncherSplitScreenListener(Context context) {
        mMainStagePosition.stageType = SplitConfigurationOptions.STAGE_TYPE_MAIN;
        mSideStagePosition.stageType = SplitConfigurationOptions.STAGE_TYPE_SIDE;
@@ -33,17 +67,30 @@ public class LauncherSplitScreenListener extends ISplitScreenListener.Stub {
    /** Also call {@link #destroy()} when done. */
    public void init() {
        SystemUiProxy.INSTANCE.getNoCreate().registerSplitScreenListener(this);
        TaskStackChangeListeners.getInstance().registerTaskStackListener(mTaskStackListener);
    }

    public void destroy() {
        SystemUiProxy.INSTANCE.getNoCreate().unregisterSplitScreenListener(this);
        TaskStackChangeListeners.getInstance().unregisterTaskStackListener(mTaskStackListener);
    }

    /**
     * This method returns the active split taskIDs that were active if a user quickswitched from
     * split screen to a fullscreen app as long as the recents task list remains frozen.
     */
    public int[] getPersistentSplitIds() {
        if (mIsRecentsListFrozen) {
            return mPersistentGroupedIds;
        } else {
            return getRunningSplitTaskIds();
        }
    }
    /**
     * @return index 0 will be task in left/top position, index 1 in right/bottom position.
     *         Will return empty array if device is not in staged split
     */
    public int[] getSplitTaskIds() {
    public int[] getRunningSplitTaskIds() {
        if (mMainStagePosition.taskId == -1 || mSideStagePosition.taskId == -1) {
            return new int[]{};
        }
Loading