Loading libs/WindowManager/Shell/res/values/dimen.xml +4 −0 Original line number Diff line number Diff line Loading @@ -295,6 +295,10 @@ <dimen name="bubble_bar_dismiss_zone_width">192dp</dimen> <!-- Height of the box around bottom center of the screen where drag only leads to dismiss --> <dimen name="bubble_bar_dismiss_zone_height">242dp</dimen> <!-- Height of the box at the corner of the screen where drag leads to app moving to bubble --> <dimen name="bubble_transform_area_width">140dp</dimen> <!-- Width of the box at the corner of the screen where drag leads to app moving to bubble --> <dimen name="bubble_transform_area_height">140dp</dimen> <!-- Bottom and end margin for compat buttons. --> <dimen name="compat_button_margin">24dp</dimen> Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicator.java +51 −4 Original line number Diff line number Diff line Loading @@ -76,7 +76,11 @@ public class DesktopModeVisualIndicator { /** Indicates impending transition into split select on the left side */ TO_SPLIT_LEFT_INDICATOR, /** Indicates impending transition into split select on the right side */ TO_SPLIT_RIGHT_INDICATOR TO_SPLIT_RIGHT_INDICATOR, /** Indicates impending transition into bubble on the left side */ TO_BUBBLE_LEFT_INDICATOR, /** Indicates impending transition into bubble on the right side */ TO_BUBBLE_RIGHT_INDICATOR } /** Loading Loading @@ -175,15 +179,24 @@ public class DesktopModeVisualIndicator { captionHeight); final Region splitRightRegion = calculateSplitRightRegion(layout, transitionAreaWidth, captionHeight); if (fullscreenRegion.contains((int) inputCoordinates.x, (int) inputCoordinates.y)) { final int x = (int) inputCoordinates.x; final int y = (int) inputCoordinates.y; if (fullscreenRegion.contains(x, y)) { result = TO_FULLSCREEN_INDICATOR; } if (splitLeftRegion.contains((int) inputCoordinates.x, (int) inputCoordinates.y)) { if (splitLeftRegion.contains(x, y)) { result = IndicatorType.TO_SPLIT_LEFT_INDICATOR; } if (splitRightRegion.contains((int) inputCoordinates.x, (int) inputCoordinates.y)) { if (splitRightRegion.contains(x, y)) { result = IndicatorType.TO_SPLIT_RIGHT_INDICATOR; } if (BubbleAnythingFlagHelper.enableBubbleToFullscreen()) { if (calculateBubbleLeftRegion(layout).contains(x, y)) { result = IndicatorType.TO_BUBBLE_LEFT_INDICATOR; } else if (calculateBubbleRightRegion(layout).contains(x, y)) { result = IndicatorType.TO_BUBBLE_RIGHT_INDICATOR; } } if (mDragStartState != DragStartState.DRAGGED_INTENT) { transitionIndicator(result); } Loading Loading @@ -247,6 +260,25 @@ public class DesktopModeVisualIndicator { return region; } @VisibleForTesting Region calculateBubbleLeftRegion(DisplayLayout layout) { int regionWidth = mContext.getResources().getDimensionPixelSize( com.android.wm.shell.R.dimen.bubble_transform_area_width); int regionHeight = mContext.getResources().getDimensionPixelSize( com.android.wm.shell.R.dimen.bubble_transform_area_height); return new Region(0, layout.height() - regionHeight, regionWidth, layout.height()); } @VisibleForTesting Region calculateBubbleRightRegion(DisplayLayout layout) { int regionWidth = mContext.getResources().getDimensionPixelSize( com.android.wm.shell.R.dimen.bubble_transform_area_width); int regionHeight = mContext.getResources().getDimensionPixelSize( com.android.wm.shell.R.dimen.bubble_transform_area_height); return new Region(layout.width() - regionWidth, layout.height() - regionHeight, layout.width(), layout.height()); } /** * Create a fullscreen indicator with no animation */ Loading Loading @@ -481,6 +513,21 @@ public class DesktopModeVisualIndicator { return new Rect(desktopStableBounds.width() / 2 + padding, padding, desktopStableBounds.width() - padding, desktopStableBounds.height()); case TO_BUBBLE_LEFT_INDICATOR: // TODO(b/388851898): define based on bubble size on the device return new Rect( padding, desktopStableBounds.height() / 2 - padding, desktopStableBounds.width() / 2 - padding, desktopStableBounds.height()); case TO_BUBBLE_RIGHT_INDICATOR: // TODO(b/388851898): define based on bubble size on the device return new Rect( desktopStableBounds.width() / 2 + padding, desktopStableBounds.height() / 2 - padding, desktopStableBounds.width() - padding, desktopStableBounds.height() ); default: throw new IllegalArgumentException("Invalid indicator type provided."); } Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +10 −1 Original line number Diff line number Diff line Loading @@ -2788,7 +2788,11 @@ class DesktopTasksController( desktopModeWindowDecoration, ) } IndicatorType.NO_INDICATOR -> { IndicatorType.NO_INDICATOR, IndicatorType.TO_BUBBLE_LEFT_INDICATOR, IndicatorType.TO_BUBBLE_RIGHT_INDICATOR -> { // TODO(b/391928049): add support fof dragging desktop apps to a bubble // Create a copy so that we can animate from the current bounds if we end up having // to snap the surface back without a WCT change. val destinationBounds = Rect(currentDragBounds) Loading Loading @@ -2915,6 +2919,11 @@ class DesktopTasksController( ) requestSplit(taskInfo, leftOrTop = false) } IndicatorType.TO_BUBBLE_LEFT_INDICATOR, IndicatorType.TO_BUBBLE_RIGHT_INDICATOR -> { // TODO(b/388851898): move to bubble cancelDragToDesktop(taskInfo) } } return indicatorType } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicatorTest.kt +53 −5 Original line number Diff line number Diff line Loading @@ -193,6 +193,40 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { assertThat(testRegion.bounds).isEqualTo(Rect(2368, -50, 2400, 1600)) } @Test fun testBubbleLeftRegionCalculation() { val bubbleRegionWidth = context.resources.getDimensionPixelSize(R.dimen.bubble_transform_area_width) val bubbleRegionHeight = context.resources.getDimensionPixelSize(R.dimen.bubble_transform_area_height) val expectedRect = Rect(0, 1600 - bubbleRegionHeight, bubbleRegionWidth, 1600) createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FULLSCREEN) var testRegion = visualIndicator.calculateBubbleLeftRegion(displayLayout) assertThat(testRegion.bounds).isEqualTo(expectedRect) createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_SPLIT) testRegion = visualIndicator.calculateBubbleLeftRegion(displayLayout) assertThat(testRegion.bounds).isEqualTo(expectedRect) } @Test fun testBubbleRightRegionCalculation() { val bubbleRegionWidth = context.resources.getDimensionPixelSize(R.dimen.bubble_transform_area_width) val bubbleRegionHeight = context.resources.getDimensionPixelSize(R.dimen.bubble_transform_area_height) val expectedRect = Rect(2400 - bubbleRegionWidth, 1600 - bubbleRegionHeight, 2400, 1600) createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FULLSCREEN) var testRegion = visualIndicator.calculateBubbleRightRegion(displayLayout) assertThat(testRegion.bounds).isEqualTo(expectedRect) createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_SPLIT) testRegion = visualIndicator.calculateBubbleRightRegion(displayLayout) assertThat(testRegion.bounds).isEqualTo(expectedRect) } @Test fun testDefaultIndicators() { createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FULLSCREEN) Loading @@ -219,26 +253,40 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { fun testDefaultIndicatorWithNoDesktop() { whenever(DesktopModeStatus.canEnterDesktopMode(any())).thenReturn(false) // Fullscreen to center, no desktop indicator createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FULLSCREEN) var result = visualIndicator.updateIndicatorType(PointF(500f, 500f)) assertThat(result).isEqualTo(DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR) // Fullscreen to split result = visualIndicator.updateIndicatorType(PointF(10000f, 500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_RIGHT_INDICATOR) result = visualIndicator.updateIndicatorType(PointF(-10000f, 500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_LEFT_INDICATOR) // Fullscreen to bubble result = visualIndicator.updateIndicatorType(PointF(100f, 1500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_LEFT_INDICATOR) result = visualIndicator.updateIndicatorType(PointF(2300f, 1500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_RIGHT_INDICATOR) // Split to center, no desktop indicator createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_SPLIT) result = visualIndicator.updateIndicatorType(PointF(500f, 500f)) assertThat(result).isEqualTo(DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR) // Split to fullscreen result = visualIndicator.updateIndicatorType(PointF(500f, 0f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_FULLSCREEN_INDICATOR) // Split to bubble result = visualIndicator.updateIndicatorType(PointF(100f, 1500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_LEFT_INDICATOR) result = visualIndicator.updateIndicatorType(PointF(2300f, 1500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_RIGHT_INDICATOR) // Drag app to center, no desktop indicator createVisualIndicator(DesktopModeVisualIndicator.DragStartState.DRAGGED_INTENT) result = visualIndicator.updateIndicatorType(PointF(500f, 500f)) assertThat(result).isEqualTo(DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR) Loading Loading
libs/WindowManager/Shell/res/values/dimen.xml +4 −0 Original line number Diff line number Diff line Loading @@ -295,6 +295,10 @@ <dimen name="bubble_bar_dismiss_zone_width">192dp</dimen> <!-- Height of the box around bottom center of the screen where drag only leads to dismiss --> <dimen name="bubble_bar_dismiss_zone_height">242dp</dimen> <!-- Height of the box at the corner of the screen where drag leads to app moving to bubble --> <dimen name="bubble_transform_area_width">140dp</dimen> <!-- Width of the box at the corner of the screen where drag leads to app moving to bubble --> <dimen name="bubble_transform_area_height">140dp</dimen> <!-- Bottom and end margin for compat buttons. --> <dimen name="compat_button_margin">24dp</dimen> Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicator.java +51 −4 Original line number Diff line number Diff line Loading @@ -76,7 +76,11 @@ public class DesktopModeVisualIndicator { /** Indicates impending transition into split select on the left side */ TO_SPLIT_LEFT_INDICATOR, /** Indicates impending transition into split select on the right side */ TO_SPLIT_RIGHT_INDICATOR TO_SPLIT_RIGHT_INDICATOR, /** Indicates impending transition into bubble on the left side */ TO_BUBBLE_LEFT_INDICATOR, /** Indicates impending transition into bubble on the right side */ TO_BUBBLE_RIGHT_INDICATOR } /** Loading Loading @@ -175,15 +179,24 @@ public class DesktopModeVisualIndicator { captionHeight); final Region splitRightRegion = calculateSplitRightRegion(layout, transitionAreaWidth, captionHeight); if (fullscreenRegion.contains((int) inputCoordinates.x, (int) inputCoordinates.y)) { final int x = (int) inputCoordinates.x; final int y = (int) inputCoordinates.y; if (fullscreenRegion.contains(x, y)) { result = TO_FULLSCREEN_INDICATOR; } if (splitLeftRegion.contains((int) inputCoordinates.x, (int) inputCoordinates.y)) { if (splitLeftRegion.contains(x, y)) { result = IndicatorType.TO_SPLIT_LEFT_INDICATOR; } if (splitRightRegion.contains((int) inputCoordinates.x, (int) inputCoordinates.y)) { if (splitRightRegion.contains(x, y)) { result = IndicatorType.TO_SPLIT_RIGHT_INDICATOR; } if (BubbleAnythingFlagHelper.enableBubbleToFullscreen()) { if (calculateBubbleLeftRegion(layout).contains(x, y)) { result = IndicatorType.TO_BUBBLE_LEFT_INDICATOR; } else if (calculateBubbleRightRegion(layout).contains(x, y)) { result = IndicatorType.TO_BUBBLE_RIGHT_INDICATOR; } } if (mDragStartState != DragStartState.DRAGGED_INTENT) { transitionIndicator(result); } Loading Loading @@ -247,6 +260,25 @@ public class DesktopModeVisualIndicator { return region; } @VisibleForTesting Region calculateBubbleLeftRegion(DisplayLayout layout) { int regionWidth = mContext.getResources().getDimensionPixelSize( com.android.wm.shell.R.dimen.bubble_transform_area_width); int regionHeight = mContext.getResources().getDimensionPixelSize( com.android.wm.shell.R.dimen.bubble_transform_area_height); return new Region(0, layout.height() - regionHeight, regionWidth, layout.height()); } @VisibleForTesting Region calculateBubbleRightRegion(DisplayLayout layout) { int regionWidth = mContext.getResources().getDimensionPixelSize( com.android.wm.shell.R.dimen.bubble_transform_area_width); int regionHeight = mContext.getResources().getDimensionPixelSize( com.android.wm.shell.R.dimen.bubble_transform_area_height); return new Region(layout.width() - regionWidth, layout.height() - regionHeight, layout.width(), layout.height()); } /** * Create a fullscreen indicator with no animation */ Loading Loading @@ -481,6 +513,21 @@ public class DesktopModeVisualIndicator { return new Rect(desktopStableBounds.width() / 2 + padding, padding, desktopStableBounds.width() - padding, desktopStableBounds.height()); case TO_BUBBLE_LEFT_INDICATOR: // TODO(b/388851898): define based on bubble size on the device return new Rect( padding, desktopStableBounds.height() / 2 - padding, desktopStableBounds.width() / 2 - padding, desktopStableBounds.height()); case TO_BUBBLE_RIGHT_INDICATOR: // TODO(b/388851898): define based on bubble size on the device return new Rect( desktopStableBounds.width() / 2 + padding, desktopStableBounds.height() / 2 - padding, desktopStableBounds.width() - padding, desktopStableBounds.height() ); default: throw new IllegalArgumentException("Invalid indicator type provided."); } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +10 −1 Original line number Diff line number Diff line Loading @@ -2788,7 +2788,11 @@ class DesktopTasksController( desktopModeWindowDecoration, ) } IndicatorType.NO_INDICATOR -> { IndicatorType.NO_INDICATOR, IndicatorType.TO_BUBBLE_LEFT_INDICATOR, IndicatorType.TO_BUBBLE_RIGHT_INDICATOR -> { // TODO(b/391928049): add support fof dragging desktop apps to a bubble // Create a copy so that we can animate from the current bounds if we end up having // to snap the surface back without a WCT change. val destinationBounds = Rect(currentDragBounds) Loading Loading @@ -2915,6 +2919,11 @@ class DesktopTasksController( ) requestSplit(taskInfo, leftOrTop = false) } IndicatorType.TO_BUBBLE_LEFT_INDICATOR, IndicatorType.TO_BUBBLE_RIGHT_INDICATOR -> { // TODO(b/388851898): move to bubble cancelDragToDesktop(taskInfo) } } return indicatorType } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicatorTest.kt +53 −5 Original line number Diff line number Diff line Loading @@ -193,6 +193,40 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { assertThat(testRegion.bounds).isEqualTo(Rect(2368, -50, 2400, 1600)) } @Test fun testBubbleLeftRegionCalculation() { val bubbleRegionWidth = context.resources.getDimensionPixelSize(R.dimen.bubble_transform_area_width) val bubbleRegionHeight = context.resources.getDimensionPixelSize(R.dimen.bubble_transform_area_height) val expectedRect = Rect(0, 1600 - bubbleRegionHeight, bubbleRegionWidth, 1600) createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FULLSCREEN) var testRegion = visualIndicator.calculateBubbleLeftRegion(displayLayout) assertThat(testRegion.bounds).isEqualTo(expectedRect) createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_SPLIT) testRegion = visualIndicator.calculateBubbleLeftRegion(displayLayout) assertThat(testRegion.bounds).isEqualTo(expectedRect) } @Test fun testBubbleRightRegionCalculation() { val bubbleRegionWidth = context.resources.getDimensionPixelSize(R.dimen.bubble_transform_area_width) val bubbleRegionHeight = context.resources.getDimensionPixelSize(R.dimen.bubble_transform_area_height) val expectedRect = Rect(2400 - bubbleRegionWidth, 1600 - bubbleRegionHeight, 2400, 1600) createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FULLSCREEN) var testRegion = visualIndicator.calculateBubbleRightRegion(displayLayout) assertThat(testRegion.bounds).isEqualTo(expectedRect) createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_SPLIT) testRegion = visualIndicator.calculateBubbleRightRegion(displayLayout) assertThat(testRegion.bounds).isEqualTo(expectedRect) } @Test fun testDefaultIndicators() { createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FULLSCREEN) Loading @@ -219,26 +253,40 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { fun testDefaultIndicatorWithNoDesktop() { whenever(DesktopModeStatus.canEnterDesktopMode(any())).thenReturn(false) // Fullscreen to center, no desktop indicator createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FULLSCREEN) var result = visualIndicator.updateIndicatorType(PointF(500f, 500f)) assertThat(result).isEqualTo(DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR) // Fullscreen to split result = visualIndicator.updateIndicatorType(PointF(10000f, 500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_RIGHT_INDICATOR) result = visualIndicator.updateIndicatorType(PointF(-10000f, 500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_LEFT_INDICATOR) // Fullscreen to bubble result = visualIndicator.updateIndicatorType(PointF(100f, 1500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_LEFT_INDICATOR) result = visualIndicator.updateIndicatorType(PointF(2300f, 1500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_RIGHT_INDICATOR) // Split to center, no desktop indicator createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_SPLIT) result = visualIndicator.updateIndicatorType(PointF(500f, 500f)) assertThat(result).isEqualTo(DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR) // Split to fullscreen result = visualIndicator.updateIndicatorType(PointF(500f, 0f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_FULLSCREEN_INDICATOR) // Split to bubble result = visualIndicator.updateIndicatorType(PointF(100f, 1500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_LEFT_INDICATOR) result = visualIndicator.updateIndicatorType(PointF(2300f, 1500f)) assertThat(result) .isEqualTo(DesktopModeVisualIndicator.IndicatorType.TO_BUBBLE_RIGHT_INDICATOR) // Drag app to center, no desktop indicator createVisualIndicator(DesktopModeVisualIndicator.DragStartState.DRAGGED_INTENT) result = visualIndicator.updateIndicatorType(PointF(500f, 500f)) assertThat(result).isEqualTo(DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR) Loading