From d59314801c035ea1292e5c685437ff0b09982c54 Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Mon, 27 Dec 2021 18:57:17 +0100 Subject: [PATCH] Code rework --- .../preferencesearch/PreferenceParser.java | 4 +-- .../PreferenceSearchItem.java | 33 ++++++++++++------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/settings/preferencesearch/PreferenceParser.java b/app/src/main/java/org/schabi/newpipe/settings/preferencesearch/PreferenceParser.java index b52daeb5b..afd2c1b4f 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/preferencesearch/PreferenceParser.java +++ b/app/src/main/java/org/schabi/newpipe/settings/preferencesearch/PreferenceParser.java @@ -5,6 +5,7 @@ import android.text.TextUtils; import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.annotation.XmlRes; import androidx.preference.PreferenceManager; import org.xmlpull.v1.XmlPullParser; @@ -111,7 +112,7 @@ public class PreferenceParser { private PreferenceSearchItem parseSearchResult( final XmlPullParser xpp, final String breadcrumbs, - final int searchIndexItemResId + @XmlRes final int searchIndexItemResId ) { final String key = readString(getAttribute(xpp, "key")); final String[] entries = readStringArray(getAttribute(xpp, "entries")); @@ -130,7 +131,6 @@ public class PreferenceParser { entries, entryValues), TextUtils.join(",", entries), - readString(getAttribute(xpp, NS_SEARCH, "keywords")), breadcrumbs, searchIndexItemResId ); diff --git a/app/src/main/java/org/schabi/newpipe/settings/preferencesearch/PreferenceSearchItem.java b/app/src/main/java/org/schabi/newpipe/settings/preferencesearch/PreferenceSearchItem.java index 3030a78bb..52935ef8e 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/preferencesearch/PreferenceSearchItem.java +++ b/app/src/main/java/org/schabi/newpipe/settings/preferencesearch/PreferenceSearchItem.java @@ -1,6 +1,7 @@ package org.schabi.newpipe.settings.preferencesearch; import androidx.annotation.NonNull; +import androidx.annotation.XmlRes; import java.util.Arrays; import java.util.List; @@ -10,18 +11,35 @@ import java.util.Objects; * Represents a preference-item inside the search. */ public class PreferenceSearchItem { + /** + * Key of the setting/preference. E.g. used inside {@link android.content.SharedPreferences}. + */ @NonNull private final String key; + /** + * Title of the setting, e.g. 'Default resolution' or 'Show higher resolutions'. + */ @NonNull private final String title; + /** + * Summary of the setting, e.g. '480p' or 'Only some devices can play 2k/4k'. + */ @NonNull private final String summary; + /** + * Possible entries of the setting, e.g. 480p,720p,... + */ @NonNull private final String entries; - @NonNull - private final String keywords; + /** + * Breadcrumbs - a hint where the setting is located e.g. 'Video and Audio > Player' + */ @NonNull private final String breadcrumbs; + /** + * The xml-resource where this item was found/built from. + */ + @XmlRes private final int searchIndexItemResId; public PreferenceSearchItem( @@ -29,15 +47,13 @@ public class PreferenceSearchItem { @NonNull final String title, @NonNull final String summary, @NonNull final String entries, - @NonNull final String keywords, @NonNull final String breadcrumbs, - final int searchIndexItemResId + @XmlRes final int searchIndexItemResId ) { this.key = Objects.requireNonNull(key); this.title = Objects.requireNonNull(title); this.summary = Objects.requireNonNull(summary); this.entries = Objects.requireNonNull(entries); - this.keywords = Objects.requireNonNull(keywords); this.breadcrumbs = Objects.requireNonNull(breadcrumbs); this.searchIndexItemResId = searchIndexItemResId; } @@ -62,10 +78,6 @@ public class PreferenceSearchItem { return breadcrumbs; } - public String getKeywords() { - return keywords; - } - public int getSearchIndexItemResId() { return searchIndexItemResId; } @@ -79,8 +91,7 @@ public class PreferenceSearchItem { getTitle(), getSummary(), getEntries(), - getBreadcrumbs(), - getKeywords()); + getBreadcrumbs()); }