4/N The road to Material NEXT (color int format)
Fix issue where leading zeros would be missing from overlay names. Bug: 173561906 Test: manual Change-Id: If19f18099ae3e7c3c2d852ebb991da211566c5e2
This commit is contained in:
@@ -47,7 +47,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@SysUISingleton
|
||||
public class ThemeOverlayApplier implements Dumpable {
|
||||
private static final String TAG = "ThemeOverlayManager";
|
||||
private static final String TAG = "ThemeOverlayApplier";
|
||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
@@ -307,13 +307,13 @@ public class ThemeOverlayController extends SystemUI implements Dumpable {
|
||||
if (!hasSystemPalette && mSystemOverlayColor != Color.TRANSPARENT) {
|
||||
categoryToPackage.put(OVERLAY_CATEGORY_SYSTEM_PALETTE,
|
||||
ThemeOverlayApplier.MONET_SYSTEM_PALETTE_PACKAGE
|
||||
+ Integer.toHexString(mSystemOverlayColor).toUpperCase());
|
||||
+ getColorString(mSystemOverlayColor));
|
||||
}
|
||||
// Same for the accent color
|
||||
if (!hasAccentColor && mAccentOverlayColor != Color.TRANSPARENT) {
|
||||
categoryToPackage.put(OVERLAY_CATEGORY_ACCENT_COLOR,
|
||||
ThemeOverlayApplier.MONET_ACCENT_COLOR_PACKAGE
|
||||
+ Integer.toHexString(mAccentOverlayColor).toUpperCase());
|
||||
+ getColorString(mAccentOverlayColor));
|
||||
}
|
||||
|
||||
Set<UserHandle> userHandles = Sets.newHashSet(UserHandle.of(currentUser));
|
||||
@@ -325,6 +325,14 @@ public class ThemeOverlayController extends SystemUI implements Dumpable {
|
||||
mThemeManager.applyCurrentUserOverlays(categoryToPackage, userHandles);
|
||||
}
|
||||
|
||||
private String getColorString(int color) {
|
||||
String colorString = Integer.toHexString(color).toUpperCase();
|
||||
while (colorString.length() < 6) {
|
||||
colorString = "0" + colorString;
|
||||
}
|
||||
return colorString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) {
|
||||
pw.println("mLockColors=" + mLockColors);
|
||||
|
||||
@@ -107,7 +107,7 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
||||
eq(UserHandle.USER_ALL));
|
||||
verify(mDumpManager).registerDumpable(any(), any());
|
||||
|
||||
List<Integer> colorList = List.of(Color.RED, Color.BLUE);
|
||||
List<Integer> colorList = List.of(Color.RED, Color.BLUE, 0x0CCCCC, 0x000111);
|
||||
when(mThemeOverlayApplier.getAvailableAccentColors()).thenReturn(colorList);
|
||||
when(mThemeOverlayApplier.getAvailableSystemColors()).thenReturn(colorList);
|
||||
}
|
||||
@@ -147,6 +147,23 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
|
||||
verifyNoMoreInteractions(mThemeOverlayApplier);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onWallpaperColorsChanged_addsLeadingZerosToColors() {
|
||||
// Should ask for a new theme when wallpaper colors change
|
||||
WallpaperColors mainColors = new WallpaperColors(Color.valueOf(0x0CCCCC),
|
||||
Color.valueOf(0x000111), null);
|
||||
mColorsListener.getValue().onColorsChanged(mainColors, WallpaperManager.FLAG_SYSTEM);
|
||||
ArgumentCaptor<Map<String, String>> themeOverlays = ArgumentCaptor.forClass(Map.class);
|
||||
|
||||
verify(mThemeOverlayApplier).applyCurrentUserOverlays(themeOverlays.capture(), any());
|
||||
|
||||
// Assert that we received the colors that we were expecting
|
||||
assertThat(themeOverlays.getValue().get(OVERLAY_CATEGORY_SYSTEM_PALETTE))
|
||||
.isEqualTo(MONET_SYSTEM_PALETTE_PACKAGE + "0CCCCC");
|
||||
assertThat(themeOverlays.getValue().get(OVERLAY_CATEGORY_ACCENT_COLOR))
|
||||
.isEqualTo(MONET_ACCENT_COLOR_PACKAGE + "000111");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onWallpaperColorsChanged_preservesWallpaperPickerTheme() {
|
||||
// Should ask for a new theme when wallpaper colors change
|
||||
|
||||
Reference in New Issue
Block a user