diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-10-02 17:36:02 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-10-02 17:36:02 +0200 |
commit | 4b09f0e9d3296b4b71d3b31c9102610cc8037d20 (patch) | |
tree | 3313c2b066774278a4dd4f85d3f6232af6bd0671 /src/eu/siacs/conversations/services/NotificationService.java | |
parent | fd6f5b0e84763e98be6299d63d48786c602211a3 (diff) |
properly dismiss notifications
Diffstat (limited to '')
-rw-r--r-- | src/eu/siacs/conversations/services/NotificationService.java | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/eu/siacs/conversations/services/NotificationService.java b/src/eu/siacs/conversations/services/NotificationService.java index 831ce51f..1bc494b7 100644 --- a/src/eu/siacs/conversations/services/NotificationService.java +++ b/src/eu/siacs/conversations/services/NotificationService.java @@ -120,10 +120,11 @@ public class NotificationService { + mXmppConnectionService .getString(R.string.unread_conversations)); StringBuilder names = new StringBuilder(); + Conversation conversation = null; for (ArrayList<Message> messages : notifications.values()) { if (messages.size() > 0) { - String name = messages.get(0).getConversation() - .getName(); + conversation = messages.get(0).getConversation(); + String name = conversation.getName(); style.addLine(Html.fromHtml("<b>" + name + "</b> " @@ -142,6 +143,10 @@ public class NotificationService { .getString(R.string.unread_conversations)); mBuilder.setContentText(names.toString()); mBuilder.setStyle(style); + if (conversation!=null) { + mBuilder.setContentIntent(createContentIntent(conversation + .getUuid())); + } } if (notify) { if (vibrate) { @@ -153,6 +158,7 @@ public class NotificationService { mBuilder.setSound(Uri.parse(ringtone)); } } + mBuilder.setDeleteIntent(createDeleteIntent()); mBuilder.setLights(0xffffffff, 2000, 4000); Notification notification = mBuilder.build(); mNotificationManager.notify(NOTIFICATION_ID, notification); @@ -177,6 +183,12 @@ public class NotificationService { PendingIntent.FLAG_UPDATE_CURRENT); return resultPendingIntent; } + + private PendingIntent createDeleteIntent() { + Intent intent = new Intent(mXmppConnectionService, XmppConnectionService.class); + intent.setAction("clear_notification"); + return PendingIntent.getService(mXmppConnectionService, 0, intent, 0); + } public static boolean wasHighlightedOrPrivate(Message message) { String nick = message.getConversation().getMucOptions().getActualNick(); |