From bff06c66f99f78fb272d5ea9696a988cd41f620c Mon Sep 17 00:00:00 2001 From: Phillip Hsu Date: Thu, 1 Sep 2016 03:53:32 -0700 Subject: [PATCH] Added comments about colors --- .../com/philliphsu/clock2/alarms/BaseAlarmViewHolder.java | 6 ++++++ .../philliphsu/clock2/alarms/ExpandedAlarmViewHolder.java | 2 ++ 2 files changed, 8 insertions(+) diff --git a/app/src/main/java/com/philliphsu/clock2/alarms/BaseAlarmViewHolder.java b/app/src/main/java/com/philliphsu/clock2/alarms/BaseAlarmViewHolder.java index 5a7237d..a7df937 100644 --- a/app/src/main/java/com/philliphsu/clock2/alarms/BaseAlarmViewHolder.java +++ b/app/src/main/java/com/philliphsu/clock2/alarms/BaseAlarmViewHolder.java @@ -182,7 +182,13 @@ public abstract class BaseAlarmViewHolder extends BaseViewHolder { int def = colors.getDefaultColor(); // Too light // int disabled = colors.getColorForState(new int[] {-android.R.attr.state_enabled}, def); + // Material guidelines say text hints and disabled text should have the same color. int disabled = colorsSource.getCurrentHintTextColor(); + // However, digging around in the system's textColorHint for 21+ says its 50% black for our + // light theme. I'd like to follow what the guidelines says, but I want code that is robust + // against theme changes. Alternatively, override the attribute values to what you want + // in both your dark and light themes... +// int disabled = ContextCompat.getColor(getContext(), R.color.text_color_disabled_light); // We only have two states, so we don't care about losing the other state colors. mTime.setTextColor(alarm.isEnabled() ? def : disabled); } diff --git a/app/src/main/java/com/philliphsu/clock2/alarms/ExpandedAlarmViewHolder.java b/app/src/main/java/com/philliphsu/clock2/alarms/ExpandedAlarmViewHolder.java index f350f79..a1e937d 100644 --- a/app/src/main/java/com/philliphsu/clock2/alarms/ExpandedAlarmViewHolder.java +++ b/app/src/main/java/com/philliphsu/clock2/alarms/ExpandedAlarmViewHolder.java @@ -69,6 +69,8 @@ public class ExpandedAlarmViewHolder extends BaseAlarmViewHolder { /*item 1*/{/*states*/android.R.attr.state_checked}, /*item 2*/{/*states*/} }; + // TODO: Phase out Utils.getColorFromThemeAttr because it doesn't work for text colors. + // WHereas getTextColorFromThemeAttr works for both regular colors and text colors. int[] colors = { /*item 1*/Utils.getTextColorFromThemeAttr(getContext(), R.attr.colorAccent), /*item 2*/Utils.getTextColorFromThemeAttr(getContext(), android.R.attr.textColorHint)