OSDN Git Service

Allow going back to a voice search to work when choosing from n-best.
authorLeon Scroggins <scroggo@google.com>
Mon, 15 Mar 2010 20:56:57 +0000 (16:56 -0400)
committerLeon Scroggins <scroggo@google.com>
Mon, 15 Mar 2010 20:56:57 +0000 (16:56 -0400)
Store a copy of the Intent rather than the Intent itself.  This way,
when choosing from the n-best, the number will not be appended to
the original Intent, so pressing back works properly.

Change-Id: Id6a0232339f34e5f91928e2bc1502f8f2fc33228

src/com/android/browser/Tab.java

index 409f68c..535e8e7 100644 (file)
@@ -229,7 +229,7 @@ class Tab {
                     .EXTRA_VOICE_SEARCH_RESULT_HTTP_HEADERS);
             mVoiceSearchData.mSourceIsGoogle = intent.getBooleanExtra(
                     VoiceSearchData.SOURCE_IS_GOOGLE, false);
-            mVoiceSearchData.mVoiceSearchIntent = intent;
+            mVoiceSearchData.mVoiceSearchIntent = new Intent(intent);
         }
         String extraData = intent.getStringExtra(
                 SearchManager.EXTRA_DATA_KEY);
@@ -250,8 +250,11 @@ class Tab {
                 mActivity.sendBroadcast(logIntent);
             }
             if (mVoiceSearchData.mVoiceSearchIntent != null) {
-                mVoiceSearchData.mVoiceSearchIntent.putExtra(
-                        SearchManager.EXTRA_DATA_KEY, extraData);
+                // Copy the Intent, so that each history item will have its own
+                // Intent, with different (or none) extra data.
+                Intent latest = new Intent(mVoiceSearchData.mVoiceSearchIntent);
+                latest.putExtra(SearchManager.EXTRA_DATA_KEY, extraData);
+                mVoiceSearchData.mVoiceSearchIntent = latest;
             }
         }
         mVoiceSearchData.mLastVoiceSearchTitle