count xmpp uris when disableing text selection
This commit is contained in:
parent
b3f50d1ad0
commit
fde27f447f
|
@ -35,6 +35,7 @@ import java.lang.ref.WeakReference;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.RejectedExecutionException;
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
|
import java.util.regex.MatchResult;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -352,14 +353,26 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||||
viewHolder.messageBody.setText(span);
|
viewHolder.messageBody.setText(span);
|
||||||
}
|
}
|
||||||
int urlCount = 0;
|
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()) {
|
while (matcher.find()) {
|
||||||
|
MatchResult result = matcher.toMatchResult();
|
||||||
|
beginWebURL = result.start();
|
||||||
|
endWebURL = result.end();
|
||||||
urlCount++;
|
urlCount++;
|
||||||
}
|
}
|
||||||
Matcher geoMatcher = GeoHelper.GEO_URI.matcher(body);
|
final Matcher geoMatcher = GeoHelper.GEO_URI.matcher(body);
|
||||||
while (matcher.find()) {
|
while (geoMatcher.find()) {
|
||||||
urlCount++;
|
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.setTextIsSelectable(urlCount <= 1);
|
||||||
viewHolder.messageBody.setAutoLinkMask(0);
|
viewHolder.messageBody.setAutoLinkMask(0);
|
||||||
Linkify.addLinks(viewHolder.messageBody, Linkify.WEB_URLS);
|
Linkify.addLinks(viewHolder.messageBody, Linkify.WEB_URLS);
|
||||||
|
|
Loading…
Reference in a new issue