From caf214c2123b481fedd296cccdfb1c22be1df5a4 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 4 Apr 2014 13:01:07 +0200 Subject: fixing more notification f-ups --- src/eu/siacs/conversations/utils/UIHelper.java | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/eu/siacs/conversations/utils/UIHelper.java b/src/eu/siacs/conversations/utils/UIHelper.java index 9b9fd8a9..3cc99dc5 100644 --- a/src/eu/siacs/conversations/utils/UIHelper.java +++ b/src/eu/siacs/conversations/utils/UIHelper.java @@ -187,15 +187,11 @@ public class UIHelper { if ((currentCon != null) &&(currentCon.getMode() == Conversation.MODE_MULTI)&&(!alwaysNotify)) { String nick = currentCon.getMucOptions().getNick(); notify = currentCon.getLatestMessage().getBody().contains(nick); - /*if (!notify) { - //mNotificationManager.cancel(2342); - return; - }*/ } List unread = new ArrayList(); for (Conversation conversation : conversations) { - if (!conversation.isRead()) { + if ((!conversation.isRead())&&((wasHighlighted(conversation)||(alwaysNotify)))) { unread.add(conversation); } } @@ -289,6 +285,21 @@ public class UIHelper { } } + private static boolean wasHighlighted(Conversation conversation) { + List messages = conversation.getMessages(); + String nick = conversation.getMucOptions().getNick(); + for(int i = messages.size() - 1; i >= 0; --i) { + if (messages.get(i).isRead()) { + break; + } else { + if (messages.get(i).getBody().contains(nick)) { + return true; + } + } + } + return false; + } + public static void prepareContactBadge(final Activity activity, QuickContactBadge badge, final Contact contact) { if (contact.getSystemAccount() != null) { -- cgit v1.2.3