diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-03-14 20:32:21 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-03-14 20:32:21 +0100 |
commit | e15c8b73161faf9bd2acb2a548fb0e77a10f218e (patch) | |
tree | cf3ce21c0d96f2afe50b56e3e261013592a90930 /src/main/java/de/pixart/messenger/services | |
parent | e9336d8152734d122c989737360a77a0b57cbd3d (diff) |
don't open conversation when opening contact details
Diffstat (limited to 'src/main/java/de/pixart/messenger/services')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/XmppConnectionService.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index ce839766d..4ea6b5f35 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -1861,6 +1861,61 @@ public class XmppConnectionService extends Service { } } + public Conversation findConversation(final Account account, final Jid jid, final boolean muc) { + synchronized (this.conversations) { + Conversation conversation = find(account, jid); + if (conversation != null) { + return conversation; + } + conversation = databaseBackend.findConversation(account, jid); + final boolean loadMessagesFromDb; + if (conversation != null) { + conversation.setStatus(Conversation.STATUS_AVAILABLE); + conversation.setAccount(account); + if (muc) { + conversation.setMode(Conversation.MODE_MULTI); + conversation.setContactJid(jid); + } else { + conversation.setMode(Conversation.MODE_SINGLE); + conversation.setContactJid(jid.toBareJid()); + } + databaseBackend.updateConversation(conversation); + loadMessagesFromDb = conversation.messagesLoaded.compareAndSet(true,false); + } else { + String conversationName; + Contact contact = account.getRoster().getContact(jid); + if (contact != null) { + conversationName = contact.getDisplayName(); + } else { + conversationName = jid.getLocalpart(); + } + if (muc) { + conversation = new Conversation(conversationName, account, jid, + Conversation.MODE_MULTI); + } else { + conversation = new Conversation(conversationName, account, jid.toBareJid(), + Conversation.MODE_SINGLE); + } + this.databaseBackend.createConversation(conversation); + loadMessagesFromDb = false; + } + final Conversation c = conversation; + mDatabaseExecutor.execute(new Runnable() { + @Override + public void run() { + if (loadMessagesFromDb) { + c.addAll(0, databaseBackend.getMessages(c, Config.PAGE_SIZE)); + updateConversationUi(); + c.messagesLoaded.set(true); + } + checkDeletedFiles(c); + } + }); + updateConversationUi(); + return conversation; + } + } + public void archiveConversation(Conversation conversation) { getNotificationService().clear(conversation); conversation.setStatus(Conversation.STATUS_ARCHIVED); |