@Override
 public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
   final String key = preference.getKey();
   if (KEY_CLEAR_SEARCH_HISTORY.equals(key)) {
     SearchRecentSuggestions suggestions =
         new SearchRecentSuggestions(
             getActivity(),
             Utils.getSearchAuthority(getActivity()),
             CalendarRecentSuggestionsProvider.MODE);
     suggestions.clearHistory();
     Toast.makeText(getActivity(), R.string.search_history_cleared, Toast.LENGTH_SHORT).show();
     return true;
   } else {
     return super.onPreferenceTreeClick(preferenceScreen, preference);
   }
 }
Esempio n. 2
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    int id = item.getItemId();

    switch (id) {
      case R.id.action_settings: // TODO
        return true;

      case R.id.itm_action_search: // TODO
        showSearch(true);
        return true;

      case R.id.action_clear_history: // ok
        suggestions.clearHistory();
        return true;
    }
    return super.onOptionsItemSelected(item);
  }