Loading src/com/android/settings/widget/AdaptiveHomepageIcon.java +2 −0 Original line number Diff line number Diff line Loading @@ -72,11 +72,13 @@ public class AdaptiveHomepageIcon extends LayerDrawable { // If found anything, use it. if (bgColor != 0) { setBackgroundColor(bgColor); return; } } } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, "Failed to set background color for " + tile.getPackageName()); } setBackgroundColor(context.getColor(R.color.homepage_generic_icon_background)); } public void setBackgroundColor(int color) { Loading tests/robotests/src/com/android/settings/widget/AdaptiveHomepageIconTest.java +14 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,20 @@ public class AdaptiveHomepageIconTest { assertThat(icon.mBackgroundColor).isEqualTo(0xff0000); } @Test public void setBackgroundColor_tileWithoutBackgroundColor_shouldSetDefaultBackgroundColor() { final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE)); doReturn(Icon.createWithResource(mContext, R.drawable.ic_settings)) .when(tile).getIcon(mContext); final AdaptiveHomepageIcon icon = new AdaptiveHomepageIcon(mContext, new ColorDrawable(Color.BLACK)); icon.setBackgroundColor(mContext, tile); assertThat(icon.mBackgroundColor).isEqualTo( mContext.getColor(R.color.homepage_generic_icon_background)); } @Test public void onBindTile_externalTileWithBackgroundColorHint_shouldUpdateIcon() { final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE)); Loading Loading
src/com/android/settings/widget/AdaptiveHomepageIcon.java +2 −0 Original line number Diff line number Diff line Loading @@ -72,11 +72,13 @@ public class AdaptiveHomepageIcon extends LayerDrawable { // If found anything, use it. if (bgColor != 0) { setBackgroundColor(bgColor); return; } } } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, "Failed to set background color for " + tile.getPackageName()); } setBackgroundColor(context.getColor(R.color.homepage_generic_icon_background)); } public void setBackgroundColor(int color) { Loading
tests/robotests/src/com/android/settings/widget/AdaptiveHomepageIconTest.java +14 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,20 @@ public class AdaptiveHomepageIconTest { assertThat(icon.mBackgroundColor).isEqualTo(0xff0000); } @Test public void setBackgroundColor_tileWithoutBackgroundColor_shouldSetDefaultBackgroundColor() { final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE)); doReturn(Icon.createWithResource(mContext, R.drawable.ic_settings)) .when(tile).getIcon(mContext); final AdaptiveHomepageIcon icon = new AdaptiveHomepageIcon(mContext, new ColorDrawable(Color.BLACK)); icon.setBackgroundColor(mContext, tile); assertThat(icon.mBackgroundColor).isEqualTo( mContext.getColor(R.color.homepage_generic_icon_background)); } @Test public void onBindTile_externalTileWithBackgroundColorHint_shouldUpdateIcon() { final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE)); Loading