diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-07-15 17:11:43 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-07-15 17:11:43 +0200 |
commit | 2a82f23f36e56fa18c59d48231b886edd26a3425 (patch) | |
tree | bcc5d33454aef065a831309c93923be184923493 /src/eu/siacs/conversations/entities/MucOptions.java | |
parent | 2ebd92b7a7b97c7ecca43eb1e3c7d408508aadb2 (diff) |
use nick from bookmark if available
Diffstat (limited to 'src/eu/siacs/conversations/entities/MucOptions.java')
-rw-r--r-- | src/eu/siacs/conversations/entities/MucOptions.java | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/eu/siacs/conversations/entities/MucOptions.java b/src/eu/siacs/conversations/entities/MucOptions.java index 0f8e3565..d8c8b2a3 100644 --- a/src/eu/siacs/conversations/entities/MucOptions.java +++ b/src/eu/siacs/conversations/entities/MucOptions.java @@ -7,6 +7,7 @@ import eu.siacs.conversations.crypto.PgpEngine; import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xmpp.stanzas.PresencePacket; import android.annotation.SuppressLint; +import android.util.Log; @SuppressLint("DefaultLocale") public class MucOptions { @@ -87,6 +88,7 @@ public class MucOptions { private boolean aboutToRename = false; private User self = new User(); private String subject = null; + private String nick; public MucOptions(Account account) { this.account = account; @@ -123,7 +125,7 @@ public class MucOptions { user.setAffiliation(item.getAttribute("affiliation")); user.setRole(item.getAttribute("role")); user.setName(name); - if (name.equals(getNick())) { + if (name.equals(getJoinNick())) { this.isOnline = true; this.error = 0; self = user; @@ -145,7 +147,7 @@ public class MucOptions { } } } else if (type.equals("unavailable")) { - if (name.equals(getNick())) { + if (name.equals(getJoinNick())) { Element item = packet.findChild("x","http://jabber.org/protocol/muc#user").findChild("item"); String nick = item.getAttribute("nick"); if (nick!=null) { @@ -153,7 +155,7 @@ public class MucOptions { if (renameListener!=null) { renameListener.onRename(true); } - this.setNick(nick); + this.setJoinNick(nick); } } deleteUser(packet.getAttribute("from").split("/")[1]); @@ -177,22 +179,25 @@ public class MucOptions { return this.users; } - public String getNick() { - String[] split = conversation.getContactJid().split("/"); - if (split.length == 2) { - return split[1]; + public String getProposedNick() { + String[] mucParts = conversation.getContactJid().split("/"); + if (conversation.getBookmark() != null && conversation.getBookmark().getNick() != null) { + return conversation.getBookmark().getNick(); } else { - if (conversation.getAccount()!=null) { - return conversation.getAccount().getUsername(); + if (mucParts.length == 2) { + return mucParts[1]; } else { - return null; + return account.getUsername(); } } } - public void setNick(String nick) { - String jid = conversation.getContactJid().split("/")[0]+"/"+nick; - conversation.setContactJid(jid); + public String getJoinNick() { + return this.nick; + } + + public void setJoinNick(String nick) { + this.nick = nick; } public void setConversation(Conversation conversation) { @@ -268,4 +273,8 @@ public class MucOptions { } return true; } + + public String getJoinJid() { + return this.conversation.getContactJid().split("/")[0]+"/"+this.getJoinNick(); + } }
\ No newline at end of file |