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

Commit e09b6863 authored by tibbi's avatar tibbi
Browse files

fix some color dialog issues at dragging the Hue bar

parent 3c7b8d39
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ class ColorPickerDialog(val context: Context, color: Int, val callback: (color:
    lateinit var viewContainer: ViewGroup
    val currentColorHsv = FloatArray(3)
    val backgroundColor = context.baseConfig.backgroundColor
    var isHueBeingDragged = false

    init {
        Color.colorToHSV(color, currentColorHsv)
@@ -57,6 +58,10 @@ class ColorPickerDialog(val context: Context, color: Int, val callback: (color:
        }

        viewHue.setOnTouchListener(OnTouchListener { v, event ->
            if (event.action == MotionEvent.ACTION_DOWN) {
                isHueBeingDragged = true
            }

            if (event.action == MotionEvent.ACTION_MOVE || event.action == MotionEvent.ACTION_DOWN || event.action == MotionEvent.ACTION_UP) {
                var y = event.y
                if (y < 0f)
@@ -70,8 +75,12 @@ class ColorPickerDialog(val context: Context, color: Int, val callback: (color:
                    hue = 0f

                currentColorHsv[0] = hue
                newHexField.setText(getHexCode(getColor()))
                updateHue()
                newHexField.setText(getHexCode(getColor()))

                if (event.action == MotionEvent.ACTION_UP) {
                    isHueBeingDragged = false
                }
                return@OnTouchListener true
            }
            false
@@ -110,7 +119,7 @@ class ColorPickerDialog(val context: Context, color: Int, val callback: (color:
            }

            override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
                if (s.length == 6) {
                if (s.length == 6 && !isHueBeingDragged) {
                    val newColor = Color.parseColor("#$s")
                    Color.colorToHSV(newColor, currentColorHsv)
                    updateHue()