mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-21 12:58:39 +00:00
Support for ShortcutBadger
// FREEBIE Closes #1574 Closes #1952 Fixes #1526 Fixes #321
This commit is contained in:
@@ -56,6 +56,9 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
import me.leolin.shortcutbadger.ShortcutBadgeException;
|
||||
import me.leolin.shortcutbadger.ShortcutBadger;
|
||||
|
||||
/**
|
||||
* Handles posting system notifications for new messages.
|
||||
*
|
||||
@@ -134,6 +137,7 @@ public class MessageNotifier {
|
||||
{
|
||||
((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE))
|
||||
.cancel(NOTIFICATION_ID);
|
||||
updateBadge(context, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -146,6 +150,8 @@ public class MessageNotifier {
|
||||
} else {
|
||||
sendSingleThreadNotification(context, masterSecret, notificationState, signal);
|
||||
}
|
||||
|
||||
updateBadge(context, notificationState.getMessageCount());
|
||||
} finally {
|
||||
if (telcoCursor != null) telcoCursor.close();
|
||||
if (pushCursor != null) pushCursor.close();
|
||||
@@ -384,4 +390,14 @@ public class MessageNotifier {
|
||||
|
||||
return blinkPattern.split(",");
|
||||
}
|
||||
|
||||
private static void updateBadge(Context context, int count) {
|
||||
try {
|
||||
ShortcutBadger.setBadge(context, count);
|
||||
} catch (Throwable t) {
|
||||
// NOTE :: I don't totally trust this thing, so I'm catching
|
||||
// everything.
|
||||
Log.w("MessageNotifier", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user