diff options
author | Paul Kocialkowski <contact@paulk.fr> | 2012-12-31 20:15:03 +0100 |
---|---|---|
committer | Paul Kocialkowski <contact@paulk.fr> | 2013-10-29 15:23:45 +0100 |
commit | 7f8a22a6d3515b9bd244311c0a56c00287f24437 (patch) | |
tree | 922f6f44054fe1f5873d6b4e477b2a1294537ec0 | |
parent | 92e9a8826cf59141408e39b657b17aeeccc9d60c (diff) | |
download | packages_apps_browser-7f8a22a6d3515b9bd244311c0a56c00287f24437.zip packages_apps_browser-7f8a22a6d3515b9bd244311c0a56c00287f24437.tar.gz packages_apps_browser-7f8a22a6d3515b9bd244311c0a56c00287f24437.tar.bz2 |
Show search suggestions only when enabled in preferences
Change-Id: I6d6cd753f1bdffa6aecd078db62b1bbc08e95aa7
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r-- | res/values/strings.xml | 4 | ||||
-rw-r--r-- | res/xml/privacy_security_preferences.xml | 6 | ||||
-rw-r--r-- | src/com/android/browser/BrowserSettings.java | 4 | ||||
-rw-r--r-- | src/com/android/browser/PreferenceKeys.java | 1 | ||||
-rw-r--r-- | src/com/android/browser/SuggestionsAdapter.java | 8 |
5 files changed, 22 insertions, 1 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index 5720410..8121e5c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -485,6 +485,10 @@ <!-- Settings summmary --> <string name="pref_security_show_security_warning_summary">Show warning if there\'s a problem with a site\'s security</string> <!-- Settings label --> + <string name="pref_security_show_search_suggestions">Show search suggestions</string> + <!-- Settings summmary --> + <string name="pref_security_show_search_suggestions_summary">Show search suggestions when typing in the URL field</string> + <!-- Settings label --> <string name="pref_security_accept_cookies">Accept cookies</string> <!-- Settings summary --> <string name="pref_security_accept_cookies_summary">Allow sites to save and read cookie data</string> diff --git a/res/xml/privacy_security_preferences.xml b/res/xml/privacy_security_preferences.xml index 2633600..a574e61 100644 --- a/res/xml/privacy_security_preferences.xml +++ b/res/xml/privacy_security_preferences.xml @@ -37,6 +37,12 @@ android:title="@string/pref_security_show_security_warning" android:summary="@string/pref_security_show_security_warning_summary" /> + <CheckBoxPreference + android:key="show_search_suggestions" + android:defaultValue="false" + android:title="@string/pref_security_show_search_suggestions" + android:summary="@string/pref_security_show_search_suggestions_summary" /> + <PreferenceCategory android:title="@string/pref_privacy_cookies_title"> <CheckBoxPreference android:key="accept_cookies" diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java index efab039..b514954 100644 --- a/src/com/android/browser/BrowserSettings.java +++ b/src/com/android/browser/BrowserSettings.java @@ -863,6 +863,10 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, return mPrefs.getBoolean(PREF_SHOW_SECURITY_WARNINGS, true); } + public boolean showSearchSuggestions() { + return mPrefs.getBoolean(PREF_SHOW_SEARCH_SUGGESTIONS, false); + } + public boolean acceptCookies() { return mPrefs.getBoolean(PREF_ACCEPT_COOKIES, true); } diff --git a/src/com/android/browser/PreferenceKeys.java b/src/com/android/browser/PreferenceKeys.java index b0bade2..06cff5e 100644 --- a/src/com/android/browser/PreferenceKeys.java +++ b/src/com/android/browser/PreferenceKeys.java @@ -100,6 +100,7 @@ public interface PreferenceKeys { static final String PREF_REMEMBER_PASSWORDS = "remember_passwords"; static final String PREF_SAVE_FORMDATA = "save_formdata"; static final String PREF_SHOW_SECURITY_WARNINGS = "show_security_warnings"; + static final String PREF_SHOW_SEARCH_SUGGESTIONS = "show_search_suggestions"; // ---------------------- // Keys for bandwidth_preferences.xml diff --git a/src/com/android/browser/SuggestionsAdapter.java b/src/com/android/browser/SuggestionsAdapter.java index 9f66e3c..e9aae4a 100644 --- a/src/com/android/browser/SuggestionsAdapter.java +++ b/src/com/android/browser/SuggestionsAdapter.java @@ -204,9 +204,15 @@ public class SuggestionsAdapter extends BaseAdapter implements Filterable, @Override protected List<SuggestItem> doInBackground(CharSequence... params) { + List<SuggestItem> results = new ArrayList<SuggestItem>(); + + // Don't query the search engine if disabled in settings + if (!mSettings.showSearchSuggestions()) { + return results; + } + SuggestCursor cursor = new SuggestCursor(); cursor.runQuery(params[0]); - List<SuggestItem> results = new ArrayList<SuggestItem>(); int count = cursor.getCount(); for (int i = 0; i < count; i++) { results.add(cursor.getItem()); |