From 511b7a53f41f8254449e6c2c6eff795f728e7a33 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 29 Sep 2014 18:28:13 +0200 Subject: notifiy only when necessary --- .../conversations/ui/ConversationActivity.java | 38 ++++++++++++++-------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'src/eu/siacs/conversations/ui/ConversationActivity.java') diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java index 3accafe8..03cf753d 100644 --- a/src/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/eu/siacs/conversations/ui/ConversationActivity.java @@ -12,7 +12,6 @@ import eu.siacs.conversations.services.XmppConnectionService.OnConversationUpdat import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate; import eu.siacs.conversations.ui.adapter.ConversationAdapter; import eu.siacs.conversations.utils.ExceptionHelper; -import eu.siacs.conversations.utils.UIHelper; import android.net.Uri; import android.os.Bundle; import android.os.SystemClock; @@ -144,6 +143,9 @@ public class ConversationActivity extends XmppActivity implements } invalidateOptionsMenu(); hideKeyboard(); + if (xmppConnectionServiceBound) { + xmppConnectionService.getNotificationService().setOpenConversation(null); + } } @Override @@ -151,19 +153,7 @@ public class ConversationActivity extends XmppActivity implements paneShouldBeOpen = false; if ((conversationList.size() > 0) && (getSelectedConversation() != null)) { - ActionBar ab = getActionBar(); - if (ab != null) { - ab.setDisplayHomeAsUpEnabled(true); - ab.setHomeButtonEnabled(true); - if (getSelectedConversation().getMode() == Conversation.MODE_SINGLE - || activity.useSubjectToIdentifyConference()) { - ab.setTitle(getSelectedConversation().getName()); - } else { - ab.setTitle(getSelectedConversation() - .getContactJid().split("/")[0]); - } - } - invalidateOptionsMenu(); + openConversation(getSelectedConversation()); if (!getSelectedConversation().isRead()) { xmppConnectionService .markRead(getSelectedConversation()); @@ -179,6 +169,25 @@ public class ConversationActivity extends XmppActivity implements } }); } + + public void openConversation(Conversation conversation) { + ActionBar ab = getActionBar(); + if (ab != null) { + ab.setDisplayHomeAsUpEnabled(true); + ab.setHomeButtonEnabled(true); + if (getSelectedConversation().getMode() == Conversation.MODE_SINGLE + || activity.useSubjectToIdentifyConference()) { + ab.setTitle(getSelectedConversation().getName()); + } else { + ab.setTitle(getSelectedConversation() + .getContactJid().split("/")[0]); + } + } + invalidateOptionsMenu(); + if (xmppConnectionServiceBound) { + xmppConnectionService.getNotificationService().setOpenConversation(conversation); + } + } @Override public boolean onCreateOptionsMenu(Menu menu) { @@ -603,6 +612,7 @@ public class ConversationActivity extends XmppActivity implements xmppConnectionService.removeOnConversationListChangedListener(); xmppConnectionService.removeOnAccountListChangedListener(); xmppConnectionService.removeOnRosterUpdateListener(); + xmppConnectionService.getNotificationService().setOpenConversation(null); } super.onStop(); } -- cgit v1.2.3