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
This commit is contained in:
+15
-8
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user