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

Commit ccec5b6c authored by Lucas Dupin's avatar Lucas Dupin
Browse files

New palette picking algorithm

Test: visual
Change-Id: I149951dd82b420b6d1fd0466ac593a218a0f2be2
parent 8d94fedb
Loading
Loading
Loading
Loading
+14 −1
Original line number Original line Diff line number Diff line
@@ -95,12 +95,25 @@ public class ColorExtractor implements WallpaperManager.OnColorsChangedListener
        if (inWallpaperColors == null) {
        if (inWallpaperColors == null) {
            return;
            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) {
    private void applyFallback(GradientColors outGradientColors) {
        outGradientColors.setMainColor(mMainFallbackColor);
        outGradientColors.setMainColor(mMainFallbackColor);
        outGradientColors.setSecondaryColor(mSecondaryFallbackColor);
        outGradientColors.setSecondaryColor(mSecondaryFallbackColor);
        outGradientColors.setSupportsDarkText(false);
    }
    }


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

File changed.

Preview size limit exceeded, changes collapsed.