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..2730d6738ea9ab34c1846d6cbf3dba2db8b25267 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,8 @@ import android.content.Context; |
import android.content.DialogInterface; |
import android.graphics.Color; |
import android.graphics.drawable.ColorDrawable; |
+import android.support.annotation.ColorInt; |
+import android.support.annotation.ColorRes; |
import android.text.SpannableString; |
import android.text.method.LinkMovementMethod; |
import android.view.Gravity; |
@@ -135,9 +137,6 @@ public class ItemChooserDialog { |
// The background color of the highlighted item. |
private final int mBackgroundHighlightColor; |
- // The color of the non-highlighted text. |
- private final int mDefaultTextColor; |
- |
// The zero-based index of the item currently selected in the dialog, |
// or -1 (INVALID_POSITION) if nothing is selected. |
private int mSelectedItem = ListView.INVALID_POSITION; |
@@ -158,8 +157,6 @@ public class ItemChooserDialog { |
mBackgroundHighlightColor = ApiCompatibilityUtils.getColor(getContext().getResources(), |
R.color.light_active_color); |
- mDefaultTextColor = ApiCompatibilityUtils.getColor(getContext().getResources(), |
- R.color.default_text_color); |
} |
@Override |
@@ -281,18 +278,18 @@ public class ItemChooserDialog { |
} |
// Set highlighting for currently selected item. |
- if (position == mSelectedItem) { |
- view.setBackgroundColor(mBackgroundHighlightColor); |
- view.setTextColor(Color.WHITE); |
- } else { |
- view.setBackground(null); |
- if (!isEnabled(position)) { |
- view.setTextColor(ApiCompatibilityUtils.getColor(getContext().getResources(), |
- R.color.primary_text_disabled_material_light)); |
- } else { |
- view.setTextColor(mDefaultTextColor); |
- } |
- } |
+ final boolean isItemSelected = (position == mSelectedItem); |
+ |
+ view.setBackgroundColor(isItemSelected ? mBackgroundHighlightColor : null); |
+ |
+ @ColorInt final int textColor = isEnabled(position) |
+ ? R.color.default_text_color |
+ : R.color.primary_text_disabled_material_light; |
+ |
+ @ColorRes final int textColorRes = ApiCompatibilityUtils.getColor( |
+ getContext().getResources(), textColor); |
+ |
+ view.setTextColor(isItemSelected ? Color.WHITE : textColorRes); |
view.setText(getDisplayText(position)); |
return view; |