OSDN Git Service

Fixes for changing the search engine.
authorLeon Scroggins III <scroggo@google.com>
Tue, 14 Sep 2010 14:57:37 +0000 (10:57 -0400)
committerandroid-build SharedAccount <android-build@sekiwake.mtv.corp.google.com>
Thu, 16 Sep 2010 20:31:53 +0000 (13:31 -0700)
Provide a default value for the Select search engine preference.
Move the Select search engine preference into advanced settings.
When opening the SearchDialog with a SearchEngine other than
Google, add a flag to hide the voice search icon.

Depends on a change to frameworks/base.

Change-Id: I6da2e582789253b3c5ffac9fe1ad3732f99f28ea

res/xml/browser_preferences.xml
src/com/android/browser/BrowserActivity.java
src/com/android/browser/search/DefaultSearchEngine.java
src/com/android/browser/search/OpenSearchSearchEngine.java
src/com/android/browser/search/SearchEngine.java

index fd994e8..501d8c1 100644 (file)
                 android:hint="@string/http"
                 android:inputType="textUri|textMultiLine" />
 
-        <!-- Entries and values in this list are set dynamically. -->
-        <com.android.browser.search.SearchEnginePreference
-                android:key="search_engine"
-                android:title="@string/pref_content_search_engine"
-                android:summary="@string/pref_content_search_engine_summary"
-                android:dialogTitle="@string/pref_content_search_engine" />
-
-        <CheckBoxPreference
-                android:key="show_search_suggestions"
-                android:defaultValue="true"
-                android:title="@string/pref_content_show_search_suggestions"
-                android:summaryOn="@string/pref_content_show_web_suggestions_summary_on"
-                android:summaryOff="@string/pref_content_show_web_suggestions_summary_off" />
-
     </PreferenceCategory>
 
     <PreferenceCategory
     <PreferenceCategory
             android:title="@string/pref_extras_title">
 
+            <!-- Entries and values in this list are set dynamically. -->
+            <com.android.browser.search.SearchEnginePreference
+                    android:key="search_engine"
+                    android:title="@string/pref_content_search_engine"
+                    android:defaultValue="google"
+                    android:summary="@string/pref_content_search_engine_summary"
+                    android:dialogTitle="@string/pref_content_search_engine" />
+
+            <CheckBoxPreference
+                    android:key="show_search_suggestions"
+                    android:defaultValue="true"
+                    android:title="@string/pref_content_show_search_suggestions"
+                    android:summaryOn="@string/pref_content_show_web_suggestions_summary_on"
+                    android:summaryOff="@string/pref_content_show_web_suggestions_summary_off" />
+
             <PreferenceScreen
                   android:key="website_settings"
                   android:title="@string/pref_extras_website_settings"
index 6f47788..5583466 100644 (file)
@@ -1185,6 +1185,12 @@ public class BrowserActivity extends Activity
         if (appSearchData == null) {
             appSearchData = createGoogleSearchSourceBundle(GOOGLE_SEARCH_SOURCE_TYPE);
         }
+
+        SearchEngine searchEngine = mSettings.getSearchEngine();
+        if (searchEngine != null && !searchEngine.supportsVoiceSearch()) {
+            appSearchData.putBoolean(SearchManager.DISABLE_VOICE_SEARCH, true);
+        }
+
         super.startSearch(initialQuery, selectInitialQuery, appSearchData, globalSearch);
     }
 
index 42d274d..c939de7 100644 (file)
@@ -67,9 +67,9 @@ public class DefaultSearchEngine implements SearchEngine {
         String packageName = mSearchable.getSearchActivity().getPackageName();
         // Use "google" as name to avoid showing Google twice (app + OpenSearch)
         if ("com.google.android.googlequicksearchbox".equals(packageName)) {
-            return "google";
+            return SearchEngine.GOOGLE;
         } else if ("com.android.quicksearchbox".equals(packageName)) {
-            return "google";
+            return SearchEngine.GOOGLE;
         } else {
             return packageName;
         }
@@ -110,6 +110,10 @@ public class DefaultSearchEngine implements SearchEngine {
     public void close() {
     }
 
+    public boolean supportsVoiceSearch() {
+        return getName().equals(SearchEngine.GOOGLE);
+    }
+
     @Override
     public String toString() {
         return "ActivitySearchEngine{" + mSearchable + "}";
index e78a93c..3c1cd5b 100644 (file)
@@ -196,6 +196,10 @@ public class OpenSearchSearchEngine implements SearchEngine {
         mHttpClient.close();
     }
 
+    public boolean supportsVoiceSearch() {
+        return getName().equals(SearchEngine.GOOGLE);
+    }
+
     private boolean isNetworkConnected(Context context) {
         NetworkInfo networkInfo = getActiveNetworkInfo(context);
         return networkInfo != null && networkInfo.isConnected();
index 3d24d2e..b7e1859 100644 (file)
@@ -24,6 +24,9 @@ import android.os.Bundle;
  */
 public interface SearchEngine {
 
+    // Used if the search engine is Google
+    static final String GOOGLE = "google";
+
     /**
      * Gets the unique name of this search engine.
      */
@@ -54,4 +57,8 @@ public interface SearchEngine {
      */
     public void close();
 
+    /**
+     * Checks whether this search engine supports voice search.
+     */
+    public boolean supportsVoiceSearch();
 }