Fix UI location and snackbar padding for RTL.

Screenshots:
- Padding: https://screenshot.googleplex.com/3yd42n8MzSaw7Xv
- LTR portrait: https://screenshot.googleplex.com/5uskVaFs5hPHxod
- RTL portrait: https://screenshot.googleplex.com/4zn8Ds76TXZF7BP
- LTR landscape: https://screenshot.googleplex.com/5GQFYN5MTiJWxyB
- RTL landscape: https://screenshot.googleplex.com/ANmwpmf2A53GE5D

Fix: 276298668
Fix: 276236465
Test: Change device to RTL locale, open and interact with the
      AccessibilityMenu service.
Change-Id: I1633840bae0da0a576efb16d9d45659083deb1b9
This commit is contained in:
Daniel Norman
2023-03-31 17:43:50 -07:00
parent abd084a692
commit 97299f2bc4
2 changed files with 8 additions and 5 deletions

View File

@@ -56,6 +56,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:gravity="center_vertical"
android:textColor="@color/colorControlNormal"
android:textSize="@dimen/label_text_size"

View File

@@ -194,13 +194,15 @@ public class A11yMenuOverlayLayout {
/** Updates a11y menu layout position by configuring layout params. */
private void updateLayoutPosition() {
final Display display = mDisplayManager.getDisplay(Display.DEFAULT_DISPLAY);
final int orientation = mService.getResources().getConfiguration().orientation;
final Configuration configuration = mService.getResources().getConfiguration();
final int orientation = configuration.orientation;
if (display != null && orientation == Configuration.ORIENTATION_LANDSCAPE) {
final boolean ltr = configuration.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;
switch (display.getRotation()) {
case Surface.ROTATION_90:
case Surface.ROTATION_0:
case Surface.ROTATION_180:
mLayoutParameter.gravity =
Gravity.END | Gravity.BOTTOM
(ltr ? Gravity.END : Gravity.START) | Gravity.BOTTOM
| Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL;
mLayoutParameter.width = WindowManager.LayoutParams.WRAP_CONTENT;
mLayoutParameter.height = WindowManager.LayoutParams.MATCH_PARENT;
@@ -208,10 +210,10 @@ public class A11yMenuOverlayLayout {
mLayoutParameter.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
mLayout.setBackgroundResource(R.drawable.shadow_90deg);
break;
case Surface.ROTATION_0:
case Surface.ROTATION_90:
case Surface.ROTATION_270:
mLayoutParameter.gravity =
Gravity.START | Gravity.BOTTOM
(ltr ? Gravity.START : Gravity.END) | Gravity.BOTTOM
| Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL;
mLayoutParameter.width = WindowManager.LayoutParams.WRAP_CONTENT;
mLayoutParameter.height = WindowManager.LayoutParams.MATCH_PARENT;