From 82c3cbaf2a794bbfabe305be08bca217469fbaaa Mon Sep 17 00:00:00 2001 From: GDR! Date: Thu, 26 May 2016 23:26:38 +0200 Subject: [PATCH] Add geo: link support in longer messages --- .../eu/siacs/conversations/ui/adapter/MessageAdapter.java | 5 +++++ src/main/java/eu/siacs/conversations/utils/GeoHelper.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) 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 10179d7e9..c08b41f05 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -356,10 +356,15 @@ public class MessageAdapter extends ArrayAdapter { while (matcher.find()) { urlCount++; } + Matcher geoMatcher = GeoHelper.GEO_URI.matcher(body); + while (matcher.find()) { + 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); diff --git a/src/main/java/eu/siacs/conversations/utils/GeoHelper.java b/src/main/java/eu/siacs/conversations/utils/GeoHelper.java index 9a93df38c..e2e9a212d 100644 --- a/src/main/java/eu/siacs/conversations/utils/GeoHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/GeoHelper.java @@ -14,7 +14,7 @@ import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Message; public class GeoHelper { - private static Pattern GEO_URI = Pattern.compile("geo:([\\-0-9.]+),([\\-0-9.]+)(?:,([\\-0-9.]+))?(?:\\?(.*))?", Pattern.CASE_INSENSITIVE); + public static Pattern GEO_URI = Pattern.compile("geo:([\\-0-9.]+),([\\-0-9.]+)(?:,([\\-0-9.]+))?(?:\\?(.*))?", Pattern.CASE_INSENSITIVE); public static boolean isGeoUri(String body) { return body != null && GEO_URI.matcher(body).matches();