diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/views/MyAppCompatCheckbox.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/views/MyAppCompatCheckbox.kt index f94b3186a..594e0f995 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/views/MyAppCompatCheckbox.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/views/MyAppCompatCheckbox.kt @@ -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 + } } }