blob: db36fc05c1214bf434b44bcddce7fd63fe799e18 [file] [log] [blame]
Leon Scroggins571b3762010-05-26 10:25:01 -04001/*
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
17package com.android.browser;
18
Michael Kolb3aaef252011-03-09 18:13:56 -080019import com.android.browser.autocomplete.SuggestedTextController.TextChangeWatcher;
Michael Kolbc7485ae2010-09-03 10:10:58 -070020
Michael Kolb8233fac2010-10-26 16:08:53 -070021import android.app.Activity;
Leon Scroggins571b3762010-05-26 10:25:01 -040022import android.content.Context;
23import android.content.res.Resources;
Michael Kolbfe251992010-07-08 15:41:55 -070024import android.graphics.Bitmap;
Leon Scroggins571b3762010-05-26 10:25:01 -040025import android.graphics.drawable.Drawable;
Michael Kolb1ce78132010-09-23 15:50:53 -070026import android.text.TextUtils;
Leon Scroggins571b3762010-05-26 10:25:01 -040027import android.view.View;
Michael Kolba2b2ba82010-08-04 17:54:03 -070028import android.view.View.OnClickListener;
Michael Kolb31d469b2010-12-09 20:49:54 -080029import android.view.View.OnFocusChangeListener;
Michael Kolb7cdc4902011-02-03 17:54:40 -080030import android.view.ViewGroup;
Michael Kolbb6bc32c2010-12-10 11:51:54 -080031import android.webkit.WebView;
Michael Kolb7cdc4902011-02-03 17:54:40 -080032import android.widget.AbsoluteLayout;
33import android.widget.FrameLayout;
Michael Kolb5a72f182011-01-13 20:35:06 -080034import android.widget.ImageButton;
Leon Scroggins571b3762010-05-26 10:25:01 -040035import android.widget.ImageView;
Leon Scroggins571b3762010-05-26 10:25:01 -040036
Michael Kolbcfa3af52010-12-14 10:36:11 -080037import java.util.List;
38
Leon Scroggins571b3762010-05-26 10:25:01 -040039/**
Michael Kolbfe251992010-07-08 15:41:55 -070040 * tabbed title bar for xlarge screen browser
Leon Scroggins571b3762010-05-26 10:25:01 -040041 */
Michael Kolbfe251992010-07-08 15:41:55 -070042public class TitleBarXLarge extends TitleBarBase
Patrick Scott92066772011-03-10 08:46:27 -050043 implements OnClickListener, OnFocusChangeListener, TextChangeWatcher,
44 DeviceAccountLogin.AutoLoginCallback {
Leon Scroggins571b3762010-05-26 10:25:01 -040045
Michael Kolb66706532010-12-12 19:50:22 -080046 private XLargeUi mUi;
Michael Kolb8233fac2010-10-26 16:08:53 -070047
Michael Kolba2b2ba82010-08-04 17:54:03 -070048 private Drawable mStopDrawable;
49 private Drawable mReloadDrawable;
Michael Kolbc7485ae2010-09-03 10:10:58 -070050
Michael Kolb11d19782011-03-20 10:17:40 -070051 private View mUrlContainer;
Michael Kolb5a72f182011-01-13 20:35:06 -080052 private ImageButton mBackButton;
53 private ImageButton mForwardButton;
Michael Kolb31d469b2010-12-09 20:49:54 -080054 private ImageView mStar;
Michael Kolbe3524d82011-03-02 14:53:15 -080055 private ImageView mUrlIcon;
56 private ImageView mSearchButton;
Michael Kolb11d19782011-03-20 10:17:40 -070057 private View mContainer;
Michael Kolb513286f2010-09-09 12:55:12 -070058 private View mGoButton;
Michael Kolba2b2ba82010-08-04 17:54:03 -070059 private ImageView mStopButton;
Michael Kolba2b2ba82010-08-04 17:54:03 -070060 private View mAllButton;
Michael Kolbb7b115e2010-09-25 16:59:37 -070061 private View mClearButton;
Michael Kolbe3524d82011-03-02 14:53:15 -080062 private ImageView mVoiceSearch;
Michael Kolbc7485ae2010-09-03 10:10:58 -070063 private PageProgressView mProgressView;
Michael Kolbcfa3af52010-12-14 10:36:11 -080064 private Drawable mFocusDrawable;
65 private Drawable mUnfocusDrawable;
Michael Kolb81b6f832010-12-12 12:44:27 -080066
Michael Kolba2b2ba82010-08-04 17:54:03 -070067 private boolean mInLoad;
Michael Kolb376b5412010-12-15 11:52:57 -080068 private boolean mUseQuickControls;
Michael Kolbfe251992010-07-08 15:41:55 -070069
Michael Kolb81b6f832010-12-12 12:44:27 -080070 public TitleBarXLarge(Activity activity, UiController controller,
Michael Kolb66706532010-12-12 19:50:22 -080071 XLargeUi ui) {
John Reck92026732011-02-15 10:12:30 -080072 super(activity, controller, ui);
Michael Kolb81b6f832010-12-12 12:44:27 -080073 mUi = ui;
Michael Kolb8233fac2010-10-26 16:08:53 -070074 Resources resources = activity.getResources();
Michael Kolb5a72f182011-01-13 20:35:06 -080075 mStopDrawable = resources.getDrawable(R.drawable.ic_stop_holo_dark);
76 mReloadDrawable = resources.getDrawable(R.drawable.ic_refresh_holo_dark);
Michael Kolbcfa3af52010-12-14 10:36:11 -080077 mFocusDrawable = resources.getDrawable(
78 R.drawable.textfield_active_holo_dark);
79 mUnfocusDrawable = resources.getDrawable(
80 R.drawable.textfield_default_holo_dark);
Michael Kolbcfa3af52010-12-14 10:36:11 -080081 mInVoiceMode = false;
Michael Kolb11d19782011-03-20 10:17:40 -070082 initLayout(activity, R.layout.url_bar);
Michael Kolbfe251992010-07-08 15:41:55 -070083 }
Leon Scroggins571b3762010-05-26 10:25:01 -040084
Michael Kolb7cdc4902011-02-03 17:54:40 -080085 @Override
86 void setTitleGravity(int gravity) {
87 if (mUseQuickControls) {
88 FrameLayout.LayoutParams lp =
89 (FrameLayout.LayoutParams) getLayoutParams();
90 lp.gravity = gravity;
91 setLayoutParams(lp);
92 } else {
93 super.setTitleGravity(gravity);
94 }
95 }
96
Michael Kolb11d19782011-03-20 10:17:40 -070097 @Override
98 protected void initLayout(Context context, int layoutId) {
99 super.initLayout(context, layoutId);
Michael Kolbfe251992010-07-08 15:41:55 -0700100
Michael Kolb3f65c382010-08-20 15:31:16 -0700101 mContainer = findViewById(R.id.taburlbar);
Michael Kolbfe251992010-07-08 15:41:55 -0700102 mAllButton = findViewById(R.id.all_btn);
103 // TODO: Change enabled states based on whether you can go
Leon Scroggins571b3762010-05-26 10:25:01 -0400104 // back/forward. Probably should be done inside onPageStarted.
Michael Kolb5a72f182011-01-13 20:35:06 -0800105 mBackButton = (ImageButton) findViewById(R.id.back);
106 mForwardButton = (ImageButton) findViewById(R.id.forward);
Michael Kolbe3524d82011-03-02 14:53:15 -0800107 mUrlIcon = (ImageView) findViewById(R.id.url_icon);
Michael Kolb31d469b2010-12-09 20:49:54 -0800108 mStar = (ImageView) findViewById(R.id.star);
Michael Kolba2b2ba82010-08-04 17:54:03 -0700109 mStopButton = (ImageView) findViewById(R.id.stop);
Michael Kolbe3524d82011-03-02 14:53:15 -0800110 mSearchButton = (ImageView) findViewById(R.id.search);
Michael Kolba2b2ba82010-08-04 17:54:03 -0700111 mLockIcon = (ImageView) findViewById(R.id.lock);
Michael Kolb513286f2010-09-09 12:55:12 -0700112 mGoButton = findViewById(R.id.go);
Michael Kolbb7b115e2010-09-25 16:59:37 -0700113 mClearButton = findViewById(R.id.clear);
Michael Kolbe3524d82011-03-02 14:53:15 -0800114 mVoiceSearch = (ImageView) findViewById(R.id.voicesearch);
Michael Kolbc7485ae2010-09-03 10:10:58 -0700115 mProgressView = (PageProgressView) findViewById(R.id.progress);
Michael Kolb31d469b2010-12-09 20:49:54 -0800116 mUrlContainer = findViewById(R.id.urlbar_focused);
Michael Kolba2b2ba82010-08-04 17:54:03 -0700117 mBackButton.setOnClickListener(this);
118 mForwardButton.setOnClickListener(this);
119 mStar.setOnClickListener(this);
120 mAllButton.setOnClickListener(this);
121 mStopButton.setOnClickListener(this);
122 mSearchButton.setOnClickListener(this);
Michael Kolb513286f2010-09-09 12:55:12 -0700123 mGoButton.setOnClickListener(this);
Michael Kolbb7b115e2010-09-25 16:59:37 -0700124 mClearButton.setOnClickListener(this);
Michael Kolbcfa3af52010-12-14 10:36:11 -0800125 mVoiceSearch.setOnClickListener(this);
Michael Kolb31d469b2010-12-09 20:49:54 -0800126 mUrlInput.setContainer(mUrlContainer);
Michael Kolbdc2ee1b2011-02-14 14:34:40 -0800127 setFocusState(false);
Michael Kolb31d469b2010-12-09 20:49:54 -0800128 }
129
Michael Kolb5a72f182011-01-13 20:35:06 -0800130 void updateNavigationState(Tab tab) {
131 WebView web = tab.getWebView();
132 if (web != null) {
133 mBackButton.setImageResource(web.canGoBack()
134 ? R.drawable.ic_back_holo_dark
135 : R.drawable.ic_back_disabled_holo_dark);
136 mForwardButton.setImageResource(web.canGoForward()
137 ? R.drawable.ic_forward_holo_dark
138 : R.drawable.ic_forward_disabled_holo_dark);
139 }
140 }
141
Michael Kolb7cdc4902011-02-03 17:54:40 -0800142 private ViewGroup.LayoutParams makeLayoutParams() {
143 if (mUseQuickControls) {
144 return new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
145 LayoutParams.WRAP_CONTENT);
Michael Kolbcfa3af52010-12-14 10:36:11 -0800146 } else {
Michael Kolb7cdc4902011-02-03 17:54:40 -0800147 return new AbsoluteLayout.LayoutParams(
148 LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT,
149 0, 0);
Michael Kolbcfa3af52010-12-14 10:36:11 -0800150 }
151 }
152
Michael Kolb29ccf8a2011-02-23 16:13:24 -0800153 @Override
154 public int getEmbeddedHeight() {
Patrick Scott92066772011-03-10 08:46:27 -0500155 int height = mContainer.getHeight();
156 if (mAutoLogin.getVisibility() == View.VISIBLE) {
157 height += mAutoLogin.getHeight();
158 }
159 return height;
Michael Kolb29ccf8a2011-02-23 16:13:24 -0800160 }
161
Michael Kolb376b5412010-12-15 11:52:57 -0800162 void setUseQuickControls(boolean useQuickControls) {
163 mUseQuickControls = useQuickControls;
Michael Kolb7cdc4902011-02-03 17:54:40 -0800164 setLayoutParams(makeLayoutParams());
Michael Kolb376b5412010-12-15 11:52:57 -0800165 }
166
167 void setShowProgressOnly(boolean progress) {
Michael Kolb8a4c3822011-03-15 14:52:05 -0700168 if (progress && !inAutoLogin()) {
Michael Kolb376b5412010-12-15 11:52:57 -0800169 mContainer.setVisibility(View.GONE);
170 } else {
171 mContainer.setVisibility(View.VISIBLE);
172 }
173 }
174
Michael Kolb31d469b2010-12-09 20:49:54 -0800175 @Override
176 public void onFocusChange(View view, boolean hasFocus) {
Michael Kolbdc2ee1b2011-02-14 14:34:40 -0800177 // if losing focus and not in touch mode, leave as is
178 if (hasFocus || view.isInTouchMode() || mUrlInput.needsUpdate()) {
179 setFocusState(hasFocus);
180 mUrlContainer.setBackgroundDrawable(hasFocus
181 ? mFocusDrawable : mUnfocusDrawable);
182 }
183 if (hasFocus) {
184 mUrlInput.forceIme();
185 if (mInVoiceMode) {
186 mUrlInput.forceFilter();
187 }
188 } else if (!mUrlInput.needsUpdate()) {
189 mUrlInput.dismissDropDown();
190 mUrlInput.hideIME();
Michael Kolb2a56eca2011-02-25 09:45:06 -0800191 if (mUseQuickControls) {
192 mUi.hideTitleBar();
193 }
Narayan Kamathc93a2a92011-03-15 11:33:52 +0000194
195 if (mUrlInput.getText().length() == 0) {
196 Tab currentTab = mUiController.getTabControl().getCurrentTab();
197 if (currentTab != null) {
198 mUrlInput.setText(currentTab.getUrl(), false);
199 }
200 }
Michael Kolbdc2ee1b2011-02-14 14:34:40 -0800201 }
202 mUrlInput.clearNeedsUpdate();
Michael Kolbc7485ae2010-09-03 10:10:58 -0700203 }
Michael Kolbb7b115e2010-09-25 16:59:37 -0700204
John Reck94b7e042011-02-15 15:02:33 -0800205 @Override
Leon Scroggins4cd97792010-12-03 15:31:56 -0500206 public void setCurrentUrlIsBookmark(boolean isBookmark) {
Michael Kolb31d469b2010-12-09 20:49:54 -0800207 mStar.setActivated(isBookmark);
Leon Scroggins4cd97792010-12-03 15:31:56 -0500208 }
209
Michael Kolb81b6f832010-12-12 12:44:27 -0800210 /**
211 * called from the Ui when the user wants to edit
Michael Kolb81b6f832010-12-12 12:44:27 -0800212 * @param clearInput clear the input field
213 */
Michael Kolbdc2ee1b2011-02-14 14:34:40 -0800214 void startEditingUrl(boolean clearInput) {
Michael Kolbbd018d42010-12-15 15:43:39 -0800215 // editing takes preference of progress
216 mContainer.setVisibility(View.VISIBLE);
217 if (mUseQuickControls) {
218 mProgressView.setVisibility(View.GONE);
219 }
Michael Kolbcfa3af52010-12-14 10:36:11 -0800220 if (!mUrlInput.hasFocus()) {
221 mUrlInput.requestFocus();
222 }
Michael Kolb81b6f832010-12-12 12:44:27 -0800223 if (clearInput) {
224 mUrlInput.setText("");
Michael Kolbcfa3af52010-12-14 10:36:11 -0800225 } else if (mInVoiceMode) {
226 mUrlInput.showDropDown();
Michael Kolb81b6f832010-12-12 12:44:27 -0800227 }
228 }
229
Michael Kolb11d19782011-03-20 10:17:40 -0700230 @Override
231 protected void showAutoLogin(boolean animate) {
232 if (mUseQuickControls) {
233 mUi.showTitleBar();
234 }
235 super.showAutoLogin(animate);
Michael Kolb81b6f832010-12-12 12:44:27 -0800236 }
237
Michael Kolb11d19782011-03-20 10:17:40 -0700238 @Override
239 protected void hideAutoLogin(boolean animate) {
240 mAutoLoginHandler = null;
241 if (mUseQuickControls) {
242 mUi.hideTitleBar();
243 mAutoLogin.setVisibility(View.GONE);
244 mUi.refreshWebView();
245 } else {
246 super.hideAutoLogin(animate);
247 }
Patrick Scott92066772011-03-10 08:46:27 -0500248 }
249
Michael Kolba2b2ba82010-08-04 17:54:03 -0700250 @Override
251 public void onClick(View v) {
Michael Kolb7cdc4902011-02-03 17:54:40 -0800252 if (mBackButton == v) {
Michael Kolb8233fac2010-10-26 16:08:53 -0700253 mUiController.getCurrentTopWebView().goBack();
Michael Kolba2b2ba82010-08-04 17:54:03 -0700254 } else if (mForwardButton == v) {
Michael Kolb8233fac2010-10-26 16:08:53 -0700255 mUiController.getCurrentTopWebView().goForward();
Michael Kolba2b2ba82010-08-04 17:54:03 -0700256 } else if (mStar == v) {
Michael Kolb8233fac2010-10-26 16:08:53 -0700257 mUiController.bookmarkCurrentPage(
Leon Scrogginsbdff8a72011-02-11 15:49:04 -0500258 AddBookmarkPage.DEFAULT_FOLDER_ID, true);
Michael Kolba2b2ba82010-08-04 17:54:03 -0700259 } else if (mAllButton == v) {
Michael Kolb8233fac2010-10-26 16:08:53 -0700260 mUiController.bookmarksOrHistoryPicker(false);
Michael Kolba2b2ba82010-08-04 17:54:03 -0700261 } else if (mSearchButton == v) {
Michael Kolb81b6f832010-12-12 12:44:27 -0800262 mUi.editUrl(true);
Michael Kolba2b2ba82010-08-04 17:54:03 -0700263 } else if (mStopButton == v) {
264 stopOrRefresh();
Michael Kolb513286f2010-09-09 12:55:12 -0700265 } else if (mGoButton == v) {
Michael Kolb31d469b2010-12-09 20:49:54 -0800266 if (!TextUtils.isEmpty(mUrlInput.getText())) {
267 onAction(mUrlInput.getText().toString(), null,
Michael Kolb257cc2c2010-12-09 09:45:52 -0800268 UrlInputView.TYPED);
Michael Kolb1ce78132010-09-23 15:50:53 -0700269 }
Michael Kolbb7b115e2010-09-25 16:59:37 -0700270 } else if (mClearButton == v) {
Michael Kolb31d469b2010-12-09 20:49:54 -0800271 clearOrClose();
Michael Kolbcfa3af52010-12-14 10:36:11 -0800272 } else if (mVoiceSearch == v) {
273 mUiController.startVoiceSearch();
Michael Kolb11d19782011-03-20 10:17:40 -0700274 } else {
275 super.onClick(v);
Michael Kolbfe251992010-07-08 15:41:55 -0700276 }
277 }
278
Michael Kolba2b2ba82010-08-04 17:54:03 -0700279 @Override
280 void setFavicon(Bitmap icon) { }
Michael Kolbfe251992010-07-08 15:41:55 -0700281
Michael Kolb31d469b2010-12-09 20:49:54 -0800282 private void clearOrClose() {
Narayan Kamath5119edd2011-02-23 15:49:17 +0000283 if (TextUtils.isEmpty(mUrlInput.getUserText())) {
Michael Kolb31d469b2010-12-09 20:49:54 -0800284 // close
Michael Kolb7cdc4902011-02-03 17:54:40 -0800285 mUrlInput.clearFocus();
Michael Kolb31d469b2010-12-09 20:49:54 -0800286 } else {
287 // clear
288 mUrlInput.setText("");
289 }
290 }
291
Michael Kolb11d19782011-03-20 10:17:40 -0700292 @Override
293 protected void setFocusState(boolean focus) {
294 super.setFocusState(focus);
Michael Kolbdc2ee1b2011-02-14 14:34:40 -0800295 if (focus) {
Michael Kolbb7b115e2010-09-25 16:59:37 -0700296 mSearchButton.setVisibility(View.GONE);
Michael Kolb31d469b2010-12-09 20:49:54 -0800297 mStar.setVisibility(View.GONE);
298 mClearButton.setVisibility(View.VISIBLE);
Michael Kolbe3524d82011-03-02 14:53:15 -0800299 mUrlIcon.setImageResource(R.drawable.ic_search_holo_dark);
Michael Kolb60a68f52011-02-24 11:02:52 -0800300 updateSearchMode(false);
Michael Kolbb7b115e2010-09-25 16:59:37 -0700301 } else {
Michael Kolbb7b115e2010-09-25 16:59:37 -0700302 mGoButton.setVisibility(View.GONE);
Michael Kolb31d469b2010-12-09 20:49:54 -0800303 mVoiceSearch.setVisibility(View.GONE);
304 mStar.setVisibility(View.VISIBLE);
305 mClearButton.setVisibility(View.GONE);
Michael Kolb376b5412010-12-15 11:52:57 -0800306 if (mUseQuickControls) {
307 mSearchButton.setVisibility(View.GONE);
308 } else {
309 mSearchButton.setVisibility(View.VISIBLE);
310 }
Michael Kolbe3524d82011-03-02 14:53:15 -0800311 mUrlIcon.setImageResource(mInVoiceMode ?
312 R.drawable.ic_search_holo_dark
313 : R.drawable.ic_web_holo_dark);
Michael Kolbb7b115e2010-09-25 16:59:37 -0700314 }
315 }
316
Michael Kolba2b2ba82010-08-04 17:54:03 -0700317 private void stopOrRefresh() {
318 if (mInLoad) {
Michael Kolb8233fac2010-10-26 16:08:53 -0700319 mUiController.stopLoading();
Michael Kolba2b2ba82010-08-04 17:54:03 -0700320 } else {
Michael Kolb8233fac2010-10-26 16:08:53 -0700321 mUiController.getCurrentTopWebView().reload();
Michael Kolba2b2ba82010-08-04 17:54:03 -0700322 }
Leon Scroggins571b3762010-05-26 10:25:01 -0400323 }
324
325 /**
Michael Kolbfe251992010-07-08 15:41:55 -0700326 * Update the progress, from 0 to 100.
Leon Scroggins571b3762010-05-26 10:25:01 -0400327 */
Michael Kolbfe251992010-07-08 15:41:55 -0700328 @Override
Michael Kolba2b2ba82010-08-04 17:54:03 -0700329 void setProgress(int newProgress) {
Michael Kolbbd018d42010-12-15 15:43:39 -0800330 boolean blockvisuals = mUseQuickControls && isEditingUrl();
Michael Kolba2b2ba82010-08-04 17:54:03 -0700331 if (newProgress >= PROGRESS_MAX) {
Michael Kolbbd018d42010-12-15 15:43:39 -0800332 if (!blockvisuals) {
333 mProgressView.setProgress(PageProgressView.MAX_PROGRESS);
334 mProgressView.setVisibility(View.GONE);
335 mStopButton.setImageDrawable(mReloadDrawable);
336 }
Michael Kolba2b2ba82010-08-04 17:54:03 -0700337 mInLoad = false;
Michael Kolba2b2ba82010-08-04 17:54:03 -0700338 } else {
339 if (!mInLoad) {
Michael Kolbbd018d42010-12-15 15:43:39 -0800340 if (!blockvisuals) {
341 mProgressView.setVisibility(View.VISIBLE);
342 mStopButton.setImageDrawable(mStopDrawable);
343 }
Michael Kolba2b2ba82010-08-04 17:54:03 -0700344 mInLoad = true;
Michael Kolba2b2ba82010-08-04 17:54:03 -0700345 }
Michael Kolbb7b115e2010-09-25 16:59:37 -0700346 mProgressView.setProgress(newProgress * PageProgressView.MAX_PROGRESS
347 / PROGRESS_MAX);
Michael Kolba2b2ba82010-08-04 17:54:03 -0700348 }
Michael Kolbfe251992010-07-08 15:41:55 -0700349 }
350
Michael Kolb11d19782011-03-20 10:17:40 -0700351 @Override
352 protected void updateSearchMode(boolean userEdited) {
Narayan Kamath5119edd2011-02-23 15:49:17 +0000353 setSearchMode(!userEdited || TextUtils.isEmpty(mUrlInput.getUserText()));
Michael Kolb31d469b2010-12-09 20:49:54 -0800354 }
355
Michael Kolb11d19782011-03-20 10:17:40 -0700356 @Override
357 protected void setSearchMode(boolean voiceSearchEnabled) {
Michael Kolb793e05e2011-01-11 15:17:31 -0800358 boolean showvoicebutton = voiceSearchEnabled &&
Michael Kolb736990c2011-03-20 10:01:20 -0700359 mUiController.supportsVoiceSearch();
Michael Kolb793e05e2011-01-11 15:17:31 -0800360 mVoiceSearch.setVisibility(showvoicebutton ? View.VISIBLE :
Michael Kolb31d469b2010-12-09 20:49:54 -0800361 View.GONE);
362 mGoButton.setVisibility(voiceSearchEnabled ? View.GONE :
363 View.VISIBLE);
364 }
365
Michael Kolbfe251992010-07-08 15:41:55 -0700366 @Override
Michael Kolbcfa3af52010-12-14 10:36:11 -0800367 public void setInVoiceMode(boolean voicemode, List<String> voiceResults) {
Michael Kolb11d19782011-03-20 10:17:40 -0700368 super.setInVoiceMode(voicemode, voiceResults);
Michael Kolb3aaef252011-03-09 18:13:56 -0800369 if (voicemode) {
370 mUrlIcon.setImageDrawable(mSearchButton.getDrawable());
371 }
Michael Kolbcfa3af52010-12-14 10:36:11 -0800372 }
373
John Reck117f07d2011-01-24 09:39:03 -0800374 @Override
Michael Kolbdc2ee1b2011-02-14 14:34:40 -0800375 public View focusSearch(View focused, int dir) {
376 if (FOCUS_DOWN == dir && hasFocus()) {
377 return getCurrentWebView();
378 }
379 return super.focusSearch(focused, dir);
380 }
381
Leon Scroggins571b3762010-05-26 10:25:01 -0400382}