diff options
author | Michael Kolb <kolby@google.com> | 2012-05-03 11:37:58 -0700 |
---|---|---|
committer | Michael Kolb <kolby@google.com> | 2012-05-03 15:25:01 -0700 |
commit | 5ff5c8b88968fa794eab4b7a263cae25f05bd4d3 (patch) | |
tree | 5c64bedb6089f7516b1e34de38e6bde5ecc098d3 /src/com/android/browser/Tab.java | |
parent | f6504f863a407c9b4615ac14de9b623775f65f69 (diff) | |
download | packages_apps_Browser-5ff5c8b88968fa794eab4b7a263cae25f05bd4d3.zip packages_apps_Browser-5ff5c8b88968fa794eab4b7a263cae25f05bd4d3.tar.gz packages_apps_Browser-5ff5c8b88968fa794eab4b7a263cae25f05bd4d3.tar.bz2 |
Remove voice search handling
Bug: 6439925
Change-Id: I1b7161a67fa0c20d87f147d6ed19c02e53093054
Diffstat (limited to 'src/com/android/browser/Tab.java')
-rw-r--r-- | src/com/android/browser/Tab.java | 267 |
1 files changed, 0 insertions, 267 deletions
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java index 73f5b9e..712e30a 100644 --- a/src/com/android/browser/Tab.java +++ b/src/com/android/browser/Tab.java @@ -18,13 +18,11 @@ package com.android.browser; import android.app.Activity; import android.app.AlertDialog; -import android.app.SearchManager; import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnCancelListener; -import android.content.Intent; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; import android.graphics.BitmapFactory; @@ -42,7 +40,6 @@ import android.os.Message; import android.os.SystemClock; import android.security.KeyChain; import android.security.KeyChainAliasCallback; -import android.speech.RecognizerResultsIntent; import android.text.TextUtils; import android.util.Log; import android.view.KeyEvent; @@ -73,16 +70,12 @@ import android.widget.Toast; import com.android.browser.TabControl.OnThumbnailUpdatedListener; import com.android.browser.homepages.HomeProvider; import com.android.browser.provider.SnapshotProvider.Snapshots; -import com.android.common.speech.LoggingEvents; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; import java.util.LinkedList; import java.util.Map; import java.util.UUID; @@ -256,234 +249,6 @@ class Tab implements PictureListener { static final String USERAGENT = "useragent"; static final String CLOSEFLAG = "closeOnBack"; - // ------------------------------------------------------------------------- - - /** - * Private information regarding the latest voice search. If the Tab is not - * in voice search mode, this will be null. - */ - private VoiceSearchData mVoiceSearchData; - /** - * Remove voice search mode from this tab. - */ - public void revertVoiceSearchMode() { - if (mVoiceSearchData != null) { - mVoiceSearchData = null; - if (mInForeground) { - mWebViewController.revertVoiceSearchMode(this); - } - } - } - - /** - * Return whether the tab is in voice search mode. - */ - public boolean isInVoiceSearchMode() { - return mVoiceSearchData != null; - } - /** - * Return true if the Tab is in voice search mode and the voice search - * Intent came with a String identifying that Google provided the Intent. - */ - public boolean voiceSearchSourceIsGoogle() { - return mVoiceSearchData != null && mVoiceSearchData.mSourceIsGoogle; - } - /** - * Get the title to display for the current voice search page. If the Tab - * is not in voice search mode, return null. - */ - public String getVoiceDisplayTitle() { - if (mVoiceSearchData == null) return null; - return mVoiceSearchData.mLastVoiceSearchTitle; - } - /** - * Get the latest array of voice search results, to be passed to the - * BrowserProvider. If the Tab is not in voice search mode, return null. - */ - public ArrayList<String> getVoiceSearchResults() { - if (mVoiceSearchData == null) return null; - return mVoiceSearchData.mVoiceSearchResults; - } - /** - * Activate voice search mode. - * @param intent Intent which has the results to use, or an index into the - * results when reusing the old results. - */ - /* package */ void activateVoiceSearchMode(Intent intent) { - int index = 0; - ArrayList<String> results = intent.getStringArrayListExtra( - RecognizerResultsIntent.EXTRA_VOICE_SEARCH_RESULT_STRINGS); - if (results != null) { - ArrayList<String> urls = intent.getStringArrayListExtra( - RecognizerResultsIntent.EXTRA_VOICE_SEARCH_RESULT_URLS); - ArrayList<String> htmls = intent.getStringArrayListExtra( - RecognizerResultsIntent.EXTRA_VOICE_SEARCH_RESULT_HTML); - ArrayList<String> baseUrls = intent.getStringArrayListExtra( - RecognizerResultsIntent - .EXTRA_VOICE_SEARCH_RESULT_HTML_BASE_URLS); - // This tab is now entering voice search mode for the first time, or - // a new voice search was done. - int size = results.size(); - if (urls == null || size != urls.size()) { - throw new AssertionError("improper extras passed in Intent"); - } - if (htmls == null || htmls.size() != size || baseUrls == null || - (baseUrls.size() != size && baseUrls.size() != 1)) { - // If either of these arrays are empty/incorrectly sized, ignore - // them. - htmls = null; - baseUrls = null; - } - mVoiceSearchData = new VoiceSearchData(results, urls, htmls, - baseUrls); - mVoiceSearchData.mHeaders = intent.getParcelableArrayListExtra( - RecognizerResultsIntent - .EXTRA_VOICE_SEARCH_RESULT_HTTP_HEADERS); - mVoiceSearchData.mSourceIsGoogle = intent.getBooleanExtra( - VoiceSearchData.SOURCE_IS_GOOGLE, false); - mVoiceSearchData.mVoiceSearchIntent = new Intent(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); - mContext.sendBroadcast(logIntent); - } - if (mVoiceSearchData.mVoiceSearchIntent != null) { - // 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 - = mVoiceSearchData.mVoiceSearchResults.get(index); - if (mInForeground) { - mWebViewController.activateVoiceSearchMode( - mVoiceSearchData.mLastVoiceSearchTitle, - mVoiceSearchData.mVoiceSearchResults); - } - if (mVoiceSearchData.mVoiceSearchHtmls != null) { - // When index was found it was already ensured that it was valid - String uriString = mVoiceSearchData.mVoiceSearchHtmls.get(index); - if (uriString != null) { - Uri dataUri = Uri.parse(uriString); - if (RecognizerResultsIntent.URI_SCHEME_INLINE.equals( - dataUri.getScheme())) { - // If there is only one base URL, use it. If there are - // more, there will be one for each index, so use the base - // URL corresponding to the index. - String baseUrl = mVoiceSearchData.mVoiceSearchBaseUrls.get( - mVoiceSearchData.mVoiceSearchBaseUrls.size() > 1 ? - index : 0); - mVoiceSearchData.mLastVoiceSearchUrl = baseUrl; - mMainView.loadDataWithBaseURL(baseUrl, - uriString.substring(RecognizerResultsIntent - .URI_SCHEME_INLINE.length() + 1), "text/html", - "utf-8", baseUrl); - return; - } - } - } - mVoiceSearchData.mLastVoiceSearchUrl - = mVoiceSearchData.mVoiceSearchUrls.get(index); - if (null == mVoiceSearchData.mLastVoiceSearchUrl) { - mVoiceSearchData.mLastVoiceSearchUrl = UrlUtils.smartUrlFilter( - mVoiceSearchData.mLastVoiceSearchTitle); - } - Map<String, String> headers = null; - if (mVoiceSearchData.mHeaders != null) { - int bundleIndex = mVoiceSearchData.mHeaders.size() == 1 ? 0 - : index; - Bundle bundle = mVoiceSearchData.mHeaders.get(bundleIndex); - if (bundle != null && !bundle.isEmpty()) { - Iterator<String> iter = bundle.keySet().iterator(); - headers = new HashMap<String, String>(); - while (iter.hasNext()) { - String key = iter.next(); - headers.put(key, bundle.getString(key)); - } - } - } - mMainView.loadUrl(mVoiceSearchData.mLastVoiceSearchUrl, headers); - } - /* package */ static class VoiceSearchData { - public VoiceSearchData(ArrayList<String> results, - ArrayList<String> urls, ArrayList<String> htmls, - ArrayList<String> baseUrls) { - mVoiceSearchResults = results; - mVoiceSearchUrls = urls; - mVoiceSearchHtmls = htmls; - mVoiceSearchBaseUrls = baseUrls; - } - /* - * ArrayList of suggestions to be displayed when opening the - * SearchManager - */ - public ArrayList<String> mVoiceSearchResults; - /* - * ArrayList of urls, associated with the suggestions in - * mVoiceSearchResults. - */ - public ArrayList<String> mVoiceSearchUrls; - /* - * ArrayList holding content to load for each item in - * mVoiceSearchResults. - */ - public ArrayList<String> mVoiceSearchHtmls; - /* - * ArrayList holding base urls for the items in mVoiceSearchResults. - * If non null, this will either have the same size as - * mVoiceSearchResults or have a size of 1, in which case all will use - * the same base url - */ - public ArrayList<String> mVoiceSearchBaseUrls; - /* - * The last url provided by voice search. Used for comparison to see if - * we are going to a page by some method besides voice search. - */ - public String mLastVoiceSearchUrl; - /** - * The last title used for voice search. Needed to update the title bar - * when switching tabs. - */ - public String mLastVoiceSearchTitle; - /** - * Whether the Intent which turned on voice search mode contained the - * String signifying that Google was the source. - */ - public boolean mSourceIsGoogle; - /** - * List of headers to be passed into the WebView containing location - * information - */ - public ArrayList<Bundle> mHeaders; - /** - * 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 Intent mVoiceSearchIntent; - /** - * String used to identify Google as the source of voice search. - */ - public static String SOURCE_IS_GOOGLE - = "android.speech.extras.SOURCE_IS_GOOGLE"; - } - // Container class for the next error dialog that needs to be displayed private class ErrorDialog { public final int mTitle; @@ -573,16 +338,6 @@ class Tab implements PictureListener { mCurrentState = new PageState(mContext, view.isPrivateBrowsingEnabled(), url, favicon); mLoadStartTime = SystemClock.uptimeMillis(); - if (mVoiceSearchData != null - && providersDiffer(url, mVoiceSearchData.mLastVoiceSearchUrl)) { - if (mVoiceSearchData.mSourceIsGoogle) { - Intent i = new Intent(LoggingEvents.ACTION_LOG_EVENT); - i.putExtra(LoggingEvents.EXTRA_FLUSH, true); - mContext.sendBroadcast(i); - } - revertVoiceSearchMode(); - } - // If we start a touch icon load and then load a new page, we don't // want to cancel the current touch icon loader. But, we do want to @@ -626,18 +381,6 @@ class Tab implements PictureListener { // return true if want to hijack the url to let another app to handle it @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { - if (voiceSearchSourceIsGoogle()) { - // This method is called when the user clicks on a link. - // VoiceSearchMode is turned off when the user leaves the - // Google results page, so at this point the user must be on - // that page. If the user clicked a link on that page, assume - // that the voice search was effective, and broadcast an Intent - // so a receiver can take note of that fact. - Intent logIntent = new Intent(LoggingEvents.ACTION_LOG_EVENT); - logIntent.putExtra(LoggingEvents.EXTRA_EVENT, - LoggingEvents.VoiceSearch.RESULT_CLICKED); - mContext.sendBroadcast(logIntent); - } if (mInForeground) { return mWebViewController.shouldOverrideUrlLoading(Tab.this, view, url); @@ -1420,9 +1163,6 @@ class Tab implements PictureListener { mWebBackForwardListClient = new WebBackForwardListClient() { @Override public void onNewHistoryItem(WebHistoryItem item) { - if (isInVoiceSearchMode()) { - item.setCustomData(mVoiceSearchData.mVoiceSearchIntent); - } if (mClearHistoryUrlPattern != null) { boolean match = mClearHistoryUrlPattern.matcher(item.getOriginalUrl()).matches(); @@ -1439,13 +1179,6 @@ class Tab implements PictureListener { mClearHistoryUrlPattern = null; } } - @Override - public void onIndexChanged(WebHistoryItem item, int index) { - Object data = item.getCustomData(); - if (data != null && data instanceof Intent) { - activateVoiceSearchMode((Intent) data); - } - } }; mCaptureWidth = mContext.getResources().getDimensionPixelSize( |