diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:05:56 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:05:56 -0800 |
commit | a2d1d1355f5d09f766bab52e080fd57e32d70558 (patch) | |
tree | 275468f49fac64dcc334814d014d22b45b3f7827 | |
parent | c398e48938ffaa5ff8db0de81a54a4952e26394f (diff) | |
download | GoogleSearch-a2d1d1355f5d09f766bab52e080fd57e32d70558.tar.gz |
Code drop from //branches/cupcake/...@124589
-rw-r--r-- | AndroidManifest.xml | 4 | ||||
-rw-r--r-- | res/values-de/strings.xml | 5 | ||||
-rw-r--r-- | res/values-ja/strings.xml | 5 | ||||
-rw-r--r-- | res/values/strings.xml | 16 | ||||
-rw-r--r-- | src/com/android/googlesearch/GoogleSearch.java | 4 | ||||
-rw-r--r-- | src/com/android/googlesearch/SuggestionProvider.java | 28 |
6 files changed, 56 insertions, 6 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 0434f3a..c4e90d4 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -25,7 +25,9 @@ android:process="android.process.acore" android:label="Google Search"> - <activity android:name=".GoogleSearch"> + <activity android:name=".GoogleSearch" + android:theme="@android:style/Theme.NoDisplay" + android:excludeFromRecents="true"> <intent-filter> <action android:name="android.intent.action.SEARCH" /> <category android:name="android.intent.category.DEFAULT" /> diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml new file mode 100644 index 0000000..fa64560 --- /dev/null +++ b/res/values-de/strings.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="search_hint">"Google-Suche"</string> +</resources> diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml new file mode 100644 index 0000000..2ac186e --- /dev/null +++ b/res/values-ja/strings.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="search_hint">"Google検索"</string> +</resources> diff --git a/res/values/strings.xml b/res/values/strings.xml index f87d418..4e26577 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -13,8 +13,22 @@ See the License for the specific language governing permissions and limitations under the License. --> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> -<resources> + <!-- Do not translate. This string is not displayed in UI (because we have a badge icon). --> <string name="search_label">Google</string> + + <!-- This is the hint text shown in the search widget, before text is entered. --> + <!-- This translation MUST MATCH the string "search_hint" which is found in + Home/res/values/strings.xml --> <string name="search_hint">Google Search</string> + + <!-- Note that this is the standard suggest url. It uses the current locale for language --> + <!-- (t%1$s) and country (%2$s) and should not need to be replaced by locale or mcc --> + <!-- selected resources. --> + <!-- Any changes to this (especially in terms of adding/removing the MCC-specific flavors) --> + <!-- should be mirrored by changes in apps/Browser --> + <!-- Do not translate. This string is an internal URI, not seen in the UI. --> + <string name="google_search_base" translatable="false"> + http://www.google.com/complete/search?hl=%1$s&gl=%2$s&</string> </resources> diff --git a/src/com/android/googlesearch/GoogleSearch.java b/src/com/android/googlesearch/GoogleSearch.java index 4c8b9b3..63a870d 100644 --- a/src/com/android/googlesearch/GoogleSearch.java +++ b/src/com/android/googlesearch/GoogleSearch.java @@ -40,6 +40,10 @@ public class GoogleSearch extends Activity { Intent search = new Intent(Intent.ACTION_WEB_SEARCH); search.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); search.putExtra(SearchManager.QUERY, query); + final Bundle appData = intent.getBundleExtra(SearchManager.APP_DATA); + if (appData != null) { + search.putExtra(SearchManager.APP_DATA, appData); + } startActivity(search); } } diff --git a/src/com/android/googlesearch/SuggestionProvider.java b/src/com/android/googlesearch/SuggestionProvider.java index cab47a4..625a03d 100644 --- a/src/com/android/googlesearch/SuggestionProvider.java +++ b/src/com/android/googlesearch/SuggestionProvider.java @@ -16,9 +16,8 @@ package com.android.googlesearch; -import com.google.android.net.GoogleHttpClient; - import com.android.internal.database.ArrayListCursor; +import com.google.android.net.GoogleHttpClient; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; @@ -42,6 +41,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.ArrayList; +import java.util.Locale; /** * Use network-based Google Suggests to provide search suggestions. @@ -54,7 +54,7 @@ public class SuggestionProvider extends ContentProvider { "content://com.android.googlesearch.SuggestionProvider"); private static final String USER_AGENT = "Android/1.0"; - private static final String SUGGEST_URI = "http://www.google.com/complete/search?json=true&q="; + private String mSuggestUri; private static final int HTTP_TIMEOUT_MS = 1000; // TODO: this should be defined somewhere @@ -80,6 +80,10 @@ public class SuggestionProvider extends ContentProvider { mHttpClient = new GoogleHttpClient(getContext().getContentResolver(), USER_AGENT); HttpParams params = mHttpClient.getParams(); params.setLongParameter(HTTP_TIMEOUT, HTTP_TIMEOUT_MS); + + // NOTE: Do not look up the resource here; Localization changes may not have completed + // yet (e.g. we may still be reading the SIM card). + mSuggestUri = null; return true; } @@ -107,7 +111,23 @@ public class SuggestionProvider extends ContentProvider { } try { query = URLEncoder.encode(query, "UTF-8"); - HttpPost method = new HttpPost(SUGGEST_URI + query); + // NOTE: This code uses resources to optionally select the search Uri, based on the + // MCC value from the SIM. iThe default string will most likely be fine. It is + // paramerterized to accept info from the Locale, the language code is the first + // parameter (%1$s) and the country code is the second (%2$s). This code *must* + // function in the same way as a similar lookup in + // com.android.browser.BrowserActivity#onCreate(). If you change + // either of these functions, change them both. (The same is true for the underlying + // resource strings, which are stored in mcc-specific xml files.) + if (mSuggestUri == null) { + Locale l = Locale.getDefault(); + mSuggestUri = getContext().getResources().getString(R.string.google_search_base, + l.getLanguage(), + l.getCountry().toLowerCase()) + + "json=true&q="; + } + + HttpPost method = new HttpPost(mSuggestUri + query); StringEntity content = new StringEntity(""); method.setEntity(content); HttpResponse response = mHttpClient.execute(method); |