diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/StartConversationActivity.java | 3 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/utils/XmppUri.java | 18 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java index 83427a713..30c6b8d97 100644 --- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java @@ -442,6 +442,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU } final Contact contact = account.getRoster().getContact(contactJid); + if (invite.getName() != null) { + contact.setServerName(invite.getName()); + } if (contact.isSelf()) { switchToConversation(contact, null); return true; diff --git a/src/main/java/de/pixart/messenger/utils/XmppUri.java b/src/main/java/de/pixart/messenger/utils/XmppUri.java index 63640089e..daa14a3c3 100644 --- a/src/main/java/de/pixart/messenger/utils/XmppUri.java +++ b/src/main/java/de/pixart/messenger/utils/XmppUri.java @@ -17,6 +17,7 @@ public class XmppUri { protected String fingerprint; protected List<Fingerprint> fingerprints = new ArrayList<>(); private String body; + private String name; private String action; protected boolean safeSource = true; public static final String OMEMO_URI_PARAM = "omemo-sid-"; @@ -93,7 +94,8 @@ public class XmppUri { } } this.fingerprints = parseFingerprints(uri.getQuery()); - this.body = parseBody(uri.getQuery()); + this.body = parseParameter("body", uri.getQuery()); + this.name = parseParameter("name", uri.getQuery()); } else if ("imto".equalsIgnoreCase(scheme)) { // sample: imto://xmpp/foo@bar.com try { @@ -138,12 +140,12 @@ public class XmppUri { return fingerprints; } - protected String parseBody(String query) { - for(String pair : query == null ? new String[0] : query.split(";")) { - final String[] parts = pair.split("=",2); - if (parts.length == 2 && "body".equals(parts[0].toLowerCase(Locale.US))) { + protected String parseParameter(String key, String query) { + for (String pair : query == null ? new String[0] : query.split(";")) { + final String[] parts = pair.split("=", 2); + if (parts.length == 2 && key.equals(parts[0].toLowerCase(Locale.US))) { try { - return URLDecoder.decode(parts[1],"UTF-8"); + return URLDecoder.decode(parts[1], "UTF-8"); } catch (UnsupportedEncodingException e) { return null; } @@ -191,6 +193,10 @@ public class XmppUri { return body; } + public String getName() { + return name; + } + public List<Fingerprint> getFingerprints() { return this.fingerprints; } |