Add Handle Menu RTL support
1) Fixes the initial position of the Handle Menu in freeform to align
with the app chip when it's in RTL
2) Fixes the menu's view padding to not explicitly use left/right
Fix: 353304148
Flag: EXEMPT bug fix
Test: open handle menu in freeform with forced RTL, verify its location
matches the App Chip
Change-Id: I4240f5cad6693cf62b57d37419fc4aabc4d83f88
diff --git a/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu.xml b/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu.xml
index a18a251..bfd9c81 100644
--- a/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu.xml
+++ b/libs/WindowManager/Shell/res/layout/desktop_mode_window_decor_handle_menu.xml
@@ -23,7 +23,7 @@
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:paddingEnd="@dimen/desktop_mode_handle_menu_pill_elevation"
android:orientation="vertical">
<LinearLayout
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/HandleMenu.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/HandleMenu.kt
index 54c247b..62be2c7 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/HandleMenu.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/HandleMenu.kt
@@ -238,8 +238,12 @@
val taskBounds = taskInfo.getConfiguration().windowConfiguration.bounds
updateGlobalMenuPosition(taskBounds, captionX, captionY)
if (layoutResId == R.layout.desktop_mode_app_header) {
- // Align the handle menu to the left side of the caption.
- menuX = marginMenuStart
+ // Align the handle menu to the start of the header.
+ menuX = if (context.isRtl()) {
+ taskBounds.width() - menuWidth - marginMenuStart
+ } else {
+ marginMenuStart
+ }
menuY = captionY + marginMenuTop
} else {
if (DesktopModeFlags.ENABLE_HANDLE_INPUT_FIX.isTrue()) {
@@ -261,10 +265,17 @@
val nonFreeformX = captionX + (captionWidth / 2) - (menuWidth / 2)
when {
taskInfo.isFreeform -> {
- globalMenuPosition.set(
- /* x = */ taskBounds.left + marginMenuStart,
- /* y = */ taskBounds.top + captionY + marginMenuTop
- )
+ if (context.isRtl()) {
+ globalMenuPosition.set(
+ /* x= */ taskBounds.right - menuWidth - marginMenuStart,
+ /* y= */ taskBounds.top + captionY + marginMenuTop
+ )
+ } else {
+ globalMenuPosition.set(
+ /* x= */ taskBounds.left + marginMenuStart,
+ /* y= */ taskBounds.top + captionY + marginMenuTop
+ )
+ }
}
taskInfo.isFullscreen -> {
globalMenuPosition.set(
@@ -430,6 +441,9 @@
return context.resources.getDimensionPixelSize(resourceId)
}
+ private fun Context.isRtl() =
+ resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_RTL
+
fun close() {
handleMenuView?.animateCloseMenu {
handleMenuViewContainer?.releaseView()