Index: chrome/android/java/src/org/chromium/chrome/browser/ItemChooserDialog.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ItemChooserDialog.java b/chrome/android/java/src/org/chromium/chrome/browser/ItemChooserDialog.java |
index d93e107d842d9a3df9b1288538dbc1e9eab095a6..02cc90732e0f3826b42964ba8ba71353bf59a82f 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/ItemChooserDialog.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ItemChooserDialog.java |
@@ -10,6 +10,7 @@ import android.content.Context; |
import android.content.DialogInterface; |
import android.graphics.Color; |
import android.graphics.drawable.ColorDrawable; |
+import android.graphics.drawable.Drawable; |
import android.text.SpannableString; |
import android.text.method.LinkMovementMethod; |
import android.view.Gravity; |
@@ -65,10 +66,12 @@ public class ItemChooserDialog { |
public static class ItemChooserRow { |
private final String mKey; |
private String mDescription; |
+ private Drawable mDrawable; |
- public ItemChooserRow(String key, String description) { |
+ public ItemChooserRow(String key, String description, Drawable drawable) { |
mKey = key; |
mDescription = description; |
+ mDrawable = drawable; |
ortuno
2016/09/27 07:02:30
The main reason for the ItemChooserIcon object was
|
} |
@Override |
@@ -76,7 +79,7 @@ public class ItemChooserDialog { |
if (!(obj instanceof ItemChooserRow)) return false; |
if (this == obj) return true; |
ItemChooserRow item = (ItemChooserRow) obj; |
- return mKey.equals(item.mKey) && mDescription.equals(item.mDescription); |
+ return mKey.equals(item.mKey) && mDescription.equals(item.mDescription) && mDrawable == item.mDrawable; |
} |
@Override |
@@ -188,6 +191,9 @@ public class ItemChooserDialog { |
oldItem.mDescription = item.mDescription; |
addToDescriptionsMap(oldItem.mDescription); |
} |
+ if (oldItem.mDrawable != item.mDrawable) { |
+ oldItem.mDrawable = item.mDrawable; |
+ } |
notifyDataSetChanged(); |
return; |
} |
@@ -240,6 +246,11 @@ public class ItemChooserDialog { |
item.mKey); |
} |
+ private Drawable getDrawable(int p) { |
+ ItemChooserRow item = getItem(p); |
+ return item.mDrawable; |
+ } |
+ |
/** |
* Sets whether the itam is enabled. Disabled items are grayed out. |
* @param id The id of the item to affect. |
@@ -295,6 +306,7 @@ public class ItemChooserDialog { |
} |
view.setText(getDisplayText(position)); |
+ ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(view, getDrawable(position), null, null, null); |
return view; |
} |
@@ -393,8 +405,8 @@ public class ItemChooserDialog { |
@Override |
public void onClick(View v) { |
mItemSelectedCallback.onItemSelected(mItemAdapter.getSelectedItemKey()); |
- mDialog.setOnDismissListener(null); |
- mDialog.dismiss(); |
+// mDialog.setOnDismissListener(null); |
+// mDialog.dismiss(); |
} |
}); |
@@ -424,7 +436,7 @@ public class ItemChooserDialog { |
// Round to (an integer + 0.5) times LIST_ROW_HEIGHT. |
heightDp = (Math.round(heightDp / LIST_ROW_HEIGHT_DP - 0.5f) + 0.5f) * LIST_ROW_HEIGHT_DP; |
heightDp = MathUtils.clamp(heightDp, MIN_HEIGHT_DP, MAX_HEIGHT_DP); |
- return (int) Math.round(heightDp * density); |
+ return Math.round(heightDp * density); |
} |
private void showDialogForView(View view) { |