Clear search history (#173)

* Long press on magnifying glass to clear search history

* Long press on magnifying glass to clear search history

* Long press on magnifying glass to clear search history

* Long press on magnifying glass to clear search history

* Long press on magnifying glass to clear search history

* Long press on magnifying glass to clear search history
This commit is contained in:
Don Kimberlin 2020-06-20 06:10:25 -07:00 committed by GitHub
parent ceb2f44beb
commit ee64df7fc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -19,8 +19,10 @@
package net.schueller.peertube.activity; package net.schueller.peertube.activity;
import android.Manifest; import android.Manifest;
import android.app.AlertDialog;
import android.app.SearchManager; import android.app.SearchManager;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@ -146,6 +148,26 @@ public class VideoListActivity extends CommonActivity {
searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
searchView.setQueryRefinementEnabled(true); searchView.setQueryRefinementEnabled(true);
searchMenuItem.getActionView().setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
new AlertDialog.Builder(VideoListActivity.this)
.setTitle(getString(R.string.clear_search_history))
.setMessage(getString(R.string.clear_search_history_prompt))
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(getApplicationContext(),
SearchSuggestionsProvider.AUTHORITY,
SearchSuggestionsProvider.MODE);
suggestions.clearHistory();
}
})
.setNegativeButton(android.R.string.no, null)
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
return true;
}
});
searchMenuItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() { searchMenuItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
@Override @Override
public boolean onMenuItemActionExpand(MenuItem menuItem) { public boolean onMenuItemActionExpand(MenuItem menuItem) {

View File

@ -65,6 +65,8 @@
<string name="pref_language_app">Application Language</string> <string name="pref_language_app">Application Language</string>
<string name="pref_description_language_app">Select language for application interface. Restart app for change to take effect.</string> <string name="pref_description_language_app">Select language for application interface. Restart app for change to take effect.</string>
<string name="clear_search_history">Clear Search History</string>
<string name="clear_search_history_prompt">Do you want to permanently delete the search history?</string>
<!-- languages --> <!-- languages -->
<string name="ab">Abkhazian</string> <string name="ab">Abkhazian</string>
<string name="aa">Afar</string> <string name="aa">Afar</string>