Fix tinting on injected pref icon
We used to tint the injected pref icon when refreshing Tile. However, when we are going to render the icon, we used Tile.getIcon which uses the icon resource id to get the original version of icon directly. Do a little refactor here to move the tinting logic inside Tile.getIcon. Test: Manual/Visual inspection Fixes: 129010399 Change-Id: I6f187b12cb6d91b54dcfe43e0ff34add55fd7b07
This commit is contained in:
@@ -192,7 +192,9 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void bindIcon(Preference preference, Tile tile, boolean forceRoundedIcon) {
|
void bindIcon(Preference preference, Tile tile, boolean forceRoundedIcon) {
|
||||||
final Icon tileIcon = tile.getIcon(mContext);
|
// Use preference context instead here when get icon from Tile, as we are using the context
|
||||||
|
// to get the style to tint the icon. Using mContext here won't get the correct style.
|
||||||
|
final Icon tileIcon = tile.getIcon(preference.getContext());
|
||||||
if (tileIcon != null) {
|
if (tileIcon != null) {
|
||||||
Drawable iconDrawable = tileIcon.loadDrawable(preference.getContext());
|
Drawable iconDrawable = tileIcon.loadDrawable(preference.getContext());
|
||||||
if (forceRoundedIcon
|
if (forceRoundedIcon
|
||||||
|
@@ -18,8 +18,6 @@ package com.android.settings.dashboard;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
|
||||||
import android.graphics.drawable.Icon;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
@@ -410,10 +408,6 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
|||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
mSummaryLoader = new SummaryLoader(getActivity(), getCategoryKey());
|
mSummaryLoader = new SummaryLoader(getActivity(), getCategoryKey());
|
||||||
mSummaryLoader.setSummaryConsumer(this);
|
mSummaryLoader.setSummaryConsumer(this);
|
||||||
final TypedArray a = context.obtainStyledAttributes(new int[]{
|
|
||||||
android.R.attr.colorControlNormal});
|
|
||||||
final int tintColor = a.getColor(0, context.getColor(android.R.color.white));
|
|
||||||
a.recycle();
|
|
||||||
// Install dashboard tiles.
|
// Install dashboard tiles.
|
||||||
final boolean forceRoundedIcons = shouldForceRoundedIcon();
|
final boolean forceRoundedIcons = shouldForceRoundedIcon();
|
||||||
for (Tile tile : tiles) {
|
for (Tile tile : tiles) {
|
||||||
@@ -425,12 +419,6 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
|||||||
if (!displayTile(tile)) {
|
if (!displayTile(tile)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (tile.isIconTintable(context)) {
|
|
||||||
final Icon icon = tile.getIcon(context);
|
|
||||||
if (icon != null) {
|
|
||||||
icon.setTint(tintColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mDashboardTilePrefKeys.contains(key)) {
|
if (mDashboardTilePrefKeys.contains(key)) {
|
||||||
// Have the key already, will rebind.
|
// Have the key already, will rebind.
|
||||||
final Preference preference = screen.findPreference(key);
|
final Preference preference = screen.findPreference(key);
|
||||||
|
Reference in New Issue
Block a user