Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add preference option for unlimited search history #2666

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public class SearchFragment
private String nextPageUrl;
private String contentCountry;
private boolean isSuggestionsEnabled = true;
private boolean isUnlimitedSearchHistory = false;

private final PublishSubject<String> suggestionPublisher = PublishSubject.create();
private Disposable searchDisposable;
Expand Down Expand Up @@ -190,6 +191,7 @@ public void onCreate(Bundle savedInstanceState) {

SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
isSuggestionsEnabled = preferences.getBoolean(getString(R.string.show_search_suggestions_key), true);
isUnlimitedSearchHistory = preferences.getBoolean(getString(R.string.unlimited_search_history_key), false);
contentCountry = preferences.getString(getString(R.string.content_country_key), getString(R.string.default_country_value));
}

Expand Down Expand Up @@ -637,7 +639,9 @@ private void initSuggestionObserver() {
suggestionDisposable = observable
.switchMap(query -> {
final Flowable<List<SearchHistoryEntry>> flowable = historyRecordManager
.getRelatedSearches(query, 3, 25);
.getRelatedSearches(query,
isUnlimitedSearchHistory ? -1 : 3,
isUnlimitedSearchHistory ? -1 : 25);
final Observable<List<SuggestionItem>> local = flowable.toObservable()
.map(searchHistoryEntries -> {
List<SuggestionItem> result = new ArrayList<>();
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-nb-rNO/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@
<string name="show_search_suggestions_summary">Vis søkeforslag ved søk</string>
<string name="enable_search_history_title">Søkehistorikk</string>
<string name="enable_search_history_summary">Lagre søkemønster lokalt</string>
<string name="unlimited_search_history_title">Ubegrenset søkehistorikk</string>
<string name="unlimited_search_history_summary">Ubegrenset antall føringer i søkehistorikken</string>
<string name="enable_watch_history_title">Visningshistorikk</string>
<string name="enable_watch_history_summary">Lagre visningshistorikk</string>
<string name="settings_category_popup_title">Oppsprett</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/settings_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
<string name="show_age_restricted_content" translatable="false">show_age_restricted_content</string>
<string name="use_tor_key" translatable="false">use_tor</string>
<string name="enable_search_history_key" translatable="false">enable_search_history</string>
<string name="unlimited_search_history_key" translatable="false">unlimited_search_history</string>
<string name="enable_watch_history_key" translatable="false">enable_watch_history</string>
<string name="main_page_content_key" translatable="false">main_page_content</string>
<string name="enable_playback_resume_key" translatable="false">enable_playback_resume</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
<string name="show_search_suggestions_summary">Show suggestions when searching</string>
<string name="enable_search_history_title">Search history</string>
<string name="enable_search_history_summary">Store search queries locally</string>
<string name="unlimited_search_history_title">Unlimited search history</string>
<string name="unlimited_search_history_summary">Unlimited search history entries</string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better suited description would probably be "Show as many search suggestions as possible from history"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this show all suggestions or only the related ones? Maybe "Display all (related) entries from search history" does also fit.

<string name="enable_watch_history_title">Watch history</string>
<string name="enable_playback_resume_title">Resume playback</string>
<string name="enable_playback_resume_summary">Restore last playback position</string>
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/xml/history_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
android:title="@string/enable_search_history_title"
app:iconSpaceReserved="false" />

<SwitchPreference
android:defaultValue="false"
android:key="@string/unlimited_search_history_key"
android:summary="@string/unlimited_search_history_summary"
android:title="@string/unlimited_search_history_title"
android:dependency="@string/enable_search_history_key"
app:iconSpaceReserved="false" />

<PreferenceCategory
android:layout="@layout/settings_category_header_layout"
android:title="@string/settings_category_clear_data_title"
Expand Down