determine the colorpicker rectangle background based on the actual background

This commit is contained in:
tibbi 2017-01-10 18:48:36 +01:00
parent be7c9c9ca1
commit e1d82817d6
3 changed files with 8 additions and 7 deletions

View file

@ -101,7 +101,7 @@ class CustomizationActivity : BaseSimpleActivity() {
private fun setupColorsPickers() {
customization_text_color.setBackgroundColor(curTextColor)
customization_primary_color.setBackgroundColor(curPrimaryColor)
customization_background_color.setBackgroundWithStroke(curBackgroundColor)
customization_background_color.setBackgroundWithStroke(curBackgroundColor, curBackgroundColor)
}
private fun hasColorChanged(old: Int, new: Int) = Math.abs(old - new) > 1

View file

@ -29,6 +29,7 @@ class ColorPickerDialog(val context: Context, color: Int, val callback: (color:
init {
Color.colorToHSV(color, currentColorHsv)
val backgroundColor = BaseConfig.newInstance(context).backgroundColor
val view = LayoutInflater.from(context).inflate(R.layout.dialog_colorpicker, null).apply {
viewHue = color_picker_hue
viewSatVal = color_picker_square
@ -39,8 +40,8 @@ class ColorPickerDialog(val context: Context, color: Int, val callback: (color:
viewContainer = color_picker_holder
viewSatVal.setHue(getHue())
viewNewColor.setBackgroundWithStroke(getColor())
color_picker_old_color.setBackgroundWithStroke(color)
viewNewColor.setBackgroundWithStroke(getColor(), backgroundColor)
color_picker_old_color.setBackgroundWithStroke(color, backgroundColor)
}
viewHue.setOnTouchListener(OnTouchListener { v, event ->
@ -55,7 +56,7 @@ class ColorPickerDialog(val context: Context, color: Int, val callback: (color:
currentColorHsv[0] = hue
viewSatVal.setHue(getHue())
moveHuePicker()
viewNewColor.setBackgroundWithStroke(getColor())
viewNewColor.setBackgroundWithStroke(getColor(), backgroundColor)
return@OnTouchListener true
}
false
@ -79,7 +80,7 @@ class ColorPickerDialog(val context: Context, color: Int, val callback: (color:
currentColorHsv[2] = 1f - 1f / viewSatVal.measuredHeight * y
moveColorPicker()
viewNewColor.setBackgroundWithStroke(getColor())
viewNewColor.setBackgroundWithStroke(getColor(), backgroundColor)
return@OnTouchListener true
}
false

View file

@ -3,8 +3,8 @@ package com.simplemobiletools.commons.extensions
import android.graphics.drawable.GradientDrawable
import android.widget.ImageView
fun ImageView.setBackgroundWithStroke(backgroundColor: Int) {
val strokeColor = backgroundColor.getContrastColor()
fun ImageView.setBackgroundWithStroke(backgroundColor: Int, realStrokeColor: Int) {
val strokeColor = realStrokeColor.getContrastColor()
GradientDrawable().apply {
shape = GradientDrawable.RECTANGLE
setColor(backgroundColor)