summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Kolb <kolby@google.com>2011-03-20 10:01:20 -0700
committerMichael Kolb <kolby@google.com>2011-03-20 10:01:20 -0700
commit736990cb9c57a346666d4424304947c21fb78ab7 (patch)
treef1c86713ac04fa19303f4bf79e429e89838d26b4 /src
parent1421c40e43eb7c35a8c326a80981ba85c9d46273 (diff)
downloadpackages_apps_Browser-736990cb9c57a346666d4424304947c21fb78ab7.zip
packages_apps_Browser-736990cb9c57a346666d4424304947c21fb78ab7.tar.gz
packages_apps_Browser-736990cb9c57a346666d4424304947c21fb78ab7.tar.bz2
unify voice search code
Change-Id: Icf1fc84405d08da8504ac91094e67c7d8d1c901d
Diffstat (limited to 'src')
-rw-r--r--src/com/android/browser/Controller.java6
-rw-r--r--src/com/android/browser/TitleBar.java27
-rw-r--r--src/com/android/browser/TitleBarXLarge.java6
-rw-r--r--src/com/android/browser/UiController.java2
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();