|
|
@ -23,7 +23,6 @@ class AccentBgTextView @JvmOverloads constructor( |
|
|
|
radius = typedArray.getDimensionPixelOffset(R.styleable.AccentBgTextView_radius, radius) |
|
|
|
radius = typedArray.getDimensionPixelOffset(R.styleable.AccentBgTextView_radius, radius) |
|
|
|
typedArray.recycle() |
|
|
|
typedArray.recycle() |
|
|
|
upBackground() |
|
|
|
upBackground() |
|
|
|
setTextColor(Color.WHITE) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun setRadius(radius: Int) { |
|
|
|
fun setRadius(radius: Int) { |
|
|
@ -32,18 +31,22 @@ class AccentBgTextView @JvmOverloads constructor( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun upBackground() { |
|
|
|
private fun upBackground() { |
|
|
|
background = if (isInEditMode) { |
|
|
|
val accentColor = if (isInEditMode) { |
|
|
|
Selector.shapeBuild() |
|
|
|
context.getCompatColor(R.color.accent) |
|
|
|
.setCornerRadius(radius) |
|
|
|
|
|
|
|
.setDefaultBgColor(context.getCompatColor(R.color.accent)) |
|
|
|
|
|
|
|
.setPressedBgColor(ColorUtils.darkenColor(context.getCompatColor(R.color.accent))) |
|
|
|
|
|
|
|
.create() |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Selector.shapeBuild() |
|
|
|
ThemeStore.accentColor(context) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
background = Selector.shapeBuild() |
|
|
|
.setCornerRadius(radius) |
|
|
|
.setCornerRadius(radius) |
|
|
|
.setDefaultBgColor(ThemeStore.accentColor(context)) |
|
|
|
.setDefaultBgColor(accentColor) |
|
|
|
.setPressedBgColor(ColorUtils.darkenColor(ThemeStore.accentColor(context))) |
|
|
|
.setPressedBgColor(ColorUtils.darkenColor(accentColor)) |
|
|
|
.create() |
|
|
|
.create() |
|
|
|
|
|
|
|
setTextColor( |
|
|
|
|
|
|
|
if (ColorUtils.isColorLight(accentColor)) { |
|
|
|
|
|
|
|
Color.BLACK |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Color.WHITE |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|