From 10faea6c76358340a3fdf372cc65f78489ca933a Mon Sep 17 00:00:00 2001 From: Jagrut Desai Date: Fri, 9 May 2025 14:06:29 -0700 Subject: [PATCH] Fix NavButton Position when in RTL and Lanscape This cl changes the order of adding nav button to contrianer, so upon user rotating phone to landscape more while in RTL will not cause buttons to switch positions. Test: Manual Bug: 396135895 Flag: EXEMPT bugfix Change-Id: If5512cbdac06bc65f10c8d1e326ae6b786de98ba --- .../navbutton/PhoneLandscapeNavLayoutter.kt | 23 ++++++++++++------- .../navbutton/PhoneSeascapeNavLayoutter.kt | 21 +++++++++++------ 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt index 9f7f07e773..d989f6b534 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt @@ -25,6 +25,7 @@ import android.widget.ImageView import android.widget.LinearLayout import android.widget.Space import com.android.launcher3.R +import com.android.launcher3.Utilities import com.android.launcher3.taskbar.TaskbarActivityContext open class PhoneLandscapeNavLayoutter( @@ -34,7 +35,7 @@ open class PhoneLandscapeNavLayoutter( startContextualContainer: ViewGroup, imeSwitcher: ImageView?, a11yButton: ImageView?, - space: Space? + space: Space?, ) : AbstractNavButtonLayoutter( resources, @@ -43,7 +44,7 @@ open class PhoneLandscapeNavLayoutter( startContextualContainer, imeSwitcher, a11yButton, - space + space, ) { override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) { @@ -112,9 +113,15 @@ open class PhoneLandscapeNavLayoutter( open fun addThreeButtons() { // Swap recents and back button - navButtonContainer.addView(recentsButton) - navButtonContainer.addView(homeButton) - navButtonContainer.addView(backButton) + if (Utilities.isRtl(resources)) { + navButtonContainer.addView(backButton) + navButtonContainer.addView(homeButton) + navButtonContainer.addView(recentsButton) + } else { + navButtonContainer.addView(recentsButton) + navButtonContainer.addView(homeButton) + navButtonContainer.addView(backButton) + } } open fun repositionContextualButtons(buttonSize: Int) { @@ -129,14 +136,14 @@ open class PhoneLandscapeNavLayoutter( buttonSize, roundedCornerContentMargin + contentPadding, 0, - Gravity.TOP + Gravity.TOP, ) repositionContextualContainer( endContextualContainer, buttonSize, 0, roundedCornerContentMargin + contentPadding, - Gravity.BOTTOM + Gravity.BOTTOM, ) if (imeSwitcher != null) { @@ -155,7 +162,7 @@ open class PhoneLandscapeNavLayoutter( buttonSize: Int, barAxisMarginTop: Int, barAxisMarginBottom: Int, - gravity: Int + gravity: Int, ) { val contextualContainerParams = FrameLayout.LayoutParams(MATCH_PARENT, buttonSize) contextualContainerParams.apply { diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneSeascapeNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneSeascapeNavLayoutter.kt index f0b47f4caa..cf6f89857a 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneSeascapeNavLayoutter.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneSeascapeNavLayoutter.kt @@ -24,6 +24,7 @@ import android.widget.ImageView import android.widget.LinearLayout import android.widget.Space import com.android.launcher3.R +import com.android.launcher3.Utilities class PhoneSeascapeNavLayoutter( resources: Resources, @@ -32,7 +33,7 @@ class PhoneSeascapeNavLayoutter( startContextualContainer: ViewGroup, imeSwitcher: ImageView?, a11yButton: ImageView?, - space: Space? + space: Space?, ) : PhoneLandscapeNavLayoutter( resources, @@ -41,14 +42,20 @@ class PhoneSeascapeNavLayoutter( startContextualContainer, imeSwitcher, a11yButton, - space + space, ) { override fun addThreeButtons() { // Flip ordering of back and recents buttons - navButtonContainer.addView(backButton) - navButtonContainer.addView(homeButton) - navButtonContainer.addView(recentsButton) + if (Utilities.isRtl(resources)) { + navButtonContainer.addView(recentsButton) + navButtonContainer.addView(homeButton) + navButtonContainer.addView(backButton) + } else { + navButtonContainer.addView(backButton) + navButtonContainer.addView(homeButton) + navButtonContainer.addView(recentsButton) + } } override fun repositionContextualButtons(buttonSize: Int) { @@ -63,14 +70,14 @@ class PhoneSeascapeNavLayoutter( buttonSize, roundedCornerContentMargin + contentPadding, 0, - Gravity.TOP + Gravity.TOP, ) repositionContextualContainer( endContextualContainer, buttonSize, 0, roundedCornerContentMargin + contentPadding, - Gravity.BOTTOM + Gravity.BOTTOM, ) startContextualContainer.addView(space, MATCH_PARENT, MATCH_PARENT)