diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-06-06 11:46:30 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-06-06 11:46:30 +0300 |
commit | 52531d601761e55d0a9b883d8a380eb1b28aad66 (patch) | |
tree | aab06acfdb9240dca95b35f733385034a208dd8a /app/src/main | |
parent | 613cf63c9a62d99a7c67a3b83e2377feb2b6d9b3 (diff) |
Reapply patch from #851
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolder.java | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolder.java b/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolder.java index 3b665c23..a42c8377 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolder.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolder.java @@ -110,7 +110,10 @@ public class NoteViewHolder extends RecyclerView.ViewHolder implements View.OnLo @ColorInt final int searchBackground = context.getResources().getColor(R.color.bg_highlighted); @ColorInt final int searchForeground = BrandingUtil.getSecondaryForegroundColorDependingOnTheme(context, mainColor); - final Pattern pattern = Pattern.compile("(" + searchQuery + ")", Pattern.CASE_INSENSITIVE); + // The Pattern.quote method will add \Q to the very beginning of the string and \E to the end of the string + // It implies that the string between \Q and \E is a literal string and thus the reserved keyword in such string will be ignored. + // See https://stackoverflow.com/questions/15409296/what-is-the-use-of-pattern-quote-method + final Pattern pattern = Pattern.compile("(" + Pattern.quote(searchQuery.toString()) + ")", Pattern.CASE_INSENSITIVE); SpannableString spannableString = new SpannableString(note.getTitle()); Matcher matcher = pattern.matcher(spannableString); while (matcher.find()) { |