diff options
author | steckbrief <steckbrief@chefmail.de> | 2015-12-16 21:55:02 +0100 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2015-12-16 21:55:02 +0100 |
commit | 4f0061293e1d8e90d2828deeb6b72d8a2c8bd509 (patch) | |
tree | a365b75f1d8cd49639b0e6b597aeb48ea82b1773 /libs/emojicon | |
parent | f49b979cbe96a81c7f20f209bec7e5a1c9f3c24f (diff) | |
parent | c26335f3e366110366eb89025a42875bcb7840a9 (diff) |
Merge remote-tracking branch 'remotes/origin/trz/rename' into trz/rebase
Diffstat (limited to 'libs/emojicon')
-rw-r--r-- | libs/emojicon/build.gradle | 1 | ||||
-rw-r--r-- | libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconHandler.java | 18 |
2 files changed, 12 insertions, 7 deletions
diff --git a/libs/emojicon/build.gradle b/libs/emojicon/build.gradle index a9776be0..8673b750 100644 --- a/libs/emojicon/build.gradle +++ b/libs/emojicon/build.gradle @@ -12,7 +12,6 @@ android { buildTypes { release { minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } } 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..5523314b 100644 --- a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconHandler.java +++ b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconHandler.java @@ -1406,6 +1406,7 @@ public final class EmojiconHandler { } public static final Map<Pattern, Integer> ANDROID_EMOTICONS = new HashMap<Pattern, Integer>(); + private static final Pattern TIME_AND_SCORING_PATTERN = Pattern.compile("[0-9]{1,3}:[0-9]{1,3}"); private static final Spannable.Factory spannableFactory = Spannable.Factory .getInstance(); @@ -1448,9 +1449,14 @@ public final class EmojiconHandler { boolean hasChanges = false; Matcher webUrlMatcher = Patterns.WEB_URL.matcher(spannable); - Set<Pair<Integer, Integer>> webUrls = new HashSet<Pair<Integer, Integer>>(); + Set<Pair<Integer, Integer>> falsePositives = new HashSet<Pair<Integer, Integer>>(); while (webUrlMatcher.find()) { - webUrls.add(Pair.create(webUrlMatcher.start(), webUrlMatcher.end())); + falsePositives.add(Pair.create(webUrlMatcher.start(), webUrlMatcher.end())); + } + + Matcher timeAndScoringMatcher = TIME_AND_SCORING_PATTERN.matcher(spannable); + while (timeAndScoringMatcher.find()) { + falsePositives.add(Pair.create(timeAndScoringMatcher.start(), timeAndScoringMatcher.end())); } Map<Pattern, Integer> emoticons = ANDROID_EMOTICONS; @@ -1469,10 +1475,10 @@ public final class EmojiconHandler { } } if (set) { - // check that found emojicon is not in an web url - for (Pair<Integer, Integer> webUrl : webUrls) { - if ((matcher.start() >= webUrl.first && matcher.start() <= webUrl.second) - || (matcher.end() >= webUrl.first && matcher.end() <= webUrl.second)) { + // check that found emojicon is not in an web url or in a time or in a scoring + for (Pair<Integer, Integer> falsePositive : falsePositives) { + if ((matcher.start() >= falsePositive.first && matcher.start() <= falsePositive.second) + || (matcher.end() >= falsePositive.first && matcher.end() <= falsePositive.second)) { set = false; break; } |