Skip to content

Commit cf12897

Browse files
author
Fabrice Di Meglio
committed
Fix bug #7363252 Popup and Dialog UI widgets should be RTL aware
- set the Configuration's layout direction in ViewRootImpl instead of PhoneWindow$DecorView - then remove unecessary API on ListPopupWindow for passing the layout direction Change-Id: Ia2c6e4aa8cb82aed9b088bc3b8004ea0a1ded1f3
1 parent 809bb40 commit cf12897

6 files changed

Lines changed: 7 additions & 23 deletions

File tree

api/17.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28617,7 +28617,6 @@ package android.widget {
2861728617
method public void setHeight(int);
2861828618
method public void setHorizontalOffset(int);
2861928619
method public void setInputMethodMode(int);
28620-
method public void setLayoutDirection(int);
2862128620
method public void setListSelector(android.graphics.drawable.Drawable);
2862228621
method public void setModal(boolean);
2862328622
method public void setOnDismissListener(android.widget.PopupWindow.OnDismissListener);

api/current.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16149,7 +16149,7 @@ package android.os {
1614916149

1615016150
public class Looper {
1615116151
method public void dump(android.util.Printer, java.lang.String);
16152-
method public static synchronized android.os.Looper getMainLooper();
16152+
method public static android.os.Looper getMainLooper();
1615316153
method public java.lang.Thread getThread();
1615416154
method public static void loop();
1615516155
method public static android.os.Looper myLooper();
@@ -28617,7 +28617,6 @@ package android.widget {
2861728617
method public void setHeight(int);
2861828618
method public void setHorizontalOffset(int);
2861928619
method public void setInputMethodMode(int);
28620-
method public void setLayoutDirection(int);
2862128620
method public void setListSelector(android.graphics.drawable.Drawable);
2862228621
method public void setModal(boolean);
2862328622
method public void setOnDismissListener(android.widget.PopupWindow.OnDismissListener);

core/java/android/view/ViewRootImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,7 @@ private void performTraversals() {
11821182
viewVisibilityChanged = false;
11831183
mLastConfiguration.setTo(host.getResources().getConfiguration());
11841184
mLastSystemUiVisibility = mAttachInfo.mSystemUiVisibility;
1185+
host.setLayoutDirection(mLastConfiguration.getLayoutDirection());
11851186
host.dispatchAttachedToWindow(attachInfo, 0);
11861187
mFitSystemWindowsInsets.set(mAttachInfo.mContentInsets);
11871188
host.fitSystemWindows(mFitSystemWindowsInsets);
@@ -2684,7 +2685,12 @@ void updateConfiguration(Configuration config, boolean force) {
26842685
// the one in them which may be newer.
26852686
config = mView.getResources().getConfiguration();
26862687
if (force || mLastConfiguration.diff(config) != 0) {
2688+
final int lastLayoutDirection = mLastConfiguration.getLayoutDirection();
2689+
final int currentLayoutDirection = config.getLayoutDirection();
26872690
mLastConfiguration.setTo(config);
2691+
if (lastLayoutDirection != currentLayoutDirection) {
2692+
mView.setLayoutDirection(currentLayoutDirection);
2693+
}
26882694
mView.dispatchConfigurationChanged(config);
26892695
}
26902696
}

core/java/android/widget/AutoCompleteTextView.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,6 @@ public void showDropDown() {
10931093
mPopup.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NEEDED);
10941094
mPopup.setListItemExpandMax(EXPAND_MAX);
10951095
}
1096-
mPopup.setLayoutDirection(getLayoutDirection());
10971096
mPopup.show();
10981097
mPopup.getListView().setOverScrollMode(View.OVER_SCROLL_ALWAYS);
10991098
}

core/java/android/widget/ListPopupWindow.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,8 +1021,6 @@ public void onNothingSelected(AdapterView<?> parent) {
10211021
mDropDownList.setOnItemSelectedListener(mItemSelectedListener);
10221022
}
10231023

1024-
mDropDownList.setLayoutDirection(mLayoutDirection);
1025-
10261024
dropDownView = mDropDownList;
10271025

10281026
View hintView = mPromptView;
@@ -1131,21 +1129,6 @@ public void onNothingSelected(AdapterView<?> parent) {
11311129
return listContent + otherHeights;
11321130
}
11331131

1134-
/**
1135-
* Set the layout direction for this popup. Should be a resolved direction as the
1136-
* popup as no capacity to do the resolution on his own.
1137-
*
1138-
* @param layoutDirection One of {@link View#LAYOUT_DIRECTION_LTR},
1139-
* {@link View#LAYOUT_DIRECTION_RTL},
1140-
*
1141-
*/
1142-
public void setLayoutDirection(int layoutDirection) {
1143-
mLayoutDirection = layoutDirection;
1144-
if (mDropDownList != null) {
1145-
mDropDownList.setLayoutDirection(mLayoutDirection);
1146-
}
1147-
}
1148-
11491132
/**
11501133
* <p>Wrapper class for a ListView. This wrapper can hijack the focus to
11511134
* make sure the list uses the appropriate drawables and states when

policy/src/com/android/internal/policy/impl/PhoneWindow.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2867,8 +2867,6 @@ private void installDecor() {
28672867
mDecor = generateDecor();
28682868
mDecor.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
28692869
mDecor.setIsRootNamespace(true);
2870-
mDecor.setLayoutDirection(
2871-
getContext().getResources().getConfiguration().getLayoutDirection());
28722870
if (!mInvalidatePanelMenuPosted && mInvalidatePanelMenuFeatures != 0) {
28732871
mDecor.postOnAnimation(mInvalidatePanelMenuRunnable);
28742872
}

0 commit comments

Comments
 (0)