Merge pull request #568 from mauriciocolli/option-search-suggestions

Add option to disable the search suggestions
This commit is contained in:
Mauricio Colli 2017-05-16 22:17:28 -03:00 committed by GitHub
commit b260570e8c
4 changed files with 18 additions and 0 deletions

View file

@ -5,6 +5,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
@ -68,6 +69,7 @@ public class SearchFragment extends BaseFragment implements SuggestionWorker.OnS
private int serviceId = -1;
private String searchQuery = "";
private int pageNumber = 0;
private boolean showSuggestions = true;
private SearchWorker curSearchWorker;
private SuggestionWorker curSuggestionWorker;
@ -135,6 +137,8 @@ public class SearchFragment extends BaseFragment implements SuggestionWorker.OnS
if (pageNumber > 0) search(searchQuery, pageNumber);
else search(searchQuery, 0, true);
}
showSuggestions = PreferenceManager.getDefaultSharedPreferences(activity).getBoolean(getString(R.string.show_search_suggestions_key), true);
}
@Override
@ -523,6 +527,11 @@ public class SearchFragment extends BaseFragment implements SuggestionWorker.OnS
}
private void searchSuggestions(String query) {
if (!showSuggestions) {
if (DEBUG) Log.d(TAG, "searchSuggestions() showSuggestions is disabled");
return;
}
if (DEBUG) Log.d(TAG, "searchSuggestions() called with: query = [" + query + "]");
if (curSuggestionWorker != null && curSuggestionWorker.isRunning()) curSuggestionWorker.cancel();
curSuggestionWorker = SuggestionWorker.startForQuery(activity, serviceId, query, this);

View file

@ -44,6 +44,7 @@
<item>3GPP</item>
</string-array>
<string name="show_search_suggestions_key" translatable="false">show_search_suggestions</string>
<string name="show_play_with_kodi_key" translatable="false">show_play_with_kodi</string>
<string name="theme_key" translatable="false">theme</string>

View file

@ -64,6 +64,8 @@
<string name="popup_remember_size_pos_summary">Remember the last size and position set to the popup</string>
<string name="player_gesture_controls_title">Player gesture controls</string>
<string name="player_gesture_controls_summary">Use gestures to control the brightness and volume of the player</string>
<string name="show_search_suggestions_title">Search suggestions</string>
<string name="show_search_suggestions_summary">Show suggestions when searching</string>
<string name="download_dialog_title">Download</string>
<string-array name="download_options">

View file

@ -155,6 +155,12 @@
android:summary="@string/autoplay_by_calling_app_summary"
android:defaultValue="false" />
<CheckBoxPreference
android:key="@string/show_search_suggestions_key"
android:title="@string/show_search_suggestions_title"
android:summary="@string/show_search_suggestions_summary"
android:defaultValue="true"/>
<!--
<CheckBoxPreference
android:key="@string/use_tor_key"