Going back to a voice search will reenter voice search mode.
Store the Intent that initiated voice search mode in the history
item, so that when going back to that page, we can reinvoke voice
search with all of the intended extras.
Fix for http://b/issue?id=2425052
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index a313269..7e03bbc 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -55,6 +55,7 @@
import android.webkit.URLUtil;
import android.webkit.ValueCallback;
import android.webkit.WebBackForwardList;
+import android.webkit.WebBackForwardListClient;
import android.webkit.WebChromeClient;
import android.webkit.WebHistoryItem;
import android.webkit.WebIconDatabase;
@@ -127,6 +128,8 @@
// The listener that gets invoked when a download is started from the
// mMainView
private final DownloadListener mDownloadListener;
+ // Listener used to know when we move forward or back in the history list.
+ private final WebBackForwardListClient mWebBackForwardListClient;
// AsyncTask for downloading touch icons
DownloadTouchIcon mTouchIconLoader;
@@ -241,6 +244,7 @@
}
}
}
+ mVoiceSearchData.mVoiceSearchIntent = intent;
mVoiceSearchData.mLastVoiceSearchTitle
= mVoiceSearchData.mVoiceSearchResults.get(index);
if (mInForeground) {
@@ -323,6 +327,12 @@
*/
public boolean mSourceIsGoogle;
/**
+ * The Intent used to invoke voice search. Placed on the
+ * WebHistoryItem so that when coming back to a previous voice search
+ * page we can again activate voice search.
+ */
+ public Object mVoiceSearchIntent;
+ /**
* String used to identify Google as the source of voice search.
*/
public static String SOURCE_IS_GOOGLE
@@ -1270,6 +1280,21 @@
}
}
};
+ mWebBackForwardListClient = new WebBackForwardListClient() {
+ @Override
+ public void onNewHistoryItem(WebHistoryItem item) {
+ if (isInVoiceSearchMode()) {
+ item.setCustomData(mVoiceSearchData.mVoiceSearchIntent);
+ }
+ }
+ @Override
+ public void onIndexChanged(WebHistoryItem item, int index) {
+ Object data = item.getCustomData();
+ if (data != null && data instanceof Intent) {
+ activateVoiceSearchMode((Intent) data);
+ }
+ }
+ };
setWebView(w);
}
@@ -1302,6 +1327,7 @@
// does a redirect after a period of time. The user could have
// switched to another tab while waiting for the download to start.
mMainView.setDownloadListener(mDownloadListener);
+ mMainView.setWebBackForwardListClient(mWebBackForwardListClient);
}
}