Loading libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerSnapAlgorithm.java +12 −18 Original line number Diff line number Diff line Loading @@ -235,7 +235,7 @@ public class DividerSnapAlgorithm { private SnapTarget snap(int position, boolean hardDismiss) { if (shouldApplyFreeSnapMode(position)) { return new SnapTarget(position, position, SNAP_TO_NONE); return new SnapTarget(position, SNAP_TO_NONE); } int minIndex = -1; float minDistance = Float.MAX_VALUE; Loading Loading @@ -263,7 +263,7 @@ public class DividerSnapAlgorithm { if (dockedSide == DOCKED_RIGHT) { startPos += mInsets.left; } mTargets.add(new SnapTarget(startPos, startPos, SNAP_TO_START_AND_DISMISS, 0.35f)); mTargets.add(new SnapTarget(startPos, SNAP_TO_START_AND_DISMISS, 0.35f)); switch (mSnapMode) { case SNAP_MODE_16_9: addRatio16_9Targets(isHorizontalDivision, dividerMax); Loading @@ -278,7 +278,7 @@ public class DividerSnapAlgorithm { addMinimizedTarget(isHorizontalDivision, dockedSide); break; } mTargets.add(new SnapTarget(dividerMax, dividerMax, SNAP_TO_END_AND_DISMISS, 0.35f)); mTargets.add(new SnapTarget(dividerMax, SNAP_TO_END_AND_DISMISS, 0.35f)); } private void addNonDismissingTargets(boolean isHorizontalDivision, int topPosition, Loading Loading @@ -325,14 +325,14 @@ public class DividerSnapAlgorithm { */ private void maybeAddTarget(int position, int smallerSize, @SnapPosition int snapPosition) { if (smallerSize >= mMinimalSizeResizableTask) { mTargets.add(new SnapTarget(position, position, snapPosition)); mTargets.add(new SnapTarget(position, snapPosition)); } } private void addMiddleTarget(boolean isHorizontalDivision) { int position = DockedDividerUtils.calculateMiddlePosition(isHorizontalDivision, mInsets, mDisplayWidth, mDisplayHeight, mDividerSize); mTargets.add(new SnapTarget(position, position, SNAP_TO_50_50)); mTargets.add(new SnapTarget(position, SNAP_TO_50_50)); } private void addMinimizedTarget(boolean isHorizontalDivision, int dockedSide) { Loading @@ -346,7 +346,7 @@ public class DividerSnapAlgorithm { position = mDisplayWidth - position - mInsets.right - mDividerSize; } } mTargets.add(new SnapTarget(position, position, SNAP_TO_MINIMIZE)); mTargets.add(new SnapTarget(position, SNAP_TO_MINIMIZE)); } public SnapTarget getMiddleTarget() { Loading Loading @@ -377,20 +377,15 @@ public class DividerSnapAlgorithm { } /** * Represents a snap target for the divider. * An object, calculated at boot time, representing a legal position for the split screen * divider (i.e. the divider can be dragged to this spot). */ public static class SnapTarget { /** Position of this snap target. The right/bottom edge of the top/left task snaps here. */ public final int position; /** * Like {@link #position}, but used to calculate the task bounds which might be different * from the stack bounds. */ public final int taskPosition; /** * An int describing the placement of the divider in this snap target. * An int (enum) describing the placement of the divider in this snap target. */ public final @SnapPosition int snapPosition; Loading @@ -402,14 +397,13 @@ public class DividerSnapAlgorithm { */ private final float distanceMultiplier; public SnapTarget(int position, int taskPosition, @SnapPosition int snapPosition) { this(position, taskPosition, snapPosition, 1f); public SnapTarget(int position, @SnapPosition int snapPosition) { this(position, snapPosition, 1f); } public SnapTarget(int position, int taskPosition, @SnapPosition int snapPosition, public SnapTarget(int position, @SnapPosition int snapPosition, float distanceMultiplier) { this.position = position; this.taskPosition = taskPosition; this.snapPosition = snapPosition; this.distanceMultiplier = distanceMultiplier; } Loading libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java +6 −5 Original line number Diff line number Diff line Loading @@ -72,11 +72,12 @@ import com.android.wm.shell.common.DisplayImeController; import com.android.wm.shell.common.DisplayInsetsController; import com.android.wm.shell.common.DisplayLayout; import com.android.wm.shell.common.pip.PipUtils; import com.android.wm.shell.common.split.DividerSnapAlgorithm.SnapTarget; import com.android.wm.shell.protolog.ShellProtoLogGroup; import com.android.wm.shell.shared.animation.Interpolators; import com.android.wm.shell.shared.split.SplitScreenConstants.PersistentSnapPosition; import com.android.wm.shell.shared.split.SplitScreenConstants.SnapPosition; import com.android.wm.shell.shared.split.SplitScreenConstants.SplitPosition; import com.android.wm.shell.protolog.ShellProtoLogGroup; import com.android.wm.shell.splitscreen.StageTaskListener; import java.io.PrintWriter; Loading Loading @@ -543,7 +544,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange * to middle position if the provided SnapTarget is not supported. */ public void setDivideRatio(@PersistentSnapPosition int snapPosition) { final DividerSnapAlgorithm.SnapTarget snapTarget = mDividerSnapAlgorithm.findSnapTarget( final SnapTarget snapTarget = mDividerSnapAlgorithm.findSnapTarget( snapPosition); setDividerPosition(snapTarget != null Loading Loading @@ -577,7 +578,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange * Sets new divider position and updates bounds correspondingly. Notifies listener if the new * target indicates dismissing split. */ public void snapToTarget(int currentPosition, DividerSnapAlgorithm.SnapTarget snapTarget) { public void snapToTarget(int currentPosition, SnapTarget snapTarget) { switch (snapTarget.snapPosition) { case SNAP_TO_START_AND_DISMISS: flingDividerPosition(currentPosition, snapTarget.position, FLING_RESIZE_DURATION, Loading Loading @@ -613,10 +614,10 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange } /** * Returns {@link DividerSnapAlgorithm.SnapTarget} which matches passing position and velocity. * Returns {@link SnapTarget} which matches passing position and velocity. * If hardDismiss is set to {@code true}, it will be harder to reach dismiss target. */ public DividerSnapAlgorithm.SnapTarget findSnapTarget(int position, float velocity, public SnapTarget findSnapTarget(int position, float velocity, boolean hardDismiss) { return mDividerSnapAlgorithm.calculateSnapTarget(position, velocity, hardDismiss); } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/split/SplitLayoutTests.java +4 −11 Original line number Diff line number Diff line Loading @@ -20,8 +20,6 @@ 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_END_AND_DISMISS; import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_START_AND_DISMISS; import static com.google.common.truth.Truth.assertThat; Loading Loading @@ -150,8 +148,8 @@ public class SplitLayoutTests extends ShellTestCase { @UiThreadTest public void testSnapToDismissStart() { // verify it callbacks properly when the snap target indicates dismissing split. DividerSnapAlgorithm.SnapTarget snapTarget = getSnapTarget(0 /* position */, SNAP_TO_START_AND_DISMISS); DividerSnapAlgorithm.SnapTarget snapTarget = mSplitLayout.mDividerSnapAlgorithm.getDismissStartTarget(); mSplitLayout.snapToTarget(mSplitLayout.getDividerPosition(), snapTarget); waitDividerFlingFinished(); Loading @@ -162,8 +160,8 @@ public class SplitLayoutTests extends ShellTestCase { @UiThreadTest public void testSnapToDismissEnd() { // verify it callbacks properly when the snap target indicates dismissing split. DividerSnapAlgorithm.SnapTarget snapTarget = getSnapTarget(0 /* position */, SNAP_TO_END_AND_DISMISS); DividerSnapAlgorithm.SnapTarget snapTarget = mSplitLayout.mDividerSnapAlgorithm.getDismissEndTarget(); mSplitLayout.snapToTarget(mSplitLayout.getDividerPosition(), snapTarget); waitDividerFlingFinished(); Loading Loading @@ -203,9 +201,4 @@ public class SplitLayoutTests extends ShellTestCase { new Rect(0, 0, 1080, 2160)); return configuration; } private static DividerSnapAlgorithm.SnapTarget getSnapTarget(int position, int flag) { return new DividerSnapAlgorithm.SnapTarget( position /* position */, position /* taskPosition */, flag); } } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerSnapAlgorithm.java +12 −18 Original line number Diff line number Diff line Loading @@ -235,7 +235,7 @@ public class DividerSnapAlgorithm { private SnapTarget snap(int position, boolean hardDismiss) { if (shouldApplyFreeSnapMode(position)) { return new SnapTarget(position, position, SNAP_TO_NONE); return new SnapTarget(position, SNAP_TO_NONE); } int minIndex = -1; float minDistance = Float.MAX_VALUE; Loading Loading @@ -263,7 +263,7 @@ public class DividerSnapAlgorithm { if (dockedSide == DOCKED_RIGHT) { startPos += mInsets.left; } mTargets.add(new SnapTarget(startPos, startPos, SNAP_TO_START_AND_DISMISS, 0.35f)); mTargets.add(new SnapTarget(startPos, SNAP_TO_START_AND_DISMISS, 0.35f)); switch (mSnapMode) { case SNAP_MODE_16_9: addRatio16_9Targets(isHorizontalDivision, dividerMax); Loading @@ -278,7 +278,7 @@ public class DividerSnapAlgorithm { addMinimizedTarget(isHorizontalDivision, dockedSide); break; } mTargets.add(new SnapTarget(dividerMax, dividerMax, SNAP_TO_END_AND_DISMISS, 0.35f)); mTargets.add(new SnapTarget(dividerMax, SNAP_TO_END_AND_DISMISS, 0.35f)); } private void addNonDismissingTargets(boolean isHorizontalDivision, int topPosition, Loading Loading @@ -325,14 +325,14 @@ public class DividerSnapAlgorithm { */ private void maybeAddTarget(int position, int smallerSize, @SnapPosition int snapPosition) { if (smallerSize >= mMinimalSizeResizableTask) { mTargets.add(new SnapTarget(position, position, snapPosition)); mTargets.add(new SnapTarget(position, snapPosition)); } } private void addMiddleTarget(boolean isHorizontalDivision) { int position = DockedDividerUtils.calculateMiddlePosition(isHorizontalDivision, mInsets, mDisplayWidth, mDisplayHeight, mDividerSize); mTargets.add(new SnapTarget(position, position, SNAP_TO_50_50)); mTargets.add(new SnapTarget(position, SNAP_TO_50_50)); } private void addMinimizedTarget(boolean isHorizontalDivision, int dockedSide) { Loading @@ -346,7 +346,7 @@ public class DividerSnapAlgorithm { position = mDisplayWidth - position - mInsets.right - mDividerSize; } } mTargets.add(new SnapTarget(position, position, SNAP_TO_MINIMIZE)); mTargets.add(new SnapTarget(position, SNAP_TO_MINIMIZE)); } public SnapTarget getMiddleTarget() { Loading Loading @@ -377,20 +377,15 @@ public class DividerSnapAlgorithm { } /** * Represents a snap target for the divider. * An object, calculated at boot time, representing a legal position for the split screen * divider (i.e. the divider can be dragged to this spot). */ public static class SnapTarget { /** Position of this snap target. The right/bottom edge of the top/left task snaps here. */ public final int position; /** * Like {@link #position}, but used to calculate the task bounds which might be different * from the stack bounds. */ public final int taskPosition; /** * An int describing the placement of the divider in this snap target. * An int (enum) describing the placement of the divider in this snap target. */ public final @SnapPosition int snapPosition; Loading @@ -402,14 +397,13 @@ public class DividerSnapAlgorithm { */ private final float distanceMultiplier; public SnapTarget(int position, int taskPosition, @SnapPosition int snapPosition) { this(position, taskPosition, snapPosition, 1f); public SnapTarget(int position, @SnapPosition int snapPosition) { this(position, snapPosition, 1f); } public SnapTarget(int position, int taskPosition, @SnapPosition int snapPosition, public SnapTarget(int position, @SnapPosition int snapPosition, float distanceMultiplier) { this.position = position; this.taskPosition = taskPosition; this.snapPosition = snapPosition; this.distanceMultiplier = distanceMultiplier; } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java +6 −5 Original line number Diff line number Diff line Loading @@ -72,11 +72,12 @@ import com.android.wm.shell.common.DisplayImeController; import com.android.wm.shell.common.DisplayInsetsController; import com.android.wm.shell.common.DisplayLayout; import com.android.wm.shell.common.pip.PipUtils; import com.android.wm.shell.common.split.DividerSnapAlgorithm.SnapTarget; import com.android.wm.shell.protolog.ShellProtoLogGroup; import com.android.wm.shell.shared.animation.Interpolators; import com.android.wm.shell.shared.split.SplitScreenConstants.PersistentSnapPosition; import com.android.wm.shell.shared.split.SplitScreenConstants.SnapPosition; import com.android.wm.shell.shared.split.SplitScreenConstants.SplitPosition; import com.android.wm.shell.protolog.ShellProtoLogGroup; import com.android.wm.shell.splitscreen.StageTaskListener; import java.io.PrintWriter; Loading Loading @@ -543,7 +544,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange * to middle position if the provided SnapTarget is not supported. */ public void setDivideRatio(@PersistentSnapPosition int snapPosition) { final DividerSnapAlgorithm.SnapTarget snapTarget = mDividerSnapAlgorithm.findSnapTarget( final SnapTarget snapTarget = mDividerSnapAlgorithm.findSnapTarget( snapPosition); setDividerPosition(snapTarget != null Loading Loading @@ -577,7 +578,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange * Sets new divider position and updates bounds correspondingly. Notifies listener if the new * target indicates dismissing split. */ public void snapToTarget(int currentPosition, DividerSnapAlgorithm.SnapTarget snapTarget) { public void snapToTarget(int currentPosition, SnapTarget snapTarget) { switch (snapTarget.snapPosition) { case SNAP_TO_START_AND_DISMISS: flingDividerPosition(currentPosition, snapTarget.position, FLING_RESIZE_DURATION, Loading Loading @@ -613,10 +614,10 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange } /** * Returns {@link DividerSnapAlgorithm.SnapTarget} which matches passing position and velocity. * Returns {@link SnapTarget} which matches passing position and velocity. * If hardDismiss is set to {@code true}, it will be harder to reach dismiss target. */ public DividerSnapAlgorithm.SnapTarget findSnapTarget(int position, float velocity, public SnapTarget findSnapTarget(int position, float velocity, boolean hardDismiss) { return mDividerSnapAlgorithm.calculateSnapTarget(position, velocity, hardDismiss); } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/split/SplitLayoutTests.java +4 −11 Original line number Diff line number Diff line Loading @@ -20,8 +20,6 @@ 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_END_AND_DISMISS; import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_START_AND_DISMISS; import static com.google.common.truth.Truth.assertThat; Loading Loading @@ -150,8 +148,8 @@ public class SplitLayoutTests extends ShellTestCase { @UiThreadTest public void testSnapToDismissStart() { // verify it callbacks properly when the snap target indicates dismissing split. DividerSnapAlgorithm.SnapTarget snapTarget = getSnapTarget(0 /* position */, SNAP_TO_START_AND_DISMISS); DividerSnapAlgorithm.SnapTarget snapTarget = mSplitLayout.mDividerSnapAlgorithm.getDismissStartTarget(); mSplitLayout.snapToTarget(mSplitLayout.getDividerPosition(), snapTarget); waitDividerFlingFinished(); Loading @@ -162,8 +160,8 @@ public class SplitLayoutTests extends ShellTestCase { @UiThreadTest public void testSnapToDismissEnd() { // verify it callbacks properly when the snap target indicates dismissing split. DividerSnapAlgorithm.SnapTarget snapTarget = getSnapTarget(0 /* position */, SNAP_TO_END_AND_DISMISS); DividerSnapAlgorithm.SnapTarget snapTarget = mSplitLayout.mDividerSnapAlgorithm.getDismissEndTarget(); mSplitLayout.snapToTarget(mSplitLayout.getDividerPosition(), snapTarget); waitDividerFlingFinished(); Loading Loading @@ -203,9 +201,4 @@ public class SplitLayoutTests extends ShellTestCase { new Rect(0, 0, 1080, 2160)); return configuration; } private static DividerSnapAlgorithm.SnapTarget getSnapTarget(int position, int flag) { return new DividerSnapAlgorithm.SnapTarget( position /* position */, position /* taskPosition */, flag); } }