1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-31 20:25:38 +00:00

Lighten filter icon if needed

This commit is contained in:
M66B 2021-11-09 11:11:13 +01:00
parent ad8c38aeea
commit 90c68a979b

View file

@ -4444,13 +4444,16 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
boolean filter_active = (filter_seen || filter_unflagged || filter_unknown ||
(language_detection && !TextUtils.isEmpty(filter_language)));
int filterColor = Helper.resolveColor(context, R.attr.colorAccent);
float filterLighten = 0.7f - (float) ColorUtils.calculateLuminance(filterColor);
if (filterLighten > 0)
filterColor = ColorUtils.blendARGB(filterColor, Color.WHITE, filterLighten);
MenuItem menuFilter = menu.findItem(R.id.menu_filter);
menuFilter.setShowAsAction(folder && filter_active
? MenuItem.SHOW_AS_ACTION_ALWAYS
: MenuItem.SHOW_AS_ACTION_NEVER);
MenuItemCompat.setIconTintList(menuFilter,
folder && filter_active ?
ColorStateList.valueOf(Helper.resolveColor(context, R.attr.colorAccent)) : null);
MenuItemCompat.setIconTintList(menuFilter, folder && filter_active
? ColorStateList.valueOf(filterColor) : null);
menuFilter.setIcon(folder && filter_active ? R.drawable.twotone_filter_alt_24 : R.drawable.twotone_filter_list_24);
MenuItem menuSearch = menu.findItem(R.id.menu_search);