use the primary color at inactive checkboxes too
This commit is contained in:
parent
ca4aa31a89
commit
cf364240ed
1 changed files with 12 additions and 5 deletions
|
@ -5,6 +5,8 @@ import android.content.res.ColorStateList
|
|||
import android.util.AttributeSet
|
||||
import androidx.appcompat.widget.AppCompatCheckBox
|
||||
import com.simplemobiletools.commons.R
|
||||
import com.simplemobiletools.commons.extensions.applyColorFilter
|
||||
import com.simplemobiletools.commons.helpers.isMarshmallowPlus
|
||||
|
||||
class MyAppCompatCheckbox : AppCompatCheckBox {
|
||||
constructor(context: Context) : super(context)
|
||||
|
@ -15,12 +17,17 @@ class MyAppCompatCheckbox : AppCompatCheckBox {
|
|||
|
||||
fun setColors(textColor: Int, accentColor: Int, backgroundColor: Int) {
|
||||
setTextColor(textColor)
|
||||
val colorStateList = ColorStateList(
|
||||
arrayOf(intArrayOf(-android.R.attr.state_checked),
|
||||
intArrayOf(android.R.attr.state_checked)
|
||||
if (isMarshmallowPlus()) {
|
||||
buttonDrawable?.applyColorFilter(accentColor)
|
||||
} else {
|
||||
val colorStateList = ColorStateList(
|
||||
arrayOf(
|
||||
intArrayOf(-android.R.attr.state_checked),
|
||||
intArrayOf(android.R.attr.state_checked)
|
||||
),
|
||||
intArrayOf(context.resources.getColor(R.color.radiobutton_disabled), accentColor)
|
||||
)
|
||||
supportButtonTintList = colorStateList
|
||||
)
|
||||
supportButtonTintList = colorStateList
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue