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

Commit d23ccace authored by Maryam Dehaini's avatar Maryam Dehaini
Browse files

Account for RTL languages for maximize menu

Makes the following changes:
1. Shifts the menu if it goes off the left side of the screen
   (previously only accounted for right side)
2. Switches buttons when screen is laid out RTL since menu will be
   mirrored in this case

Bug: 390183820
Test: Open maximize menu near left edge, hover over snap options
Flag: com.android.window.flags.enable_desktop_windowing_mode
Change-Id: Ia6aefa222aaf36eab4024fcb75eb54fef6df9aa7
parent 33f6ddfd
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1098,8 +1098,10 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        final float menuRight = menuLeft + menuWidth;
        final float menuBottom = menuTop + menuHeight;

        // If the menu is out of screen bounds, shift it up/left as needed
        if (menuRight > displayWidth) {
        // If the menu is out of screen bounds, shift it as needed
        if (menuLeft < 0) {
            menuLeft = 0;
        } else if (menuRight > displayWidth) {
            menuLeft = (displayWidth - menuWidth);
        }
        if (menuBottom > displayHeight) {
+15 −4
Original line number Diff line number Diff line
@@ -291,13 +291,24 @@ class MaximizeMenu(
            requireViewById(R.id.maximize_menu_snap_container) as View
        private val snapWindowText =
            requireViewById(R.id.maximize_menu_snap_window_text) as TextView
        private val snapRightButton =
            requireViewById(R.id.maximize_menu_snap_right_button) as Button
        private val snapLeftButton =
            requireViewById(R.id.maximize_menu_snap_left_button) as Button
        private val snapButtonsLayout =
            requireViewById(R.id.maximize_menu_snap_menu_layout)

        // If layout direction is RTL, maximize menu will be mirrored, switching the order of the
        // snap right/left buttons.
        val isRtl: Boolean =
            (context.resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_RTL)
        private val snapRightButton = if (isRtl) {
            requireViewById(R.id.maximize_menu_snap_left_button) as Button
        } else {
            requireViewById(R.id.maximize_menu_snap_right_button) as Button
        }
        private val snapLeftButton = if (isRtl) {
            requireViewById(R.id.maximize_menu_snap_right_button) as Button
        } else {
            requireViewById(R.id.maximize_menu_snap_left_button) as Button
        }

        private val decorThemeUtil = DecorThemeUtil(context)

        private val outlineRadius = context.resources