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

Commit 5bf85567 authored by Lucas Dupin's avatar Lucas Dupin Committed by Android (Google) Code Review
Browse files

Merge "New palette picking algorithm"

parents bb1d49f8 ccec5b6c
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -95,12 +95,25 @@ public class ColorExtractor implements WallpaperManager.OnColorsChangedListener
        if (inWallpaperColors == null) {
            return;
        }
        mExtractionType.extractInto(inWallpaperColors, outGradientColors);
        boolean success = mExtractionType.extractInto(inWallpaperColors, outGradientColors);
        if (success) {
            // Updating dark text support. We're going to verify if the mean luminosity
            // is greater then a threshold.
            float hsl[] = new float[3];
            float meanLuminosity = 0;
            ColorUtils.colorToHSL(outGradientColors.getMainColor(), hsl);
            meanLuminosity += hsl[2];
            ColorUtils.colorToHSL(outGradientColors.getSecondaryColor(), hsl);
            meanLuminosity += hsl[2];
            meanLuminosity /= 2;
            outGradientColors.setSupportsDarkText(meanLuminosity >= DARK_TEXT_LUMINOSITY);
        }
    }

    private void applyFallback(GradientColors outGradientColors) {
        outGradientColors.setMainColor(mMainFallbackColor);
        outGradientColors.setSecondaryColor(mSecondaryFallbackColor);
        outGradientColors.setSupportsDarkText(false);
    }

    public void destroy() {
+2 −1
Original line number Diff line number Diff line
@@ -31,7 +31,8 @@ public interface ExtractionType {
     *
     * @param inWallpaperColors where to read from
     * @param outGradientColors object that should receive the colors
     * @return true if successful
     */
    void extractInto(WallpaperColors inWallpaperColors,
    boolean extractInto(WallpaperColors inWallpaperColors,
            ColorExtractor.GradientColors outGradientColors);
}
+266 −255

File changed.

Preview size limit exceeded, changes collapsed.