Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4afecb0c authored by Maryam Dehaini's avatar Maryam Dehaini
Browse files

Corrects the height calculation of the handle menu

Height calculation did not consider the 1dp of bottom padding.

Also removes the extra 1dp added to the view's LayoutParam's height and
width. Padding is added directly to view so that the view's elevation is
not clipped.

Bug: 377619535
Test: Open menu on phone and tablet
Flag: com.android.window.flags.enable_desktop_windowing_mode
Change-Id: I0800cdeaacda70296c44c086cb04b398fde735c9
parent 7f8bd2fb
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -22,8 +22,8 @@
    android:layout_height="wrap_content"
    android:clipChildren="false"
    android:clipToPadding="false"
    android:paddingBottom="@dimen/desktop_mode_handle_menu_pill_elevation"
    android:paddingEnd="@dimen/desktop_mode_handle_menu_pill_elevation"
    android:paddingBottom="@dimen/desktop_mode_handle_menu_pill_elevation_padding"
    android:paddingEnd="@dimen/desktop_mode_handle_menu_pill_elevation_padding"
    android:orientation="vertical">

    <LinearLayout
+10 −6
Original line number Diff line number Diff line
@@ -528,17 +528,21 @@
    <!-- The radius of the Maximize menu shadow. -->
    <dimen name="desktop_mode_maximize_menu_shadow_radius">8dp</dimen>

    <!-- The width of the handle menu in desktop mode.  -->
    <dimen name="desktop_mode_handle_menu_width">216dp</dimen>
    <!-- The width of the handle menu in desktop mode plus the 2dp added for padding to account for
         pill elevation. -->
    <dimen name="desktop_mode_handle_menu_width">218dp</dimen>

    <!-- The maximum height of the handle menu in desktop mode. Three pills at 52dp each,
         additional actions pill 208dp, plus 2dp spacing between them plus 4dp top padding.
         52*3 + 52*4 + (4-1)*2 + 4 = 374 -->
    <dimen name="desktop_mode_handle_menu_height">374dp</dimen>
    <!-- The maximum height of the handle menu in desktop mode. Three pills at 52dp each plus
         additional actions pill 208dp plus 2dp spacing between them plus 4dp top padding
         plus 2dp bottom padding: 52*3 + 52*4 + (4-1)*2 + 4 + 2 = 376 -->
    <dimen name="desktop_mode_handle_menu_height">376dp</dimen>

    <!-- The elevation set on the handle menu pills. -->
    <dimen name="desktop_mode_handle_menu_pill_elevation">1dp</dimen>

    <!-- The padding added to account for the handle menu's pills' elevation. -->
    <dimen name="desktop_mode_handle_menu_pill_elevation_padding">2dp</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>

+2 −6
Original line number Diff line number Diff line
@@ -109,12 +109,9 @@ class HandleMenu(
    private val isViewAboveStatusBar: Boolean
        get() = (DesktopModeFlags.ENABLE_HANDLE_INPUT_FIX.isTrue() && !taskInfo.isFreeform)

    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 menuWidth = loadDimensionPixelSize(R.dimen.desktop_mode_handle_menu_width)
    private val menuHeight = getHandleMenuHeight()
    private val marginMenuTop = loadDimensionPixelSize(R.dimen.desktop_mode_handle_menu_margin_top)
    private val marginMenuStart = loadDimensionPixelSize(
@@ -399,8 +396,7 @@ class HandleMenu(
     * Determines handle menu height based the max size and the visibility of pills.
     */
    private fun getHandleMenuHeight(): Int {
        var menuHeight = loadDimensionPixelSize(
            R.dimen.desktop_mode_handle_menu_height) + pillElevation
        var menuHeight = loadDimensionPixelSize(R.dimen.desktop_mode_handle_menu_height)
        if (!shouldShowWindowingPill) {
            menuHeight -= loadDimensionPixelSize(
                R.dimen.desktop_mode_handle_menu_windowing_pill_height)
+3 −7
Original line number Diff line number Diff line
@@ -98,8 +98,6 @@ class HandleMenuTest : ShellTestCase() {

    private lateinit var handleMenu: HandleMenu

    private val menuWidthWithElevation = MENU_WIDTH + MENU_PILL_ELEVATION

    @Before
    fun setUp() {
        val mockAdditionalViewHostViewContainer = AdditionalViewHostViewContainer(
@@ -126,7 +124,6 @@ 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)
        }
@@ -141,7 +138,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() - menuWidthWithElevation / 2, MENU_TOP_MARGIN)
        val expected = Point(DISPLAY_BOUNDS.centerX() - MENU_WIDTH / 2, MENU_TOP_MARGIN)
        assertEquals(expected.toPointF(), handleMenu.handleMenuPosition)
    }

@@ -165,7 +162,7 @@ class HandleMenuTest : ShellTestCase() {
        // 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() - menuWidthWithElevation / 2,
            SPLIT_LEFT_BOUNDS.centerX() - MENU_WIDTH / 2,
            MENU_TOP_MARGIN
        )
        assertEquals(expected.toPointF(), handleMenu.handleMenuPosition)
@@ -180,7 +177,7 @@ class HandleMenuTest : ShellTestCase() {
        // 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() - menuWidthWithElevation / 2,
            SPLIT_RIGHT_BOUNDS.centerX() - MENU_WIDTH / 2,
            MENU_TOP_MARGIN
        )
        assertEquals(expected.toPointF(), handleMenu.handleMenuPosition)
@@ -323,7 +320,6 @@ 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
        private const val HANDLE_WIDTH = 80
        private const val APP_NAME = "Test App"