From 0321ebb7a6785b4673376f9e6458e41dd96b2230 Mon Sep 17 00:00:00 2001 From: lookshe Date: Sun, 16 Aug 2015 18:33:10 +0200 Subject: fixes FS#35 - Shortcut Badger compatible to setting always_notify_in_conference --- src/main/java/eu/siacs/conversations/entities/Account.java | 6 ++++++ .../java/eu/siacs/conversations/entities/Conversation.java | 10 ++++++++-- .../eu/siacs/conversations/services/NotificationService.java | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/eu/siacs/conversations/entities/Account.java b/src/main/java/eu/siacs/conversations/entities/Account.java index f472361f..90c10199 100644 --- a/src/main/java/eu/siacs/conversations/entities/Account.java +++ b/src/main/java/eu/siacs/conversations/entities/Account.java @@ -128,6 +128,7 @@ public class Account extends AbstractEntity { private final Roster roster = new Roster(this); private List bookmarks = new CopyOnWriteArrayList<>(); private final Collection blocklist = new CopyOnWriteArraySet<>(); + private XmppConnectionService mXmppConnectionService; public Account() { this.uuid = "0"; @@ -278,6 +279,7 @@ public class Account extends AbstractEntity { } public void initAccountServices(final XmppConnectionService context) { + this.mXmppConnectionService = context; this.mOtrService = new OtrService(context, this); } @@ -418,4 +420,8 @@ public class Account extends AbstractEntity { public boolean isOnlineAndConnected() { return this.getStatus() == State.ONLINE && this.getXmppConnection() != null; } + + public XmppConnectionService getXmppConnectionService() { + return mXmppConnectionService; + } } diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index 289ed4ea..6ff0e270 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -759,10 +759,16 @@ public class Conversation extends AbstractEntity implements Blockable { synchronized (this.messages) { int count = 0; for(int i = this.messages.size() - 1; i >= 0; --i) { - if (this.messages.get(i).isRead()) { + Message message = this.messages.get(i); + if (message.isRead()) { return count; } - ++count; + if (getMode() == Conversation.MODE_SINGLE + || account.getXmppConnectionService().getNotificationService().conferenceNotificationsEnabled() + || account.getXmppConnectionService().getNotificationService().wasHighlightedOrPrivate(message) + ) { + ++count; + } } return count; } diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index 09d223b3..683fcb04 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -442,7 +442,7 @@ public class NotificationService { return PendingIntent.getService(mXmppConnectionService,0,intent,PendingIntent.FLAG_UPDATE_CURRENT); } - private boolean wasHighlightedOrPrivate(final Message message) { + public boolean wasHighlightedOrPrivate(final Message message) { final String nick = message.getConversation().getMucOptions().getActualNick(); final Pattern highlight = generateNickHighlightPattern(nick); if (message.getBody() == null || nick == null) { -- cgit v1.2.3