From 2b0dcffc2a7682ae585b395da40222f199ba1f40 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 15 Jul 2024 23:15:53 +0200 Subject: [PATCH] Fixed task icon color --- .../java/eu/faircode/email/ActivityBase.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityBase.java b/app/src/main/java/eu/faircode/email/ActivityBase.java index c9e779a4cd..5c7b9f7b6c 100644 --- a/app/src/main/java/eu/faircode/email/ActivityBase.java +++ b/app/src/main/java/eu/faircode/email/ActivityBase.java @@ -339,16 +339,6 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc prefs.registerOnSharedPreferenceChangeListener(this); try { - Drawable d = getDrawable(R.drawable.baseline_mail_24); - Bitmap bm = Bitmap.createBitmap( - d.getIntrinsicWidth(), - d.getIntrinsicHeight(), - Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(bm); - d.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); - d.setTint(Color.WHITE); - d.draw(canvas); - boolean task_description = prefs.getBoolean("task_description", true); int colorPrimary = (task_description ? Helper.resolveColor(this, androidx.appcompat.R.attr.colorPrimaryDark) @@ -358,6 +348,18 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc colorPrimary = ColorUtils.setAlphaComponent(colorPrimary, 255); } + double lum = ColorUtils.calculateLuminance(colorPrimary); + + Drawable d = getDrawable(R.drawable.baseline_mail_24); + Bitmap bm = Bitmap.createBitmap( + d.getIntrinsicWidth(), + d.getIntrinsicHeight(), + Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(bm); + d.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); + d.setTint(lum > LUMINANCE_THRESHOLD ? Color.BLACK : Color.WHITE); + d.draw(canvas); + ActivityManager.TaskDescription td = new ActivityManager.TaskDescription( null, bm, colorPrimary); setTaskDescription(td);