diff options
author | Bjorn Bringert <bringert@android.com> | 2009-07-24 06:13:08 +0100 |
---|---|---|
committer | Bjorn Bringert <bringert@android.com> | 2009-07-24 09:49:31 +0100 |
commit | a0b01b59d8012179185bc322f51c757ed95d9311 (patch) | |
tree | 590586b6da3996d0d98c2492ee67e6b56d1c4cee | |
parent | dd787fa64ef365f17b39c742406c55b4917f8f37 (diff) | |
download | GoogleSearch-a0b01b59d8012179185bc322f51c757ed95d9311.tar.gz |
Added settings to GoogleSearch
GoogleSearch now has its own settings UI, with a
"Show web suggestions" preference.
This is the GoogleSearch part of http://b/issue?id=1996992
-rw-r--r-- | AndroidManifest.xml | 8 | ||||
-rw-r--r-- | res/values/strings.xml | 8 | ||||
-rw-r--r-- | res/xml/preferences.xml | 27 | ||||
-rw-r--r-- | src/com/android/googlesearch/Settings.java | 57 |
4 files changed, 100 insertions, 0 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index b7e59d5..bffa88b 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -51,6 +51,14 @@ android:resource="@xml/searchable" /> </activity> + <activity android:name=".Settings" + android:label="@string/google_search_settings" + android:excludeFromRecents="true"> + <intent-filter> + <action android:name="android.search.action.WEB_SEARCH_SETTINGS" /> + </intent-filter> + </activity> + <provider android:name=".SuggestionProvider" android:label="@string/search_label" android:authorities="com.android.googlesearch.SuggestionProvider" /> diff --git a/res/values/strings.xml b/res/values/strings.xml index e5e3adf..dd8c875 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -26,6 +26,14 @@ Home/res/values/strings.xml --> <string name="search_hint">Google Search</string> + <!-- Settings category title for 'Google search settings' settings activity --> + <string name="google_search_settings">Google search settings</string> + + <!-- Title and summaries for 'show web suggestions' check box setting --> + <string name="show_web_suggestions">Show web suggestions</string> + <string name="show_web_suggestions_summary_enabled">Show suggestions from Google as you type</string> + <string name="show_web_suggestions_summary_disabled">Don\'t show suggestions from Google as you type</string> + <!-- Note that this is the standard search url. It uses the current locale for language --> <!-- (%1$s) and country (%2$s) and shouldn't need to be replaced by locale or mcc selected --> <!-- resources. --> diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml new file mode 100644 index 0000000..8f2dbeb --- /dev/null +++ b/res/xml/preferences.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2009 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<PreferenceScreen + xmlns:android="http://schemas.android.com/apk/res/android"> + + <CheckBoxPreference + android:key="show_web_suggestions" + android:title="@string/show_web_suggestions" + android:summaryOn="@string/show_web_suggestions_summary_enabled" + android:summaryOff="@string/show_web_suggestions_summary_disabled" + android:defaultValue="true" /> + +</PreferenceScreen> diff --git a/src/com/android/googlesearch/Settings.java b/src/com/android/googlesearch/Settings.java new file mode 100644 index 0000000..4e7cd68 --- /dev/null +++ b/src/com/android/googlesearch/Settings.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.googlesearch; + +import android.os.Bundle; +import android.preference.CheckBoxPreference; +import android.preference.Preference; +import android.preference.PreferenceActivity; +import android.preference.PreferenceScreen; +import android.preference.Preference.OnPreferenceClickListener; +import android.provider.Settings.System; + +/** + * Activity for setting Google search preferences. + */ +public class Settings extends PreferenceActivity implements OnPreferenceClickListener { + + private static final String SHOW_WEB_SUGGESTIONS_PREF = "show_web_suggestions"; + + private CheckBoxPreference mShowWebSuggestionsPreference; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.preferences); + PreferenceScreen preferenceScreen = getPreferenceScreen(); + mShowWebSuggestionsPreference = (CheckBoxPreference) + findPreference(SHOW_WEB_SUGGESTIONS_PREF); + mShowWebSuggestionsPreference.setOnPreferenceClickListener(this); + } + + public synchronized boolean onPreferenceClick(Preference preference) { + if (preference == mShowWebSuggestionsPreference) { + System.putInt( + getContentResolver(), + System.SHOW_WEB_SUGGESTIONS, + mShowWebSuggestionsPreference.isChecked() ? 1 : 0); + return true; + } + return false; + } + +} |