Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content/browser/input/SelectPopupAdapter.java |
| diff --git a/content/public/android/java/src/org/chromium/content/browser/input/SelectPopupAdapter.java b/content/public/android/java/src/org/chromium/content/browser/input/SelectPopupAdapter.java |
| index ca8e5f0e52181de3433c592e777297a3d4cbfffa..881d1d98f071d20b3902d7a18803ebc8070bf391 100644 |
| --- a/content/public/android/java/src/org/chromium/content/browser/input/SelectPopupAdapter.java |
| +++ b/content/public/android/java/src/org/chromium/content/browser/input/SelectPopupAdapter.java |
| @@ -5,6 +5,7 @@ |
| package org.chromium.content.browser.input; |
| import android.content.Context; |
| +import android.util.TypedValue; |
| import android.view.View; |
| import android.view.ViewGroup; |
| import android.widget.ArrayAdapter; |
| @@ -25,6 +26,10 @@ public class SelectPopupAdapter extends ArrayAdapter<SelectPopupItem> { |
| // True if all items have type PopupItemType.ENABLED. |
| private boolean mAreAllItemsEnabled; |
| + private float mTextSize; |
| + private int mMinHeight; |
| + private int mPadding; |
| + |
| /** |
| * Creates a new SelectPopupItem adapter for the select popup alert dialog list. |
| * @param context Application context. |
| @@ -35,6 +40,8 @@ public class SelectPopupAdapter extends ArrayAdapter<SelectPopupItem> { |
| List<SelectPopupItem> items) { |
| super(context, layoutResource, items); |
| mItems = new ArrayList<SelectPopupItem>(items); |
| + mTextSize = -1; |
| + mPadding = -1; |
| mAreAllItemsEnabled = true; |
| for (int i = 0; i < mItems.size(); i++) { |
| @@ -45,6 +52,18 @@ public class SelectPopupAdapter extends ArrayAdapter<SelectPopupItem> { |
| } |
| } |
| + public void setTextSize(float textSize) { |
|
Ted C
2014/04/12 01:10:27
all public methods should have javadocs (like is t
|
| + mTextSize = textSize; |
| + } |
| + |
| + public void setMinHeight(int minHeight) { |
| + mMinHeight = minHeight; |
| + } |
| + |
| + public void setPadding(int padding) { |
| + mPadding = padding; |
| + } |
| + |
| @Override |
| public View getView(int position, View convertView, ViewGroup parent) { |
| if (position < 0 || position >= getCount()) return null; |
| @@ -54,7 +73,14 @@ public class SelectPopupAdapter extends ArrayAdapter<SelectPopupItem> { |
| // used as an <option> element, which needs a checkbox/radio, but it would not have |
| // one. |
| convertView = super.getView(position, null, parent); |
| - ((TextView) convertView).setText(mItems.get(position).getLabel()); |
| + TextView textView = (TextView) convertView; |
| + textView.setText(mItems.get(position).getLabel()); |
| + if (mTextSize >= 0) { |
| + textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); |
| + textView.setMinimumHeight(mMinHeight); |
| + } |
| + if (mPadding >= 0) |
|
Ted C
2014/04/12 01:10:27
braces are required in java if the conditional and
|
| + textView.setPaddingRelative(mPadding, mPadding, mPadding, mPadding); |
| if (mItems.get(position).getType() != PopupItemType.ENABLED) { |
| if (mItems.get(position).getType() == PopupItemType.GROUP) { |