Flatten swatch, add background to picker

This commit is contained in:
Moez Bhatti
2018-03-24 03:59:25 -04:00
parent eda42267c0
commit 63070609bd
3 changed files with 44 additions and 17 deletions
@@ -26,6 +26,7 @@ import android.view.MotionEvent
import android.view.View
import com.moez.QKSMS.R
import common.util.extensions.setBackgroundTint
import common.util.extensions.setTint
import common.util.extensions.within
import kotlinx.android.synthetic.main.hsv_picker_view.view.*
@@ -64,7 +65,7 @@ class HSVPickerView @JvmOverloads constructor(context: Context, attrs: Attribute
val range = max - min
val hsv = floatArrayOf(hue, (x - min) / range, 1 - (y - min) / range)
swatchPreview.setBackgroundTint(Color.HSVToColor(hsv))
swatch.setTint(Color.HSVToColor(hsv))
}
else -> return@setOnTouchListener false
@@ -81,7 +82,7 @@ class HSVPickerView @JvmOverloads constructor(context: Context, attrs: Attribute
}
fun setColor(color: Int) {
swatchPreview.setBackgroundTint(color)
swatch.setTint(color)
// Convert the rgb color to HSV
val hsv = FloatArray(3).apply {