Fix colors in importance and conversation priority preferences
This would have been simpler and faster, but the ChannelPanelActivity was giving me a context where Material colors always inflated in light theme even if the device was in dark theme, so I had to work around it. On the plus side, whoever next needs to change these colors will find them neatly organized in themes.xml! Bug: 284380876 Test: manual Change-Id: I2eee877fe44d307a96d60168d0317444ff002669
This commit is contained in:
@@ -15,10 +15,11 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid
|
||||
android:color="?attr/notification_importance_button_background_color_selected"/>
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="?androidprv:attr/materialColorOutlineVariant"/>
|
||||
android:color="?attr/notification_importance_button_border_color_selected"/>
|
||||
<corners android:radius="@dimen/rect_button_radius" />
|
||||
</shape>
|
@@ -15,12 +15,11 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid
|
||||
android:color="?androidprv:attr/materialColorSecondaryContainer" />
|
||||
android:color="?attr/notification_importance_button_background_color_unselected"/>
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="?androidprv:attr/materialColorOnSecondaryContainer"/>
|
||||
android:color="?attr/notification_importance_button_border_color_unselected"/>
|
||||
<corners android:radius="@dimen/rect_button_radius" />
|
||||
</shape>
|
@@ -34,6 +34,16 @@
|
||||
<item name="android:colorBackground">@*android:color/surface_dark</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Panel.Material" parent="Theme.Panel" >
|
||||
<item name="notification_importance_button_background_color_unselected">@android:color/transparent</item>
|
||||
<item name="notification_importance_button_border_color_unselected">@android:color/system_outline_variant_dark</item>
|
||||
<item name="notification_importance_button_foreground_color_unselected">@android:color/system_on_surface_variant_dark</item>
|
||||
|
||||
<item name="notification_importance_button_background_color_selected">@android:color/system_secondary_container_dark</item>
|
||||
<item name="notification_importance_button_border_color_selected">@android:color/system_on_secondary_container_dark</item>
|
||||
<item name="notification_importance_button_foreground_color_selected">@android:color/system_on_secondary_container_dark</item>
|
||||
</style>
|
||||
|
||||
<!-- Material theme for the pages containing TabLayout and ViewPager -->
|
||||
<style name="Theme.TabTheme" parent="@style/Theme.MaterialComponents.DayNight">
|
||||
<item name="colorPrimary">@*android:color/edge_effect_device_default_dark</item>
|
||||
|
@@ -194,4 +194,12 @@
|
||||
<attr name="biometricsEnrollProgressHelp" format="reference|color" />
|
||||
<attr name="biometricsEnrollProgressHelpWithTalkback" format="reference|color" />
|
||||
</declare-styleable>
|
||||
|
||||
<attr name="notification_importance_button_background_color_unselected" format="color" />
|
||||
<attr name="notification_importance_button_border_color_unselected" format="color" />
|
||||
<attr name="notification_importance_button_foreground_color_unselected" format="color" />
|
||||
|
||||
<attr name="notification_importance_button_background_color_selected" format="color" />
|
||||
<attr name="notification_importance_button_border_color_selected" format="color" />
|
||||
<attr name="notification_importance_button_foreground_color_selected" format="color" />
|
||||
</resources>
|
||||
|
@@ -14,7 +14,8 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<resources
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
|
||||
|
||||
<style name="Transparent">
|
||||
<item name="alertDialogTheme">@style/Theme.AlertDialog</item>
|
||||
@@ -66,6 +67,14 @@
|
||||
|
||||
<!-- For slice view in settings -->
|
||||
<item name="sliceViewStyle">@style/Widget.SliceView.Settings</item>
|
||||
|
||||
<item name="notification_importance_button_background_color_unselected">@android:color/transparent</item>
|
||||
<item name="notification_importance_button_border_color_unselected">?androidprv:attr/materialColorOutlineVariant</item>
|
||||
<item name="notification_importance_button_foreground_color_unselected">?androidprv:attr/materialColorOnSurfaceVariant</item>
|
||||
|
||||
<item name="notification_importance_button_background_color_selected">?androidprv:attr/materialColorSecondaryContainer</item>
|
||||
<item name="notification_importance_button_border_color_selected">?androidprv:attr/materialColorOnSecondaryContainer</item>
|
||||
<item name="notification_importance_button_foreground_color_selected">?androidprv:attr/materialColorOnSecondaryContainer</item>
|
||||
</style>
|
||||
|
||||
<!-- Variant of the settings theme with no action bar. -->
|
||||
@@ -229,9 +238,18 @@
|
||||
<item name="android:fontFamily">@*android:string/config_headlineFontFamilyMedium</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Panel.Material" parent="Theme.Panel" >
|
||||
<style name="Theme.Panel.Material" parent="Theme.Panel">
|
||||
<item name="android:switchStyle">@style/Switch.SettingsLib</item>
|
||||
|
||||
<item name="notification_importance_button_background_color_unselected">@android:color/transparent</item>
|
||||
<item name="notification_importance_button_border_color_unselected">@android:color/system_outline_variant_light</item>
|
||||
<item name="notification_importance_button_foreground_color_unselected">@android:color/system_on_surface_variant_light</item>
|
||||
|
||||
<item name="notification_importance_button_background_color_selected">@android:color/system_secondary_container_light</item>
|
||||
<item name="notification_importance_button_border_color_selected">@android:color/system_on_secondary_container_light</item>
|
||||
<item name="notification_importance_button_foreground_color_selected">@android:color/system_on_secondary_container_light</item>
|
||||
</style>
|
||||
|
||||
<!-- Material theme for the pages containing TabLayout and ViewPager -->
|
||||
<style name="Theme.TabTheme" parent="@style/Theme.MaterialComponents.DayNight">
|
||||
<item name="colorPrimary">@*android:color/edge_effect_device_default_light</item>
|
||||
|
@@ -163,13 +163,13 @@ public class BubblePreference extends Preference implements View.OnClickListener
|
||||
|
||||
void setSelected(Context context, boolean selected) {
|
||||
mView.setBackground(mContext.getDrawable(selected
|
||||
? R.drawable.button_border_selected
|
||||
: R.drawable.button_border_unselected));
|
||||
? R.drawable.notification_importance_button_background_selected
|
||||
: R.drawable.notification_importance_button_background_unselected));
|
||||
mView.setSelected(selected);
|
||||
|
||||
int colorResId = selected
|
||||
? com.android.internal.R.attr.materialColorOnSecondaryContainer
|
||||
: com.android.internal.R.attr.materialColorOnSurfaceVariant;
|
||||
? R.attr.notification_importance_button_foreground_color_selected
|
||||
: R.attr.notification_importance_button_foreground_color_unselected;
|
||||
ColorStateList stateList = Utils.getColorAttr(context, colorResId);
|
||||
mImageView.setImageTintList(stateList);
|
||||
mTextView.setTextColor(stateList);
|
||||
|
@@ -127,12 +127,14 @@ public class ConversationPriorityPreference extends Preference {
|
||||
});
|
||||
}
|
||||
|
||||
private ColorStateList getAccentTint() {
|
||||
return Utils.getColorAccent(getContext());
|
||||
private ColorStateList getSelectedColor() {
|
||||
return Utils.getColorAttr(getContext(),
|
||||
R.attr.notification_importance_button_foreground_color_selected);
|
||||
}
|
||||
|
||||
private ColorStateList getRegularTint() {
|
||||
return Utils.getColorAttr(getContext(), android.R.attr.textColorPrimary);
|
||||
private ColorStateList getUnselectedColor() {
|
||||
return Utils.getColorAttr(getContext(),
|
||||
R.attr.notification_importance_button_foreground_color_unselected);
|
||||
}
|
||||
|
||||
void updateToggles(ViewGroup parent, int importance, boolean isPriority,
|
||||
@@ -161,20 +163,21 @@ public class ConversationPriorityPreference extends Preference {
|
||||
}
|
||||
|
||||
void setSelected(View view, boolean selected) {
|
||||
ColorStateList colorAccent = getAccentTint();
|
||||
ColorStateList colorNormal = getRegularTint();
|
||||
ColorStateList colorSelected = getSelectedColor();
|
||||
ColorStateList colorUnselected = getUnselectedColor();
|
||||
|
||||
ImageView icon = view.findViewById(R.id.icon);
|
||||
TextView label = view.findViewById(R.id.label);
|
||||
TextView summary = view.findViewById(R.id.summary);
|
||||
|
||||
icon.setImageTintList(selected ? colorAccent : colorNormal);
|
||||
label.setTextColor(selected ? colorAccent : colorNormal);
|
||||
icon.setImageTintList(selected ? colorSelected : colorUnselected);
|
||||
label.setTextColor(selected ? colorSelected : colorUnselected);
|
||||
summary.setTextColor(selected ? colorSelected : colorUnselected);
|
||||
summary.setVisibility(selected ? VISIBLE : GONE);
|
||||
|
||||
view.setBackground(mContext.getDrawable(selected
|
||||
? R.drawable.button_border_selected
|
||||
: R.drawable.button_border_unselected));
|
||||
? R.drawable.notification_importance_button_background_selected
|
||||
: R.drawable.notification_importance_button_background_unselected));
|
||||
// a11y service won't always read the newly appearing text in the right order if the
|
||||
// selection happens too soon (readback happens on a different thread as layout). post
|
||||
// the selection to make that conflict less likely
|
||||
|
@@ -77,8 +77,10 @@ public class ImportancePreference extends Preference {
|
||||
|
||||
private void init(Context context) {
|
||||
mContext = context;
|
||||
selectedBackground = mContext.getDrawable(R.drawable.button_border_selected);
|
||||
unselectedBackground = mContext.getDrawable(R.drawable.button_border_unselected);
|
||||
selectedBackground = mContext.getDrawable(
|
||||
R.drawable.notification_importance_button_background_selected);
|
||||
unselectedBackground = mContext.getDrawable(
|
||||
R.drawable.notification_importance_button_background_unselected);
|
||||
setLayoutResource(R.layout.notif_importance_preference);
|
||||
}
|
||||
|
||||
@@ -152,12 +154,14 @@ public class ImportancePreference extends Preference {
|
||||
});
|
||||
}
|
||||
|
||||
private ColorStateList getAccentTint() {
|
||||
return Utils.getColorAccent(getContext());
|
||||
private ColorStateList getSelectedColor() {
|
||||
return Utils.getColorAttr(getContext(),
|
||||
R.attr.notification_importance_button_foreground_color_selected);
|
||||
}
|
||||
|
||||
private ColorStateList getRegularTint() {
|
||||
return Utils.getColorAttr(getContext(), android.R.attr.textColorPrimary);
|
||||
private ColorStateList getUnselectedColor() {
|
||||
return Utils.getColorAttr(getContext(),
|
||||
R.attr.notification_importance_button_foreground_color_unselected);
|
||||
}
|
||||
|
||||
void setImportanceSummary(ViewGroup parent, int importance, boolean fromUser) {
|
||||
@@ -167,25 +171,25 @@ public class ImportancePreference extends Preference {
|
||||
TransitionManager.beginDelayedTransition(parent, transition);
|
||||
}
|
||||
|
||||
ColorStateList colorAccent = getAccentTint();
|
||||
ColorStateList colorNormal = getRegularTint();
|
||||
ColorStateList colorSelected = getSelectedColor();
|
||||
ColorStateList colorUnselected = getUnselectedColor();
|
||||
|
||||
if (importance >= IMPORTANCE_DEFAULT) {
|
||||
parent.findViewById(R.id.silence_summary).setVisibility(GONE);
|
||||
((ImageView) parent.findViewById(R.id.silence_icon)).setImageTintList(colorNormal);
|
||||
((TextView) parent.findViewById(R.id.silence_label)).setTextColor(colorNormal);
|
||||
((ImageView) parent.findViewById(R.id.silence_icon)).setImageTintList(colorUnselected);
|
||||
((TextView) parent.findViewById(R.id.silence_label)).setTextColor(colorUnselected);
|
||||
|
||||
((ImageView) parent.findViewById(R.id.alert_icon)).setImageTintList(colorAccent);
|
||||
((TextView) parent.findViewById(R.id.alert_label)).setTextColor(colorAccent);
|
||||
((ImageView) parent.findViewById(R.id.alert_icon)).setImageTintList(colorSelected);
|
||||
((TextView) parent.findViewById(R.id.alert_label)).setTextColor(colorSelected);
|
||||
|
||||
parent.findViewById(R.id.alert_summary).setVisibility(VISIBLE);
|
||||
} else {
|
||||
parent.findViewById(R.id.alert_summary).setVisibility(GONE);
|
||||
((ImageView) parent.findViewById(R.id.alert_icon)).setImageTintList(colorNormal);
|
||||
((TextView) parent.findViewById(R.id.alert_label)).setTextColor(colorNormal);
|
||||
((ImageView) parent.findViewById(R.id.alert_icon)).setImageTintList(colorUnselected);
|
||||
((TextView) parent.findViewById(R.id.alert_label)).setTextColor(colorUnselected);
|
||||
|
||||
((ImageView) parent.findViewById(R.id.silence_icon)).setImageTintList(colorAccent);
|
||||
((TextView) parent.findViewById(R.id.silence_label)).setTextColor(colorAccent);
|
||||
((ImageView) parent.findViewById(R.id.silence_icon)).setImageTintList(colorSelected);
|
||||
((TextView) parent.findViewById(R.id.silence_label)).setTextColor(colorSelected);
|
||||
parent.findViewById(R.id.silence_summary).setVisibility(VISIBLE);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user