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

Commit 4f896353 authored by Vinit Nayak's avatar Vinit Nayak
Browse files

Add double tap divider swap functionality to flex split infra

Bug: 349828130
Flag: com.android.wm.shell.enable_flexible_split
Test: Tested with double tapping and re-launching apps on different sides
Change-Id: Id49d4178d6d145719093b96a91d2afbe6d68c3cb
parent 3e952ec2
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1262,6 +1262,9 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
                    // Restore focus-ability to the windows and divider
                    wct.setFocusable(mRootTaskInfo.token, true);

                    if (enableFlexibleSplit()) {
                        mStageOrderOperator.onDoubleTappedDivider();
                    }
                    setSideStagePosition(reverseSplitPosition(mSideStagePosition), wct);
                    mSyncQueue.queue(wct);
                    mSyncQueue.runInSync(st -> {
+19 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import com.android.wm.shell.splitscreen.SplitScreen.STAGE_TYPE_B
import com.android.wm.shell.splitscreen.SplitScreen.STAGE_TYPE_C
import com.android.wm.shell.splitscreen.SplitScreen.stageTypeToString
import com.android.wm.shell.windowdecor.WindowDecorViewModel
import java.util.Collections
import java.util.Optional

/**
@@ -147,6 +148,24 @@ class StageOrderOperator (
        }
    }

    /**
     * This will swap the stages for the two stages on either side of the given divider.
     * Note: This will keep [activeStages] and [allStages] in sync by swapping both of them
     * If there are no [activeStages] then this will be a no-op.
     *
     * TODO(b/379984874): Take in a divider identifier to determine which array indices to swap
     */
    fun onDoubleTappedDivider() {
        if (activeStages.isEmpty()) {
            ProtoLog.d(ShellProtoLogGroup.WM_SHELL_SPLIT_SCREEN,
                "Stages not active, ignoring swap request")
            return
        }

        Collections.swap(activeStages, 0, 1)
        Collections.swap(allStages, 0, 1)
    }

    /**
     * Returns a legacy split position for the given stage. If no stages are active then this will
     * return [SPLIT_POSITION_UNDEFINED]