summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/TitleBar.java
diff options
context:
space:
mode:
authorLeon Scroggins <scroggo@google.com>2010-01-28 15:12:40 -0500
committerLeon Scroggins <scroggo@google.com>2010-01-29 17:17:22 -0500
commit58d56c6b5052faa86083965132cd51b1a9594d0e (patch)
treeff12588ede5a3ae4eda6b1ddfb548820dc80da42 /src/com/android/browser/TitleBar.java
parente5073c271be740654469ea63b69bd4a505ca222c (diff)
downloadpackages_apps_Browser-58d56c6b5052faa86083965132cd51b1a9594d0e.tar.gz
packages_apps_Browser-58d56c6b5052faa86083965132cd51b1a9594d0e.tar.bz2
packages_apps_Browser-58d56c6b5052faa86083965132cd51b1a9594d0e.zip
Handle the voice search intent.
Once the voice search intent has been handled, the title bar background changes to green, and touching it displays other voice search possibilities. Fixes http://b/issue?id=2390686
Diffstat (limited to 'src/com/android/browser/TitleBar.java')
-rw-r--r--src/com/android/browser/TitleBar.java37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/com/android/browser/TitleBar.java b/src/com/android/browser/TitleBar.java
index a9da7c0e0..743af9b0c 100644
--- a/src/com/android/browser/TitleBar.java
+++ b/src/com/android/browser/TitleBar.java
@@ -67,6 +67,8 @@ public class TitleBar extends LinearLayout {
private MyHandler mHandler;
private Intent mVoiceSearchIntent;
private boolean mInVoiceMode;
+ private Drawable mVoiceModeBackground;
+ private Drawable mNormalBackground;
private static int LONG_PRESS = 1;
@@ -110,6 +112,9 @@ public class TitleBar extends LinearLayout {
}
mStopDrawable = resources.getDrawable(R.drawable.ic_btn_stop_v2);
mBookmarkDrawable = mRtButton.getDrawable();
+ mVoiceModeBackground = resources.getDrawable(
+ R.drawable.textfield_voice_search);
+ mNormalBackground = mTitleBg.getBackground();
}
private class MyHandler extends Handler {
@@ -186,7 +191,12 @@ public class TitleBar extends LinearLayout {
mRtButton.setPressed(false);
} else if (mTitleBg.isPressed()) {
mHandler.removeMessages(LONG_PRESS);
- mBrowserActivity.onSearchRequested();
+ if (mInVoiceMode) {
+ mBrowserActivity.showVoiceSearchResults(
+ mTitle.getText().toString());
+ } else {
+ mBrowserActivity.onSearchRequested();
+ }
mTitleBg.setPressed(false);
}
break;
@@ -222,13 +232,20 @@ public class TitleBar extends LinearLayout {
/* package */ void setInVoiceMode(boolean inVoiceMode) {
if (mInVoiceMode == inVoiceMode) return;
mInVoiceMode = inVoiceMode && mVoiceSearchIntent != null;
+ Drawable rightButtonDrawable, titleDrawable;
if (mInVoiceMode) {
- mRtButton.setImageDrawable(mVoiceDrawable);
- } else if (mInLoad) {
- mRtButton.setImageDrawable(mStopDrawable);
+ rightButtonDrawable = mVoiceDrawable;
+ titleDrawable = mVoiceModeBackground;
} else {
- mRtButton.setImageDrawable(mBookmarkDrawable);
+ titleDrawable = mNormalBackground;
+ if (mInLoad) {
+ rightButtonDrawable = mStopDrawable;
+ } else {
+ rightButtonDrawable = mBookmarkDrawable;
+ }
}
+ mTitleBg.setBackgroundDrawable(titleDrawable);
+ mRtButton.setImageDrawable(rightButtonDrawable);
}
/**
@@ -275,13 +292,15 @@ public class TitleBar extends LinearLayout {
}
/**
- * Update the title and url.
+ * Update the text displayed in the title bar.
+ * @param title String to display. If null, the loading string will be
+ * shown.
*/
- /* package */ void setTitleAndUrl(CharSequence title, CharSequence url) {
- if (url == null) {
+ /* package */ void setDisplayTitle(String title) {
+ if (title == null) {
mTitle.setText(R.string.title_bar_loading);
} else {
- mTitle.setText(url.toString());
+ mTitle.setText(title);
}
}