Browse Source

Added option to clear search suggestions history in System settings. Also removed the unused TorrentSearchHistoryProvider class.

pull/82/head
Eric Kok 11 years ago
parent
commit
8ea2a19707
  1. 8
      core/res/values/strings.xml
  2. 4
      core/res/xml/pref_system.xml
  3. 2
      core/res/xml/searchable.xml
  4. 14
      core/src/org/transdroid/core/gui/search/SearchActivity.java
  5. 5
      core/src/org/transdroid/core/gui/search/SearchHistoryProvider.java
  6. 42
      core/src/org/transdroid/core/gui/search/TorrentSearchHistoryProvider.java
  7. 12
      core/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java
  8. 4
      full/AndroidManifest.xml

8
core/res/values/strings.xml

@ -59,7 +59,7 @@
<string name="action_priority_normal">Normal</string> <string name="action_priority_normal">Normal</string>
<string name="action_priority_high">High</string> <string name="action_priority_high">High</string>
<string name="action_remoteplay">Remote play in VLC</string> <string name="action_remoteplay">Remote play in VLC</string>
<string name="action_download">Download using (S)FTP</string> <string name="action_download">Download using FTP(S)</string>
<string name="action_showdetails">Show details</string> <string name="action_showdetails">Show details</string>
<string name="action_removesettings">Remove settings</string> <string name="action_removesettings">Remove settings</string>
<string name="action_visitwebsite">Visit transdroid.org</string> <string name="action_visitwebsite">Visit transdroid.org</string>
@ -249,9 +249,9 @@
<string name="pref_downdir_info">Manually set absolute path for remote connections</string> <string name="pref_downdir_info">Manually set absolute path for remote connections</string>
<string name="pref_timeout">Connection timeout</string> <string name="pref_timeout">Connection timeout</string>
<string name="pref_timeout_info">Number of seconds before a connection attempt is aborted</string> <string name="pref_timeout_info">Number of seconds before a connection attempt is aborted</string>
<string name="pref_ftpurl">Base (S)FTP url</string> <string name="pref_ftpurl">Base FTP(S) url</string>
<string name="pref_ftpurl_into">For example ftp://me@server/downloads/</string> <string name="pref_ftpurl_into">For example ftp://me@server/downloads/</string>
<string name="pref_ftppass">(S)FTP password</string> <string name="pref_ftppass">FTP(S) password</string>
<string name="pref_disableauth">Disable authentication</string> <string name="pref_disableauth">Disable authentication</string>
<string name="pref_disableauth_info">Don\'t send username and password</string> <string name="pref_disableauth_info">Don\'t send username and password</string>
<string name="pref_sslenable">Use SSL</string> <string name="pref_sslenable">Use SSL</string>
@ -279,6 +279,8 @@
<string name="pref_checkupdates_info">Check transdroid.org for latest app version</string> <string name="pref_checkupdates_info">Check transdroid.org for latest app version</string>
<string name="pref_usedarktheme">Use dark UI theme</string> <string name="pref_usedarktheme">Use dark UI theme</string>
<string name="pref_usedarktheme_info">Requires a restart to take effect</string> <string name="pref_usedarktheme_info">Requires a restart to take effect</string>
<string name="pref_clearsearch">Clear search history</string>
<string name="pref_clearsearch_success">Search history is cleared</string>
<string name="pref_import">Import settings</string> <string name="pref_import">Import settings</string>
<string name="pref_import_dialog">%1$s will try to import server, web search, RSS and system settings from: %2$s</string> <string name="pref_import_dialog">%1$s will try to import server, web search, RSS and system settings from: %2$s</string>
<string name="pref_import_success">Settings successfully imported</string> <string name="pref_import_success">Settings successfully imported</string>

4
core/res/xml/pref_system.xml

@ -39,6 +39,10 @@
android:title="@string/pref_installhelp" android:title="@string/pref_installhelp"
android:summary="@string/pref_installhelp_info" /> android:summary="@string/pref_installhelp_info" />
<Preference
android:key="system_clearsearch"
android:title="@string/pref_clearsearch" />
<Preference <Preference
android:key="system_importsettings" android:key="system_importsettings"
android:title="@string/pref_import" /> android:title="@string/pref_import" />

2
core/res/xml/searchable.xml

@ -18,6 +18,6 @@
<searchable xmlns:android="http://schemas.android.com/apk/res/android" <searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:hint="@string/search_hint" android:hint="@string/search_hint"
android:label="@string/search_torrentsearch" android:label="@string/search_torrentsearch"
android:searchSuggestAuthority="org.transdroid.core.gui.search.TorrentSearchHistoryProvider" android:searchSuggestAuthority="org.transdroid.core.gui.search.SearchHistoryProvider"
android:searchSuggestThreshold="0" android:searchSuggestThreshold="0"
android:searchSuggestSelection=" ?" /> android:searchSuggestSelection=" ?" />

14
core/src/org/transdroid/core/gui/search/SearchActivity.java

@ -78,8 +78,8 @@ public class SearchActivity extends SherlockFragmentActivity implements OnNaviga
@SystemService @SystemService
protected SearchManager searchManager; protected SearchManager searchManager;
private MenuItem searchMenu = null; private MenuItem searchMenu = null;
private SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, private SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, SearchHistoryProvider.AUTHORITY,
TorrentSearchHistoryProvider.AUTHORITY, TorrentSearchHistoryProvider.MODE); SearchHistoryProvider.MODE);
private List<SearchSetting> searchSites; private List<SearchSetting> searchSites;
private SearchSetting lastUsedSite; private SearchSetting lastUsedSite;
@ -207,7 +207,7 @@ public class SearchActivity extends SherlockFragmentActivity implements OnNaviga
} }
return true; return true;
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @TargetApi(Build.VERSION_CODES.HONEYCOMB)
@OptionsItem(android.R.id.home) @OptionsItem(android.R.id.home)
protected void navigateUp() { protected void navigateUp() {
@ -260,15 +260,15 @@ public class SearchActivity extends SherlockFragmentActivity implements OnNaviga
// Close the search view in the ation bar // Close the search view in the ation bar
searchMenu.collapseActionView(); searchMenu.collapseActionView();
} }
if (lastUsedSite instanceof WebsearchSetting) { if (lastUsedSite instanceof WebsearchSetting) {
// Start a browser page directly to the requested search results // Start a browser page directly to the requested search results
WebsearchSetting websearch = (WebsearchSetting) lastUsedSite; WebsearchSetting websearch = (WebsearchSetting) lastUsedSite;
startActivity(new Intent(Intent.ACTION_VIEW, startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse(String.format(websearch.getBaseUrl(), lastUsedQuery)))); Uri.parse(String.format(websearch.getBaseUrl(), lastUsedQuery))));
finish(); finish();
} else if (lastUsedSite instanceof SearchSite) { } else if (lastUsedSite instanceof SearchSite) {
// Save the search site currently used to search for future usage // Save the search site currently used to search for future usage
@ -279,7 +279,7 @@ public class SearchActivity extends SherlockFragmentActivity implements OnNaviga
lastUsedSite.getName()))); lastUsedSite.getName())));
// Ask the results fragment to start a search for the specified query // Ask the results fragment to start a search for the specified query
fragmentResults.startSearch(lastUsedQuery, (SearchSite) lastUsedSite); fragmentResults.startSearch(lastUsedQuery, (SearchSite) lastUsedSite);
} }
} }

5
core/src/org/transdroid/core/gui/search/SearchHistoryProvider.java

@ -34,8 +34,7 @@ public class SearchHistoryProvider extends SearchRecentSuggestionsProvider {
} }
public static void clearHistory(Context context) { public static void clearHistory(Context context) {
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(context, SearchHistoryProvider.AUTHORITY, new SearchRecentSuggestions(context, AUTHORITY, MODE).clearHistory();
SearchHistoryProvider.MODE);
suggestions.clearHistory();
} }
} }

42
core/src/org/transdroid/core/gui/search/TorrentSearchHistoryProvider.java

@ -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 <http://www.gnu.org/licenses/>.
*/
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();
}
}

12
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.log.ErrorLogSender;
import org.transdroid.core.gui.navigation.DialogHelper; import org.transdroid.core.gui.navigation.DialogHelper;
import org.transdroid.core.gui.navigation.NavigationHelper; import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.gui.search.SearchHistoryProvider;
import org.transdroid.core.service.BootReceiver; import org.transdroid.core.service.BootReceiver;
import android.annotation.TargetApi; import android.annotation.TargetApi;
@ -86,6 +87,7 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity {
findPreference("system_sendlog").setOnPreferenceClickListener(onSendLogClick); findPreference("system_sendlog").setOnPreferenceClickListener(onSendLogClick);
findPreference("system_installhelp").setOnPreferenceClickListener(onInstallHelpClick); findPreference("system_installhelp").setOnPreferenceClickListener(onInstallHelpClick);
findPreference("system_changelog").setOnPreferenceClickListener(onChangeLogClick); findPreference("system_changelog").setOnPreferenceClickListener(onChangeLogClick);
findPreference("system_clearsearch").setOnPreferenceClickListener(onClearSearchClick);
findPreference("system_importsettings").setOnPreferenceClickListener(onImportSettingsClick); findPreference("system_importsettings").setOnPreferenceClickListener(onImportSettingsClick);
findPreference("system_exportsettings").setOnPreferenceClickListener(onExportSettingsClick); findPreference("system_exportsettings").setOnPreferenceClickListener(onExportSettingsClick);
findPreference("system_about").setTitle(getString(R.string.pref_about, getString(R.string.app_name))); 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() { private OnPreferenceClickListener onAboutClick = new OnPreferenceClickListener() {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override

4
full/AndroidManifest.xml

@ -221,8 +221,8 @@
</activity> </activity>
<provider <provider
android:name="org.transdroid.core.gui.search.TorrentSearchHistoryProvider" android:name="org.transdroid.core.gui.search.SearchHistoryProvider"
android:authorities="org.transdroid.core.gui.search.TorrentSearchHistoryProvider" android:authorities="org.transdroid.core.gui.search.SearchHistoryProvider"
android:exported="false" /> android:exported="false" />
<!-- RSS --> <!-- RSS -->

Loading…
Cancel
Save