aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-12-10 21:35:54 +0100
committerChristian Schneppe <christian@pix-art.de>2017-12-10 21:35:54 +0100
commit869a475235833392042097d78424f57fe9e82e09 (patch)
tree9955a2d43f01f11a3462b6644d316cc9be6ab576 /src/main/java/de/pixart/messenger
parenta1e3198deea193cf4392b0a37d724ebfb1ab4d19 (diff)
Do not show xmpp uris as links that have invalid jids
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
index acb8a6190..5e158415b 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
@@ -81,6 +81,7 @@ import de.pixart.messenger.utils.GeoHelper;
import de.pixart.messenger.utils.Patterns;
import de.pixart.messenger.utils.StylingHelper;
import de.pixart.messenger.utils.UIHelper;
+import de.pixart.messenger.utils.XmppUri;
import de.pixart.messenger.xmpp.mam.MamReference;
public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextView.CopyHandler {
@@ -120,6 +121,14 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
}
};
+ private static final Linkify.MatchFilter XMPPURI_MATCH_FILTER = new Linkify.MatchFilter() {
+ @Override
+ public boolean acceptMatch(CharSequence s, int start, int end) {
+ XmppUri uri = new XmppUri(s.subSequence(start, end).toString());
+ return uri.isJidValid();
+ }
+ };
+
private final ConversationActivity activity;
private DisplayMetrics metrics;
@@ -534,7 +543,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
}
}
StylingHelper.format(body, viewHolder.messageBody.getCurrentTextColor());
- Linkify.addLinks(body, XMPP_PATTERN, "xmpp");
+ Linkify.addLinks(body, XMPP_PATTERN, "xmpp", XMPPURI_MATCH_FILTER, null);
Linkify.addLinks(body, Patterns.AUTOLINK_WEB_URL, "http", WEBURL_MATCH_FILTER, WEBURL_TRANSFORM_FILTER);
Linkify.addLinks(body, GeoHelper.GEO_URI, "geo");
FixedURLSpan.fix(body);