diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2009-07-29 14:57:06 -0700 |
---|---|---|
committer | Jean-Baptiste Queru <jbq@google.com> | 2009-07-29 14:57:06 -0700 |
commit | 21fbbd5342e4017cc3777053b6b6991d45245a0b (patch) | |
tree | 2489e8a93ab761285bbf8485d3f294a0f943f306 | |
parent | 262079e3114a5f24afd6088d6ed6811a92be591d (diff) | |
parent | dd8078098fd835e8374988760955df4077b502f5 (diff) | |
download | GoogleSearch-21fbbd5342e4017cc3777053b6b6991d45245a0b.tar.gz |
merge from donut
-rw-r--r-- | AndroidManifest.xml | 5 | ||||
-rw-r--r-- | res/drawable/google.png | bin | 0 -> 5376 bytes | |||
-rwxr-xr-x | res/drawable/magnifying_glass.png | bin | 0 -> 3708 bytes | |||
-rw-r--r-- | res/values-da/strings.xml | 19 | ||||
-rw-r--r-- | res/values-el/strings.xml | 19 | ||||
-rw-r--r-- | res/values-pt-rPT/strings.xml | 19 | ||||
-rw-r--r-- | res/values-sv/strings.xml | 19 | ||||
-rw-r--r-- | res/values-tr/strings.xml | 19 | ||||
-rw-r--r-- | res/values-zh-rCN/strings.xml | 5 | ||||
-rw-r--r-- | res/values/strings.xml | 5 | ||||
-rw-r--r-- | res/xml/searchable.xml | 1 | ||||
-rw-r--r-- | src/com/android/googlesearch/SuggestionProvider.java | 60 |
12 files changed, 139 insertions, 32 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 297fb03..b7e59d5 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -26,9 +26,11 @@ <application android:process="android.process.acore" - android:label="@string/search_label"> + android:label="@string/app_label" + android:icon="@drawable/google"> <activity android:name=".GoogleSearch" + android:label="@string/search_label" android:theme="@android:style/Theme.NoDisplay" android:excludeFromRecents="true"> <intent-filter> @@ -50,6 +52,7 @@ </activity> <provider android:name=".SuggestionProvider" + android:label="@string/search_label" android:authorities="com.android.googlesearch.SuggestionProvider" /> <meta-data android:name="android.app.default_searchable" diff --git a/res/drawable/google.png b/res/drawable/google.png Binary files differnew file mode 100644 index 0000000..3ffc5a6 --- /dev/null +++ b/res/drawable/google.png diff --git a/res/drawable/magnifying_glass.png b/res/drawable/magnifying_glass.png Binary files differnew file mode 100755 index 0000000..7ce9686 --- /dev/null +++ b/res/drawable/magnifying_glass.png diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml new file mode 100644 index 0000000..8c46aa8 --- /dev/null +++ b/res/values-da/strings.xml @@ -0,0 +1,19 @@ +<?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. +--> +<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-søgning"</string> +</resources> diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml new file mode 100644 index 0000000..78edcc2 --- /dev/null +++ b/res/values-el/strings.xml @@ -0,0 +1,19 @@ +<?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. +--> +<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-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml new file mode 100644 index 0000000..c9cb3b2 --- /dev/null +++ b/res/values-pt-rPT/strings.xml @@ -0,0 +1,19 @@ +<?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. +--> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="search_hint">"Pesquisa do Google"</string> +</resources> diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml new file mode 100644 index 0000000..e1f6f1f --- /dev/null +++ b/res/values-sv/strings.xml @@ -0,0 +1,19 @@ +<?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. +--> +<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 Sökning"</string> +</resources> diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml new file mode 100644 index 0000000..265bc25 --- /dev/null +++ b/res/values-tr/strings.xml @@ -0,0 +1,19 @@ +<?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. +--> +<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 Arama"</string> +</resources> diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index ff937c7..43d39d3 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -16,9 +16,4 @@ <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> - - <!-- China has a different url than the standard suggest url. --> - <!-- Do not translate. This string is an internal URI, not seen in the UI. --> - <string name="google_search_base" translatable="false"> - http://www.google.cn/complete/search?hl=%1$s&gl=%2$s&</string> </resources> diff --git a/res/values/strings.xml b/res/values/strings.xml index 455eca2..e5e3adf 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -15,9 +15,12 @@ --> <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <!-- Do not translate. This string is not displayed in UI (because we have a badge icon). --> + <!-- Search source name as displayed in the search dialog. --> <string name="search_label">Google</string> + <!-- The app label as shown, for example, in 'manage applications'. --> + <string name="app_label">Google Search</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 --> diff --git a/res/xml/searchable.xml b/res/xml/searchable.xml index 09b8867..6c9fef1 100644 --- a/res/xml/searchable.xml +++ b/res/xml/searchable.xml @@ -26,4 +26,5 @@ android:searchSuggestAuthority="com.android.googlesearch.SuggestionProvider" android:searchSuggestSelection="field =?" + android:searchSuggestIntentAction="android.intent.action.WEB_SEARCH" /> diff --git a/src/com/android/googlesearch/SuggestionProvider.java b/src/com/android/googlesearch/SuggestionProvider.java index c6ccfb1..f4cc78c 100644 --- a/src/com/android/googlesearch/SuggestionProvider.java +++ b/src/com/android/googlesearch/SuggestionProvider.java @@ -16,7 +16,6 @@ package com.android.googlesearch; -import com.android.internal.database.ArrayListCursor; import com.google.android.net.GoogleHttpClient; import org.apache.http.HttpResponse; @@ -32,7 +31,6 @@ import android.app.SearchManager; import android.content.ContentProvider; import android.content.ContentValues; import android.content.Context; -import android.content.Intent; import android.database.AbstractCursor; import android.database.Cursor; import android.net.ConnectivityManager; @@ -44,7 +42,6 @@ import android.util.Log; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; -import java.util.ArrayList; import java.util.Locale; /** @@ -54,8 +51,7 @@ import java.util.Locale; */ public class SuggestionProvider extends ContentProvider { - public static final Uri CONTENT_URI = Uri.parse( - "content://com.android.googlesearch.SuggestionProvider"); + private static final String LOG_TAG = "GoogleSearch"; private static final String USER_AGENT = "Android/1.0"; private String mSuggestUri; @@ -64,23 +60,32 @@ public class SuggestionProvider extends ContentProvider { // TODO: this should be defined somewhere private static final String HTTP_TIMEOUT = "http.connection-manager.timeout"; - private static final String LOG_TAG = "GoogleSearch.SuggestionProvider"; + private static final String SUGGESTION_ICON = + "android.resource://com.android.googlesearch/" + R.drawable.magnifying_glass; + + // Indexes into COLUMNS + private static final int COL_ID = 0; + private static final int COL_TEXT_1 = 1; + private static final int COL_TEXT_2 = 2; + private static final int COL_ICON_1 = 3; + private static final int COL_ICON_2 = 4; + private static final int COL_QUERY = 5; /* The suggestion columns used */ private static final String[] COLUMNS = new String[] { "_id", SearchManager.SUGGEST_COLUMN_TEXT_1, SearchManager.SUGGEST_COLUMN_TEXT_2, - SearchManager.SUGGEST_COLUMN_QUERY, - SearchManager.SUGGEST_COLUMN_INTENT_ACTION, + SearchManager.SUGGEST_COLUMN_ICON_1, + SearchManager.SUGGEST_COLUMN_ICON_2, + SearchManager.SUGGEST_COLUMN_QUERY }; private HttpClient mHttpClient; @Override public boolean onCreate() { - mHttpClient = new GoogleHttpClient(getContext().getContentResolver(), - USER_AGENT, false /* not gzip capable */); + mHttpClient = new GoogleHttpClient(getContext(), USER_AGENT, false /* not gzip capable */); HttpParams params = mHttpClient.getParams(); params.setLongParameter(HTTP_TIMEOUT, HTTP_TIMEOUT_MS); @@ -214,24 +219,29 @@ public class SuggestionProvider extends ContentProvider { @Override public String getString(int column) { - if ((mPos != -1)) { - if ((column == 1) || (column == 3)) { - try { + if (mPos == -1) return null; + try { + switch (column) { + case COL_ID: + return String.valueOf(mPos); + case COL_TEXT_1: + case COL_QUERY: return mSuggestions.getString(mPos); - } catch (JSONException e) { - Log.w(LOG_TAG, "Error", e); - } - } else if (column == 2) { - try { + case COL_TEXT_2: return mPopularity.getString(mPos); - } catch (JSONException e) { - Log.w(LOG_TAG, "Error", e); - } - } else if (column == 4) { - return Intent.ACTION_WEB_SEARCH; + case COL_ICON_1: + return SUGGESTION_ICON; + case COL_ICON_2: + return null; + default: + Log.w(LOG_TAG, "Bad column: " + column); + return null; } + } catch (JSONException e) { + Log.w(LOG_TAG, "Error parsing response: " + e); + return null; } - return null; + } @Override @@ -251,7 +261,7 @@ public class SuggestionProvider extends ContentProvider { @Override public long getLong(int column) { - if (column == 0) { + if (column == COL_ID) { return mPos; // use row# as the _Id } throw new UnsupportedOperationException(); |