am 5b5a6579: Merge "Make SearchView RTL aware" into jb-mr1-dev

* commit '5b5a6579cf384643686f6bd476003fb4b106963a':
  Make SearchView RTL aware
This commit is contained in:
Fabrice Di Meglio
2012-07-27 15:46:16 -07:00
committed by Android Git Automerger
3 changed files with 23 additions and 5 deletions

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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.
*/