mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-15 13:35:04 -05:00
support for jid escapting when displaying localpart only
This commit is contained in:
parent
58de10bcab
commit
5d4aa04e5d
@ -121,7 +121,7 @@ public class Contact implements ListItem, Blockable {
|
|||||||
} else if (this.presenceName != null && mutualPresenceSubscription()) {
|
} else if (this.presenceName != null && mutualPresenceSubscription()) {
|
||||||
return this.presenceName;
|
return this.presenceName;
|
||||||
} else if (jid.hasLocalpart()) {
|
} else if (jid.hasLocalpart()) {
|
||||||
return jid.getLocalpart();
|
return jid.getUnescapedLocalpart();
|
||||||
} else {
|
} else {
|
||||||
return jid.getDomainpart();
|
return jid.getDomainpart();
|
||||||
}
|
}
|
||||||
|
@ -464,7 +464,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
|||||||
if (generatedName != null) {
|
if (generatedName != null) {
|
||||||
return generatedName;
|
return generatedName;
|
||||||
} else {
|
} else {
|
||||||
return getJid().getLocalpart();
|
return getJid().getUnescapedLocalpart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -380,7 +380,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
|||||||
MenuItem invite = menu.findItem(R.id.invite);
|
MenuItem invite = menu.findItem(R.id.invite);
|
||||||
startConversation.setVisible(true);
|
startConversation.setVisible(true);
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
showContactDetails.setVisible(true);
|
showContactDetails.setVisible(!contact.isSelf());
|
||||||
}
|
}
|
||||||
if (user.getRole() == MucOptions.Role.NONE) {
|
if (user.getRole() == MucOptions.Role.NONE) {
|
||||||
invite.setVisible(true);
|
invite.setVisible(true);
|
||||||
|
@ -21,6 +21,8 @@ public final class Jid {
|
|||||||
private final String domainpart;
|
private final String domainpart;
|
||||||
private final String resourcepart;
|
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
|
// 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).
|
// all out every time (since some characters are displayed but aren't used for comparisons).
|
||||||
private final String displayjid;
|
private final String displayjid;
|
||||||
@ -29,6 +31,18 @@ public final class Jid {
|
|||||||
return localpart;
|
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() {
|
public String getDomainpart() {
|
||||||
return IDN.toUnicode(domainpart);
|
return IDN.toUnicode(domainpart);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user