From 5be64de7be8a4e7c6a5c6d9eaf2d47cfc8e4b9ab Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 18 Sep 2018 17:15:52 +0200 Subject: [PATCH] catch conversations.im invite urls directly in fragment --- .../siacs/conversations/services/XmppConnectionService.java | 2 +- .../eu/siacs/conversations/ui/ContactDetailsActivity.java | 2 +- .../java/eu/siacs/conversations/ui/text/FixedURLSpan.java | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 3c7dabbee..e886c6b03 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -3441,7 +3441,7 @@ public class XmppConnectionService extends Service { public Conversation findUniqueConversationByJid(XmppUri xmppUri) { List findings = new ArrayList<>(); for (Conversation c : getConversations()) { - if (c.getJid().asBareJid().equals(xmppUri.getJid()) && ((c.getMode() == Conversational.MODE_MULTI) == xmppUri.isAction(XmppUri.ACTION_JOIN))) { + if (c.getAccount().isEnabled() && c.getJid().asBareJid().equals(xmppUri.getJid()) && ((c.getMode() == Conversational.MODE_MULTI) == xmppUri.isAction(XmppUri.ACTION_JOIN))) { findings.add(c); } } diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java index a72299cd3..0638f3894 100644 --- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -167,7 +167,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp @Override protected String getShareableUri(boolean http) { if (http) { - return "https://conversations.im/j/" + XmppUri.lameUrlEncode(contact.getJid().asBareJid().toEscapedString()); + return "https://conversations.im/i/" + XmppUri.lameUrlEncode(contact.getJid().asBareJid().toEscapedString()); } else { return "xmpp:" + contact.getJid().asBareJid().toEscapedString(); } diff --git a/src/main/java/eu/siacs/conversations/ui/text/FixedURLSpan.java b/src/main/java/eu/siacs/conversations/ui/text/FixedURLSpan.java index f006f2a47..0843c214f 100644 --- a/src/main/java/eu/siacs/conversations/ui/text/FixedURLSpan.java +++ b/src/main/java/eu/siacs/conversations/ui/text/FixedURLSpan.java @@ -42,6 +42,8 @@ import android.util.Log; import android.view.View; import android.widget.Toast; +import java.util.Arrays; + import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.ui.ConversationsActivity; @@ -68,7 +70,8 @@ public class FixedURLSpan extends URLSpan { public void onClick(View widget) { final Uri uri = Uri.parse(getURL()); final Context context = widget.getContext(); - if (uri.getScheme().equals("xmpp") && context instanceof ConversationsActivity) { + final boolean candidateToProcessDirecty = "xmpp".equals(uri.getScheme()) || ("https".equals(uri.getScheme()) && "conversations.im".equals(uri.getHost()) && uri.getPathSegments().size() > 1 && Arrays.asList("j","i").contains(uri.getPathSegments().get(0))); + if (candidateToProcessDirecty && context instanceof ConversationsActivity) { if (((ConversationsActivity) context).onXmppUriClicked(uri)) { widget.playSoundEffect(0); return;