summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2015-12-01 13:52:03 -0800
committerd34d <clark@cyngn.com>2015-12-03 13:28:43 -0800
commit03857bc022722980308470f59e65718c928e1278 (patch)
tree7310b3fdec484179f3183a403f5aef512ed1715e
parent39aaf2b7c6f967c0034f5dedf5a065d10f0f6940 (diff)
downloadpackages_apps_Settings-03857bc022722980308470f59e65718c928e1278.zip
packages_apps_Settings-03857bc022722980308470f59e65718c928e1278.tar.gz
packages_apps_Settings-03857bc022722980308470f59e65718c928e1278.tar.bz2
Themes: Expose color for external settings icons
Marhsmallow now allows for system apps to add settings. An icon is loaded from the external package and a tint is applied to the icon so that it matches other icons in the dashboard. The tint color uses the colorAccent attribute from the currently applied style. Themes can overlay the colorAccent but this color is also used for other elements of the UI which may not be ideal. This patch adds a new color external_tile_icon_tint_color which points to the attribute ?android:attr/colorAccent when not themed. This retains the original look but offers better flexibility for theme designers. Change-Id: I95fe8da0768f29e0b762af3a74fd2afad7b15cd2
-rw-r--r--res/values/cm_colors.xml4
-rw-r--r--src/com/android/settings/dashboard/DashboardSummary.java13
2 files changed, 12 insertions, 5 deletions
diff --git a/res/values/cm_colors.xml b/res/values/cm_colors.xml
index 751108c..d904376 100644
--- a/res/values/cm_colors.xml
+++ b/res/values/cm_colors.xml
@@ -80,4 +80,6 @@ limitations under the License.
<!-- Contributors -->
<color name="contributors_cloud_fg_color">@color/theme_accent</color>
<color name="contributors_cloud_selected_color">#ff5252</color>
-</resources> \ No newline at end of file
+
+ <color name="external_tile_icon_tint_color">?android:attr/colorAccent</color>
+</resources>
diff --git a/src/com/android/settings/dashboard/DashboardSummary.java b/src/com/android/settings/dashboard/DashboardSummary.java
index 6408636..39ff0c7 100644
--- a/src/com/android/settings/dashboard/DashboardSummary.java
+++ b/src/com/android/settings/dashboard/DashboardSummary.java
@@ -181,10 +181,15 @@ public class DashboardSummary extends InstrumentedFragment {
.getResourcesForApplication(tile.iconPkg).getDrawable(tile.iconRes, null);
if (!tile.iconPkg.equals(context.getPackageName()) && drawable != null) {
// If this drawable is coming from outside Settings, tint it to match the color.
- TypedValue tintColor = new TypedValue();
- context.getTheme().resolveAttribute(com.android.internal.R.attr.colorAccent,
- tintColor, true);
- drawable.setTint(tintColor.data);
+ TypedValue tintColorValue = new TypedValue();
+ context.getResources().getValue(R.color.external_tile_icon_tint_color,
+ tintColorValue, true);
+ // If tintColorValue is TYPE_ATTRIBUTE, resolve it
+ if (tintColorValue.type == TypedValue.TYPE_ATTRIBUTE) {
+ context.getTheme().resolveAttribute(tintColorValue.data,
+ tintColorValue, true);
+ }
+ drawable.setTint(tintColorValue.data);
}
tileIcon.setImageDrawable(drawable);
} catch (NameNotFoundException | Resources.NotFoundException e) {