diff options
author | steckbrief <steckbrief@chefmail.de> | 2018-05-05 20:28:04 +0200 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2018-05-06 13:46:22 +0200 |
commit | 132b27adeef3ab4d305facda7dd035015b00766f (patch) | |
tree | ce90c05d96d747ea1f6cf80129462119a1291dc1 /src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java | |
parent | 853f50e43f68599774469dd12240f35800144991 (diff) |
introduces new message state model
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java b/src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java index c21c90d1..c5ada873 100644 --- a/src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java +++ b/src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java @@ -29,9 +29,12 @@ import java.util.List; import de.thedevstack.conversationsplus.ConversationsPlusApplication; import de.thedevstack.conversationsplus.ConversationsPlusColors; import de.thedevstack.conversationsplus.ConversationsPlusPreferences; +import de.thedevstack.conversationsplus.enums.MessageDirection; import de.thedevstack.conversationsplus.services.avatar.AvatarCache; import de.thedevstack.conversationsplus.utils.ImageUtil; import de.thedevstack.conversationsplus.utils.MessageUtil; +import de.thedevstack.conversationsplus.utils.XmppSendUtil; +import de.thedevstack.conversationsplus.xmpp.stanzas.MessagePacket; import de.tzur.conversations.Settings; import de.thedevstack.conversationsplus.Config; import de.thedevstack.conversationsplus.R; @@ -62,7 +65,7 @@ public class NotificationService { } public boolean notify(final Message message) { - return (message.getStatus() == Message.STATUS_RECEIVED) + return MessageUtil.isIncomingMessage(message) && !message.isRead() && ConversationsPlusPreferences.showNotification() && !message.getConversation().isMuted() @@ -133,25 +136,28 @@ public class NotificationService { } public void push(final Message message) { - if (!notify(message)) { - return; - } - mXmppConnectionService.updateUnreadCountBadge(); - final boolean isScreenOn = mXmppConnectionService.isInteractive(); - if (this.mIsInForeground && isScreenOn && this.mOpenConversation == message.getConversation()) { - return; - } - synchronized (notifications) { - pushToStack(message); - final Account account = message.getConversation().getAccount(); - final boolean doNotify = (!(this.mIsInForeground && this.mOpenConversation == null) || !isScreenOn) - && !account.inGracePeriod() - && !this.inMiniGracePeriod(account); - updateNotification(doNotify); - if (doNotify) { - notifyPebble(message); + if (message.isMamReceived()) { + return; + } + if (notify(message)) { + mXmppConnectionService.updateUnreadCountBadge(); + final boolean isScreenOn = mXmppConnectionService.isInteractive(); + if (this.mIsInForeground && isScreenOn && this.mOpenConversation == message.getConversation()) { + return; + } + synchronized (notifications) { + pushToStack(message); + final Account account = message.getConversation().getAccount(); + final boolean doNotify = (!(this.mIsInForeground && this.mOpenConversation == null) || !isScreenOn) + && !account.inGracePeriod() + && !this.inMiniGracePeriod(account); + updateNotification(doNotify); + if (doNotify) { + notifyPebble(message); + } } } + } public void clear() { @@ -354,11 +360,9 @@ public class NotificationService { private Message getImage(final Iterable<Message> messages) { for (final Message message : messages) { - if (message.getType() != Message.TYPE_TEXT - && message.getTransferable() == null + if (message.getTransferable() == null && message.getEncryption() != Message.ENCRYPTION_PGP - && message.getFileParams() != null - && message.getFileParams().getHeight() > 0) { // TODO Use FileParams.getMimeType() + && MessageUtil.isAttachedFileAnImage(message)) { // TODO Use FileParams.getMimeType() return message; } } |