From 74795d2f7abaa07c0608aaa556aa4a4f6225462a Mon Sep 17 00:00:00 2001 From: Peter Serwylo <peter@serwylo.com> Date: Wed, 26 Apr 2017 09:27:02 +1000 Subject: [PATCH] Don't use attr for color value in drawables. According to the following this is not supported: * http://stackoverflow.com/a/13471695/2391921 This uses the approach in that SO answer, by extracting the attribute to instead point at a drawable, and have one drawable for each theme. Fixes #979. --- ...xml => category_preview_app_card_background_dark.xml} | 2 +- .../category_preview_app_card_background_light.xml | 9 +++++++++ ...ound.xml => details_panel_donate_background_dark.xml} | 2 +- .../drawable/details_panel_donate_background_light.xml | 6 ++++++ app/src/main/res/layout/app_card_normal.xml | 2 +- app/src/main/res/layout/app_details2_donate.xml | 2 +- app/src/main/res/values/attrs.xml | 4 ++-- app/src/main/res/values/styles.xml | 8 ++++---- 8 files changed, 25 insertions(+), 10 deletions(-) rename app/src/main/res/drawable/{category_preview_app_card_background.xml => category_preview_app_card_background_dark.xml} (80%) create mode 100644 app/src/main/res/drawable/category_preview_app_card_background_light.xml rename app/src/main/res/drawable/{details_panel_light_background.xml => details_panel_donate_background_dark.xml} (79%) create mode 100644 app/src/main/res/drawable/details_panel_donate_background_light.xml diff --git a/app/src/main/res/drawable/category_preview_app_card_background.xml b/app/src/main/res/drawable/category_preview_app_card_background_dark.xml similarity index 80% rename from app/src/main/res/drawable/category_preview_app_card_background.xml rename to app/src/main/res/drawable/category_preview_app_card_background_dark.xml index ac7b975e2..fef43a2c1 100644 --- a/app/src/main/res/drawable/category_preview_app_card_background.xml +++ b/app/src/main/res/drawable/category_preview_app_card_background_dark.xml @@ -5,5 +5,5 @@ --> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="4dp" /> - <solid android:color="?attr/categoryPreviewAppCardBackground" /> + <solid android:color="#212121" /> </shape> diff --git a/app/src/main/res/drawable/category_preview_app_card_background_light.xml b/app/src/main/res/drawable/category_preview_app_card_background_light.xml new file mode 100644 index 000000000..5bb971142 --- /dev/null +++ b/app/src/main/res/drawable/category_preview_app_card_background_light.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Visually different from other app cards because it doesn't have a drop shadow, and has a larger + corner radius. +--> +<shape xmlns:android="http://schemas.android.com/apk/res/android"> + <corners android:radius="4dp" /> + <solid android:color="#faf8ef" /> +</shape> diff --git a/app/src/main/res/drawable/details_panel_light_background.xml b/app/src/main/res/drawable/details_panel_donate_background_dark.xml similarity index 79% rename from app/src/main/res/drawable/details_panel_light_background.xml rename to app/src/main/res/drawable/details_panel_donate_background_dark.xml index ad2d047b3..3e7d0e8c1 100644 --- a/app/src/main/res/drawable/details_panel_light_background.xml +++ b/app/src/main/res/drawable/details_panel_donate_background_dark.xml @@ -2,5 +2,5 @@ <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius="3dp" /> - <solid android:color="?attr/detailPanel" /> + <solid android:color="#303030" /> </shape> \ No newline at end of file diff --git a/app/src/main/res/drawable/details_panel_donate_background_light.xml b/app/src/main/res/drawable/details_panel_donate_background_light.xml new file mode 100644 index 000000000..aed890e90 --- /dev/null +++ b/app/src/main/res/drawable/details_panel_donate_background_light.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle"> + <corners android:radius="3dp" /> + <solid android:color="#eff4f9" /> +</shape> \ No newline at end of file diff --git a/app/src/main/res/layout/app_card_normal.xml b/app/src/main/res/layout/app_card_normal.xml index e303d6196..69916bb03 100644 --- a/app/src/main/res/layout/app_card_normal.xml +++ b/app/src/main/res/layout/app_card_normal.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="100dp" android:layout_height="130dp" - android:background="@drawable/category_preview_app_card_background" + android:background="?attr/categoryPreviewAppCardBackground" android:padding="8dp"> <!-- Ignore ContentDescription because it is kind of meaningless to have TTS read out "App icon" diff --git a/app/src/main/res/layout/app_details2_donate.xml b/app/src/main/res/layout/app_details2_donate.xml index 54fa19110..994eec35e 100644 --- a/app/src/main/res/layout/app_details2_donate.xml +++ b/app/src/main/res/layout/app_details2_donate.xml @@ -7,7 +7,7 @@ android:layout_margin="@dimen/details_activity_padding" android:clickable="true" android:orientation="vertical" - android:background="@drawable/details_panel_light_background" + android:background="?attr/detailPanel" android:padding="@dimen/details_activity_padding"> <TextView diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 4d0afccee..694c7db89 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -3,12 +3,12 @@ <declare-styleable name="Theme"> <attr name="appDetailsBackground" format="color" /> <attr name="appDetailsCardBackground" format="color" /> - <attr name="categoryPreviewAppCardBackground" format="color" /> + <attr name="categoryPreviewAppCardBackground" format="reference" /> <attr name="mainTabSwapBackground" format="color" /> <attr name="mainTabSwapSplashTint" format="color" /> <attr name="categoryName" format="color" /> <attr name="installedApps" format="color" /> - <attr name="detailPanel" format="color" /> + <attr name="detailPanel" format="reference" /> <attr name="appListItem" format="color" /> </declare-styleable> </resources> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 2a133a8b6..c9fbb8073 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -14,12 +14,12 @@ <item name="actionBarPopupTheme">@style/AppThemeLight.Toolbar</item> <item name="appDetailsBackground">#0c0c0c</item> <item name="appDetailsCardBackground">#000000</item> - <item name="categoryPreviewAppCardBackground">#303030</item> + <item name="categoryPreviewAppCardBackground">@drawable/category_preview_app_card_background_dark</item> <item name="mainTabSwapBackground">#0a0a0a</item> <item name="mainTabSwapSplashTint">#050505</item> <item name="categoryName">#ffffff</item> <item name="installedApps">#ffffff</item> - <item name="detailPanel">#212121</item> + <item name="detailPanel">@drawable/details_panel_donate_background_dark</item> <item name="appListItem">#ffffff</item> </style> @@ -36,12 +36,12 @@ <item name="actionBarPopupTheme">@style/AppThemeLight.Toolbar</item> <item name="appDetailsBackground">#fcfcfc</item> <item name="appDetailsCardBackground">#ffffff</item> - <item name="categoryPreviewAppCardBackground">#faf8ef</item> + <item name="categoryPreviewAppCardBackground">@drawable/category_preview_app_card_background_light</item> <item name="mainTabSwapBackground">#fafafa</item> <item name="mainTabSwapSplashTint">#f5f5f5</item> <item name="categoryName">#4a4a4a</item> <item name="installedApps">#424242</item> - <item name="detailPanel">#eff4f9</item> + <item name="detailPanel">@drawable/details_panel_donate_background_light</item> <item name="appListItem">#424242</item> </style>