diff options
3 files changed, 15 insertions, 3 deletions
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<Bookmark> bookmarks = new CopyOnWriteArrayList<>(); private final Collection<Jid> 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) { |