Merge "Make SearchView RTL aware" into jb-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5b5a6579cf
@@ -1078,6 +1078,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
|
||||
mPopup.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NEEDED);
|
||||
mPopup.setListItemExpandMax(EXPAND_MAX);
|
||||
}
|
||||
mPopup.setLayoutDirection(getResolvedLayoutDirection());
|
||||
mPopup.show();
|
||||
mPopup.getListView().setOverScrollMode(View.OVER_SCROLL_ALWAYS);
|
||||
}
|
||||
|
||||
@@ -1121,6 +1121,12 @@ public class ListPopupWindow {
|
||||
return listContent + otherHeights;
|
||||
}
|
||||
|
||||
public void setLayoutDirection(int resolvedLayoutDirection) {
|
||||
if (mDropDownList != null) {
|
||||
mDropDownList.setLayoutDirection(resolvedLayoutDirection);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Wrapper class for a ListView. This wrapper can hijack the focus to
|
||||
* make sure the list uses the appropriate drawables and states when
|
||||
|
||||
@@ -326,7 +326,6 @@ public class SearchView extends LinearLayout implements CollapsibleActionView {
|
||||
int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||
adjustDropDownSizeAndPosition();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1285,15 +1284,22 @@ public class SearchView extends LinearLayout implements CollapsibleActionView {
|
||||
Resources res = getContext().getResources();
|
||||
int anchorPadding = mSearchPlate.getPaddingLeft();
|
||||
Rect dropDownPadding = new Rect();
|
||||
final boolean isLayoutRtl = isLayoutRtl();
|
||||
int iconOffset = mIconifiedByDefault
|
||||
? res.getDimensionPixelSize(R.dimen.dropdownitem_icon_width)
|
||||
+ res.getDimensionPixelSize(R.dimen.dropdownitem_text_padding_left)
|
||||
: 0;
|
||||
mQueryTextView.getDropDownBackground().getPadding(dropDownPadding);
|
||||
mQueryTextView.setDropDownHorizontalOffset(-(dropDownPadding.left + iconOffset)
|
||||
+ anchorPadding);
|
||||
mQueryTextView.setDropDownWidth(mDropDownAnchor.getWidth() + dropDownPadding.left
|
||||
+ dropDownPadding.right + iconOffset - (anchorPadding));
|
||||
int offset;
|
||||
if (isLayoutRtl) {
|
||||
offset = - dropDownPadding.left;
|
||||
} else {
|
||||
offset = anchorPadding - (dropDownPadding.left + iconOffset);
|
||||
}
|
||||
mQueryTextView.setDropDownHorizontalOffset(offset);
|
||||
final int width = mDropDownAnchor.getWidth() + dropDownPadding.left
|
||||
+ dropDownPadding.right + iconOffset - anchorPadding;
|
||||
mQueryTextView.setDropDownWidth(width);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1347,6 +1353,11 @@ public class SearchView extends LinearLayout implements CollapsibleActionView {
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onResolvedLayoutDirectionChanged() {
|
||||
mQueryTextView.setLayoutDirection(getResolvedLayoutDirection());
|
||||
}
|
||||
|
||||
/**
|
||||
* Query rewriting.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user