diff options
-rw-r--r-- | src/com/android/browser/Controller.java | 6 | ||||
-rw-r--r-- | src/com/android/browser/TitleBar.java | 27 | ||||
-rw-r--r-- | src/com/android/browser/TitleBarXLarge.java | 6 | ||||
-rw-r--r-- | src/com/android/browser/UiController.java | 2 |
4 files changed, 12 insertions, 29 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index 36c519a..e7e999d 100644 --- a/src/com/android/browser/Controller.java +++ b/src/com/android/browser/Controller.java @@ -1067,6 +1067,12 @@ public class Controller mUi.revertVoiceTitleBar(tab); } + public boolean supportsVoiceSearch() { + SearchEngine searchEngine = BrowserSettings.getInstance() + .getSearchEngine(); + return (searchEngine != null && searchEngine.supportsVoiceSearch()); + } + public void showCustomView(Tab tab, View view, WebChromeClient.CustomViewCallback callback) { if (tab.inForeground()) { diff --git a/src/com/android/browser/TitleBar.java b/src/com/android/browser/TitleBar.java index f1fcdc3..361e94c 100644 --- a/src/com/android/browser/TitleBar.java +++ b/src/com/android/browser/TitleBar.java @@ -17,12 +17,8 @@ package com.android.browser; import android.app.Activity; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.graphics.drawable.Drawable; -import android.speech.RecognizerIntent; import android.text.SpannableString; import android.text.Spanned; import android.text.TextUtils; @@ -50,7 +46,6 @@ public class TitleBar extends TitleBarBase implements OnFocusChangeListener, private Drawable mBookmarkDrawable; private Drawable mVoiceDrawable; private boolean mInLoad; - private Intent mVoiceSearchIntent; private ImageSpan mArcsSpan; private View mContainer; @@ -78,25 +73,9 @@ public class TitleBar extends TitleBarBase implements OnFocusChangeListener, mHorizontalProgress = (PageProgressView) findViewById( R.id.progress_horizontal); - mVoiceSearchIntent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH); - mVoiceSearchIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, - RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH); - // This extra tells voice search not to send the application id in its - // results intent - http://b/2546173 - // - // TODO: Make a constant for this extra. - mVoiceSearchIntent.putExtra("android.speech.extras.SEND_APPLICATION_ID_EXTRA", - false); - PackageManager pm = activity.getPackageManager(); - ResolveInfo ri = pm.resolveActivity(mVoiceSearchIntent, - PackageManager.MATCH_DEFAULT_ONLY); Resources resources = getResources(); - if (ri == null) { - mVoiceSearchIntent = null; - } else { - mVoiceDrawable = resources.getDrawable( - android.R.drawable.ic_btn_speak_now); - } + mVoiceDrawable = resources.getDrawable( + android.R.drawable.ic_btn_speak_now); mBookmarkDrawable = mBookmarkButton.getDrawable(); mArcsSpan = new ImageSpan(activity, R.drawable.arcs, ImageSpan.ALIGN_BASELINE); @@ -122,7 +101,7 @@ public class TitleBar extends TitleBarBase implements OnFocusChangeListener, @Override void setInVoiceMode(boolean inVoiceMode) { if (mInVoiceMode == inVoiceMode) return; - mInVoiceMode = inVoiceMode && mVoiceSearchIntent != null; + mInVoiceMode = inVoiceMode && mUiController.supportsVoiceSearch(); Drawable titleDrawable; if (mInVoiceMode) { mBookmarkButton.setImageDrawable(mVoiceDrawable); diff --git a/src/com/android/browser/TitleBarXLarge.java b/src/com/android/browser/TitleBarXLarge.java index 5f02002..ee46561 100644 --- a/src/com/android/browser/TitleBarXLarge.java +++ b/src/com/android/browser/TitleBarXLarge.java @@ -18,9 +18,7 @@ package com.android.browser; import com.android.browser.UI.DropdownChangeListener; import com.android.browser.autocomplete.SuggestedTextController.TextChangeWatcher; -import com.android.browser.search.SearchEngine; -import android.accounts.Account; import android.app.Activity; import android.content.Context; import android.content.res.Resources; @@ -477,10 +475,8 @@ public class TitleBarXLarge extends TitleBarBase } private void setSearchMode(boolean voiceSearchEnabled) { - SearchEngine searchEngine = BrowserSettings.getInstance() - .getSearchEngine(); boolean showvoicebutton = voiceSearchEnabled && - (searchEngine != null && searchEngine.supportsVoiceSearch()); + mUiController.supportsVoiceSearch(); mVoiceSearch.setVisibility(showvoicebutton ? View.VISIBLE : View.GONE); mGoButton.setVisibility(voiceSearchEnabled ? View.GONE : diff --git a/src/com/android/browser/UiController.java b/src/com/android/browser/UiController.java index 65fa5f8..c22494b 100644 --- a/src/com/android/browser/UiController.java +++ b/src/com/android/browser/UiController.java @@ -60,6 +60,8 @@ public interface UiController extends BookmarksHistoryCallbacks { void startVoiceSearch(); + boolean supportsVoiceSearch(); + void showVoiceSearchResults(String title); void editUrl(); |