aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-12-01 20:49:18 +0100
committerDaniel Gultsch <daniel@gultsch.de>2016-12-01 20:49:18 +0100
commit5d4aa04e5d6db297890283c27dd2a41d499f9f13 (patch)
tree8ab5f6dd15a803d32fb15ebfa4d014035690d627 /src
parent58de10bcab4b3366a3a154f02bf5b2aa22215023 (diff)
support for jid escapting when displaying localpart only
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Contact.java2
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Conversation.java2
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java2
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java14
4 files changed, 17 insertions, 3 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Contact.java b/src/main/java/eu/siacs/conversations/entities/Contact.java
index 72ce1a5a..b7307a8b 100644
--- a/src/main/java/eu/siacs/conversations/entities/Contact.java
+++ b/src/main/java/eu/siacs/conversations/entities/Contact.java
@@ -121,7 +121,7 @@ public class Contact implements ListItem, Blockable {
} else if (this.presenceName != null && mutualPresenceSubscription()) {
return this.presenceName;
} else if (jid.hasLocalpart()) {
- return jid.getLocalpart();
+ return jid.getUnescapedLocalpart();
} else {
return jid.getDomainpart();
}
diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java
index 9605fefc..ced48913 100644
--- a/src/main/java/eu/siacs/conversations/entities/Conversation.java
+++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java
@@ -464,7 +464,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
if (generatedName != null) {
return generatedName;
} else {
- return getJid().getLocalpart();
+ return getJid().getUnescapedLocalpart();
}
}
} else {
diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
index 7791372a..42eb49fb 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
@@ -380,7 +380,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
MenuItem invite = menu.findItem(R.id.invite);
startConversation.setVisible(true);
if (contact != null) {
- showContactDetails.setVisible(true);
+ showContactDetails.setVisible(!contact.isSelf());
}
if (user.getRole() == MucOptions.Role.NONE) {
invite.setVisible(true);
diff --git a/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java b/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java
index 20f1feb4..f551dd20 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java
@@ -21,6 +21,8 @@ public final class Jid {
private final String domainpart;
private final String resourcepart;
+ private static final char[] JID_ESCAPING_CHARS = {' ','"','&','\'','/',':','<','>','@','\\'};
+
// It's much more efficient to store the ful JID as well as the parts instead of figuring them
// all out every time (since some characters are displayed but aren't used for comparisons).
private final String displayjid;
@@ -29,6 +31,18 @@ public final class Jid {
return localpart;
}
+ public String getUnescapedLocalpart() {
+ if (localpart == null || !localpart.contains("\\")) {
+ return localpart;
+ } else {
+ String localpart = this.localpart;
+ for(char c : JID_ESCAPING_CHARS) {
+ localpart = localpart.replace(String.format ("\\%02x", (int)c),String.valueOf(c));
+ }
+ return localpart;
+ }
+ }
+
public String getDomainpart() {
return IDN.toUnicode(domainpart);
}