From d36daa6006fb2bfdf2af229145441e3f6ba4c39a Mon Sep 17 00:00:00 2001 From: Finn M Glas Date: Sun, 7 Jun 2020 20:58:30 +0200 Subject: [PATCH] Fix color inconsistencies for different APIS Closes #43 --- .../main/java/com/finnmglas/launcher/extern/Functions.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/finnmglas/launcher/extern/Functions.kt b/app/src/main/java/com/finnmglas/launcher/extern/Functions.kt index 9c58602..f32759d 100644 --- a/app/src/main/java/com/finnmglas/launcher/extern/Functions.kt +++ b/app/src/main/java/com/finnmglas/launcher/extern/Functions.kt @@ -323,10 +323,13 @@ fun getDominantColor(bitmap: Bitmap?): Int { fun setButtonColor(btn: Button, color: Int) { if (Build.VERSION.SDK_INT >= 29) 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 { // 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) } }