OSDN Git Service

Remove hardcoded color for settings dashboard
authorjackqdyulei <jackqdyulei@google.com>
Thu, 9 Mar 2017 20:48:54 +0000 (12:48 -0800)
committerjackqdyulei <jackqdyulei@google.com>
Tue, 14 Mar 2017 17:40:09 +0000 (10:40 -0700)
1. Change card_background to default background color. In settings
light theme, background color is exactly the #fafafa
2. Change card_background_grey to colorSecondary, which is
material_grey_200 in settings light theme.

Bug: 36139640
Test: Screenshot
Change-Id: I20081e768985ce6c0b9000448ae48599f18b293a

res/drawable/selectable_card.xml
res/drawable/selectable_card_grey.xml
res/layout/dashboard_category.xml
res/layout/dashboard_spacer.xml
res/layout/support_fragment.xml
res/layout/support_tile_spacer.xml
res/values/colors.xml
res/values/styles.xml
tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java

index df9ddb1..3a1e8b2 100644 (file)
@@ -18,5 +18,5 @@
 <ripple
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:color="?android:attr/colorControlHighlight">
-    <item android:drawable="@color/card_background"/>
+    <item android:drawable="?android:attr/colorBackground"/>
 </ripple>
\ No newline at end of file
index e4c73ba..225e72f 100644 (file)
@@ -18,5 +18,5 @@
 <ripple
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:color="?android:attr/colorControlHighlight">
-    <item android:drawable="@color/card_background_grey"/>
+    <item android:drawable="?android:attr/colorSecondary"/>
 </ripple>
index 2e5dd5c..1314c16 100644 (file)
@@ -19,8 +19,7 @@
     android:layout_width="match_parent"
     android:layout_height="@dimen/dashboard_category_height"
     android:orientation="vertical"
-    android:paddingBottom="8dip"
-    android:background="@color/card_background">
+    android:paddingBottom="8dip">
 
     <TextView android:id="@android:id/title"
         android:layout_width="match_parent"
index 8d58c80..3ebcb09 100644 (file)
@@ -18,4 +18,4 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="8dp"
-    android:background="@color/card_background_grey"/>
+    android:background="?android:attr/colorSecondary"/>
index 7c79a63..6864d32 100644 (file)
@@ -27,6 +27,5 @@
     <android.support.v7.widget.RecyclerView
         android:id="@+id/support_items"
         android:layout_height="match_parent"
-        android:layout_width="match_parent"
-        android:background="@color/card_background"/>
+        android:layout_width="match_parent"/>
 </FrameLayout>
index 41cc221..aa86e1e 100644 (file)
@@ -18,5 +18,4 @@
 <View
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="@dimen/support_spacer_height"
-    android:background="@color/card_background"/>
+    android:layout_height="@dimen/support_spacer_height"/>
index 6705494..9e41a08 100644 (file)
@@ -55,8 +55,6 @@
     <color name="running_processes_system_ram">#ff384248</color>
     <color name="running_processes_free_ram">#ffced7db</color>
 
-    <color name="card_background">#fffafafa</color>
-
     <color name="wifi_divider">#ffe0e0e0</color>
     <color name="sim_noitification">@*android:color/material_deep_teal_500</color>
 
@@ -99,8 +97,6 @@
 
     <color name="usage_graph_dots">#B0BEC5</color>
 
-    <color name="card_background_grey">#eeeeee</color>
-
     <!-- Gestures settings -->
     <color name="gestures_setting_background_color">#f5f5f5</color>
 
index 2692508..fa40932 100644 (file)
     </style>
 
     <style name="SupportEscalationCard">
-        <item name="android:background">@color/card_background_grey</item>
+        <item name="android:background">?android:attr/colorSecondary</item>
         <item name="android:gravity">center</item>
         <item name="android:minHeight">368dp</item>
         <item name="android:paddingStart">@dimen/support_escalation_card_padding_start</item>
     </style>
 
     <style name="EntityHeader">
-        <item name="android:background">@color/card_background_grey</item>
+        <item name="android:background">?android:attr/colorSecondary</item>
         <item name="android:gravity">center_horizontal</item>
         <item name="android:paddingTop">16dp</item>
         <item name="android:paddingStart">16dp</item>
index b1144f0..7f0229a 100644 (file)
@@ -27,6 +27,9 @@ import com.android.settings.SettingsRobolectricTestRunner;
 import com.android.settings.TestConfig;
 import com.android.settings.core.instrumentation.MetricsFeatureProvider;
 import com.android.settings.dashboard.conditional.Condition;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.testutils.shadow.ShadowDynamicIndexableContentMonitor;
 import com.android.settingslib.drawer.DashboardCategory;
 import com.android.settingslib.drawer.Tile;
 import org.junit.Before;
@@ -52,7 +55,13 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 @RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH,
+        sdk = TestConfig.SDK_VERSION,
+        shadows = {
+                SettingsShadowResources.class,
+                SettingsShadowResources.SettingsShadowTheme.class,
+                ShadowDynamicIndexableContentMonitor.class
+        })
 public class DashboardAdapterTest {
 
     @Mock
@@ -82,6 +91,7 @@ public class DashboardAdapterTest {
         when(mResources
                 .getQuantityString(any(int.class), any(int.class), Matchers.<Object>anyVararg()))
                 .thenReturn("");
+        FakeFeatureFactory.setupForTest(context);
         mDashboardAdapter = new DashboardAdapter(context, null, mMetricsFeatureProvider,
                 null, null);
         mSuggestionHeaderData = new DashboardData.SuggestionHeaderData(true, 1, 0);
index 113c7aa..e87e9c5 100644 (file)
@@ -66,6 +66,8 @@ public class SettingsShadowResources extends ShadowResources {
             id = R.drawable.ic_settings_wireless;
         } else if (id == R.drawable.app_filter_spinner_background) {
             id = R.drawable.ic_expand_more_inverse;
+        } else if (id == R.drawable.selectable_card_grey) {
+            id = R.drawable.ic_expand_more_inverse;
         }
         return super.loadDrawable(value, id, theme);
     }