From 8ea2a19707ae22fda1d0952333d75cb72fbccbc6 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Fri, 15 Nov 2013 10:49:13 +0100 Subject: [PATCH] Added option to clear search suggestions history in System settings. Also removed the unused TorrentSearchHistoryProvider class. --- core/res/values/strings.xml | 8 ++-- core/res/xml/pref_system.xml | 4 ++ core/res/xml/searchable.xml | 2 +- .../core/gui/search/SearchActivity.java | 14 +++---- .../gui/search/SearchHistoryProvider.java | 5 +-- .../search/TorrentSearchHistoryProvider.java | 42 ------------------- .../gui/settings/SystemSettingsActivity.java | 12 ++++++ full/AndroidManifest.xml | 4 +- 8 files changed, 33 insertions(+), 58 deletions(-) delete mode 100644 core/src/org/transdroid/core/gui/search/TorrentSearchHistoryProvider.java diff --git a/core/res/values/strings.xml b/core/res/values/strings.xml index c2fd3083..b03014c9 100644 --- a/core/res/values/strings.xml +++ b/core/res/values/strings.xml @@ -59,7 +59,7 @@ Normal High Remote play in VLC - Download using (S)FTP + Download using FTP(S) Show details Remove settings Visit transdroid.org @@ -249,9 +249,9 @@ Manually set absolute path for remote connections Connection timeout Number of seconds before a connection attempt is aborted - Base (S)FTP url + Base FTP(S) url For example ftp://me@server/downloads/ - (S)FTP password + FTP(S) password Disable authentication Don\'t send username and password Use SSL @@ -279,6 +279,8 @@ Check transdroid.org for latest app version Use dark UI theme Requires a restart to take effect + Clear search history + Search history is cleared Import settings %1$s will try to import server, web search, RSS and system settings from: %2$s Settings successfully imported diff --git a/core/res/xml/pref_system.xml b/core/res/xml/pref_system.xml index d46c8d94..7060eb10 100644 --- a/core/res/xml/pref_system.xml +++ b/core/res/xml/pref_system.xml @@ -39,6 +39,10 @@ android:title="@string/pref_installhelp" android:summary="@string/pref_installhelp_info" /> + + diff --git a/core/res/xml/searchable.xml b/core/res/xml/searchable.xml index aab9caad..52cc1559 100644 --- a/core/res/xml/searchable.xml +++ b/core/res/xml/searchable.xml @@ -18,6 +18,6 @@ diff --git a/core/src/org/transdroid/core/gui/search/SearchActivity.java b/core/src/org/transdroid/core/gui/search/SearchActivity.java index 1031723c..fe5e91c4 100644 --- a/core/src/org/transdroid/core/gui/search/SearchActivity.java +++ b/core/src/org/transdroid/core/gui/search/SearchActivity.java @@ -78,8 +78,8 @@ public class SearchActivity extends SherlockFragmentActivity implements OnNaviga @SystemService protected SearchManager searchManager; private MenuItem searchMenu = null; - private SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, - TorrentSearchHistoryProvider.AUTHORITY, TorrentSearchHistoryProvider.MODE); + private SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, SearchHistoryProvider.AUTHORITY, + SearchHistoryProvider.MODE); private List searchSites; private SearchSetting lastUsedSite; @@ -207,7 +207,7 @@ public class SearchActivity extends SherlockFragmentActivity implements OnNaviga } return true; } - + @TargetApi(Build.VERSION_CODES.HONEYCOMB) @OptionsItem(android.R.id.home) protected void navigateUp() { @@ -260,15 +260,15 @@ public class SearchActivity extends SherlockFragmentActivity implements OnNaviga // Close the search view in the ation bar searchMenu.collapseActionView(); } - + if (lastUsedSite instanceof WebsearchSetting) { - + // Start a browser page directly to the requested search results WebsearchSetting websearch = (WebsearchSetting) lastUsedSite; startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(String.format(websearch.getBaseUrl(), lastUsedQuery)))); finish(); - + } else if (lastUsedSite instanceof SearchSite) { // Save the search site currently used to search for future usage @@ -279,7 +279,7 @@ public class SearchActivity extends SherlockFragmentActivity implements OnNaviga lastUsedSite.getName()))); // Ask the results fragment to start a search for the specified query fragmentResults.startSearch(lastUsedQuery, (SearchSite) lastUsedSite); - + } } diff --git a/core/src/org/transdroid/core/gui/search/SearchHistoryProvider.java b/core/src/org/transdroid/core/gui/search/SearchHistoryProvider.java index f2219239..546531fa 100644 --- a/core/src/org/transdroid/core/gui/search/SearchHistoryProvider.java +++ b/core/src/org/transdroid/core/gui/search/SearchHistoryProvider.java @@ -34,8 +34,7 @@ public class SearchHistoryProvider extends SearchRecentSuggestionsProvider { } public static void clearHistory(Context context) { - SearchRecentSuggestions suggestions = new SearchRecentSuggestions(context, SearchHistoryProvider.AUTHORITY, - SearchHistoryProvider.MODE); - suggestions.clearHistory(); + new SearchRecentSuggestions(context, AUTHORITY, MODE).clearHistory(); } + } diff --git a/core/src/org/transdroid/core/gui/search/TorrentSearchHistoryProvider.java b/core/src/org/transdroid/core/gui/search/TorrentSearchHistoryProvider.java deleted file mode 100644 index 824136c9..00000000 --- a/core/src/org/transdroid/core/gui/search/TorrentSearchHistoryProvider.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2010-2013 Eric Kok et al. - * - * Transdroid is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Transdroid is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Transdroid. If not, see . - */ -package org.transdroid.core.gui.search; - -import android.content.Context; -import android.content.SearchRecentSuggestionsProvider; -import android.provider.SearchRecentSuggestions; - -/** - * Provides a wrapper for the {@link SearchRecentSuggestionsProvider} to show the last torrent searches to the user. - * @author Eric Kok - */ -public class TorrentSearchHistoryProvider extends SearchRecentSuggestionsProvider { - - public static final String AUTHORITY = "org.transdroid.core.gui.search.TorrentSearchHistoryProvider"; - public static final int MODE = DATABASE_MODE_QUERIES; - - public TorrentSearchHistoryProvider() { - super(); - setupSuggestions(AUTHORITY, MODE); - } - - public static void clearHistory(Context context) { - SearchRecentSuggestions suggestions = new SearchRecentSuggestions(context, - TorrentSearchHistoryProvider.AUTHORITY, TorrentSearchHistoryProvider.MODE); - suggestions.clearHistory(); - } -} diff --git a/core/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java b/core/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java index 30aae1f1..cae772ef 100644 --- a/core/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java +++ b/core/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java @@ -30,6 +30,7 @@ import org.transdroid.core.app.settings.SystemSettings; import org.transdroid.core.gui.log.ErrorLogSender; import org.transdroid.core.gui.navigation.DialogHelper; import org.transdroid.core.gui.navigation.NavigationHelper; +import org.transdroid.core.gui.search.SearchHistoryProvider; import org.transdroid.core.service.BootReceiver; import android.annotation.TargetApi; @@ -86,6 +87,7 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity { findPreference("system_sendlog").setOnPreferenceClickListener(onSendLogClick); findPreference("system_installhelp").setOnPreferenceClickListener(onInstallHelpClick); findPreference("system_changelog").setOnPreferenceClickListener(onChangeLogClick); + findPreference("system_clearsearch").setOnPreferenceClickListener(onClearSearchClick); findPreference("system_importsettings").setOnPreferenceClickListener(onImportSettingsClick); findPreference("system_exportsettings").setOnPreferenceClickListener(onExportSettingsClick); findPreference("system_about").setTitle(getString(R.string.pref_about, getString(R.string.app_name))); @@ -152,6 +154,16 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity { } }; + private OnPreferenceClickListener onClearSearchClick = new OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + SearchHistoryProvider.clearHistory(getApplicationContext()); + Crouton.showText(SystemSettingsActivity.this, R.string.pref_clearsearch_success, + NavigationHelper.CROUTON_INFO_STYLE); + return true; + } + }; + private OnPreferenceClickListener onAboutClick = new OnPreferenceClickListener() { @SuppressWarnings("deprecation") @Override diff --git a/full/AndroidManifest.xml b/full/AndroidManifest.xml index 3242a73b..da9ffc01 100644 --- a/full/AndroidManifest.xml +++ b/full/AndroidManifest.xml @@ -221,8 +221,8 @@