diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java index 54abbc7..107a200 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java @@ -19,8 +19,10 @@ package net.schueller.peertube.activity; import android.Manifest; +import android.app.AlertDialog; import android.app.SearchManager; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; 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.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() { @Override public boolean onMenuItemActionExpand(MenuItem menuItem) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c9cccd5..fdc857d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -65,6 +65,8 @@ Application Language Select language for application interface. Restart app for change to take effect. + Clear Search History + Do you want to permanently delete the search history? Abkhazian Afar