Loading src/com/android/settings/wifi/details/WifiDetailPreferenceController.java +13 −6 Original line number Diff line number Diff line Loading @@ -450,8 +450,7 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController headerPref.findViewById(R.id.entity_header)); ImageView iconView = headerPref.findViewById(R.id.entity_header_icon); iconView.setBackground( mContext.getDrawable(R.drawable.ic_settings_widget_background)); iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); mEntityHeaderController.setLabel(mAccessPoint.getTitle()); Loading Loading @@ -603,10 +602,9 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController mRssiSignalLevel = signalLevel; Drawable wifiIcon = mIconInjector.getIcon(mRssiSignalLevel); wifiIcon.setTintList(Utils.getColorAccent(mContext)); if (mEntityHeaderController != null) { mEntityHeaderController .setIcon(rescaleIconForHeader(wifiIcon)).done(mFragment.getActivity(), .setIcon(redrawIconForHeader(wifiIcon)).done(mFragment.getActivity(), true /* rebind */); } Loading @@ -618,7 +616,7 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController mSignalStrengthPref.setVisible(true); } private Drawable rescaleIconForHeader(Drawable original) { private Drawable redrawIconForHeader(Drawable original) { final int iconSize = mContext.getResources().getDimensionPixelSize( R.dimen.wifi_detail_page_header_image_size); final int actualWidth = original.getMinimumWidth(); Loading @@ -629,10 +627,19 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController return original; } // clear tint list to make sure can set 87% black after enlarge original.setTintList(null); // enlarge icon size final Bitmap bitmap = Utils.createBitmap(original, iconSize /*width*/, iconSize /*height*/); return new BitmapDrawable(null /*resource*/, bitmap); Drawable newIcon = new BitmapDrawable(null /*resource*/, bitmap); // config color for 87% black after enlarge newIcon.setTintList(Utils.getColorAttr(mContext, android.R.attr.textColorPrimary)); return newIcon; } private void refreshFrequency() { Loading tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.net.ConnectivityManager; Loading Loading @@ -69,6 +70,7 @@ import com.android.internal.logging.nano.MetricsProto; import com.android.settings.R; import com.android.settings.core.FeatureFlags; import com.android.settings.development.featureflags.FeatureFlagPersistent; import com.android.settings.Utils; import com.android.settings.testutils.shadow.ShadowDevicePolicyManager; import com.android.settings.testutils.shadow.ShadowEntityHeaderController; import com.android.settings.widget.EntityHeaderController; Loading Loading @@ -1458,6 +1460,36 @@ public class WifiDetailPreferenceControllerTest { verify(mockSignalStrengthPref, times(2)).setVisible(false); } @Test public void testRedrawIconForHeader_shouldEnlarge() { ArgumentCaptor<BitmapDrawable> drawableCaptor = ArgumentCaptor.forClass(BitmapDrawable.class); Drawable original = mContext.getDrawable(Utils.getWifiIconResource(LEVEL)).mutate(); when(mockIconInjector.getIcon(anyInt())).thenReturn(original); displayAndResume(); verify(mockHeaderController, times(1)).setIcon(drawableCaptor.capture()); int expectedSize = mContext.getResources().getDimensionPixelSize( R.dimen.wifi_detail_page_header_image_size); BitmapDrawable icon = drawableCaptor.getValue(); assertThat(icon.getMinimumWidth()).isEqualTo(expectedSize); assertThat(icon.getMinimumHeight()).isEqualTo(expectedSize); } @Test public void testRedrawIconForHeader_shouldNotEnlargeIfNotVectorDrawable() { ArgumentCaptor<ColorDrawable> drawableCaptor = ArgumentCaptor.forClass(ColorDrawable.class); displayAndResume(); verify(mockHeaderController, times(1)).setIcon(drawableCaptor.capture()); ColorDrawable icon = drawableCaptor.getValue(); assertThat(icon).isNotNull(); } private ActionButtonsPreference createMock() { final ActionButtonsPreference pref = mock(ActionButtonsPreference.class); when(pref.setButton1Text(anyInt())).thenReturn(pref); Loading Loading
src/com/android/settings/wifi/details/WifiDetailPreferenceController.java +13 −6 Original line number Diff line number Diff line Loading @@ -450,8 +450,7 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController headerPref.findViewById(R.id.entity_header)); ImageView iconView = headerPref.findViewById(R.id.entity_header_icon); iconView.setBackground( mContext.getDrawable(R.drawable.ic_settings_widget_background)); iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); mEntityHeaderController.setLabel(mAccessPoint.getTitle()); Loading Loading @@ -603,10 +602,9 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController mRssiSignalLevel = signalLevel; Drawable wifiIcon = mIconInjector.getIcon(mRssiSignalLevel); wifiIcon.setTintList(Utils.getColorAccent(mContext)); if (mEntityHeaderController != null) { mEntityHeaderController .setIcon(rescaleIconForHeader(wifiIcon)).done(mFragment.getActivity(), .setIcon(redrawIconForHeader(wifiIcon)).done(mFragment.getActivity(), true /* rebind */); } Loading @@ -618,7 +616,7 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController mSignalStrengthPref.setVisible(true); } private Drawable rescaleIconForHeader(Drawable original) { private Drawable redrawIconForHeader(Drawable original) { final int iconSize = mContext.getResources().getDimensionPixelSize( R.dimen.wifi_detail_page_header_image_size); final int actualWidth = original.getMinimumWidth(); Loading @@ -629,10 +627,19 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController return original; } // clear tint list to make sure can set 87% black after enlarge original.setTintList(null); // enlarge icon size final Bitmap bitmap = Utils.createBitmap(original, iconSize /*width*/, iconSize /*height*/); return new BitmapDrawable(null /*resource*/, bitmap); Drawable newIcon = new BitmapDrawable(null /*resource*/, bitmap); // config color for 87% black after enlarge newIcon.setTintList(Utils.getColorAttr(mContext, android.R.attr.textColorPrimary)); return newIcon; } private void refreshFrequency() { Loading
tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.net.ConnectivityManager; Loading Loading @@ -69,6 +70,7 @@ import com.android.internal.logging.nano.MetricsProto; import com.android.settings.R; import com.android.settings.core.FeatureFlags; import com.android.settings.development.featureflags.FeatureFlagPersistent; import com.android.settings.Utils; import com.android.settings.testutils.shadow.ShadowDevicePolicyManager; import com.android.settings.testutils.shadow.ShadowEntityHeaderController; import com.android.settings.widget.EntityHeaderController; Loading Loading @@ -1458,6 +1460,36 @@ public class WifiDetailPreferenceControllerTest { verify(mockSignalStrengthPref, times(2)).setVisible(false); } @Test public void testRedrawIconForHeader_shouldEnlarge() { ArgumentCaptor<BitmapDrawable> drawableCaptor = ArgumentCaptor.forClass(BitmapDrawable.class); Drawable original = mContext.getDrawable(Utils.getWifiIconResource(LEVEL)).mutate(); when(mockIconInjector.getIcon(anyInt())).thenReturn(original); displayAndResume(); verify(mockHeaderController, times(1)).setIcon(drawableCaptor.capture()); int expectedSize = mContext.getResources().getDimensionPixelSize( R.dimen.wifi_detail_page_header_image_size); BitmapDrawable icon = drawableCaptor.getValue(); assertThat(icon.getMinimumWidth()).isEqualTo(expectedSize); assertThat(icon.getMinimumHeight()).isEqualTo(expectedSize); } @Test public void testRedrawIconForHeader_shouldNotEnlargeIfNotVectorDrawable() { ArgumentCaptor<ColorDrawable> drawableCaptor = ArgumentCaptor.forClass(ColorDrawable.class); displayAndResume(); verify(mockHeaderController, times(1)).setIcon(drawableCaptor.capture()); ColorDrawable icon = drawableCaptor.getValue(); assertThat(icon).isNotNull(); } private ActionButtonsPreference createMock() { final ActionButtonsPreference pref = mock(ActionButtonsPreference.class); when(pref.setButton1Text(anyInt())).thenReturn(pref); Loading