Merge "Set dark theme flag when initializing with Color" into rvc-dev
This commit is contained in:
@@ -222,6 +222,14 @@ public final class WallpaperColors implements Parcelable {
|
|||||||
public WallpaperColors(@NonNull Color primaryColor, @Nullable Color secondaryColor,
|
public WallpaperColors(@NonNull Color primaryColor, @Nullable Color secondaryColor,
|
||||||
@Nullable Color tertiaryColor) {
|
@Nullable Color tertiaryColor) {
|
||||||
this(primaryColor, secondaryColor, tertiaryColor, 0);
|
this(primaryColor, secondaryColor, tertiaryColor, 0);
|
||||||
|
|
||||||
|
// Calculate dark theme support based on primary color.
|
||||||
|
final float[] tmpHsl = new float[3];
|
||||||
|
ColorUtils.colorToHSL(primaryColor.toArgb(), tmpHsl);
|
||||||
|
final float luminance = tmpHsl[2];
|
||||||
|
if (luminance < DARK_THEME_MEAN_LUMINANCE) {
|
||||||
|
mColorHints |= HINT_SUPPORTS_DARK_THEME;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -87,6 +87,14 @@ public class WallpaperColorsTest {
|
|||||||
+ "HINT_FROM_BITMAP.", fromBitmap);
|
+ "HINT_FROM_BITMAP.", fromBitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void darkMainColorSupportsDarkTheme() {
|
||||||
|
final Color color = Color.valueOf(Color.BLACK);
|
||||||
|
WallpaperColors colors = new WallpaperColors(color, null, null);
|
||||||
|
Assert.assertTrue("Dark theme should be supported by dark main colors.",
|
||||||
|
(colors.getColorHints() & WallpaperColors.HINT_SUPPORTS_DARK_THEME) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WallpaperColors should not recycle bitmaps that it didn't create.
|
* WallpaperColors should not recycle bitmaps that it didn't create.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user