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

Commit 91af339b authored by James O'Leary's avatar James O'Leary Committed by Android (Google) Code Review
Browse files

Merge "Fix error computing tertiary hue" into sc-v2-dev

parents d9422307 62918fe1
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -85,9 +85,10 @@ public class ColorScheme(@ColorInt seed: Int, val darkTheme: Boolean) {
        val camSeed = Cam.fromInt(seedArgb)
        val camSeed = Cam.fromInt(seedArgb)
        val hue = camSeed.hue
        val hue = camSeed.hue
        val chroma = camSeed.chroma.coerceAtLeast(ACCENT1_CHROMA)
        val chroma = camSeed.chroma.coerceAtLeast(ACCENT1_CHROMA)
        val tertiaryHue = wrapDegrees((hue + ACCENT3_HUE_SHIFT).toInt())
        accent1 = Shades.of(hue, chroma).toList()
        accent1 = Shades.of(hue, chroma).toList()
        accent2 = Shades.of(hue, ACCENT2_CHROMA).toList()
        accent2 = Shades.of(hue, ACCENT2_CHROMA).toList()
        accent3 = Shades.of(hue + ACCENT3_HUE_SHIFT, ACCENT3_CHROMA).toList()
        accent3 = Shades.of(tertiaryHue.toFloat(), ACCENT3_CHROMA).toList()
        neutral1 = Shades.of(hue, NEUTRAL1_CHROMA).toList()
        neutral1 = Shades.of(hue, NEUTRAL1_CHROMA).toList()
        neutral2 = Shades.of(hue, NEUTRAL2_CHROMA).toList()
        neutral2 = Shades.of(hue, NEUTRAL2_CHROMA).toList()
    }
    }
+10 −0
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ import android.testing.AndroidTestingRunner;


import androidx.test.filters.SmallTest;
import androidx.test.filters.SmallTest;


import com.android.internal.graphics.cam.Cam;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.SysuiTestCase;


import org.junit.Assert;
import org.junit.Assert;
@@ -90,4 +91,13 @@ public class ColorSchemeTest extends SysuiTestCase {
        List<Integer> rankedSeedColors = ColorScheme.getSeedColors(wallpaperColors);
        List<Integer> rankedSeedColors = ColorScheme.getSeedColors(wallpaperColors);
        Assert.assertEquals(rankedSeedColors, List.of(0xffaec00a, 0xffbe0000, 0xffcc040f));
        Assert.assertEquals(rankedSeedColors, List.of(0xffaec00a, 0xffbe0000, 0xffcc040f));
    }
    }

    @Test
    public void testTertiaryHueWrapsProperly() {
        int colorInt = 0xffB3588A; // H350 C50 T50
        ColorScheme colorScheme = new ColorScheme(colorInt, false /* darkTheme */);
        int tertiaryMid = colorScheme.getAccent3().get(colorScheme.getAccent3().size() / 2);
        Cam cam = Cam.fromInt(tertiaryMid);
        Assert.assertEquals(cam.getHue(), 50.0, 10.0);
    }
}
}