Skip to content

Commit 2558acd

Browse files
feat(theming): Remove NotesViewThemeUtils#getOnPrimaryContainer in favor of AndroidViewThemeUtils#highlightText
Signed-off-by: Stefan Niedermann <info@niedermann.it>
1 parent 990a5b5 commit 2558acd

2 files changed

Lines changed: 5 additions & 29 deletions

File tree

app/src/main/java/it/niedermann/owncloud/notes/branding/NotesViewThemeUtils.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,6 @@ public NotesViewThemeUtils(@NonNull MaterialSchemes schemes) {
4141
super(schemes);
4242
}
4343

44-
/**
45-
* Use {@link ColorRole#ON_PRIMARY_CONTAINER}
46-
*/
47-
@Deprecated(forRemoval = true)
48-
@ColorInt
49-
public int getOnPrimaryContainer(@NonNull Context context) {
50-
return withScheme(context, Scheme::getOnPrimaryContainer);
51-
}
52-
5344
/**
5445
* The Notes app uses custom navigation view items because they have several features which are
5546
* not covered by {@link NavigationItem}.

app/src/main/java/it/niedermann/owncloud/notes/main/items/NoteViewHolder.java

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,28 +89,13 @@ protected void bindFavorite(@NonNull ImageView noteFavorite, boolean isFavorite)
8989
noteFavorite.setOnClickListener(view -> noteClickListener.onNoteFavoriteClick(getLayoutPosition(), view));
9090
}
9191

92-
protected void bindSearchableContent(@NonNull Context context, @NonNull TextView textView, @Nullable CharSequence searchQuery, @NonNull String content, int mainColor) {
93-
CharSequence processedContent = content;
94-
if (!TextUtils.isEmpty(searchQuery)) {
95-
final var util = BrandingUtil.of(mainColor, context);
96-
@ColorInt final int searchForeground = util.notes.getOnPrimaryContainer(context);
97-
@ColorInt final int searchBackground = ContextCompat.getColor(context, R.color.bg_highlighted);
98-
99-
// The Pattern.quote method will add \Q to the very beginning of the string and \E to the end of the string
100-
// It implies that the string between \Q and \E is a literal string and thus the reserved keyword in such string will be ignored.
101-
// See https://stackoverflow.com/questions/15409296/what-is-the-use-of-pattern-quote-method
102-
final Pattern pattern = Pattern.compile("(" + Pattern.quote(searchQuery.toString()) + ")", Pattern.CASE_INSENSITIVE);
103-
SpannableString spannableString = new SpannableString(content);
104-
Matcher matcher = pattern.matcher(spannableString);
105-
106-
while (matcher.find()) {
107-
spannableString.setSpan(new ForegroundColorSpan(searchForeground), matcher.start(), matcher.end(), 0);
108-
spannableString.setSpan(new BackgroundColorSpan(searchBackground), matcher.start(), matcher.end(), 0);
109-
}
92+
protected void bindSearchableContent(@NonNull Context context, @NonNull TextView textView, @Nullable CharSequence searchQuery, @NonNull String content, int color) {
93+
textView.setText(content);
11094

111-
processedContent = spannableString;
95+
if (!TextUtils.isEmpty(searchQuery)) {
96+
final var util = BrandingUtil.of(color, context);
97+
util.platform.highlightText(textView, content, searchQuery.toString());
11298
}
113-
textView.setText(processedContent);
11499
}
115100

116101
public abstract void showSwipe(boolean left);

0 commit comments

Comments
 (0)