summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/WindowManager/Shell/res/values/dimen.xml4
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicator.java55
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt11
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicatorTest.kt58
4 files changed, 118 insertions, 10 deletions
diff --git a/libs/WindowManager/Shell/res/values/dimen.xml b/libs/WindowManager/Shell/res/values/dimen.xml
index 9e2d23b41556..f1cb0c89c229 100644
--- a/libs/WindowManager/Shell/res/values/dimen.xml
+++ b/libs/WindowManager/Shell/res/values/dimen.xml
@@ -293,6 +293,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>
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicator.java b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicator.java
index 621ccba40db2..27ccb8bc71fe 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicator.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicator.java
@@ -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
}
/**
@@ -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);
}
@@ -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
*/
@@ -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.");
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt
index 3f88e7bddd34..037bded686a0 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt
@@ -2633,7 +2633,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)
@@ -2760,6 +2764,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
}
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicatorTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicatorTest.kt
index 13b44977e9c7..c5db2c592aa0 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicatorTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicatorTest.kt
@@ -194,6 +194,40 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() {
}
@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)
var result = visualIndicator.updateIndicatorType(PointF(-10000f, 500f))
@@ -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)