Support for ShortcutBadger

// FREEBIE

Closes #1574
Closes #1952

Fixes #1526
Fixes #321
This commit is contained in:
Jabro
2014-12-11 17:12:10 -08:00
committed by Moxie Marlinspike
parent 3c4ac4b105
commit 1d0c9536fc
2 changed files with 21 additions and 0 deletions

View File

@@ -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);
}
}
}