| Index: ui/android/java/src/org/chromium/ui/DropdownAdapter.java
|
| diff --git a/ui/android/java/src/org/chromium/ui/DropdownAdapter.java b/ui/android/java/src/org/chromium/ui/DropdownAdapter.java
|
| index ec3505f48c6cf73cc9930993184030fe16dc0f4d..68ce171a002688eab3cbaa7f53a6eccf07345d58 100644
|
| --- a/ui/android/java/src/org/chromium/ui/DropdownAdapter.java
|
| +++ b/ui/android/java/src/org/chromium/ui/DropdownAdapter.java
|
| @@ -30,14 +30,27 @@ public class DropdownAdapter extends ArrayAdapter<DropdownItem> {
|
| private final Context mContext;
|
| private final Set<Integer> mSeparators;
|
| private final boolean mAreAllItemsEnabled;
|
| -
|
| - public DropdownAdapter(
|
| - Context context, List<? extends DropdownItem> items, Set<Integer> separators) {
|
| - super(context, R.layout.dropdown_item);
|
| + // Keep comparison with default values (i.e. not overriden by experiment value) consistent with
|
| + // native code. 0 == SK_ColorTRANSPARENT is default value if not overriden by experiment.
|
| + private final int mBackgroundColor;
|
| + private final int mDividerColor;
|
| + // 0 => use the default value for |dropdown_item_height| specified in XML resource file.
|
| + private final int mDropdownItemHeight;
|
| + private final int mDropdownItemResourceId;
|
| +
|
| + public DropdownAdapter(Context context, List<? extends DropdownItem> items,
|
| + Set<Integer> separators, int backgroundColor, int dividerColor, int dropdownItemHeight,
|
| + boolean isIconAtLeft) {
|
| + super(context, isIconAtLeft ? R.layout.dropdown_item_icon_at_left : R.layout.dropdown_item);
|
| + mContext = context;
|
| addAll(items);
|
| mSeparators = separators;
|
| - mContext = context;
|
| mAreAllItemsEnabled = checkAreAllItemsEnabled();
|
| + mBackgroundColor = backgroundColor;
|
| + mDividerColor = dividerColor;
|
| + mDropdownItemHeight = dropdownItemHeight;
|
| + mDropdownItemResourceId =
|
| + isIconAtLeft ? R.layout.dropdown_item_icon_at_left : R.layout.dropdown_item;
|
| }
|
|
|
| private boolean checkAreAllItemsEnabled() {
|
| @@ -56,26 +69,36 @@ public class DropdownAdapter extends ArrayAdapter<DropdownItem> {
|
| if (convertView == null) {
|
| LayoutInflater inflater =
|
| (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
| - layout = inflater.inflate(R.layout.dropdown_item, null);
|
| - layout.setBackground(new DropdownDividerDrawable());
|
| + layout = inflater.inflate(mDropdownItemResourceId, null);
|
| + layout.setBackground(new DropdownDividerDrawable(mBackgroundColor));
|
| }
|
| -
|
| DropdownDividerDrawable divider = (DropdownDividerDrawable) layout.getBackground();
|
| - int height = mContext.getResources().getDimensionPixelSize(R.dimen.dropdown_item_height);
|
| + int height;
|
| + if (mDropdownItemHeight == 0) {
|
| + height = mContext.getResources().getDimensionPixelSize(R.dimen.dropdown_item_height);
|
| + } else {
|
| + height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
|
| + mDropdownItemHeight, mContext.getResources().getDisplayMetrics());
|
| + }
|
| +
|
| if (position == 0) {
|
| - divider.setColor(Color.TRANSPARENT);
|
| + divider.setDividerColor(Color.TRANSPARENT);
|
| } else {
|
| int dividerHeight = mContext.getResources().getDimensionPixelSize(
|
| R.dimen.dropdown_item_divider_height);
|
| height += dividerHeight;
|
| divider.setHeight(dividerHeight);
|
| + int dividerColor;
|
| if (mSeparators != null && mSeparators.contains(position)) {
|
| - divider.setColor(ApiCompatibilityUtils.getColor(mContext.getResources(),
|
| - R.color.dropdown_dark_divider_color));
|
| + dividerColor = ApiCompatibilityUtils.getColor(mContext.getResources(),
|
| + R.color.dropdown_dark_divider_color);
|
| + } else if (mDividerColor == 0) {
|
| + dividerColor = ApiCompatibilityUtils.getColor(mContext.getResources(),
|
| + R.color.dropdown_divider_color);
|
| } else {
|
| - divider.setColor(ApiCompatibilityUtils.getColor(mContext.getResources(),
|
| - R.color.dropdown_divider_color));
|
| + dividerColor = mDividerColor;
|
| }
|
| + divider.setDividerColor(dividerColor);
|
| }
|
|
|
| DropdownItem item = getItem(position);
|
| @@ -94,7 +117,7 @@ public class DropdownAdapter extends ArrayAdapter<DropdownItem> {
|
| labelView.setSingleLine(!item.isMultilineLabel());
|
|
|
| labelView.setEnabled(item.isEnabled());
|
| - if (item.isGroupHeader()) {
|
| + if (item.isGroupHeader() || item.isBoldLabel()) {
|
| labelView.setTypeface(null, Typeface.BOLD);
|
| } else {
|
| labelView.setTypeface(null, Typeface.NORMAL);
|
|
|