mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-31 11:31:40 +00:00
Updated widget/badge count on change only
This commit is contained in:
parent
76718567d9
commit
5243b92e10
1 changed files with 14 additions and 9 deletions
|
@ -1709,21 +1709,26 @@ class Core {
|
|||
static void notifyMessages(Context context, Map<String, List<Long>> groupNotifying, List<TupleMessageEx> messages) {
|
||||
Log.i("Notify messages=" + messages.size());
|
||||
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean badge = prefs.getBoolean("badge", true);
|
||||
|
||||
Widget.update(context, messages.size());
|
||||
try {
|
||||
ShortcutBadger.applyCount(context, badge ? messages.size() : 0);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
// Update widget/badge count
|
||||
int lastUnseen = 0;
|
||||
for (String group : groupNotifying.keySet())
|
||||
lastUnseen += groupNotifying.get(group).size();
|
||||
if (messages.size() != lastUnseen) {
|
||||
Widget.update(context, messages.size());
|
||||
try {
|
||||
ShortcutBadger.applyCount(context, badge ? messages.size() : 0);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
}
|
||||
}
|
||||
|
||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
Map<String, List<TupleMessageEx>> groupMessages = new HashMap<>();
|
||||
|
||||
// Current
|
||||
Map<String, List<TupleMessageEx>> groupMessages = new HashMap<>();
|
||||
for (TupleMessageEx message : messages) {
|
||||
// Check if notification channel enabled
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O &&
|
||||
|
|
Loading…
Reference in a new issue