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

Commit 7e701af4 authored by Moez Bhatti's avatar Moez Bhatti
Browse files

Optimize CIECLhEvaluator and ThemeManager.setActiveColor

parent b91473e5
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -18,7 +18,13 @@ public class CIELChEvaluator implements TypeEvaluator<Integer> {
    private final ColorCIELCh mStartColor;
    private final ColorCIELCh mEndColor;

    private final int mStartInt;
    private final int mEndInt;

    public CIELChEvaluator(int startColor, int endColor) {
        mStartInt = startColor;
        mEndInt = endColor;

        mStartColor = convertRgbToCIELCH(startColor);
        mEndColor = convertRgbToCIELCH(endColor);
    }
@@ -29,6 +35,9 @@ public class CIELChEvaluator implements TypeEvaluator<Integer> {

    @Override
    public Integer evaluate(float fraction, Integer ignored, Integer ignored2) {
        if (mStartInt == mEndInt) {
            return mStartInt;
        }

        // CIELCH to CIELAB
        double L = mStartColor.L * (1 - fraction) + mEndColor.L * fraction;
+4 −2
Original line number Diff line number Diff line
@@ -621,9 +621,11 @@ public class ThemeManager {
    }

    public static void setActiveColor(int color) {
        if (mActiveColor != color) {
            mActiveColor = color;
            LiveViewManager.refreshViews(QKPreference.THEME);
        }
    }

    private static boolean isColorDarkEnough(int color) {
        for (int i = 0; i < COLORS.length; i++) {