extend button theming for primary actions to respect states and also cover icons

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-07-27 20:25:46 +02:00
parent e54abe63f1
commit 9aabb8804e
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B

View File

@ -136,7 +136,18 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme) {
fun colorMaterialButtonBackground(button: MaterialButton) {
withElementColor(button) { color ->
button.setBackgroundColor(color)
button.setTextColor(theme.colorText)
val disabledColor = ContextCompat.getColor(button.context, R.color.disabled_text)
val colorStateList = ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_enabled)
),
intArrayOf(theme.colorText, disabledColor)
)
button.setTextColor(colorStateList)
button.iconTint = colorStateList
}
}