blob: 425404685cccc9918a92282ecdcc95ecde1a2658 [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 Kolbfe251992010-07-08 15:41:55 -070068
Michael Kolb81b6f832010-12-12 12:44:27 -080069 public TitleBarXLarge(Activity activity, UiController controller,
Michael Kolb66706532010-12-12 19:50:22 -080070 XLargeUi ui) {
John Reck92026732011-02-15 10:12:30 -080071 super(activity, controller, ui);
Michael Kolb81b6f832010-12-12 12:44:27 -080072 mUi = ui;
Michael Kolb8233fac2010-10-26 16:08:53 -070073 Resources resources = activity.getResources();
Michael Kolb5a72f182011-01-13 20:35:06 -080074 mStopDrawable = resources.getDrawable(R.drawable.ic_stop_holo_dark);
75 mReloadDrawable = resources.getDrawable(R.drawable.ic_refresh_holo_dark);
Michael Kolbcfa3af52010-12-14 10:36:11 -080076 mFocusDrawable = resources.getDrawable(
77 R.drawable.textfield_active_holo_dark);
78 mUnfocusDrawable = resources.getDrawable(
79 R.drawable.textfield_default_holo_dark);
Michael Kolbcfa3af52010-12-14 10:36:11 -080080 mInVoiceMode = false;
Michael Kolb11d19782011-03-20 10:17:40 -070081 initLayout(activity, R.layout.url_bar);
Michael Kolbfe251992010-07-08 15:41:55 -070082 }
Leon Scroggins571b3762010-05-26 10:25:01 -040083
Michael Kolb7cdc4902011-02-03 17:54:40 -080084 @Override
85 void setTitleGravity(int gravity) {
86 if (mUseQuickControls) {
87 FrameLayout.LayoutParams lp =
88 (FrameLayout.LayoutParams) getLayoutParams();
89 lp.gravity = gravity;
90 setLayoutParams(lp);
91 } else {
92 super.setTitleGravity(gravity);
93 }
94 }
95
Michael Kolb11d19782011-03-20 10:17:40 -070096 @Override
97 protected void initLayout(Context context, int layoutId) {
98 super.initLayout(context, layoutId);
Michael Kolbfe251992010-07-08 15:41:55 -070099
Michael Kolb3f65c382010-08-20 15:31:16 -0700100 mContainer = findViewById(R.id.taburlbar);
Michael Kolbfe251992010-07-08 15:41:55 -0700101 mAllButton = findViewById(R.id.all_btn);
102 // TODO: Change enabled states based on whether you can go
Leon Scroggins571b3762010-05-26 10:25:01 -0400103 // back/forward. Probably should be done inside onPageStarted.
Michael Kolb5a72f182011-01-13 20:35:06 -0800104 mBackButton = (ImageButton) findViewById(R.id.back);
105 mForwardButton = (ImageButton) findViewById(R.id.forward);
Michael Kolbe3524d82011-03-02 14:53:15 -0800106 mUrlIcon = (ImageView) findViewById(R.id.url_icon);
Michael Kolb31d469b2010-12-09 20:49:54 -0800107 mStar = (ImageView) findViewById(R.id.star);
Michael Kolba2b2ba82010-08-04 17:54:03 -0700108 mStopButton = (ImageView) findViewById(R.id.stop);
Michael Kolbe3524d82011-03-02 14:53:15 -0800109 mSearchButton = (ImageView) findViewById(R.id.search);
Michael Kolba2b2ba82010-08-04 17:54:03 -0700110 mLockIcon = (ImageView) findViewById(R.id.lock);
Michael Kolb513286f2010-09-09 12:55:12 -0700111 mGoButton = findViewById(R.id.go);
Michael Kolbb7b115e2010-09-25 16:59:37 -0700112 mClearButton = findViewById(R.id.clear);
Michael Kolbe3524d82011-03-02 14:53:15 -0800113 mVoiceSearch = (ImageView) findViewById(R.id.voicesearch);
Michael Kolbc7485ae2010-09-03 10:10:58 -0700114 mProgressView = (PageProgressView) findViewById(R.id.progress);
Michael Kolb31d469b2010-12-09 20:49:54 -0800115 mUrlContainer = findViewById(R.id.urlbar_focused);
Michael Kolba2b2ba82010-08-04 17:54:03 -0700116 mBackButton.setOnClickListener(this);
117 mForwardButton.setOnClickListener(this);
118 mStar.setOnClickListener(this);
119 mAllButton.setOnClickListener(this);
120 mStopButton.setOnClickListener(this);
121 mSearchButton.setOnClickListener(this);
Michael Kolb513286f2010-09-09 12:55:12 -0700122 mGoButton.setOnClickListener(this);
Michael Kolbb7b115e2010-09-25 16:59:37 -0700123 mClearButton.setOnClickListener(this);
Michael Kolbcfa3af52010-12-14 10:36:11 -0800124 mVoiceSearch.setOnClickListener(this);
Michael Kolb31d469b2010-12-09 20:49:54 -0800125 mUrlInput.setContainer(mUrlContainer);
Michael Kolbdc2ee1b2011-02-14 14:34:40 -0800126 setFocusState(false);
Michael Kolb31d469b2010-12-09 20:49:54 -0800127 }
128
Michael Kolb5a72f182011-01-13 20:35:06 -0800129 void updateNavigationState(Tab tab) {
130 WebView web = tab.getWebView();
131 if (web != null) {
132 mBackButton.setImageResource(web.canGoBack()
133 ? R.drawable.ic_back_holo_dark
134 : R.drawable.ic_back_disabled_holo_dark);
135 mForwardButton.setImageResource(web.canGoForward()
136 ? R.drawable.ic_forward_holo_dark
137 : R.drawable.ic_forward_disabled_holo_dark);
138 }
139 }
140
Michael Kolb7cdc4902011-02-03 17:54:40 -0800141 private ViewGroup.LayoutParams makeLayoutParams() {
142 if (mUseQuickControls) {
143 return new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
144 LayoutParams.WRAP_CONTENT);
Michael Kolbcfa3af52010-12-14 10:36:11 -0800145 } else {
Michael Kolb7cdc4902011-02-03 17:54:40 -0800146 return new AbsoluteLayout.LayoutParams(
147 LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT,
148 0, 0);
Michael Kolbcfa3af52010-12-14 10:36:11 -0800149 }
150 }
151
Michael Kolb29ccf8a2011-02-23 16:13:24 -0800152 @Override
153 public int getEmbeddedHeight() {
Patrick Scott92066772011-03-10 08:46:27 -0500154 int height = mContainer.getHeight();
155 if (mAutoLogin.getVisibility() == View.VISIBLE) {
156 height += mAutoLogin.getHeight();
157 }
158 return height;
Michael Kolb29ccf8a2011-02-23 16:13:24 -0800159 }
160
Michael Kolbfdb70242011-03-24 09:41:11 -0700161 @Override
162 protected void setUseQuickControls(boolean useQuickControls) {
Michael Kolb376b5412010-12-15 11:52:57 -0800163 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 Kolbc16c5952011-03-29 15:37:03 -0700214 @Override
Michael Kolbdc2ee1b2011-02-14 14:34:40 -0800215 void startEditingUrl(boolean clearInput) {
Michael Kolbbd018d42010-12-15 15:43:39 -0800216 // editing takes preference of progress
217 mContainer.setVisibility(View.VISIBLE);
218 if (mUseQuickControls) {
219 mProgressView.setVisibility(View.GONE);
220 }
Michael Kolbcfa3af52010-12-14 10:36:11 -0800221 if (!mUrlInput.hasFocus()) {
222 mUrlInput.requestFocus();
223 }
Michael Kolb81b6f832010-12-12 12:44:27 -0800224 if (clearInput) {
225 mUrlInput.setText("");
Michael Kolbcfa3af52010-12-14 10:36:11 -0800226 } else if (mInVoiceMode) {
227 mUrlInput.showDropDown();
Michael Kolb81b6f832010-12-12 12:44:27 -0800228 }
229 }
230
Michael Kolb11d19782011-03-20 10:17:40 -0700231 @Override
232 protected void showAutoLogin(boolean animate) {
233 if (mUseQuickControls) {
234 mUi.showTitleBar();
235 }
236 super.showAutoLogin(animate);
Michael Kolb81b6f832010-12-12 12:44:27 -0800237 }
238
Michael Kolb11d19782011-03-20 10:17:40 -0700239 @Override
240 protected void hideAutoLogin(boolean animate) {
241 mAutoLoginHandler = null;
242 if (mUseQuickControls) {
243 mUi.hideTitleBar();
244 mAutoLogin.setVisibility(View.GONE);
245 mUi.refreshWebView();
246 } else {
247 super.hideAutoLogin(animate);
248 }
Patrick Scott92066772011-03-10 08:46:27 -0500249 }
250
Michael Kolba2b2ba82010-08-04 17:54:03 -0700251 @Override
252 public void onClick(View v) {
Michael Kolb7cdc4902011-02-03 17:54:40 -0800253 if (mBackButton == v) {
Michael Kolb8233fac2010-10-26 16:08:53 -0700254 mUiController.getCurrentTopWebView().goBack();
Michael Kolba2b2ba82010-08-04 17:54:03 -0700255 } else if (mForwardButton == v) {
Michael Kolb8233fac2010-10-26 16:08:53 -0700256 mUiController.getCurrentTopWebView().goForward();
Michael Kolba2b2ba82010-08-04 17:54:03 -0700257 } else if (mStar == v) {
Michael Kolb8233fac2010-10-26 16:08:53 -0700258 mUiController.bookmarkCurrentPage(
Leon Scrogginsbdff8a72011-02-11 15:49:04 -0500259 AddBookmarkPage.DEFAULT_FOLDER_ID, true);
Michael Kolba2b2ba82010-08-04 17:54:03 -0700260 } else if (mAllButton == v) {
Michael Kolb8233fac2010-10-26 16:08:53 -0700261 mUiController.bookmarksOrHistoryPicker(false);
Michael Kolba2b2ba82010-08-04 17:54:03 -0700262 } else if (mSearchButton == v) {
Michael Kolb81b6f832010-12-12 12:44:27 -0800263 mUi.editUrl(true);
Michael Kolba2b2ba82010-08-04 17:54:03 -0700264 } else if (mStopButton == v) {
265 stopOrRefresh();
Michael Kolb513286f2010-09-09 12:55:12 -0700266 } else if (mGoButton == v) {
Michael Kolb31d469b2010-12-09 20:49:54 -0800267 if (!TextUtils.isEmpty(mUrlInput.getText())) {
268 onAction(mUrlInput.getText().toString(), null,
Michael Kolb257cc2c2010-12-09 09:45:52 -0800269 UrlInputView.TYPED);
Michael Kolb1ce78132010-09-23 15:50:53 -0700270 }
Michael Kolbb7b115e2010-09-25 16:59:37 -0700271 } else if (mClearButton == v) {
Michael Kolb31d469b2010-12-09 20:49:54 -0800272 clearOrClose();
Michael Kolbcfa3af52010-12-14 10:36:11 -0800273 } else if (mVoiceSearch == v) {
274 mUiController.startVoiceSearch();
Michael Kolb11d19782011-03-20 10:17:40 -0700275 } else {
276 super.onClick(v);
Michael Kolbfe251992010-07-08 15:41:55 -0700277 }
278 }
279
Michael Kolba2b2ba82010-08-04 17:54:03 -0700280 @Override
281 void setFavicon(Bitmap icon) { }
Michael Kolbfe251992010-07-08 15:41:55 -0700282
Michael Kolb31d469b2010-12-09 20:49:54 -0800283 private void clearOrClose() {
Narayan Kamath5119edd2011-02-23 15:49:17 +0000284 if (TextUtils.isEmpty(mUrlInput.getUserText())) {
Michael Kolb31d469b2010-12-09 20:49:54 -0800285 // close
Michael Kolb7cdc4902011-02-03 17:54:40 -0800286 mUrlInput.clearFocus();
Michael Kolb31d469b2010-12-09 20:49:54 -0800287 } else {
288 // clear
289 mUrlInput.setText("");
290 }
291 }
292
Michael Kolb11d19782011-03-20 10:17:40 -0700293 @Override
294 protected void setFocusState(boolean focus) {
295 super.setFocusState(focus);
Michael Kolbdc2ee1b2011-02-14 14:34:40 -0800296 if (focus) {
Michael Kolbb7b115e2010-09-25 16:59:37 -0700297 mSearchButton.setVisibility(View.GONE);
Michael Kolb31d469b2010-12-09 20:49:54 -0800298 mStar.setVisibility(View.GONE);
299 mClearButton.setVisibility(View.VISIBLE);
Michael Kolbe3524d82011-03-02 14:53:15 -0800300 mUrlIcon.setImageResource(R.drawable.ic_search_holo_dark);
Michael Kolb60a68f52011-02-24 11:02:52 -0800301 updateSearchMode(false);
Michael Kolbb7b115e2010-09-25 16:59:37 -0700302 } else {
Michael Kolbb7b115e2010-09-25 16:59:37 -0700303 mGoButton.setVisibility(View.GONE);
Michael Kolb31d469b2010-12-09 20:49:54 -0800304 mVoiceSearch.setVisibility(View.GONE);
305 mStar.setVisibility(View.VISIBLE);
306 mClearButton.setVisibility(View.GONE);
Michael Kolb376b5412010-12-15 11:52:57 -0800307 if (mUseQuickControls) {
308 mSearchButton.setVisibility(View.GONE);
309 } else {
310 mSearchButton.setVisibility(View.VISIBLE);
311 }
Michael Kolbe3524d82011-03-02 14:53:15 -0800312 mUrlIcon.setImageResource(mInVoiceMode ?
313 R.drawable.ic_search_holo_dark
314 : R.drawable.ic_web_holo_dark);
Michael Kolbb7b115e2010-09-25 16:59:37 -0700315 }
316 }
317
Michael Kolba2b2ba82010-08-04 17:54:03 -0700318 private void stopOrRefresh() {
319 if (mInLoad) {
Michael Kolb8233fac2010-10-26 16:08:53 -0700320 mUiController.stopLoading();
Michael Kolba2b2ba82010-08-04 17:54:03 -0700321 } else {
Michael Kolb8233fac2010-10-26 16:08:53 -0700322 mUiController.getCurrentTopWebView().reload();
Michael Kolba2b2ba82010-08-04 17:54:03 -0700323 }
Leon Scroggins571b3762010-05-26 10:25:01 -0400324 }
325
326 /**
Michael Kolbfe251992010-07-08 15:41:55 -0700327 * Update the progress, from 0 to 100.
Leon Scroggins571b3762010-05-26 10:25:01 -0400328 */
Michael Kolbfe251992010-07-08 15:41:55 -0700329 @Override
Michael Kolba2b2ba82010-08-04 17:54:03 -0700330 void setProgress(int newProgress) {
Michael Kolbbd018d42010-12-15 15:43:39 -0800331 boolean blockvisuals = mUseQuickControls && isEditingUrl();
Michael Kolba2b2ba82010-08-04 17:54:03 -0700332 if (newProgress >= PROGRESS_MAX) {
Michael Kolbbd018d42010-12-15 15:43:39 -0800333 if (!blockvisuals) {
334 mProgressView.setProgress(PageProgressView.MAX_PROGRESS);
335 mProgressView.setVisibility(View.GONE);
336 mStopButton.setImageDrawable(mReloadDrawable);
337 }
Michael Kolba2b2ba82010-08-04 17:54:03 -0700338 mInLoad = false;
Michael Kolba2b2ba82010-08-04 17:54:03 -0700339 } else {
340 if (!mInLoad) {
Michael Kolbbd018d42010-12-15 15:43:39 -0800341 if (!blockvisuals) {
342 mProgressView.setVisibility(View.VISIBLE);
343 mStopButton.setImageDrawable(mStopDrawable);
344 }
Michael Kolba2b2ba82010-08-04 17:54:03 -0700345 mInLoad = true;
Michael Kolba2b2ba82010-08-04 17:54:03 -0700346 }
Michael Kolbb7b115e2010-09-25 16:59:37 -0700347 mProgressView.setProgress(newProgress * PageProgressView.MAX_PROGRESS
348 / PROGRESS_MAX);
Michael Kolba2b2ba82010-08-04 17:54:03 -0700349 }
Michael Kolbfe251992010-07-08 15:41:55 -0700350 }
351
Michael Kolb11d19782011-03-20 10:17:40 -0700352 @Override
353 protected void updateSearchMode(boolean userEdited) {
Narayan Kamath5119edd2011-02-23 15:49:17 +0000354 setSearchMode(!userEdited || TextUtils.isEmpty(mUrlInput.getUserText()));
Michael Kolb31d469b2010-12-09 20:49:54 -0800355 }
356
Michael Kolb11d19782011-03-20 10:17:40 -0700357 @Override
358 protected void setSearchMode(boolean voiceSearchEnabled) {
Michael Kolb793e05e2011-01-11 15:17:31 -0800359 boolean showvoicebutton = voiceSearchEnabled &&
Michael Kolb736990c2011-03-20 10:01:20 -0700360 mUiController.supportsVoiceSearch();
Michael Kolb793e05e2011-01-11 15:17:31 -0800361 mVoiceSearch.setVisibility(showvoicebutton ? View.VISIBLE :
Michael Kolb31d469b2010-12-09 20:49:54 -0800362 View.GONE);
363 mGoButton.setVisibility(voiceSearchEnabled ? View.GONE :
364 View.VISIBLE);
365 }
366
Michael Kolbfe251992010-07-08 15:41:55 -0700367 @Override
Michael Kolbcfa3af52010-12-14 10:36:11 -0800368 public void setInVoiceMode(boolean voicemode, List<String> voiceResults) {
Michael Kolb11d19782011-03-20 10:17:40 -0700369 super.setInVoiceMode(voicemode, voiceResults);
Michael Kolb3aaef252011-03-09 18:13:56 -0800370 if (voicemode) {
371 mUrlIcon.setImageDrawable(mSearchButton.getDrawable());
372 }
Michael Kolbcfa3af52010-12-14 10:36:11 -0800373 }
374
John Reck117f07d2011-01-24 09:39:03 -0800375 @Override
Michael Kolbdc2ee1b2011-02-14 14:34:40 -0800376 public View focusSearch(View focused, int dir) {
377 if (FOCUS_DOWN == dir && hasFocus()) {
378 return getCurrentWebView();
379 }
380 return super.focusSearch(focused, dir);
381 }
382
Leon Scroggins571b3762010-05-26 10:25:01 -0400383}