diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-05-28 22:21:37 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-05-28 22:21:37 +0200 |
commit | 08370421bff0a90920557cbf2de9b72db436a118 (patch) | |
tree | 170265935af9fb1c12003a09c64018f2767a8591 /src/main/java/eu/siacs/conversations/ui/adapter | |
parent | 5ec8a55ba51aa60862ec77eecb017257105fac80 (diff) | |
parent | fde27f447f008c79b797214d6351dee770b39f96 (diff) |
Merge remote-tracking branch 'refs/remotes/siacs/master'
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui/adapter')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java | 20 |
1 files changed, 19 insertions, 1 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 54cf97933..a22a4bb7f 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -39,6 +39,7 @@ import java.net.URL; import java.util.HashMap; import java.util.List; import java.util.concurrent.RejectedExecutionException; +import java.util.regex.MatchResult; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -362,14 +363,31 @@ public class MessageAdapter extends ArrayAdapter<Message> { viewHolder.messageBody.setText(span); } int urlCount = 0; - Matcher matcher = Patterns.WEB_URL.matcher(body); + final Matcher matcher = Patterns.WEB_URL.matcher(body); + int beginWebURL = Integer.MAX_VALUE; + int endWebURL = 0; while (matcher.find()) { + MatchResult result = matcher.toMatchResult(); + beginWebURL = result.start(); + endWebURL = result.end(); urlCount++; } + final Matcher geoMatcher = GeoHelper.GEO_URI.matcher(body); + while (geoMatcher.find()) { + urlCount++; + } + final Matcher xmppMatcher = XMPP_PATTERN.matcher(body); + while (xmppMatcher.find()) { + MatchResult result = xmppMatcher.toMatchResult(); + if (beginWebURL < result.start() || endWebURL > result.end()) { + urlCount++; + } + } viewHolder.messageBody.setTextIsSelectable(urlCount <= 1); viewHolder.messageBody.setAutoLinkMask(0); Linkify.addLinks(viewHolder.messageBody, Linkify.WEB_URLS); Linkify.addLinks(viewHolder.messageBody, XMPP_PATTERN, "xmpp"); + Linkify.addLinks(viewHolder.messageBody, GeoHelper.GEO_URI, "geo"); } else { viewHolder.messageBody.setText(""); viewHolder.messageBody.setTextIsSelectable(false); |