From 4fdc471d14744181e1da6483eec7817da3c84a90 Mon Sep 17 00:00:00 2001 From: Grace Jia Date: Fri, 15 May 2020 13:32:11 -0700 Subject: [PATCH] Change SIM colors to follow GAR standards in dark mode in SIM rename dialog. Add a color map to map SIM colors in light mode to dark mode. Check current system dark mode and set the SIM icon color to proper color when get the view. Bug: 144693819 Test: Manually set SIM colors to all 6 possibilities and switch from light mode to dark mode. Change-Id: I5b947d1d9c949bc6b8cc669d71cd3f5d66ddecb1 --- color-check-baseline.xml | 316 ++++++++++++------ res/values/colors.xml | 15 + .../RenameMobileNetworkDialogFragment.java | 38 ++- 3 files changed, 264 insertions(+), 105 deletions(-) diff --git a/color-check-baseline.xml b/color-check-baseline.xml index 75f46e5eff9..77eaa154db4 100644 --- a/color-check-baseline.xml +++ b/color-check-baseline.xml @@ -33,38 +33,6 @@ column="9"/> - - - - - - - - - - - - @@ -1565,7 +1517,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1581,7 +1533,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1597,7 +1549,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1613,7 +1565,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1629,7 +1581,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1645,7 +1597,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1657,11 +1609,187 @@ priority="4" summary="Using hardcoded color" explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes. This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app." - errorLine1=" <color name="palette_list_dark_mode_color_pink">#ff8bcb</color> <!-- Material Pink 300 -->" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + errorLine1=" <color name="SIM_color_teal">#ff00796b</color> <!-- Material Teal 700 -->" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2321,22 +2449,6 @@ column="13"/> - - - - + + + + @@ -2893,7 +3021,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -2909,7 +3037,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -2925,26 +3053,10 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> - - - - @@ -2973,7 +3085,7 @@ errorLine2=" ^"> @@ -2989,7 +3101,7 @@ errorLine2=" ^"> @@ -3005,7 +3117,7 @@ errorLine2=" ^"> @@ -3021,7 +3133,7 @@ errorLine2=" ^"> @@ -3037,7 +3149,7 @@ errorLine2=" ^"> @@ -3149,7 +3261,7 @@ errorLine2=" ^"> @@ -3309,7 +3421,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> diff --git a/res/values/colors.xml b/res/values/colors.xml index 06f135f05cf..322998c2be0 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -168,4 +168,19 @@ #8AB4F8 #c58af9 + + #ff00796b + #ff3367d6 + #ff303f9f + #ff7b1fa2 + #ffc2185b + #ffd32f2f + + + #ff80cbc4 + #ff90caf9 + #ffc5cae9 + #ffe1bee7 + #fff48fb1 + #ffef9a9a \ No newline at end of file diff --git a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java index e53a4521dd0..293353c917f 100644 --- a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java +++ b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java @@ -19,6 +19,7 @@ package com.android.settings.network.telephony; import android.app.Dialog; import android.app.settings.SettingsEnums; import android.content.Context; +import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Paint; import android.graphics.drawable.ShapeDrawable; @@ -48,7 +49,10 @@ import com.android.settings.R; import com.android.settings.core.instrumentation.InstrumentedDialogFragment; import com.android.settingslib.DeviceInfoUtils; +import com.google.common.collect.ImmutableMap; + import java.util.List; +import java.util.Map; /** * A dialog allowing the display name of a mobile network subscription to be changed @@ -65,6 +69,7 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen private EditText mNameView; private Spinner mColorSpinner; private Color[] mColors; + private Map mLightDarkMap; public static RenameMobileNetworkDialogFragment newInstance(int subscriptionId) { final Bundle args = new Bundle(1); @@ -100,6 +105,21 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen mTelephonyManager = getTelephonyManager(context); mSubscriptionManager = getSubscriptionManager(context); mSubId = getArguments().getInt(KEY_SUBSCRIPTION_ID); + Resources res = context.getResources(); + mLightDarkMap = ImmutableMap.builder() + .put(res.getInteger(R.color.SIM_color_teal), + res.getInteger(R.color.SIM_dark_mode_color_teal)) + .put(res.getInteger(R.color.SIM_color_blue), + res.getInteger(R.color.SIM_dark_mode_color_blue)) + .put(res.getInteger(R.color.SIM_color_indigo), + res.getInteger(R.color.SIM_dark_mode_color_indigo)) + .put(res.getInteger(R.color.SIM_color_purple), + res.getInteger(R.color.SIM_dark_mode_color_purple)) + .put(res.getInteger(R.color.SIM_color_pink), + res.getInteger(R.color.SIM_dark_mode_color_pink)) + .put(res.getInteger(R.color.SIM_color_red), + res.getInteger(R.color.SIM_dark_mode_color_red)) + .build(); } @NonNull @@ -196,8 +216,13 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen if (convertView == null) { convertView = inflater.inflate(mItemResId, null); } + boolean isDarkMode = false; + if ((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) + == Configuration.UI_MODE_NIGHT_YES) { + isDarkMode = true; + } ((ImageView) convertView.findViewById(R.id.color_icon)) - .setImageDrawable(getItem(position).getDrawable()); + .setImageDrawable(getItem(position).getDrawable(isDarkMode)); ((TextView) convertView.findViewById(R.id.color_label)) .setText(getItem(position).getLabel()); @@ -223,7 +248,7 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen return colors; } - private static class Color { + private class Color { private String mLabel; private int mColor; @@ -248,8 +273,15 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen return mColor; } - private ShapeDrawable getDrawable() { + private ShapeDrawable getDrawable(boolean isDarkMode) { + if (isDarkMode) { + mDrawable.getPaint().setColor(getDarkColor(mColor)); + } return mDrawable; } } + + private int getDarkColor(int lightColor) { + return mLightDarkMap.getOrDefault(lightColor, lightColor); + } }