aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs
diff options
context:
space:
mode:
authorTarun <tarun1995gupta@gmail.com>2016-02-29 23:35:50 +0530
committerTarun <tarun1995gupta@gmail.com>2016-02-29 23:35:50 +0530
commitdf7b399e04c9a5c6e20b0f0096bbe3b240ff2488 (patch)
treed65f0a8ea7c83d785cf4d04453dada946e160e84 /src/main/java/eu/siacs
parentddafa65849e6c7e8d17566208b57ec614de05d5f (diff)
Fix Issue #1634 : Shows XMPP URI as links.
Shows XMPP URI as links, other than Web URL's and Email Addresses. Also performs respective actions on clicking XMPP URI.
Diffstat (limited to 'src/main/java/eu/siacs')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index f6496b21..9339809c 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -17,6 +17,7 @@ import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.text.style.RelativeSizeSpan;
import android.text.style.StyleSpan;
+import android.text.util.Linkify;
import android.util.DisplayMetrics;
import android.util.Patterns;
import android.view.View;
@@ -34,6 +35,7 @@ import java.lang.ref.WeakReference;
import java.util.List;
import java.util.concurrent.RejectedExecutionException;
import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
@@ -53,6 +55,11 @@ public class MessageAdapter extends ArrayAdapter<Message> {
private static final int SENT = 0;
private static final int RECEIVED = 1;
private static final int STATUS = 2;
+ private static final Pattern XMPP_PATTERN = Pattern
+ .compile("xmpp\\:(?:(?:["
+ + Patterns.GOOD_IRI_CHAR
+ + "\\;\\/\\?\\@\\&\\=\\#\\~\\-\\.\\+\\!\\*\\'\\(\\)\\,\\_])"
+ + "|(?:\\%[a-fA-F0-9]{2}))+");
private ConversationActivity activity;
@@ -349,6 +356,9 @@ public class MessageAdapter extends ArrayAdapter<Message> {
urlCount++;
}
viewHolder.messageBody.setTextIsSelectable(urlCount <= 1);
+ viewHolder.messageBody.setAutoLinkMask(0);
+ Linkify.addLinks(viewHolder.messageBody, Linkify.WEB_URLS);
+ Linkify.addLinks(viewHolder.messageBody, XMPP_PATTERN, "xmpp");
} else {
viewHolder.messageBody.setText("");
viewHolder.messageBody.setTextIsSelectable(false);