Pass in context when loading icons from Tile
Bug: 111860183 Test: robotests Change-Id: I836ad66eb420f4e0bd0bbded541f4dfe947c9b18
This commit is contained in:
@@ -315,7 +315,7 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
|
||||
@VisibleForTesting
|
||||
void onBindTile(DashboardItemHolder holder, Tile tile) {
|
||||
Icon tileIcon = tile.getIcon();
|
||||
Icon tileIcon = tile.getIcon(mContext);
|
||||
Drawable icon = mCache.getIcon(tileIcon);
|
||||
if (!TextUtils.equals(tileIcon.getResPackage(), mContext.getPackageName())
|
||||
&& !(icon instanceof RoundedHomepageIcon)) {
|
||||
|
@@ -34,6 +34,9 @@ import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
@@ -50,9 +53,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
/**
|
||||
* Impl for {@code DashboardFeatureProvider}.
|
||||
*/
|
||||
@@ -238,7 +238,7 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
|
||||
@VisibleForTesting
|
||||
void bindIcon(Preference preference, Tile tile) {
|
||||
final Icon tileIcon = tile.getIcon();
|
||||
final Icon tileIcon = tile.getIcon(mContext);
|
||||
if (tileIcon != null) {
|
||||
preference.setIcon(tileIcon.loadDrawable(preference.getContext()));
|
||||
} else if (tile.metaData != null
|
||||
|
@@ -24,6 +24,11 @@ import android.util.ArrayMap;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.PreferenceControllerListHelper;
|
||||
@@ -43,11 +48,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
/**
|
||||
* Base fragment for dashboard style UI containing a list of static and dynamic setting items.
|
||||
*/
|
||||
@@ -256,7 +256,8 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
||||
|
||||
@VisibleForTesting
|
||||
boolean tintTileIcon(Tile tile) {
|
||||
if (tile.getIcon() == null) {
|
||||
final Context context = getContext();
|
||||
if (tile.getIcon(context) == null) {
|
||||
return false;
|
||||
}
|
||||
// First check if the tile has set the icon tintable metadata.
|
||||
@@ -265,7 +266,7 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
||||
&& metadata.containsKey(TileUtils.META_DATA_PREFERENCE_ICON_TINTABLE)) {
|
||||
return metadata.getBoolean(TileUtils.META_DATA_PREFERENCE_ICON_TINTABLE);
|
||||
}
|
||||
final String pkgName = getContext().getPackageName();
|
||||
final String pkgName = context.getPackageName();
|
||||
// If this drawable is coming from outside Settings, tint it to match the color.
|
||||
return pkgName != null && tile.intent != null
|
||||
&& !pkgName.equals(tile.intent.getComponent().getPackageName());
|
||||
@@ -370,7 +371,7 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
||||
continue;
|
||||
}
|
||||
if (tintTileIcon(tile)) {
|
||||
tile.getIcon().setTint(tintColor);
|
||||
tile.getIcon(context).setTint(tintColor);
|
||||
}
|
||||
if (mDashboardTilePrefKeys.contains(key)) {
|
||||
// Have the key already, will rebind.
|
||||
|
Reference in New Issue
Block a user