Show greyed out icon when Wi-Fi network is restricted to configurate

- Use Drawable#setTintList() instead of Drawable#setTint() to show greyed out icon when the preference is disabled.

Bug: 233175849
Test: manual test
make RunSettingsRoboTests ROBOTEST_FILTER=WifiEntryPreferenceTest

Change-Id: I451106530bc19bc733fd58a57e8ac336b023e65e
This commit is contained in:
Weng Su
2022-09-19 02:22:47 +08:00
parent 1d302c6fd8
commit 3499db23ff
2 changed files with 17 additions and 2 deletions

View File

@@ -201,7 +201,8 @@ public class WifiEntryPreference extends Preference implements WifiEntry.WifiEnt
return accent ? android.R.attr.colorAccent : android.R.attr.colorControlNormal;
}
private void updateIcon(boolean showX, int level) {
@VisibleForTesting
void updateIcon(boolean showX, int level) {
if (level == -1) {
setIcon(null);
return;
@@ -209,7 +210,9 @@ public class WifiEntryPreference extends Preference implements WifiEntry.WifiEnt
final Drawable drawable = mIconInjector.getIcon(showX, level);
if (drawable != null) {
drawable.setTint(Utils.getColorAttrDefaultColor(getContext(), getIconColorAttr()));
// Must use Drawable#setTintList() instead of Drawable#setTint() to show the grey
// icon when the preference is disabled.
drawable.setTintList(Utils.getColorAttr(getContext(), getIconColorAttr()));
setIcon(drawable);
} else {
setIcon(null);