From 1c44fd8a4b7956eb9b635b9e943286757100a8bf Mon Sep 17 00:00:00 2001 From: steckbrief Date: Mon, 14 Dec 2015 15:15:00 +0100 Subject: Fixes FS#88: Avoid smilie repacement in time messages --- .../github/ankushsachdeva/emojicon/EmojiconHandler.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'libs/emojicon') diff --git a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconHandler.java b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconHandler.java index bc1d670d..81c6c393 100644 --- a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconHandler.java +++ b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconHandler.java @@ -1448,9 +1448,14 @@ public final class EmojiconHandler { boolean hasChanges = false; Matcher webUrlMatcher = Patterns.WEB_URL.matcher(spannable); - Set> webUrls = new HashSet>(); + Set> falsePositives = new HashSet>(); while (webUrlMatcher.find()) { - webUrls.add(Pair.create(webUrlMatcher.start(), webUrlMatcher.end())); + falsePositives.add(Pair.create(webUrlMatcher.start(), webUrlMatcher.end())); + } + + Matcher timeAndScoringMatcher = Pattern.compile("[0-9]{1,3}:[0-9]{1,3}").matcher(spannable); + while (timeAndScoringMatcher.find()) { + falsePositives.add(Pair.create(timeAndScoringMatcher.start(), timeAndScoringMatcher.end())); } Map emoticons = ANDROID_EMOTICONS; @@ -1469,8 +1474,8 @@ public final class EmojiconHandler { } } if (set) { - // check that found emojicon is not in an web url - for (Pair webUrl : webUrls) { + // check that found emojicon is not in an web url or in a time or in a scoring + for (Pair webUrl : falsePositives) { if ((matcher.start() >= webUrl.first && matcher.start() <= webUrl.second) || (matcher.end() >= webUrl.first && matcher.end() <= webUrl.second)) { set = false; -- cgit v1.2.3