Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Unified Diff: ui/android/java/src/org/chromium/ui/DropdownAdapter.java

Issue 2531223003: Expanded Autofill Credit Card Popup Layout Experiment in Android. (Closed)
Patch Set: Adds clarifying comments for DropdownAdapter parameters. Moves checking whether icon should be at s… Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 d8ad3f3fdeed237e8c817613c839f37363e7c0c5..3ef04bf45ca35cc84e19fd9b4737d54ea959c578 100644
--- a/ui/android/java/src/org/chromium/ui/DropdownAdapter.java
+++ b/ui/android/java/src/org/chromium/ui/DropdownAdapter.java
@@ -30,14 +30,33 @@ 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) {
+ private final int mBackgroundColor;
+ private final int mDividerColor;
+ private final int mDropdownItemHeight;
+
+ /**
+ * Creates an {@code ArrayAdapter} with specified parameters.
+ * @param context Application context.
+ * @param items List of labels and icons to display.
+ * @param separators Set of positions that separate {@code items}.
+ * @param backgroundColor popup background color.
Theresa 2016/12/08 21:38:17 nit: capitalize Popup
csashi 2016/12/08 23:03:30 Done.
+ * @param dividerColor If Color.TRANSPARENT, use the values in colors.xml for the divider
+ * between items. Otherwise, uses {@param dividerColor} for the divider between items. Always
+ * uses the values in colors.xml for the dark divider for the separators.
+ * @param dropdownItemHeight If 0, uses the {@code dropdown_item_height} in dimens.xml.
+ * Otherwise, uses {@param dropdownItemHeight}.
+ */
+ public DropdownAdapter(Context context, List<? extends DropdownItem> items,
+ Set<Integer> separators, int backgroundColor, int dividerColor,
+ int dropdownItemHeight) {
super(context, R.layout.dropdown_item);
+ mContext = context;
addAll(items);
mSeparators = separators;
- mContext = context;
mAreAllItemsEnabled = checkAreAllItemsEnabled();
+ mBackgroundColor = backgroundColor;
+ mDividerColor = dividerColor;
+ mDropdownItemHeight = dropdownItemHeight;
}
private boolean checkAreAllItemsEnabled() {
@@ -57,25 +76,35 @@ public class DropdownAdapter extends ArrayAdapter<DropdownItem> {
LayoutInflater inflater =
(LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layout = inflater.inflate(R.layout.dropdown_item, null);
- layout.setBackground(new DropdownDividerDrawable());
+ 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);
@@ -113,7 +142,7 @@ public class DropdownAdapter extends ArrayAdapter<DropdownItem> {
}
labelView.setEnabled(item.isEnabled());
- if (item.isGroupHeader()) {
+ if (item.isGroupHeader() || item.isBoldLabel()) {
labelView.setTypeface(null, Typeface.BOLD);
} else {
labelView.setTypeface(null, Typeface.NORMAL);

Powered by Google App Engine
This is Rietveld 408576698