don't show duplicate nofications on android 4
This commit is contained in:
parent
7917c19d18
commit
f14ab4c391
|
@ -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,6 +325,7 @@ 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 ?
|
||||
|
@ -335,7 +335,6 @@ public class NotificationService {
|
|||
createDownloadIntent(message)
|
||||
);
|
||||
}
|
||||
}
|
||||
if ((message = getFirstLocationMessage(messages)) != null) {
|
||||
mBuilder.addAction(R.drawable.ic_room_white_24dp,
|
||||
mXmppConnectionService.getString(R.string.show_location),
|
||||
|
@ -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()) {
|
||||
|
|
Loading…
Reference in New Issue