Skip to content

Commit

Permalink
Fixed task icon color
Browse files Browse the repository at this point in the history
  • Loading branch information
M66B committed Jul 15, 2024
1 parent 766c3df commit 2b0dcff
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions app/src/main/java/eu/faircode/email/ActivityBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -339,16 +339,6 @@ public void onFragmentResult(@NonNull String requestKey, @NonNull Bundle result)
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)
Expand All @@ -358,6 +348,18 @@ public void onFragmentResult(@NonNull String requestKey, @NonNull Bundle result)
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);
Expand Down

0 comments on commit 2b0dcff

Please sign in to comment.