Loading libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu.xml +8 −4 Original line number Diff line number Diff line Loading @@ -19,6 +19,10 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="@dimen/desktop_mode_handle_menu_width" android:layout_height="wrap_content" android:clipChildren="false" android:clipToPadding="false" android:paddingBottom="@dimen/desktop_mode_handle_menu_pill_elevation" android:paddingRight="@dimen/desktop_mode_handle_menu_pill_elevation" android:orientation="vertical"> <LinearLayout Loading @@ -27,7 +31,7 @@ android:layout_height="@dimen/desktop_mode_handle_menu_app_info_pill_height" android:layout_marginTop="@dimen/desktop_mode_handle_menu_margin_top" android:layout_marginStart="1dp" android:elevation="1dp" android:elevation="@dimen/desktop_mode_handle_menu_pill_elevation" android:orientation="horizontal" android:background="@drawable/desktop_mode_decor_handle_menu_background" android:gravity="center_vertical"> Loading Loading @@ -73,7 +77,7 @@ android:layout_marginTop="@dimen/desktop_mode_handle_menu_pill_spacing_margin" android:layout_marginStart="1dp" android:orientation="horizontal" android:elevation="1dp" android:elevation="@dimen/desktop_mode_handle_menu_pill_elevation" android:background="@drawable/desktop_mode_decor_handle_menu_background" android:gravity="center_vertical"> Loading Loading @@ -124,7 +128,7 @@ android:layout_marginTop="@dimen/desktop_mode_handle_menu_pill_spacing_margin" android:layout_marginStart="1dp" android:orientation="vertical" android:elevation="1dp" android:elevation="@dimen/desktop_mode_handle_menu_pill_elevation" android:background="@drawable/desktop_mode_decor_handle_menu_background"> <Button Loading @@ -143,7 +147,7 @@ android:layout_marginTop="@dimen/desktop_mode_handle_menu_pill_spacing_margin" android:layout_marginStart="1dp" android:orientation="vertical" android:elevation="1dp" android:elevation="@dimen/desktop_mode_handle_menu_pill_elevation" android:background="@drawable/desktop_mode_decor_handle_menu_background"> <Button Loading libs/WindowManager/Shell/res/values/dimen.xml +10 −6 Original line number Diff line number Diff line Loading @@ -498,6 +498,13 @@ <!-- The width of the handle menu in desktop mode. --> <dimen name="desktop_mode_handle_menu_width">216dp</dimen> <!-- The maximum height of the handle menu in desktop mode. Four pills (52dp each) plus 2dp spacing between them plus 4dp top padding. --> <dimen name="desktop_mode_handle_menu_height">218dp</dimen> <!-- The elevation set on the handle menu pills. --> <dimen name="desktop_mode_handle_menu_pill_elevation">1dp</dimen> <!-- The height of the handle menu's "App Info" pill in desktop mode. --> <dimen name="desktop_mode_handle_menu_app_info_pill_height">52dp</dimen> Loading @@ -510,8 +517,8 @@ <!-- The height of the handle menu's "Open in browser" pill in desktop mode. --> <dimen name="desktop_mode_handle_menu_open_in_browser_pill_height">52dp</dimen> <!-- The height of the handle menu in desktop mode. --> <dimen name="desktop_mode_handle_menu_height">380dp</dimen> <!-- The margin between pills of the handle menu in desktop mode. --> <dimen name="desktop_mode_handle_menu_pill_spacing_margin">2dp</dimen> <!-- The top margin of the handle menu in desktop mode. --> <dimen name="desktop_mode_handle_menu_margin_top">4dp</dimen> Loading @@ -519,9 +526,6 @@ <!-- The start margin of the handle menu in desktop mode. --> <dimen name="desktop_mode_handle_menu_margin_start">6dp</dimen> <!-- The margin between pills of the handle menu in desktop mode. --> <dimen name="desktop_mode_handle_menu_pill_spacing_margin">2dp</dimen> <!-- The radius of the caption menu corners. --> <dimen name="desktop_mode_handle_menu_corner_radius">26dp</dimen> Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/HandleMenu.kt +24 −31 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ package com.android.wm.shell.windowdecor import android.annotation.DimenRes import android.app.ActivityManager import android.app.WindowConfiguration import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM Loading Loading @@ -75,10 +76,17 @@ class HandleMenu( private val isViewAboveStatusBar: Boolean get() = (Flags.enableAdditionalWindowsAboveStatusBar() && !taskInfo.isFreeform) private var marginMenuTop = 0 private var marginMenuStart = 0 private var menuHeight = 0 private var menuWidth = 0 private val pillElevation: Int = loadDimensionPixelSize( R.dimen.desktop_mode_handle_menu_pill_elevation) private val pillTopMargin: Int = loadDimensionPixelSize( R.dimen.desktop_mode_handle_menu_pill_spacing_margin) private val menuWidth = loadDimensionPixelSize( R.dimen.desktop_mode_handle_menu_width) + pillElevation private val menuHeight = getHandleMenuHeight() private val marginMenuTop = loadDimensionPixelSize(R.dimen.desktop_mode_handle_menu_margin_top) private val marginMenuStart = loadDimensionPixelSize( R.dimen.desktop_mode_handle_menu_margin_start) private var handleMenuAnimator: HandleMenuAnimator? = null @VisibleForTesting Loading Loading @@ -120,7 +128,6 @@ class HandleMenu( } init { loadHandleMenuDimensions() updateHandleMenuPillPositions() } Loading Loading @@ -426,49 +433,35 @@ class HandleMenu( */ private fun viewsLaidOut(): Boolean = handleMenuViewContainer?.view?.isLaidOut ?: false private fun loadHandleMenuDimensions() { val resources = context.resources menuWidth = loadDimensionPixelSize(resources, R.dimen.desktop_mode_handle_menu_width) menuHeight = getHandleMenuHeight(resources) marginMenuTop = loadDimensionPixelSize( resources, R.dimen.desktop_mode_handle_menu_margin_top ) marginMenuStart = loadDimensionPixelSize( resources, R.dimen.desktop_mode_handle_menu_margin_start ) } /** * Determines handle menu height based on if windowing pill should be shown. * Determines handle menu height based the max size and the visibility of pills. */ private fun getHandleMenuHeight(resources: Resources): Int { var menuHeight = loadDimensionPixelSize(resources, R.dimen.desktop_mode_handle_menu_height) private fun getHandleMenuHeight(): Int { var menuHeight = loadDimensionPixelSize( R.dimen.desktop_mode_handle_menu_height) + pillElevation if (!shouldShowWindowingPill) { menuHeight -= loadDimensionPixelSize( resources, R.dimen.desktop_mode_handle_menu_windowing_pill_height ) R.dimen.desktop_mode_handle_menu_windowing_pill_height) menuHeight -= pillTopMargin } if (!SHOULD_SHOW_MORE_ACTIONS_PILL) { menuHeight -= loadDimensionPixelSize( resources, R.dimen.desktop_mode_handle_menu_more_actions_pill_height ) R.dimen.desktop_mode_handle_menu_more_actions_pill_height) menuHeight -= pillTopMargin } if (!shouldShowBrowserPill) { menuHeight -= loadDimensionPixelSize(resources, menuHeight -= loadDimensionPixelSize( R.dimen.desktop_mode_handle_menu_open_in_browser_pill_height) menuHeight -= pillTopMargin } return menuHeight } private fun loadDimensionPixelSize(resources: Resources, resourceId: Int): Int { private fun loadDimensionPixelSize(@DimenRes resourceId: Int): Int { if (resourceId == Resources.ID_NULL) { return 0 } return resources.getDimensionPixelSize(resourceId) return context.resources.getDimensionPixelSize(resourceId) } fun close() { Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/HandleMenuTest.kt +16 −3 Original line number Diff line number Diff line Loading @@ -94,6 +94,8 @@ class HandleMenuTest : ShellTestCase() { private lateinit var handleMenu: HandleMenu private val menuWidthWithElevation = MENU_WIDTH + MENU_PILL_ELEVATION @Before fun setUp() { val mockAdditionalViewHostViewContainer = AdditionalViewHostViewContainer( Loading @@ -117,6 +119,9 @@ class HandleMenuTest : ShellTestCase() { addOverride(R.dimen.desktop_mode_handle_menu_height, MENU_HEIGHT) addOverride(R.dimen.desktop_mode_handle_menu_margin_top, MENU_TOP_MARGIN) addOverride(R.dimen.desktop_mode_handle_menu_margin_start, MENU_START_MARGIN) addOverride(R.dimen.desktop_mode_handle_menu_pill_elevation, MENU_PILL_ELEVATION) addOverride( R.dimen.desktop_mode_handle_menu_pill_spacing_margin, MENU_PILL_SPACING_MARGIN) } mockDesktopWindowDecoration.mDecorWindowContext = mContext } Loading @@ -129,7 +134,7 @@ class HandleMenuTest : ShellTestCase() { assertTrue(handleMenu.handleMenuViewContainer is AdditionalSystemViewContainer) // Verify menu is created at coordinates that, when added to WindowManager, // show at the top-center of display. val expected = Point(DISPLAY_BOUNDS.centerX() - MENU_WIDTH / 2, MENU_TOP_MARGIN) val expected = Point(DISPLAY_BOUNDS.centerX() - menuWidthWithElevation / 2, MENU_TOP_MARGIN) assertEquals(expected.toPointF(), handleMenu.handleMenuPosition) } Loading @@ -152,7 +157,10 @@ class HandleMenuTest : ShellTestCase() { assertTrue(handleMenu.handleMenuViewContainer is AdditionalSystemViewContainer) // Verify menu is created at coordinates that, when added to WindowManager, // show at the top-center of split left task. val expected = Point(SPLIT_LEFT_BOUNDS.centerX() - MENU_WIDTH / 2, MENU_TOP_MARGIN) val expected = Point( SPLIT_LEFT_BOUNDS.centerX() - menuWidthWithElevation / 2, MENU_TOP_MARGIN ) assertEquals(expected.toPointF(), handleMenu.handleMenuPosition) } Loading @@ -164,7 +172,10 @@ class HandleMenuTest : ShellTestCase() { assertTrue(handleMenu.handleMenuViewContainer is AdditionalSystemViewContainer) // Verify menu is created at coordinates that, when added to WindowManager, // show at the top-center of split right task. val expected = Point(SPLIT_RIGHT_BOUNDS.centerX() - MENU_WIDTH / 2, MENU_TOP_MARGIN) val expected = Point( SPLIT_RIGHT_BOUNDS.centerX() - menuWidthWithElevation / 2, MENU_TOP_MARGIN ) assertEquals(expected.toPointF(), handleMenu.handleMenuPosition) } Loading Loading @@ -220,5 +231,7 @@ class HandleMenuTest : ShellTestCase() { private const val MENU_HEIGHT = 400 private const val MENU_TOP_MARGIN = 10 private const val MENU_START_MARGIN = 20 private const val MENU_PILL_ELEVATION = 2 private const val MENU_PILL_SPACING_MARGIN = 4 } } Loading
libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu.xml +8 −4 Original line number Diff line number Diff line Loading @@ -19,6 +19,10 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="@dimen/desktop_mode_handle_menu_width" android:layout_height="wrap_content" android:clipChildren="false" android:clipToPadding="false" android:paddingBottom="@dimen/desktop_mode_handle_menu_pill_elevation" android:paddingRight="@dimen/desktop_mode_handle_menu_pill_elevation" android:orientation="vertical"> <LinearLayout Loading @@ -27,7 +31,7 @@ android:layout_height="@dimen/desktop_mode_handle_menu_app_info_pill_height" android:layout_marginTop="@dimen/desktop_mode_handle_menu_margin_top" android:layout_marginStart="1dp" android:elevation="1dp" android:elevation="@dimen/desktop_mode_handle_menu_pill_elevation" android:orientation="horizontal" android:background="@drawable/desktop_mode_decor_handle_menu_background" android:gravity="center_vertical"> Loading Loading @@ -73,7 +77,7 @@ android:layout_marginTop="@dimen/desktop_mode_handle_menu_pill_spacing_margin" android:layout_marginStart="1dp" android:orientation="horizontal" android:elevation="1dp" android:elevation="@dimen/desktop_mode_handle_menu_pill_elevation" android:background="@drawable/desktop_mode_decor_handle_menu_background" android:gravity="center_vertical"> Loading Loading @@ -124,7 +128,7 @@ android:layout_marginTop="@dimen/desktop_mode_handle_menu_pill_spacing_margin" android:layout_marginStart="1dp" android:orientation="vertical" android:elevation="1dp" android:elevation="@dimen/desktop_mode_handle_menu_pill_elevation" android:background="@drawable/desktop_mode_decor_handle_menu_background"> <Button Loading @@ -143,7 +147,7 @@ android:layout_marginTop="@dimen/desktop_mode_handle_menu_pill_spacing_margin" android:layout_marginStart="1dp" android:orientation="vertical" android:elevation="1dp" android:elevation="@dimen/desktop_mode_handle_menu_pill_elevation" android:background="@drawable/desktop_mode_decor_handle_menu_background"> <Button Loading
libs/WindowManager/Shell/res/values/dimen.xml +10 −6 Original line number Diff line number Diff line Loading @@ -498,6 +498,13 @@ <!-- The width of the handle menu in desktop mode. --> <dimen name="desktop_mode_handle_menu_width">216dp</dimen> <!-- The maximum height of the handle menu in desktop mode. Four pills (52dp each) plus 2dp spacing between them plus 4dp top padding. --> <dimen name="desktop_mode_handle_menu_height">218dp</dimen> <!-- The elevation set on the handle menu pills. --> <dimen name="desktop_mode_handle_menu_pill_elevation">1dp</dimen> <!-- The height of the handle menu's "App Info" pill in desktop mode. --> <dimen name="desktop_mode_handle_menu_app_info_pill_height">52dp</dimen> Loading @@ -510,8 +517,8 @@ <!-- The height of the handle menu's "Open in browser" pill in desktop mode. --> <dimen name="desktop_mode_handle_menu_open_in_browser_pill_height">52dp</dimen> <!-- The height of the handle menu in desktop mode. --> <dimen name="desktop_mode_handle_menu_height">380dp</dimen> <!-- The margin between pills of the handle menu in desktop mode. --> <dimen name="desktop_mode_handle_menu_pill_spacing_margin">2dp</dimen> <!-- The top margin of the handle menu in desktop mode. --> <dimen name="desktop_mode_handle_menu_margin_top">4dp</dimen> Loading @@ -519,9 +526,6 @@ <!-- The start margin of the handle menu in desktop mode. --> <dimen name="desktop_mode_handle_menu_margin_start">6dp</dimen> <!-- The margin between pills of the handle menu in desktop mode. --> <dimen name="desktop_mode_handle_menu_pill_spacing_margin">2dp</dimen> <!-- The radius of the caption menu corners. --> <dimen name="desktop_mode_handle_menu_corner_radius">26dp</dimen> Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/HandleMenu.kt +24 −31 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ package com.android.wm.shell.windowdecor import android.annotation.DimenRes import android.app.ActivityManager import android.app.WindowConfiguration import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM Loading Loading @@ -75,10 +76,17 @@ class HandleMenu( private val isViewAboveStatusBar: Boolean get() = (Flags.enableAdditionalWindowsAboveStatusBar() && !taskInfo.isFreeform) private var marginMenuTop = 0 private var marginMenuStart = 0 private var menuHeight = 0 private var menuWidth = 0 private val pillElevation: Int = loadDimensionPixelSize( R.dimen.desktop_mode_handle_menu_pill_elevation) private val pillTopMargin: Int = loadDimensionPixelSize( R.dimen.desktop_mode_handle_menu_pill_spacing_margin) private val menuWidth = loadDimensionPixelSize( R.dimen.desktop_mode_handle_menu_width) + pillElevation private val menuHeight = getHandleMenuHeight() private val marginMenuTop = loadDimensionPixelSize(R.dimen.desktop_mode_handle_menu_margin_top) private val marginMenuStart = loadDimensionPixelSize( R.dimen.desktop_mode_handle_menu_margin_start) private var handleMenuAnimator: HandleMenuAnimator? = null @VisibleForTesting Loading Loading @@ -120,7 +128,6 @@ class HandleMenu( } init { loadHandleMenuDimensions() updateHandleMenuPillPositions() } Loading Loading @@ -426,49 +433,35 @@ class HandleMenu( */ private fun viewsLaidOut(): Boolean = handleMenuViewContainer?.view?.isLaidOut ?: false private fun loadHandleMenuDimensions() { val resources = context.resources menuWidth = loadDimensionPixelSize(resources, R.dimen.desktop_mode_handle_menu_width) menuHeight = getHandleMenuHeight(resources) marginMenuTop = loadDimensionPixelSize( resources, R.dimen.desktop_mode_handle_menu_margin_top ) marginMenuStart = loadDimensionPixelSize( resources, R.dimen.desktop_mode_handle_menu_margin_start ) } /** * Determines handle menu height based on if windowing pill should be shown. * Determines handle menu height based the max size and the visibility of pills. */ private fun getHandleMenuHeight(resources: Resources): Int { var menuHeight = loadDimensionPixelSize(resources, R.dimen.desktop_mode_handle_menu_height) private fun getHandleMenuHeight(): Int { var menuHeight = loadDimensionPixelSize( R.dimen.desktop_mode_handle_menu_height) + pillElevation if (!shouldShowWindowingPill) { menuHeight -= loadDimensionPixelSize( resources, R.dimen.desktop_mode_handle_menu_windowing_pill_height ) R.dimen.desktop_mode_handle_menu_windowing_pill_height) menuHeight -= pillTopMargin } if (!SHOULD_SHOW_MORE_ACTIONS_PILL) { menuHeight -= loadDimensionPixelSize( resources, R.dimen.desktop_mode_handle_menu_more_actions_pill_height ) R.dimen.desktop_mode_handle_menu_more_actions_pill_height) menuHeight -= pillTopMargin } if (!shouldShowBrowserPill) { menuHeight -= loadDimensionPixelSize(resources, menuHeight -= loadDimensionPixelSize( R.dimen.desktop_mode_handle_menu_open_in_browser_pill_height) menuHeight -= pillTopMargin } return menuHeight } private fun loadDimensionPixelSize(resources: Resources, resourceId: Int): Int { private fun loadDimensionPixelSize(@DimenRes resourceId: Int): Int { if (resourceId == Resources.ID_NULL) { return 0 } return resources.getDimensionPixelSize(resourceId) return context.resources.getDimensionPixelSize(resourceId) } fun close() { Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/HandleMenuTest.kt +16 −3 Original line number Diff line number Diff line Loading @@ -94,6 +94,8 @@ class HandleMenuTest : ShellTestCase() { private lateinit var handleMenu: HandleMenu private val menuWidthWithElevation = MENU_WIDTH + MENU_PILL_ELEVATION @Before fun setUp() { val mockAdditionalViewHostViewContainer = AdditionalViewHostViewContainer( Loading @@ -117,6 +119,9 @@ class HandleMenuTest : ShellTestCase() { addOverride(R.dimen.desktop_mode_handle_menu_height, MENU_HEIGHT) addOverride(R.dimen.desktop_mode_handle_menu_margin_top, MENU_TOP_MARGIN) addOverride(R.dimen.desktop_mode_handle_menu_margin_start, MENU_START_MARGIN) addOverride(R.dimen.desktop_mode_handle_menu_pill_elevation, MENU_PILL_ELEVATION) addOverride( R.dimen.desktop_mode_handle_menu_pill_spacing_margin, MENU_PILL_SPACING_MARGIN) } mockDesktopWindowDecoration.mDecorWindowContext = mContext } Loading @@ -129,7 +134,7 @@ class HandleMenuTest : ShellTestCase() { assertTrue(handleMenu.handleMenuViewContainer is AdditionalSystemViewContainer) // Verify menu is created at coordinates that, when added to WindowManager, // show at the top-center of display. val expected = Point(DISPLAY_BOUNDS.centerX() - MENU_WIDTH / 2, MENU_TOP_MARGIN) val expected = Point(DISPLAY_BOUNDS.centerX() - menuWidthWithElevation / 2, MENU_TOP_MARGIN) assertEquals(expected.toPointF(), handleMenu.handleMenuPosition) } Loading @@ -152,7 +157,10 @@ class HandleMenuTest : ShellTestCase() { assertTrue(handleMenu.handleMenuViewContainer is AdditionalSystemViewContainer) // Verify menu is created at coordinates that, when added to WindowManager, // show at the top-center of split left task. val expected = Point(SPLIT_LEFT_BOUNDS.centerX() - MENU_WIDTH / 2, MENU_TOP_MARGIN) val expected = Point( SPLIT_LEFT_BOUNDS.centerX() - menuWidthWithElevation / 2, MENU_TOP_MARGIN ) assertEquals(expected.toPointF(), handleMenu.handleMenuPosition) } Loading @@ -164,7 +172,10 @@ class HandleMenuTest : ShellTestCase() { assertTrue(handleMenu.handleMenuViewContainer is AdditionalSystemViewContainer) // Verify menu is created at coordinates that, when added to WindowManager, // show at the top-center of split right task. val expected = Point(SPLIT_RIGHT_BOUNDS.centerX() - MENU_WIDTH / 2, MENU_TOP_MARGIN) val expected = Point( SPLIT_RIGHT_BOUNDS.centerX() - menuWidthWithElevation / 2, MENU_TOP_MARGIN ) assertEquals(expected.toPointF(), handleMenu.handleMenuPosition) } Loading Loading @@ -220,5 +231,7 @@ class HandleMenuTest : ShellTestCase() { private const val MENU_HEIGHT = 400 private const val MENU_TOP_MARGIN = 10 private const val MENU_START_MARGIN = 20 private const val MENU_PILL_ELEVATION = 2 private const val MENU_PILL_SPACING_MARGIN = 4 } }