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

Commit af3e452c authored by Fynn Godau's avatar Fynn Godau
Browse files

Fix important bugs

parent 0fbe6233
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -141,18 +141,18 @@ fun String.parseColor(): Int {
    if (startsWith("#") && length in listOf(7, 9)) {
        return Color.parseColor(this)
    } else if (startsWith("hsl(")) {
        val hsvArray = replace("hsl(", "").replace(")", "").split(", ")
        if (hsvArray.size != 3) {
        val hslArray = replace("hsl(", "").replace(")", "").split(", ")
        if (hslArray.size != 3) {
            Log.w(TAG, "Invalid color `$this`")
            return 0
        }

        return try {
            Color.HSVToColor(
            ColorUtils.HSLToColor(
                floatArrayOf(
                    hsvArray[0].toFloat(),
                    hsvArray[1].parseFloat(),
                    hsvArray[2].parseFloat()
                    hslArray[0].toFloat(),
                    hslArray[1].parseFloat(),
                    hslArray[2].parseFloat()
                )
            )
        } catch (e: NumberFormatException) {
@@ -177,7 +177,7 @@ fun Int.colorToString() = com.mapbox.mapboxsdk.utils.ColorUtils.colorToRgbaStrin
 */
fun String.parseFloat(): Float {
    return if (contains("%")) {
        replace("%", "").toFloat()
        replace("%", "").toFloat() / 100f
    } else {
        toFloat()
    }