diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-08-31 17:02:42 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2016-08-31 17:02:42 +0200 |
commit | f14ab4c3912fae99ceec29a1df9f9c108e39306a (patch) | |
tree | dacb139d12d24cd0821457f46cb5586738bbe6a0 /src/main/java/eu/siacs | |
parent | 7917c19d1853c890d08985d29c709f53ec8ae54b (diff) |
don't show duplicate nofications on android 4
Diffstat (limited to 'src/main/java/eu/siacs')
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/NotificationService.java | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index 00b76c76..8e8a5d85 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -1,7 +1,6 @@ package eu.siacs.conversations.services; import android.app.Notification; -import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; @@ -13,6 +12,7 @@ import android.os.SystemClock; import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat.BigPictureStyle; import android.support.v4.app.NotificationCompat.Builder; +import android.support.v4.app.NotificationManagerCompat; import android.support.v4.app.RemoteInput; import android.support.v4.app.TaskStackBuilder; import android.text.Html; @@ -183,8 +183,8 @@ public class NotificationService { synchronized (notifications) { markAsReadIfHasDirectReply(conversation); notifications.remove(conversation.getUuid()); - final NotificationManager nm = (NotificationManager) mXmppConnectionService.getSystemService(Context.NOTIFICATION_SERVICE); - nm.cancel(conversation.getUuid(), NOTIFICATION_ID); + final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(mXmppConnectionService); + notificationManager.cancel(conversation.getUuid(), NOTIFICATION_ID); updateNotification(false); } } @@ -207,8 +207,7 @@ public class NotificationService { } public void updateNotification(final boolean notify) { - final NotificationManager notificationManager = (NotificationManager) mXmppConnectionService - .getSystemService(Context.NOTIFICATION_SERVICE); + final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(mXmppConnectionService); final SharedPreferences preferences = mXmppConnectionService.getPreferences(); if (notifications.size() == 0) { @@ -326,15 +325,15 @@ public class NotificationService { RemoteInput remoteInput = new RemoteInput.Builder("text_reply").setLabel(UIHelper.getMessageHint(mXmppConnectionService, conversation)).build(); NotificationCompat.Action action = new NotificationCompat.Action.Builder(R.drawable.ic_send_text_offline, "Reply", createReplyIntent(conversation)).addRemoteInput(remoteInput).build(); mBuilder.addAction(action); - if ((message = getFirstDownloadableMessage(messages)) != null) { - mBuilder.addAction( - Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? - R.drawable.ic_file_download_white_24dp : R.drawable.ic_action_download, - mXmppConnectionService.getResources().getString(R.string.download_x_file, - UIHelper.getFileDescriptionString(mXmppConnectionService, message)), - createDownloadIntent(message) - ); - } + } + if ((message = getFirstDownloadableMessage(messages)) != null) { + mBuilder.addAction( + Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? + R.drawable.ic_file_download_white_24dp : R.drawable.ic_action_download, + mXmppConnectionService.getResources().getString(R.string.download_x_file, + UIHelper.getFileDescriptionString(mXmppConnectionService, message)), + createDownloadIntent(message) + ); } if ((message = getFirstLocationMessage(messages)) != null) { mBuilder.addAction(R.drawable.ic_room_white_24dp, @@ -613,7 +612,7 @@ public class NotificationService { } public void updateErrorNotification() { - final NotificationManager notificationManager = (NotificationManager) mXmppConnectionService.getSystemService(Context.NOTIFICATION_SERVICE); + final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(mXmppConnectionService); final List<Account> errors = new ArrayList<>(); for (final Account account : mXmppConnectionService.getAccounts()) { if (account.hasErrorStatus()) { |