diff options
3 files changed, 22 insertions, 23 deletions
diff --git a/libs/WindowManager/Shell/res/values/dimen.xml b/libs/WindowManager/Shell/res/values/dimen.xml index 269a58693a24..606ebb41bc5f 100644 --- a/libs/WindowManager/Shell/res/values/dimen.xml +++ b/libs/WindowManager/Shell/res/values/dimen.xml @@ -554,15 +554,10 @@ enable_windowing_edge_drag_resize is disabled. --> <dimen name="freeform_resize_corner">44dp</dimen> - <!-- The width of the area at the sides of the screen where a freeform task will transition to - split select if dragged until the touch input is within the range. --> - <dimen name="desktop_mode_transition_area_width">32dp</dimen> + <!-- The thickness in dp for all desktop drag transition regions. --> + <dimen name="desktop_mode_transition_region_thickness">44dp</dimen> - <!-- The width of the area where a desktop task will transition to fullscreen. --> - <dimen name="desktop_mode_fullscreen_from_desktop_width">80dp</dimen> - - <!-- The height of the area where a desktop task will transition to fullscreen. --> - <dimen name="desktop_mode_fullscreen_from_desktop_height">40dp</dimen> + <item type="dimen" format="float" name="desktop_mode_fullscreen_region_scale">0.4</item> <!-- The height on the screen where drag to the left or right edge will result in a desktop task snapping to split size. The empty space between this and the top is to allow 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 ed0d2b87b03f..6011db7fc752 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 @@ -105,7 +105,7 @@ public class DesktopModeVisualIndicator { // If we are in freeform, we don't want a visible indicator in the "freeform" drag zone. IndicatorType result = IndicatorType.NO_INDICATOR; final int transitionAreaWidth = mContext.getResources().getDimensionPixelSize( - com.android.wm.shell.R.dimen.desktop_mode_transition_area_width); + com.android.wm.shell.R.dimen.desktop_mode_transition_region_thickness); // Because drags in freeform use task position for indicator calculation, we need to // account for the possibility of the task going off the top of the screen by captionHeight final int captionHeight = mContext.getResources().getDimensionPixelSize( @@ -140,18 +140,19 @@ public class DesktopModeVisualIndicator { final Region region = new Region(); int transitionHeight = windowingMode == WINDOWING_MODE_FREEFORM ? mContext.getResources().getDimensionPixelSize( - com.android.wm.shell.R.dimen.desktop_mode_fullscreen_from_desktop_height) + com.android.wm.shell.R.dimen.desktop_mode_transition_region_thickness) : 2 * layout.stableInsets().top; - // A thin, short Rect at the top of the screen. + // A Rect at the top of the screen that takes up the center 40%. if (windowingMode == WINDOWING_MODE_FREEFORM) { - int fromFreeformWidth = mContext.getResources().getDimensionPixelSize( - com.android.wm.shell.R.dimen.desktop_mode_fullscreen_from_desktop_width); - region.union(new Rect((layout.width() / 2) - (fromFreeformWidth / 2), + final float toFullscreenScale = mContext.getResources().getFloat( + R.dimen.desktop_mode_fullscreen_region_scale); + final float toFullscreenWidth = (layout.width() * toFullscreenScale); + region.union(new Rect((int) ((layout.width() / 2f) - (toFullscreenWidth / 2f)), -captionHeight, - (layout.width() / 2) + (fromFreeformWidth / 2), + (int) ((layout.width() / 2f) + (toFullscreenWidth / 2f)), transitionHeight)); } - // A screen-wide, shorter Rect if the task is in fullscreen or split. + // A screen-wide Rect if the task is in fullscreen or split. if (windowingMode == WINDOWING_MODE_FULLSCREEN || windowingMode == WINDOWING_MODE_MULTI_WINDOW) { region.union(new Rect(0, 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 bd39aa6ace42..2dea43b508ae 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 @@ -61,20 +61,23 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() { @Test fun testFullscreenRegionCalculation() { - val transitionHeight = context.resources.getDimensionPixelSize( - R.dimen.desktop_mode_fullscreen_from_desktop_height) - val fromFreeformWidth = mContext.resources.getDimensionPixelSize( - R.dimen.desktop_mode_fullscreen_from_desktop_width - ) var testRegion = visualIndicator.calculateFullscreenRegion(displayLayout, WINDOWING_MODE_FULLSCREEN, CAPTION_HEIGHT) assertThat(testRegion.bounds).isEqualTo(Rect(0, -50, 2400, 2 * STABLE_INSETS.top)) testRegion = visualIndicator.calculateFullscreenRegion(displayLayout, WINDOWING_MODE_FREEFORM, CAPTION_HEIGHT) + + val transitionHeight = context.resources.getDimensionPixelSize( + R.dimen.desktop_mode_transition_region_thickness) + val toFullscreenScale = mContext.resources.getFloat( + R.dimen.desktop_mode_fullscreen_region_scale + ) + val toFullscreenWidth = displayLayout.width() * toFullscreenScale + assertThat(testRegion.bounds).isEqualTo(Rect( - DISPLAY_BOUNDS.width() / 2 - fromFreeformWidth / 2, + (DISPLAY_BOUNDS.width() / 2f - toFullscreenWidth / 2f).toInt(), -50, - DISPLAY_BOUNDS.width() / 2 + fromFreeformWidth / 2, + (DISPLAY_BOUNDS.width() / 2f + toFullscreenWidth / 2f).toInt(), transitionHeight)) testRegion = visualIndicator.calculateFullscreenRegion(displayLayout, WINDOWING_MODE_MULTI_WINDOW, CAPTION_HEIGHT) |