Fix color inconsistencies for different APIS

Closes #43
This commit is contained in:
Finn M Glas 2020-06-07 20:58:30 +02:00
parent 52ed08bae2
commit d36daa6006
No known key found for this signature in database
GPG key ID: 25037A2E81AB459C

View file

@ -323,10 +323,13 @@ fun getDominantColor(bitmap: Bitmap?): Int {
fun setButtonColor(btn: Button, color: Int) { fun setButtonColor(btn: Button, color: Int) {
if (Build.VERSION.SDK_INT >= 29) if (Build.VERSION.SDK_INT >= 29)
btn.background.colorFilter = BlendModeColorFilter(color, BlendMode.MULTIPLY) btn.background.colorFilter = BlendModeColorFilter(color, BlendMode.MULTIPLY)
else if(Build.VERSION.SDK_INT >= 21) {
// tested with API 17 (Android 4.4.2 on S4 mini) -> fails
// tested with API 28 (Android 9 on S8) -> necessary
btn.background.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)
}
else { else {
// not setting it here, unable to find a good alternative // not setting it here, unable to find a good alternative
// I tried:
// btn.background.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)
// TODO at some point (or you do it now) // TODO at some point (or you do it now)
} }
} }