Increase default chip text contrast

pull/935/head
Alex Baker 5 years ago
parent 3a6c9d282a
commit a4430cc213

@ -15,7 +15,6 @@ import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes; import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.core.content.res.ResourcesCompat; import androidx.core.content.res.ResourcesCompat;
import com.google.android.material.chip.Chip; import com.google.android.material.chip.Chip;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
@ -204,17 +203,19 @@ public class ChipProvider {
} }
private void apply(Context context, Chip chip, @Nullable @DrawableRes Integer icon, String name, int theme) { private void apply(Context context, Chip chip, @Nullable @DrawableRes Integer icon, String name, int theme) {
@ColorInt int color = getColor(context, theme);
chip.setText(name); chip.setText(name);
ColorStateList colorStateList = new ColorStateList(new int[][]{new int[]{}}, new int[]{color}); @ColorInt int color = getColor(context, theme);
chip.setCloseIconTint(colorStateList); if (color != 0) {
chip.setTextColor(color); ColorStateList colorStateList = new ColorStateList(new int[][]{new int[]{}}, new int[]{color});
chip.setCloseIconTint(colorStateList);
chip.setTextColor(color);
chip.setChipIconTint(colorStateList);
chip.setChipStrokeColor(colorStateList);
}
if (icon != null) { if (icon != null) {
chip.setChipIconResource(icon); chip.setChipIconResource(icon);
chip.setChipIconTint(colorStateList); chip.getChipDrawable().setAlpha(iconAlpha);
} }
chip.getChipDrawable().setAlpha(iconAlpha);
chip.setChipStrokeColor(colorStateList);
} }
private @DrawableRes Integer getIcon(int index, int def) { private @DrawableRes Integer getIcon(int index, int def) {
@ -229,6 +230,6 @@ public class ChipProvider {
return color.getPrimaryColor(); return color.getPrimaryColor();
} }
} }
return ContextCompat.getColor(context, R.color.text_secondary); return 0;
} }
} }

@ -1,7 +1,2 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.chip.Chip xmlns:android="http://schemas.android.com/apk/res/android" <com.google.android.material.chip.Chip style="@style/ChipStyle" />
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/ChipStyle"
android:textColor="@color/text_secondary"
app:chipIconTint="@color/text_secondary"
app:chipStrokeColor="@color/text_secondary" />

@ -11,6 +11,7 @@
<color name="text_tertiary">@color/white_38</color> <color name="text_tertiary">@color/white_38</color>
<color name="overdue">@color/error_color_material_dark</color> <color name="overdue">@color/error_color_material_dark</color>
<color name="tag_color_none_background">@color/grey_300</color> <color name="tag_color_none_background">@color/grey_300</color>
<color name="chip_text">@color/white_72</color>
<color name="priority_1">@color/red_200</color> <color name="priority_1">@color/red_200</color>
<color name="priority_2">@color/amber_200</color> <color name="priority_2">@color/amber_200</color>

@ -113,6 +113,7 @@
<color name="white_100">#ffffffff</color> <color name="white_100">#ffffffff</color>
<color name="white_87">#deffffff</color> <color name="white_87">#deffffff</color>
<color name="white_72">#b8ffffff</color>
<color name="white_60">#99ffffff</color> <color name="white_60">#99ffffff</color>
<color name="white_38">#61ffffff</color> <color name="white_38">#61ffffff</color>
@ -157,6 +158,7 @@
<color name="drawer_color_selected">@color/drawer_background_light_selected</color> <color name="drawer_color_selected">@color/drawer_background_light_selected</color>
<color name="text_secondary">@color/black_60</color> <color name="text_secondary">@color/black_60</color>
<color name="text_tertiary">@color/black_38</color> <color name="text_tertiary">@color/black_38</color>
<color name="chip_text">@color/black_100</color>
</resources> </resources>

@ -158,6 +158,9 @@
<item name="chipBackgroundColor">@android:color/transparent</item> <item name="chipBackgroundColor">@android:color/transparent</item>
<item name="iconStartPadding">@dimen/chip_text_padding</item> <item name="iconStartPadding">@dimen/chip_text_padding</item>
<item name="iconEndPadding">0dp</item> <item name="iconEndPadding">0dp</item>
<item name="android:textColor">@color/chip_text</item>
<item name="chipIconTint">@color/chip_text</item>
<item name="chipStrokeColor">@color/chip_text</item>
</style> </style>
<style name="ChipStyle.Closable"> <style name="ChipStyle.Closable">

Loading…
Cancel
Save