Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d0e8ec6 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Merge "Set dark theme flag when initializing with Color" into rvc-dev...

Merge "Merge "Set dark theme flag when initializing with Color" into rvc-dev am: 59dc371f am: 4c69e807" into rvc-d1-dev-plus-aosp am: 7f371d3a

Change-Id: I0c8eb2c64c684f01baf3e8b8cf69c4461fc0ae64
parents 26444049 7f371d3a
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -222,6 +222,14 @@ public final class WallpaperColors implements Parcelable {
    public WallpaperColors(@NonNull Color primaryColor, @Nullable Color secondaryColor,
            @Nullable Color tertiaryColor) {
        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;
        }
    }

    /**
+8 −0
Original line number Diff line number Diff line
@@ -87,6 +87,14 @@ public class WallpaperColorsTest {
                + "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.
     */