OSDN Git Service

Allow going back to voice search from not-first results.
authorLeon Scroggins <scroggo@google.com>
Tue, 9 Mar 2010 00:53:03 +0000 (19:53 -0500)
committerLeon Scroggins <scroggo@google.com>
Tue, 9 Mar 2010 14:04:41 +0000 (09:04 -0500)
When going to a result besides the first one, remember the original
Intent which opened voice search mode, and add the number of the
selected result.  Now going back to voice search works even if the
user selected a not-first result and then followed a link.

Change-Id: I9db335ec43c442c01f1355e2259d250a65b3aa20

src/com/android/browser/Tab.java

index 7bb6ca6..5d17691 100644 (file)
@@ -229,28 +229,31 @@ class Tab {
                     .EXTRA_VOICE_SEARCH_RESULT_HTTP_HEADERS);
             mVoiceSearchData.mSourceIsGoogle = intent.getBooleanExtra(
                     VoiceSearchData.SOURCE_IS_GOOGLE, false);
-        } else {
-            String extraData = intent.getStringExtra(
-                    SearchManager.EXTRA_DATA_KEY);
-            if (extraData != null) {
-                index = Integer.parseInt(extraData);
-                if (index >= mVoiceSearchData.mVoiceSearchResults.size()) {
-                    throw new AssertionError("index must be less than "
-                            + " size of mVoiceSearchResults");
-                }
-                if (mVoiceSearchData.mSourceIsGoogle) {
-                    Intent logIntent = new Intent(
-                            LoggingEvents.ACTION_LOG_EVENT);
-                    logIntent.putExtra(LoggingEvents.EXTRA_EVENT,
-                            LoggingEvents.VoiceSearch.N_BEST_CHOOSE);
-                    logIntent.putExtra(
-                            LoggingEvents.VoiceSearch.EXTRA_N_BEST_CHOOSE_INDEX,
-                            index);
-                    mActivity.sendBroadcast(logIntent);
-                }
+            mVoiceSearchData.mVoiceSearchIntent = intent;
+        }
+        String extraData = intent.getStringExtra(
+                SearchManager.EXTRA_DATA_KEY);
+        if (extraData != null) {
+            index = Integer.parseInt(extraData);
+            if (index >= mVoiceSearchData.mVoiceSearchResults.size()) {
+                throw new AssertionError("index must be less than "
+                        + "size of mVoiceSearchResults");
+            }
+            if (mVoiceSearchData.mSourceIsGoogle) {
+                Intent logIntent = new Intent(
+                        LoggingEvents.ACTION_LOG_EVENT);
+                logIntent.putExtra(LoggingEvents.EXTRA_EVENT,
+                        LoggingEvents.VoiceSearch.N_BEST_CHOOSE);
+                logIntent.putExtra(
+                        LoggingEvents.VoiceSearch.EXTRA_N_BEST_CHOOSE_INDEX,
+                        index);
+                mActivity.sendBroadcast(logIntent);
+            }
+            if (mVoiceSearchData.mVoiceSearchIntent != null) {
+                mVoiceSearchData.mVoiceSearchIntent.putExtra(
+                        SearchManager.EXTRA_DATA_KEY, extraData);
             }
         }
-        mVoiceSearchData.mVoiceSearchIntent = intent;
         mVoiceSearchData.mLastVoiceSearchTitle
                 = mVoiceSearchData.mVoiceSearchResults.get(index);
         if (mInForeground) {
@@ -356,7 +359,7 @@ class Tab {
          * WebHistoryItem so that when coming back to a previous voice search
          * page we can again activate voice search.
          */
-        public Object mVoiceSearchIntent;
+        public Intent mVoiceSearchIntent;
         /**
          * String used to identify Google as the source of voice search.
          */