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

Commit 1c5c698d authored by Jeremy Sim's avatar Jeremy Sim
Browse files

Update splitscreen SnapPosition constants

Bug: 349828130
Test: No logical changes, continues to pass tests
Flag: com.android.wm.shell.enable_flexible_split
Change-Id: Ib61b3b9e13640cd7e38846245a8908bb5beead30
parent 4fff1aef
Loading
Loading
Loading
Loading
+70 −15
Original line number Diff line number Diff line
@@ -66,14 +66,54 @@ public class SplitScreenConstants {
    public @interface SplitPosition {
    }

    /** A snap target in the first half of the screen, where the split is roughly 30-70. */
    public static final int SNAP_TO_30_70 = 0;
    /**
     * A snap target for two apps, where the split is 33-66. With FLAG_ENABLE_FLEXIBLE_SPLIT,
     * only used on tablets.
     */
    public static final int SNAP_TO_2_33_66 = 0;

    /** A snap target for two apps, where the split is 50-50.  */
    public static final int SNAP_TO_2_50_50 = 1;

    /**
     * A snap target for two apps, where the split is 66-33. With FLAG_ENABLE_FLEXIBLE_SPLIT,
     * only used on tablets.
     */
    public static final int SNAP_TO_2_66_33 = 2;

    /** The 50-50 snap target */
    public static final int SNAP_TO_50_50 = 1;
    /**
     * A snap target for two apps, where the split is 90-10. The "10" app extends off the screen,
     * and is actually the same size as the onscreen app, but the visible portion takes up 10% of
     * the screen. With FLAG_ENABLE_FLEXIBLE_SPLIT, used on phones and foldables.
     */
    public static final int SNAP_TO_2_90_10 = 3;

    /** A snap target in the latter half of the screen, where the split is roughly 70-30. */
    public static final int SNAP_TO_70_30 = 2;
    /**
     * A snap target for two apps, where the split is 10-90. The "10" app extends off the screen,
     * and is actually the same size as the onscreen app, but the visible portion takes up 10% of
     * the screen. With FLAG_ENABLE_FLEXIBLE_SPLIT, used on phones and foldables.
     */
    public static final int SNAP_TO_2_10_90 = 4;

    /**
     * A snap target for three apps, where the split is 33-33-33. With FLAG_ENABLE_FLEXIBLE_SPLIT,
     * only used on tablets.
     */
    public static final int SNAP_TO_3_33_33_33 = 5;

    /**
     * A snap target for three apps, where the split is 45-45-10. The "10" app extends off the
     * screen, and is actually the same size as the onscreen apps, but the visible portion takes
     * up 10% of the screen. With FLAG_ENABLE_FLEXIBLE_SPLIT, only used on unfolded foldables.
     */
    public static final int SNAP_TO_3_45_45_10 = 6;

    /**
     * A snap target for three apps, where the split is 10-45-45. The "10" app extends off the
     * screen, and is actually the same size as the onscreen apps, but the visible portion takes
     * up 10% of the screen. With FLAG_ENABLE_FLEXIBLE_SPLIT, only used on unfolded foldables.
     */
    public static final int SNAP_TO_3_10_45_45 = 7;

    /**
     * These snap targets are used for split pairs in a stable, non-transient state. They may be
@@ -81,9 +121,14 @@ public class SplitScreenConstants {
     * {@link SnapPosition}.
     */
    @IntDef(prefix = { "SNAP_TO_" }, value = {
            SNAP_TO_30_70,
            SNAP_TO_50_50,
            SNAP_TO_70_30
            SNAP_TO_2_33_66,
            SNAP_TO_2_50_50,
            SNAP_TO_2_66_33,
            SNAP_TO_2_90_10,
            SNAP_TO_2_10_90,
            SNAP_TO_3_33_33_33,
            SNAP_TO_3_45_45_10,
            SNAP_TO_3_10_45_45,
    })
    public @interface PersistentSnapPosition {}

@@ -91,9 +136,14 @@ public class SplitScreenConstants {
     * Checks if the snapPosition in question is a {@link PersistentSnapPosition}.
     */
    public static boolean isPersistentSnapPosition(@SnapPosition int snapPosition) {
        return snapPosition == SNAP_TO_30_70
                || snapPosition == SNAP_TO_50_50
                || snapPosition == SNAP_TO_70_30;
        return snapPosition == SNAP_TO_2_33_66
                || snapPosition == SNAP_TO_2_50_50
                || snapPosition == SNAP_TO_2_66_33
                || snapPosition == SNAP_TO_2_90_10
                || snapPosition == SNAP_TO_2_10_90
                || snapPosition == SNAP_TO_3_33_33_33
                || snapPosition == SNAP_TO_3_45_45_10
                || snapPosition == SNAP_TO_3_10_45_45;
    }

    /** The divider doesn't snap to any target and is freely placeable. */
@@ -109,9 +159,14 @@ public class SplitScreenConstants {
    public static final int SNAP_TO_MINIMIZE = 13;

    @IntDef(prefix = { "SNAP_TO_" }, value = {
            SNAP_TO_30_70,
            SNAP_TO_50_50,
            SNAP_TO_70_30,
            SNAP_TO_2_33_66,
            SNAP_TO_2_50_50,
            SNAP_TO_2_66_33,
            SNAP_TO_2_90_10,
            SNAP_TO_2_10_90,
            SNAP_TO_3_33_33_33,
            SNAP_TO_3_45_45_10,
            SNAP_TO_3_10_45_45,
            SNAP_TO_NONE,
            SNAP_TO_START_AND_DISMISS,
            SNAP_TO_END_AND_DISMISS,
+6 −6
Original line number Diff line number Diff line
@@ -19,9 +19,9 @@ package com.android.wm.shell.common.split;
import static android.view.WindowManager.DOCKED_LEFT;
import static android.view.WindowManager.DOCKED_RIGHT;

import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_30_70;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_50_50;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_70_30;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_33_66;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_50_50;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_66_33;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_END_AND_DISMISS;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_MINIMIZE;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_NONE;
@@ -283,10 +283,10 @@ public class DividerSnapAlgorithm {

    private void addNonDismissingTargets(boolean isHorizontalDivision, int topPosition,
            int bottomPosition, int dividerMax) {
        maybeAddTarget(topPosition, topPosition - getStartInset(), SNAP_TO_30_70);
        maybeAddTarget(topPosition, topPosition - getStartInset(), SNAP_TO_2_33_66);
        addMiddleTarget(isHorizontalDivision);
        maybeAddTarget(bottomPosition,
                dividerMax - getEndInset() - (bottomPosition + mDividerSize), SNAP_TO_70_30);
                dividerMax - getEndInset() - (bottomPosition + mDividerSize), SNAP_TO_2_66_33);
    }

    private void addFixedDivisionTargets(boolean isHorizontalDivision, int dividerMax) {
@@ -332,7 +332,7 @@ public class DividerSnapAlgorithm {
    private void addMiddleTarget(boolean isHorizontalDivision) {
        int position = DockedDividerUtils.calculateMiddlePosition(isHorizontalDivision,
                mInsets, mDisplayWidth, mDisplayHeight, mDividerSize);
        mTargets.add(new SnapTarget(position, SNAP_TO_50_50));
        mTargets.add(new SnapTarget(position, SNAP_TO_2_50_50));
    }

    private void addMinimizedTarget(boolean isHorizontalDivision, int dockedSide) {
+2 −2
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ package com.android.wm.shell.common.split;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;

import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_50_50;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_50_50;

import static com.google.common.truth.Truth.assertThat;

@@ -133,7 +133,7 @@ public class SplitLayoutTests extends ShellTestCase {
    @Test
    public void testSetDivideRatio() {
        mSplitLayout.setDividerPosition(200, false /* applyLayoutChange */);
        mSplitLayout.setDivideRatio(SNAP_TO_50_50);
        mSplitLayout.setDivideRatio(SNAP_TO_2_50_50);
        assertThat(mSplitLayout.getDividerPosition()).isEqualTo(
                mSplitLayout.mDividerSnapAlgorithm.getMiddleTarget().position);
    }
+3 −3
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ import com.android.wm.shell.shared.GroupedRecentTaskInfo.TYPE_FREEFORM
import com.android.wm.shell.shared.GroupedRecentTaskInfo.TYPE_SINGLE
import com.android.wm.shell.shared.GroupedRecentTaskInfo.TYPE_SPLIT
import com.android.wm.shell.shared.split.SplitBounds
import com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_50_50
import com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_50_50
import com.google.common.truth.Correspondence
import com.google.common.truth.Truth.assertThat
import org.junit.Assert.assertThrows
@@ -136,7 +136,7 @@ class GroupedRecentTaskInfoTest : ShellTestCase() {
        assertThat(recentTaskInfoParcel.taskInfo2).isNotNull()
        assertThat(recentTaskInfoParcel.taskInfo2!!.taskId).isEqualTo(2)
        assertThat(recentTaskInfoParcel.splitBounds).isNotNull()
        assertThat(recentTaskInfoParcel.splitBounds!!.snapPosition).isEqualTo(SNAP_TO_50_50)
        assertThat(recentTaskInfoParcel.splitBounds!!.snapPosition).isEqualTo(SNAP_TO_2_50_50)
    }

    @Test
@@ -185,7 +185,7 @@ class GroupedRecentTaskInfoTest : ShellTestCase() {
    private fun splitTasksGroupInfo(): GroupedRecentTaskInfo {
        val task1 = createTaskInfo(id = 1)
        val task2 = createTaskInfo(id = 2)
        val splitBounds = SplitBounds(Rect(), Rect(), 1, 2, SNAP_TO_50_50)
        val splitBounds = SplitBounds(Rect(), Rect(), 1, 2, SNAP_TO_2_50_50)
        return GroupedRecentTaskInfo.forSplitTasks(task1, task2, splitBounds)
    }

+9 −9
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;

import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_50_50;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_50_50;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -211,10 +211,10 @@ public class RecentTasksControllerTest extends ShellTestCase {

        // Verify only one update if the split info is the same
        SplitBounds bounds1 = new SplitBounds(new Rect(0, 0, 50, 50),
                new Rect(50, 50, 100, 100), t1.taskId, t2.taskId, SNAP_TO_50_50);
                new Rect(50, 50, 100, 100), t1.taskId, t2.taskId, SNAP_TO_2_50_50);
        mRecentTasksController.addSplitPair(t1.taskId, t2.taskId, bounds1);
        SplitBounds bounds2 = new SplitBounds(new Rect(0, 0, 50, 50),
                new Rect(50, 50, 100, 100), t1.taskId, t2.taskId, SNAP_TO_50_50);
                new Rect(50, 50, 100, 100), t1.taskId, t2.taskId, SNAP_TO_2_50_50);
        mRecentTasksController.addSplitPair(t1.taskId, t2.taskId, bounds2);
        verify(mRecentTasksController, times(1)).notifyRecentTasksChanged();
    }
@@ -246,9 +246,9 @@ public class RecentTasksControllerTest extends ShellTestCase {

        // Mark a couple pairs [t2, t4], [t3, t5]
        SplitBounds pair1Bounds =
                new SplitBounds(new Rect(), new Rect(), 2, 4, SNAP_TO_50_50);
                new SplitBounds(new Rect(), new Rect(), 2, 4, SNAP_TO_2_50_50);
        SplitBounds pair2Bounds =
                new SplitBounds(new Rect(), new Rect(), 3, 5, SNAP_TO_50_50);
                new SplitBounds(new Rect(), new Rect(), 3, 5, SNAP_TO_2_50_50);

        mRecentTasksController.addSplitPair(t2.taskId, t4.taskId, pair1Bounds);
        mRecentTasksController.addSplitPair(t3.taskId, t5.taskId, pair2Bounds);
@@ -277,9 +277,9 @@ public class RecentTasksControllerTest extends ShellTestCase {

        // Mark a couple pairs [t2, t4], [t3, t5]
        SplitBounds pair1Bounds =
                new SplitBounds(new Rect(), new Rect(), 2, 4, SNAP_TO_50_50);
                new SplitBounds(new Rect(), new Rect(), 2, 4, SNAP_TO_2_50_50);
        SplitBounds pair2Bounds =
                new SplitBounds(new Rect(), new Rect(), 3, 5, SNAP_TO_50_50);
                new SplitBounds(new Rect(), new Rect(), 3, 5, SNAP_TO_2_50_50);

        mRecentTasksController.addSplitPair(t2.taskId, t4.taskId, pair1Bounds);
        mRecentTasksController.addSplitPair(t3.taskId, t5.taskId, pair2Bounds);
@@ -339,7 +339,7 @@ public class RecentTasksControllerTest extends ShellTestCase {
        setRawList(t1, t2, t3, t4, t5);

        SplitBounds pair1Bounds =
                new SplitBounds(new Rect(), new Rect(), 1, 2, SNAP_TO_50_50);
                new SplitBounds(new Rect(), new Rect(), 1, 2, SNAP_TO_2_50_50);
        mRecentTasksController.addSplitPair(t1.taskId, t2.taskId, pair1Bounds);

        when(mDesktopModeTaskRepository.isActiveTask(3)).thenReturn(true);
@@ -449,7 +449,7 @@ public class RecentTasksControllerTest extends ShellTestCase {

        // Add a pair
        SplitBounds pair1Bounds =
                new SplitBounds(new Rect(), new Rect(), 2, 3, SNAP_TO_50_50);
                new SplitBounds(new Rect(), new Rect(), 2, 3, SNAP_TO_2_50_50);
        mRecentTasksController.addSplitPair(t2.taskId, t3.taskId, pair1Bounds);
        reset(mRecentTasksController);

Loading