Remove hardcoded color for settings dashboard
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
diff --git a/res/drawable/selectable_card.xml b/res/drawable/selectable_card.xml
index df9ddb1..3a1e8b2 100644
--- a/res/drawable/selectable_card.xml
+++ b/res/drawable/selectable_card.xml
@@ -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
diff --git a/res/drawable/selectable_card_grey.xml b/res/drawable/selectable_card_grey.xml
index e4c73ba..225e72f 100644
--- a/res/drawable/selectable_card_grey.xml
+++ b/res/drawable/selectable_card_grey.xml
@@ -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>
diff --git a/res/layout/dashboard_category.xml b/res/layout/dashboard_category.xml
index 2e5dd5c..1314c16 100644
--- a/res/layout/dashboard_category.xml
+++ b/res/layout/dashboard_category.xml
@@ -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"
diff --git a/res/layout/dashboard_spacer.xml b/res/layout/dashboard_spacer.xml
index 8d58c80..3ebcb09 100644
--- a/res/layout/dashboard_spacer.xml
+++ b/res/layout/dashboard_spacer.xml
@@ -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"/>
diff --git a/res/layout/support_fragment.xml b/res/layout/support_fragment.xml
index 7c79a63..6864d32 100644
--- a/res/layout/support_fragment.xml
+++ b/res/layout/support_fragment.xml
@@ -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>
diff --git a/res/layout/support_tile_spacer.xml b/res/layout/support_tile_spacer.xml
index 41cc221..aa86e1e 100644
--- a/res/layout/support_tile_spacer.xml
+++ b/res/layout/support_tile_spacer.xml
@@ -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"/>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 6705494..9e41a08 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -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>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 2692508..fa40932 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -393,7 +393,7 @@
</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>
@@ -414,7 +414,7 @@
</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>
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
index b1144f0..7f0229a 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
@@ -27,6 +27,9 @@
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.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 @@
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);
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java
index 113c7aa..e87e9c5 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java
@@ -66,6 +66,8 @@
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);
}