Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.browser; |
| 18 | |
Michael Kolb | 3aaef25 | 2011-03-09 18:13:56 -0800 | [diff] [blame] | 19 | import com.android.browser.autocomplete.SuggestedTextController.TextChangeWatcher; |
Michael Kolb | c7485ae | 2010-09-03 10:10:58 -0700 | [diff] [blame] | 20 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 21 | import android.app.Activity; |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 22 | import android.content.Context; |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 23 | import android.content.SharedPreferences; |
| 24 | import android.content.SharedPreferences.OnSharedPreferenceChangeListener; |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 25 | import android.content.res.Resources; |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 26 | import android.graphics.Bitmap; |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 27 | import android.graphics.drawable.Drawable; |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 28 | import android.preference.PreferenceManager; |
Michael Kolb | 1ce7813 | 2010-09-23 15:50:53 -0700 | [diff] [blame] | 29 | import android.text.TextUtils; |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 30 | import android.view.View; |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 31 | import android.view.View.OnClickListener; |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 32 | import android.view.View.OnFocusChangeListener; |
Michael Kolb | b6bc32c | 2010-12-10 11:51:54 -0800 | [diff] [blame] | 33 | import android.webkit.WebView; |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 34 | import android.widget.FrameLayout; |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 35 | import android.widget.ImageButton; |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 36 | import android.widget.ImageView; |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 37 | |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 38 | import java.util.List; |
| 39 | |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 40 | /** |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 41 | * tabbed title bar for xlarge screen browser |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 42 | */ |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 43 | public class TitleBarXLarge extends TitleBarBase |
Patrick Scott | 9206677 | 2011-03-10 08:46:27 -0500 | [diff] [blame] | 44 | implements OnClickListener, OnFocusChangeListener, TextChangeWatcher, |
| 45 | DeviceAccountLogin.AutoLoginCallback { |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 46 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 47 | private XLargeUi mUi; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 48 | |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 49 | private Drawable mStopDrawable; |
| 50 | private Drawable mReloadDrawable; |
Michael Kolb | c7485ae | 2010-09-03 10:10:58 -0700 | [diff] [blame] | 51 | |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 52 | private View mUrlContainer; |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 53 | private ImageButton mBackButton; |
| 54 | private ImageButton mForwardButton; |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 55 | private ImageView mStar; |
Michael Kolb | e3524d8 | 2011-03-02 14:53:15 -0800 | [diff] [blame] | 56 | private ImageView mUrlIcon; |
| 57 | private ImageView mSearchButton; |
Michael Kolb | 513286f | 2010-09-09 12:55:12 -0700 | [diff] [blame] | 58 | private View mGoButton; |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 59 | private ImageView mStopButton; |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 60 | private View mAllButton; |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 61 | private View mClearButton; |
Michael Kolb | e3524d8 | 2011-03-02 14:53:15 -0800 | [diff] [blame] | 62 | private ImageView mVoiceSearch; |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 63 | private Drawable mFocusDrawable; |
| 64 | private Drawable mUnfocusDrawable; |
Michael Kolb | 81b6f83 | 2010-12-12 12:44:27 -0800 | [diff] [blame] | 65 | |
Michael Kolb | 81b6f83 | 2010-12-12 12:44:27 -0800 | [diff] [blame] | 66 | public TitleBarXLarge(Activity activity, UiController controller, |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 67 | XLargeUi ui, FrameLayout parent) { |
| 68 | super(activity, controller, ui, parent); |
Michael Kolb | 81b6f83 | 2010-12-12 12:44:27 -0800 | [diff] [blame] | 69 | mUi = ui; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 70 | Resources resources = activity.getResources(); |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 71 | mStopDrawable = resources.getDrawable(R.drawable.ic_stop_holo_dark); |
| 72 | mReloadDrawable = resources.getDrawable(R.drawable.ic_refresh_holo_dark); |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 73 | mFocusDrawable = resources.getDrawable( |
| 74 | R.drawable.textfield_active_holo_dark); |
| 75 | mUnfocusDrawable = resources.getDrawable( |
| 76 | R.drawable.textfield_default_holo_dark); |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 77 | mInVoiceMode = false; |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 78 | initLayout(activity, R.layout.url_bar); |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 79 | } |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 80 | |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 81 | @Override |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 82 | protected void initLayout(Context context, int layoutId) { |
| 83 | super.initLayout(context, layoutId); |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 84 | mAllButton = findViewById(R.id.all_btn); |
| 85 | // TODO: Change enabled states based on whether you can go |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 86 | // back/forward. Probably should be done inside onPageStarted. |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 87 | mBackButton = (ImageButton) findViewById(R.id.back); |
| 88 | mForwardButton = (ImageButton) findViewById(R.id.forward); |
Michael Kolb | e3524d8 | 2011-03-02 14:53:15 -0800 | [diff] [blame] | 89 | mUrlIcon = (ImageView) findViewById(R.id.url_icon); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 90 | mStar = (ImageView) findViewById(R.id.star); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 91 | mStopButton = (ImageView) findViewById(R.id.stop); |
Michael Kolb | e3524d8 | 2011-03-02 14:53:15 -0800 | [diff] [blame] | 92 | mSearchButton = (ImageView) findViewById(R.id.search); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 93 | mLockIcon = (ImageView) findViewById(R.id.lock); |
Michael Kolb | 513286f | 2010-09-09 12:55:12 -0700 | [diff] [blame] | 94 | mGoButton = findViewById(R.id.go); |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 95 | mClearButton = findViewById(R.id.clear); |
Michael Kolb | e3524d8 | 2011-03-02 14:53:15 -0800 | [diff] [blame] | 96 | mVoiceSearch = (ImageView) findViewById(R.id.voicesearch); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 97 | mUrlContainer = findViewById(R.id.urlbar_focused); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 98 | mBackButton.setOnClickListener(this); |
| 99 | mForwardButton.setOnClickListener(this); |
| 100 | mStar.setOnClickListener(this); |
| 101 | mAllButton.setOnClickListener(this); |
| 102 | mStopButton.setOnClickListener(this); |
| 103 | mSearchButton.setOnClickListener(this); |
Michael Kolb | 513286f | 2010-09-09 12:55:12 -0700 | [diff] [blame] | 104 | mGoButton.setOnClickListener(this); |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 105 | mClearButton.setOnClickListener(this); |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 106 | mVoiceSearch.setOnClickListener(this); |
John Reck | 4650033 | 2011-06-07 14:36:10 -0700 | [diff] [blame] | 107 | setUaSwitcher(mUrlIcon); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 108 | mUrlInput.setContainer(mUrlContainer); |
Michael Kolb | dc2ee1b | 2011-02-14 14:34:40 -0800 | [diff] [blame] | 109 | setFocusState(false); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 110 | } |
| 111 | |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 112 | void updateNavigationState(Tab tab) { |
| 113 | WebView web = tab.getWebView(); |
| 114 | if (web != null) { |
| 115 | mBackButton.setImageResource(web.canGoBack() |
| 116 | ? R.drawable.ic_back_holo_dark |
| 117 | : R.drawable.ic_back_disabled_holo_dark); |
| 118 | mForwardButton.setImageResource(web.canGoForward() |
| 119 | ? R.drawable.ic_forward_holo_dark |
| 120 | : R.drawable.ic_forward_disabled_holo_dark); |
| 121 | } |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 122 | updateUrlIcon(); |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 123 | } |
| 124 | |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 125 | @Override |
Leon Scroggins | 4cd9779 | 2010-12-03 15:31:56 -0500 | [diff] [blame] | 126 | public void setCurrentUrlIsBookmark(boolean isBookmark) { |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 127 | mStar.setActivated(isBookmark); |
Leon Scroggins | 4cd9779 | 2010-12-03 15:31:56 -0500 | [diff] [blame] | 128 | } |
| 129 | |
Patrick Scott | 9206677 | 2011-03-10 08:46:27 -0500 | [diff] [blame] | 130 | |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 131 | @Override |
| 132 | public void onClick(View v) { |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 133 | if (mBackButton == v) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 134 | mUiController.getCurrentTopWebView().goBack(); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 135 | } else if (mForwardButton == v) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 136 | mUiController.getCurrentTopWebView().goForward(); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 137 | } else if (mStar == v) { |
John Reck | 3ffc5ca | 2011-06-10 15:56:06 -0700 | [diff] [blame] | 138 | mUiController.bookmarkCurrentPage(true); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 139 | } else if (mAllButton == v) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 140 | mUiController.bookmarksOrHistoryPicker(false); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 141 | } else if (mSearchButton == v) { |
Michael Kolb | 81b6f83 | 2010-12-12 12:44:27 -0800 | [diff] [blame] | 142 | mUi.editUrl(true); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 143 | } else if (mStopButton == v) { |
| 144 | stopOrRefresh(); |
Michael Kolb | 513286f | 2010-09-09 12:55:12 -0700 | [diff] [blame] | 145 | } else if (mGoButton == v) { |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 146 | if (!TextUtils.isEmpty(mUrlInput.getText())) { |
| 147 | onAction(mUrlInput.getText().toString(), null, |
Michael Kolb | 257cc2c | 2010-12-09 09:45:52 -0800 | [diff] [blame] | 148 | UrlInputView.TYPED); |
Michael Kolb | 1ce7813 | 2010-09-23 15:50:53 -0700 | [diff] [blame] | 149 | } |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 150 | } else if (mClearButton == v) { |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 151 | clearOrClose(); |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 152 | } else if (mVoiceSearch == v) { |
| 153 | mUiController.startVoiceSearch(); |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 154 | } else { |
| 155 | super.onClick(v); |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 156 | } |
| 157 | } |
| 158 | |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 159 | @Override |
| 160 | void setFavicon(Bitmap icon) { } |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 161 | |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 162 | private void clearOrClose() { |
Narayan Kamath | 5119edd | 2011-02-23 15:49:17 +0000 | [diff] [blame] | 163 | if (TextUtils.isEmpty(mUrlInput.getUserText())) { |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 164 | // close |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 165 | mUrlInput.clearFocus(); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 166 | } else { |
| 167 | // clear |
| 168 | mUrlInput.setText(""); |
| 169 | } |
| 170 | } |
| 171 | |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 172 | void updateUrlIcon() { |
John Reck | 4650033 | 2011-06-07 14:36:10 -0700 | [diff] [blame] | 173 | mUrlIcon.setImageResource(mInVoiceMode ? |
| 174 | R.drawable.ic_search_holo_dark |
| 175 | : R.drawable.ic_web_holo_dark); |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 176 | } |
| 177 | |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 178 | @Override |
| 179 | protected void setFocusState(boolean focus) { |
| 180 | super.setFocusState(focus); |
Michael Kolb | dc2ee1b | 2011-02-14 14:34:40 -0800 | [diff] [blame] | 181 | if (focus) { |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 182 | mSearchButton.setVisibility(View.GONE); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 183 | mStar.setVisibility(View.GONE); |
| 184 | mClearButton.setVisibility(View.VISIBLE); |
Michael Kolb | e3524d8 | 2011-03-02 14:53:15 -0800 | [diff] [blame] | 185 | mUrlIcon.setImageResource(R.drawable.ic_search_holo_dark); |
Michael Kolb | 60a68f5 | 2011-02-24 11:02:52 -0800 | [diff] [blame] | 186 | updateSearchMode(false); |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 187 | } else { |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 188 | mGoButton.setVisibility(View.GONE); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 189 | mVoiceSearch.setVisibility(View.GONE); |
| 190 | mStar.setVisibility(View.VISIBLE); |
| 191 | mClearButton.setVisibility(View.GONE); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 192 | if (mUseQuickControls) { |
| 193 | mSearchButton.setVisibility(View.GONE); |
| 194 | } else { |
| 195 | mSearchButton.setVisibility(View.VISIBLE); |
| 196 | } |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 197 | updateUrlIcon(); |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 198 | } |
John Reck | 7e5b8b5 | 2011-06-22 13:46:25 -0700 | [diff] [blame^] | 199 | mUrlContainer.setBackgroundDrawable(focus |
| 200 | ? mFocusDrawable : mUnfocusDrawable); |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 201 | } |
| 202 | |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 203 | private void stopOrRefresh() { |
| 204 | if (mInLoad) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 205 | mUiController.stopLoading(); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 206 | } else { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 207 | mUiController.getCurrentTopWebView().reload(); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 208 | } |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 209 | } |
| 210 | |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 211 | @Override |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 212 | protected void onProgressStarted() { |
| 213 | mStopButton.setImageDrawable(mStopDrawable); |
| 214 | } |
| 215 | |
| 216 | @Override |
| 217 | protected void onProgressStopped() { |
| 218 | mStopButton.setImageDrawable(mReloadDrawable); |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 219 | } |
| 220 | |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 221 | @Override |
| 222 | protected void updateSearchMode(boolean userEdited) { |
Narayan Kamath | 5119edd | 2011-02-23 15:49:17 +0000 | [diff] [blame] | 223 | setSearchMode(!userEdited || TextUtils.isEmpty(mUrlInput.getUserText())); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 224 | } |
| 225 | |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 226 | @Override |
| 227 | protected void setSearchMode(boolean voiceSearchEnabled) { |
Michael Kolb | 793e05e | 2011-01-11 15:17:31 -0800 | [diff] [blame] | 228 | boolean showvoicebutton = voiceSearchEnabled && |
Michael Kolb | 736990c | 2011-03-20 10:01:20 -0700 | [diff] [blame] | 229 | mUiController.supportsVoiceSearch(); |
Michael Kolb | 793e05e | 2011-01-11 15:17:31 -0800 | [diff] [blame] | 230 | mVoiceSearch.setVisibility(showvoicebutton ? View.VISIBLE : |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 231 | View.GONE); |
| 232 | mGoButton.setVisibility(voiceSearchEnabled ? View.GONE : |
| 233 | View.VISIBLE); |
| 234 | } |
| 235 | |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 236 | @Override |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 237 | public void setInVoiceMode(boolean voicemode, List<String> voiceResults) { |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 238 | super.setInVoiceMode(voicemode, voiceResults); |
Michael Kolb | 3aaef25 | 2011-03-09 18:13:56 -0800 | [diff] [blame] | 239 | if (voicemode) { |
| 240 | mUrlIcon.setImageDrawable(mSearchButton.getDrawable()); |
| 241 | } |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 242 | } |
| 243 | |
John Reck | 117f07d | 2011-01-24 09:39:03 -0800 | [diff] [blame] | 244 | @Override |
Michael Kolb | dc2ee1b | 2011-02-14 14:34:40 -0800 | [diff] [blame] | 245 | public View focusSearch(View focused, int dir) { |
| 246 | if (FOCUS_DOWN == dir && hasFocus()) { |
| 247 | return getCurrentWebView(); |
| 248 | } |
| 249 | return super.focusSearch(focused, dir); |
| 250 | } |
| 251 | |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 252 | } |