aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Account.java28
-rw-r--r--src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java2
-rw-r--r--src/main/java/eu/siacs/conversations/utils/XmppUri.java21
3 files changed, 33 insertions, 18 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Account.java b/src/main/java/eu/siacs/conversations/entities/Account.java
index bb89cf17..024f5889 100644
--- a/src/main/java/eu/siacs/conversations/entities/Account.java
+++ b/src/main/java/eu/siacs/conversations/entities/Account.java
@@ -610,23 +610,17 @@ public class Account extends AbstractEntity {
List<XmppUri.Fingerprint> fingerprints = this.getFingerprints();
String uri = "xmpp:"+this.getJid().toBareJid().toString();
if (fingerprints.size() > 0) {
- StringBuilder builder = new StringBuilder(uri);
- builder.append('?');
- for(int i = 0; i < fingerprints.size(); ++i) {
- XmppUri.FingerprintType type = fingerprints.get(i).type;
- if (type == XmppUri.FingerprintType.OMEMO) {
- builder.append(XmppUri.OMEMO_URI_PARAM);
- builder.append(fingerprints.get(i).deviceId);
- } else if (type == XmppUri.FingerprintType.OTR) {
- builder.append(XmppUri.OTR_URI_PARAM);
- }
- builder.append('=');
- builder.append(fingerprints.get(i).fingerprint);
- if (i != fingerprints.size() -1) {
- builder.append(';');
- }
- }
- return builder.toString();
+ return XmppUri.getFingerprintUri(uri,fingerprints,';');
+ } else {
+ return uri;
+ }
+ }
+
+ public String getShareableLink() {
+ List<XmppUri.Fingerprint> fingerprints = this.getFingerprints();
+ String uri = "https://conversations.im/i/"+this.getJid().toBareJid().toString();
+ if (fingerprints.size() > 0) {
+ return XmppUri.getFingerprintUri(uri,fingerprints,'&');
} else {
return uri;
}
diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
index f48e8a48..4c576771 100644
--- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
@@ -756,7 +756,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
intent.setType("text/plain");
String text;
if (http) {
- text = "https://conversations.im/i/"+mAccount.getJid().toBareJid().toString();
+ text = mAccount.getShareableLink();
} else {
text = mAccount.getShareableUri();
}
diff --git a/src/main/java/eu/siacs/conversations/utils/XmppUri.java b/src/main/java/eu/siacs/conversations/utils/XmppUri.java
index 947a3366..8ab5a262 100644
--- a/src/main/java/eu/siacs/conversations/utils/XmppUri.java
+++ b/src/main/java/eu/siacs/conversations/utils/XmppUri.java
@@ -64,6 +64,7 @@ public class XmppUri {
jid = segments.get(1) + "@" + segments.get(2);
}
muc = segments.size() > 1 && "j".equalsIgnoreCase(segments.get(0));
+ fingerprints = parseFingerprints(uri.getQuery(),'&');
} else if ("xmpp".equalsIgnoreCase(scheme)) {
// sample: xmpp:foo@bar.com
muc = isMuc(uri.getQuery());
@@ -166,6 +167,26 @@ public class XmppUri {
OTR
}
+ public static String getFingerprintUri(String base, List<XmppUri.Fingerprint> fingerprints, char seperator) {
+ StringBuilder builder = new StringBuilder(base);
+ builder.append('?');
+ for(int i = 0; i < fingerprints.size(); ++i) {
+ XmppUri.FingerprintType type = fingerprints.get(i).type;
+ if (type == XmppUri.FingerprintType.OMEMO) {
+ builder.append(XmppUri.OMEMO_URI_PARAM);
+ builder.append(fingerprints.get(i).deviceId);
+ } else if (type == XmppUri.FingerprintType.OTR) {
+ builder.append(XmppUri.OTR_URI_PARAM);
+ }
+ builder.append('=');
+ builder.append(fingerprints.get(i).fingerprint);
+ if (i != fingerprints.size() -1) {
+ builder.append(seperator);
+ }
+ }
+ return builder.toString();
+ }
+
public static class Fingerprint {
public final FingerprintType type;
public final String fingerprint;