aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/utils
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-05-03 21:38:02 +0200
committerChristian Schneppe <christian@pix-art.de>2018-05-03 21:38:02 +0200
commitcac0d886bdaee1fbbd57b03192c4f57d5889e40b (patch)
tree2711e41f8bc0e0f7ebcea363874111c2d88b0e1b /src/main/java/de/pixart/messenger/utils
parent70e50a27921e2250920c2143c13ccbb0b425377a (diff)
only highlight alphanumeric chars
Diffstat (limited to 'src/main/java/de/pixart/messenger/utils')
-rw-r--r--src/main/java/de/pixart/messenger/utils/StylingHelper.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/utils/StylingHelper.java b/src/main/java/de/pixart/messenger/utils/StylingHelper.java
index f429a2573..9db7b2b47 100644
--- a/src/main/java/de/pixart/messenger/utils/StylingHelper.java
+++ b/src/main/java/de/pixart/messenger/utils/StylingHelper.java
@@ -47,6 +47,7 @@ import android.text.style.TypefaceSpan;
import android.widget.EditText;
import android.widget.TextView;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -99,6 +100,25 @@ public class StylingHelper {
}
}
+ public static List<String> filterHighlightedWords(List<String> terms) {
+ List<String> words = new ArrayList<>();
+ for (String term : terms) {
+ if (!FtsUtils.isKeyword(term)) {
+ StringBuilder builder = new StringBuilder();
+ for (int codepoint, i = 0; i < term.length(); i += Character.charCount(codepoint)) {
+ codepoint = term.codePointAt(i);
+ if (Character.isLetterOrDigit(codepoint)) {
+ builder.append(Character.toChars(codepoint));
+ }
+ }
+ if (builder.length() > 0) {
+ words.add(builder.toString());
+ }
+ }
+ }
+ return words;
+ }
+
private static void highlight(final Context context, final Editable editable, String needle, boolean dark) {
final int length = needle.length();
String string = editable.toString();