Loading src/com/android/settings/wifi/WifiEntryPreference.java +5 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); Loading tests/robotests/src/com/android/settings/wifi/WifiEntryPreferenceTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.settings.wifi; import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.Context; Loading Loading @@ -252,4 +254,14 @@ public class WifiEntryPreferenceTest { assertThat(view.findViewById(R.id.icon_button).getVisibility()).isEqualTo(View.GONE); } @Test public void updateIcon_ShouldSetTintListForDrawable() { WifiEntryPreference pref = new WifiEntryPreference(mContext, mMockWifiEntry, mMockIconInjector); pref.updateIcon(false /* showX */, 4 /* level */); verify(mMockDrawable4).setTintList(any()); } } Loading
src/com/android/settings/wifi/WifiEntryPreference.java +5 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); Loading
tests/robotests/src/com/android/settings/wifi/WifiEntryPreferenceTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.settings.wifi; import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.Context; Loading Loading @@ -252,4 +254,14 @@ public class WifiEntryPreferenceTest { assertThat(view.findViewById(R.id.icon_button).getVisibility()).isEqualTo(View.GONE); } @Test public void updateIcon_ShouldSetTintListForDrawable() { WifiEntryPreference pref = new WifiEntryPreference(mContext, mMockWifiEntry, mMockIconInjector); pref.updateIcon(false /* showX */, 4 /* level */); verify(mMockDrawable4).setTintList(any()); } }