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

Commit 99c14cb9 authored by Fynn Godau's avatar Fynn Godau
Browse files

Preserve alpha component when applying custom styles

parent bb5c25b5
Loading
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -301,7 +301,7 @@ fun Styler.applyColorChanges(color: Int): Int {
        // Apply hue to layer color
        ColorUtils.colorToHSL(color, hslResult)
        hslResult[0] = hueDegree
        return ColorUtils.HSLToColor(hslResult)
        return ColorUtils.setAlphaComponent(ColorUtils.HSLToColor(hslResult), Color.alpha(color))
    }

    lightness?.let { lightness ->
@@ -315,7 +315,7 @@ fun Styler.applyColorChanges(color: Int): Int {
            // Increase brightness. Percentage amount = relative reduction of difference between is-lightness and 1.0.
            hsl[2] + (lightness / 100) * (1 - hsl[2])
        }
        return ColorUtils.HSLToColor(hsl)
        return ColorUtils.setAlphaComponent(ColorUtils.HSLToColor(hsl), Color.alpha(color))
    }

    saturation?.let { saturation ->
@@ -330,7 +330,7 @@ fun Styler.applyColorChanges(color: Int): Int {
            hsl[1] + (saturation / 100) * (1 - hsl[1])
        }

        return ColorUtils.HSLToColor(hsl)
        return ColorUtils.setAlphaComponent(ColorUtils.HSLToColor(hsl), Color.alpha(color))
    }

    gamma?.let { gamma ->
@@ -339,7 +339,7 @@ fun Styler.applyColorChanges(color: Int): Int {
        ColorUtils.colorToHSL(color, hsl)
        hsl[2] = hsl[2].toDouble().pow(gamma.toDouble()).toFloat()

        return ColorUtils.HSLToColor(hsl)
        return ColorUtils.setAlphaComponent(ColorUtils.HSLToColor(hsl), Color.alpha(color))
    }

    if (invertLightness == true) {
@@ -348,7 +348,7 @@ fun Styler.applyColorChanges(color: Int): Int {
        ColorUtils.colorToHSL(color, hsl)
        hsl[2] = 1 - hsl[2]

        return ColorUtils.HSLToColor(hsl)
        return ColorUtils.setAlphaComponent(ColorUtils.HSLToColor(hsl), Color.alpha(color))
    }

    this.color?.let {