OSDN Git Service

Clear voice search mode when changing search engines.
authorLeon Scroggins III <scroggo@google.com>
Tue, 14 Sep 2010 18:02:36 +0000 (14:02 -0400)
committerandroid-build SharedAccount <android-build@sekiwake.mtv.corp.google.com>
Thu, 16 Sep 2010 20:32:09 +0000 (13:32 -0700)
Not all search engines support voice search.  Also, different
search engines may support them differently.  So if we are
already in voice search mode when the search engine changes,
exit the mode.

Change-Id: I8d3f200f4829ad1383d554214c9d56d5c0b96aed

src/com/android/browser/BrowserSettings.java
src/com/android/browser/Tab.java

index 6263eb3..92b4cac 100644 (file)
@@ -305,6 +305,14 @@ class BrowserSettings extends Observable {
         String searchEngineName = p.getString(PREF_SEARCH_ENGINE, null);
         if (searchEngine == null || !searchEngine.getName().equals(searchEngineName)) {
             if (searchEngine != null) {
+                if (searchEngine.supportsVoiceSearch()) {
+                    // One or more tabs could have been in voice search mode.
+                    // Clear it, since the new SearchEngine may not support
+                    // it, or may handle it differently.
+                    for (int i = 0; i < mTabControl.getTabCount(); i++) {
+                        mTabControl.getTab(i).revertVoiceSearchMode();
+                    }
+                }
                 searchEngine.close();
             }
             searchEngine = SearchEngines.get(ctx, searchEngineName);
index 2dac050..1700961 100644 (file)
@@ -165,6 +165,17 @@ class Tab {
      */
     private VoiceSearchData mVoiceSearchData;
     /**
+     * Remove voice search mode from this tab.
+     */
+    public void revertVoiceSearchMode() {
+        if (mVoiceSearchData != null) {
+            mVoiceSearchData = null;
+            if (mInForeground) {
+                mActivity.revertVoiceTitleBar();
+            }
+        }
+    }
+    /**
      * Return whether the tab is in voice search mode.
      */
     public boolean isInVoiceSearchMode() {
@@ -457,10 +468,7 @@ class Tab {
                     i.putExtra(LoggingEvents.EXTRA_FLUSH, true);
                     mActivity.sendBroadcast(i);
                 }
-                mVoiceSearchData = null;
-                if (mInForeground) {
-                    mActivity.revertVoiceTitleBar();
-                }
+                revertVoiceSearchMode();
             }
 
             // We've started to load a new page. If there was a pending message