blob: b6805124978402b3d2ad4f07a9e91361116205fc [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 Kolbc7485ae2010-09-03 10:10:58 -070019import com.android.browser.UrlInputView.UrlInputListener;
20
Michael Kolb8233fac2010-10-26 16:08:53 -070021import android.app.Activity;
Michael Kolbfe251992010-07-08 15:41:55 -070022import android.app.SearchManager;
Leon Scroggins571b3762010-05-26 10:25:01 -040023import android.content.Context;
Michael Kolbfe251992010-07-08 15:41:55 -070024import android.content.Intent;
Leon Scroggins571b3762010-05-26 10:25:01 -040025import android.content.res.Resources;
Michael Kolbfe251992010-07-08 15:41:55 -070026import android.graphics.Bitmap;
Leon Scroggins571b3762010-05-26 10:25:01 -040027import android.graphics.drawable.Drawable;
Michael Kolb257cc2c2010-12-09 09:45:52 -080028import android.os.Bundle;
Michael Kolb31d469b2010-12-09 20:49:54 -080029import android.text.Editable;
Michael Kolb1ce78132010-09-23 15:50:53 -070030import android.text.TextUtils;
Michael Kolb31d469b2010-12-09 20:49:54 -080031import android.text.TextWatcher;
Leon Scroggins571b3762010-05-26 10:25:01 -040032import android.view.LayoutInflater;
Leon Scroggins571b3762010-05-26 10:25:01 -040033import android.view.View;
Michael Kolba2b2ba82010-08-04 17:54:03 -070034import android.view.View.OnClickListener;
Michael Kolb31d469b2010-12-09 20:49:54 -080035import android.view.View.OnFocusChangeListener;
Michael Kolbb6bc32c2010-12-10 11:51:54 -080036import android.webkit.WebView;
Leon Scroggins571b3762010-05-26 10:25:01 -040037import android.widget.ImageView;
Leon Scroggins571b3762010-05-26 10:25:01 -040038
Michael Kolbcfa3af52010-12-14 10:36:11 -080039import java.util.List;
40
Leon Scroggins571b3762010-05-26 10:25:01 -040041/**
Michael Kolbfe251992010-07-08 15:41:55 -070042 * tabbed title bar for xlarge screen browser
Leon Scroggins571b3762010-05-26 10:25:01 -040043 */
Michael Kolbfe251992010-07-08 15:41:55 -070044public class TitleBarXLarge extends TitleBarBase
Michael Kolb31d469b2010-12-09 20:49:54 -080045 implements UrlInputListener, OnClickListener, OnFocusChangeListener,
46 TextWatcher {
Leon Scroggins571b3762010-05-26 10:25:01 -040047
Michael Kolbfe251992010-07-08 15:41:55 -070048 private static final int PROGRESS_MAX = 100;
Leon Scroggins571b3762010-05-26 10:25:01 -040049
Michael Kolb8233fac2010-10-26 16:08:53 -070050 private UiController mUiController;
Michael Kolb66706532010-12-12 19:50:22 -080051 private XLargeUi mUi;
Michael Kolb8233fac2010-10-26 16:08:53 -070052
Michael Kolba2b2ba82010-08-04 17:54:03 -070053 private Drawable mStopDrawable;
54 private Drawable mReloadDrawable;
Michael Kolbc7485ae2010-09-03 10:10:58 -070055
Michael Kolb3f65c382010-08-20 15:31:16 -070056 private View mContainer;
Michael Kolba2b2ba82010-08-04 17:54:03 -070057 private View mBackButton;
58 private View mForwardButton;
Michael Kolb31d469b2010-12-09 20:49:54 -080059 private ImageView mStar;
Michael Kolba2b2ba82010-08-04 17:54:03 -070060 private View mSearchButton;
Michael Kolb31d469b2010-12-09 20:49:54 -080061 private View mUrlContainer;
Michael Kolb513286f2010-09-09 12:55:12 -070062 private View mGoButton;
Michael Kolba2b2ba82010-08-04 17:54:03 -070063 private ImageView mStopButton;
Michael Kolba2b2ba82010-08-04 17:54:03 -070064 private View mAllButton;
Michael Kolbb7b115e2010-09-25 16:59:37 -070065 private View mClearButton;
Michael Kolb31d469b2010-12-09 20:49:54 -080066 private View mVoiceSearch;
Michael Kolbcfa3af52010-12-14 10:36:11 -080067 private View mVoiceSearchIndicator;
Michael Kolbc7485ae2010-09-03 10:10:58 -070068 private PageProgressView mProgressView;
Michael Kolb31d469b2010-12-09 20:49:54 -080069 private UrlInputView mUrlInput;
Michael Kolbcfa3af52010-12-14 10:36:11 -080070 private Drawable mFocusDrawable;
71 private Drawable mUnfocusDrawable;
72 private boolean mInVoiceMode;
Michael Kolb81b6f832010-12-12 12:44:27 -080073
Michael Kolba2b2ba82010-08-04 17:54:03 -070074 private boolean mInLoad;
Michael Kolbcfa3af52010-12-14 10:36:11 -080075 private boolean mEditable;
Michael Kolbfe251992010-07-08 15:41:55 -070076
Michael Kolb81b6f832010-12-12 12:44:27 -080077 public TitleBarXLarge(Activity activity, UiController controller,
Michael Kolb66706532010-12-12 19:50:22 -080078 XLargeUi ui) {
Michael Kolb8233fac2010-10-26 16:08:53 -070079 super(activity);
Michael Kolb8233fac2010-10-26 16:08:53 -070080 mUiController = controller;
Michael Kolb81b6f832010-12-12 12:44:27 -080081 mUi = ui;
Michael Kolb8233fac2010-10-26 16:08:53 -070082 Resources resources = activity.getResources();
Michael Kolbc7485ae2010-09-03 10:10:58 -070083 mStopDrawable = resources.getDrawable(R.drawable.ic_stop_normal);
84 mReloadDrawable = resources.getDrawable(R.drawable.ic_refresh_normal);
Michael Kolbcfa3af52010-12-14 10:36:11 -080085 mFocusDrawable = resources.getDrawable(
86 R.drawable.textfield_active_holo_dark);
87 mUnfocusDrawable = resources.getDrawable(
88 R.drawable.textfield_default_holo_dark);
Michael Kolb8233fac2010-10-26 16:08:53 -070089 rebuildLayout(activity, true);
Michael Kolbcfa3af52010-12-14 10:36:11 -080090 mInVoiceMode = false;
Michael Kolbfe251992010-07-08 15:41:55 -070091 }
Leon Scroggins571b3762010-05-26 10:25:01 -040092
Michael Kolbfe251992010-07-08 15:41:55 -070093 private void rebuildLayout(Context context, boolean rebuildData) {
Michael Kolbfe251992010-07-08 15:41:55 -070094 LayoutInflater factory = LayoutInflater.from(context);
Michael Kolba2b2ba82010-08-04 17:54:03 -070095 factory.inflate(R.layout.url_bar, this);
Michael Kolbfe251992010-07-08 15:41:55 -070096
Michael Kolb3f65c382010-08-20 15:31:16 -070097 mContainer = findViewById(R.id.taburlbar);
Michael Kolb31d469b2010-12-09 20:49:54 -080098 mUrlInput = (UrlInputView) findViewById(R.id.url_focused);
Michael Kolbfe251992010-07-08 15:41:55 -070099 mAllButton = findViewById(R.id.all_btn);
100 // TODO: Change enabled states based on whether you can go
Leon Scroggins571b3762010-05-26 10:25:01 -0400101 // back/forward. Probably should be done inside onPageStarted.
102 mBackButton = findViewById(R.id.back);
103 mForwardButton = findViewById(R.id.forward);
Michael Kolb31d469b2010-12-09 20:49:54 -0800104 mStar = (ImageView) findViewById(R.id.star);
Michael Kolba2b2ba82010-08-04 17:54:03 -0700105 mStopButton = (ImageView) findViewById(R.id.stop);
106 mSearchButton = findViewById(R.id.search);
107 mLockIcon = (ImageView) findViewById(R.id.lock);
Michael Kolb513286f2010-09-09 12:55:12 -0700108 mGoButton = findViewById(R.id.go);
Michael Kolbb7b115e2010-09-25 16:59:37 -0700109 mClearButton = findViewById(R.id.clear);
Michael Kolb31d469b2010-12-09 20:49:54 -0800110 mVoiceSearch = findViewById(R.id.voicesearch);
Michael Kolbc7485ae2010-09-03 10:10:58 -0700111 mProgressView = (PageProgressView) findViewById(R.id.progress);
Michael Kolb31d469b2010-12-09 20:49:54 -0800112 mUrlContainer = findViewById(R.id.urlbar_focused);
Michael Kolbcfa3af52010-12-14 10:36:11 -0800113 mVoiceSearchIndicator = findViewById(R.id.voice_icon);
Michael Kolba2b2ba82010-08-04 17:54:03 -0700114 mBackButton.setOnClickListener(this);
115 mForwardButton.setOnClickListener(this);
116 mStar.setOnClickListener(this);
117 mAllButton.setOnClickListener(this);
118 mStopButton.setOnClickListener(this);
119 mSearchButton.setOnClickListener(this);
Michael Kolb513286f2010-09-09 12:55:12 -0700120 mGoButton.setOnClickListener(this);
Michael Kolbb7b115e2010-09-25 16:59:37 -0700121 mClearButton.setOnClickListener(this);
Michael Kolbcfa3af52010-12-14 10:36:11 -0800122 mVoiceSearch.setOnClickListener(this);
Michael Kolb31d469b2010-12-09 20:49:54 -0800123 mUrlContainer.setOnClickListener(this);
124 mUrlInput.setUrlInputListener(this);
125 mUrlInput.setContainer(mUrlContainer);
126 mUrlInput.setController(mUiController);
127 mUrlInput.setOnFocusChangeListener(this);
128 mUrlInput.setSelectAllOnFocus(true);
129 mUrlInput.addTextChangedListener(this);
130 setUrlMode(false);
131 }
132
Michael Kolbcfa3af52010-12-14 10:36:11 -0800133 public void setEditable(boolean editable) {
134 mEditable = editable;
135 mUrlInput.setFocusable(mEditable);
136 if (!mEditable) {
137 mUrlInput.setOnClickListener(this);
138 } else {
139 mUrlContainer.setOnClickListener(null);
140 }
141 }
142
Michael Kolb31d469b2010-12-09 20:49:54 -0800143 @Override
144 public void onFocusChange(View view, boolean hasFocus) {
Michael Kolbcfa3af52010-12-14 10:36:11 -0800145 if (!mEditable && hasFocus) {
146 mUi.editUrl(false);
147 } else {
148 setUrlMode(hasFocus);
149 }
150 mUrlContainer.setBackgroundDrawable(hasFocus
151 ? mFocusDrawable : mUnfocusDrawable);
Michael Kolbc7485ae2010-09-03 10:10:58 -0700152 }
Michael Kolbb7b115e2010-09-25 16:59:37 -0700153
Leon Scroggins4cd97792010-12-03 15:31:56 -0500154 public void setCurrentUrlIsBookmark(boolean isBookmark) {
Michael Kolb31d469b2010-12-09 20:49:54 -0800155 mStar.setActivated(isBookmark);
Leon Scroggins4cd97792010-12-03 15:31:56 -0500156 }
157
Michael Kolb81b6f832010-12-12 12:44:27 -0800158 /**
159 * called from the Ui when the user wants to edit
160 * Note: only the fake titlebar will get this callback
161 * independent of which input field started the edit mode
162 * @param clearInput clear the input field
163 */
164 void onEditUrl(boolean clearInput) {
Michael Kolbcfa3af52010-12-14 10:36:11 -0800165 if (!mUrlInput.hasFocus()) {
166 mUrlInput.requestFocus();
167 }
Michael Kolb81b6f832010-12-12 12:44:27 -0800168 if (clearInput) {
169 mUrlInput.setText("");
Michael Kolbcfa3af52010-12-14 10:36:11 -0800170 } else if (mInVoiceMode) {
171 mUrlInput.showDropDown();
Michael Kolb81b6f832010-12-12 12:44:27 -0800172 }
173 }
174
175 boolean isEditingUrl() {
176 return mUrlInput.hasFocus();
177 }
178
Michael Kolba2b2ba82010-08-04 17:54:03 -0700179 @Override
180 public void onClick(View v) {
Michael Kolb81b6f832010-12-12 12:44:27 -0800181 if (mUrlInput == v) {
Michael Kolbcfa3af52010-12-14 10:36:11 -0800182 mUi.editUrl(false);
183 } else if (mUrlContainer == v) {
Michael Kolb81b6f832010-12-12 12:44:27 -0800184 if (!mUrlInput.hasFocus()) {
185 mUi.editUrl(false);
186 }
187 } else if (mBackButton == v) {
Michael Kolb8233fac2010-10-26 16:08:53 -0700188 mUiController.getCurrentTopWebView().goBack();
Michael Kolba2b2ba82010-08-04 17:54:03 -0700189 } else if (mForwardButton == v) {
Michael Kolb8233fac2010-10-26 16:08:53 -0700190 mUiController.getCurrentTopWebView().goForward();
Michael Kolba2b2ba82010-08-04 17:54:03 -0700191 } else if (mStar == v) {
Michael Kolb8233fac2010-10-26 16:08:53 -0700192 mUiController.bookmarkCurrentPage(
Leon Scroggins88d08032010-10-21 15:17:10 -0400193 AddBookmarkPage.DEFAULT_FOLDER_ID);
Michael Kolba2b2ba82010-08-04 17:54:03 -0700194 } else if (mAllButton == v) {
Michael Kolb8233fac2010-10-26 16:08:53 -0700195 mUiController.bookmarksOrHistoryPicker(false);
Michael Kolba2b2ba82010-08-04 17:54:03 -0700196 } else if (mSearchButton == v) {
Michael Kolb81b6f832010-12-12 12:44:27 -0800197 mUi.editUrl(true);
Michael Kolba2b2ba82010-08-04 17:54:03 -0700198 } else if (mStopButton == v) {
199 stopOrRefresh();
Michael Kolb513286f2010-09-09 12:55:12 -0700200 } else if (mGoButton == v) {
Michael Kolb31d469b2010-12-09 20:49:54 -0800201 if (!TextUtils.isEmpty(mUrlInput.getText())) {
202 onAction(mUrlInput.getText().toString(), null,
Michael Kolb257cc2c2010-12-09 09:45:52 -0800203 UrlInputView.TYPED);
Michael Kolb1ce78132010-09-23 15:50:53 -0700204 }
Michael Kolbb7b115e2010-09-25 16:59:37 -0700205 } else if (mClearButton == v) {
Michael Kolb31d469b2010-12-09 20:49:54 -0800206 clearOrClose();
Michael Kolbcfa3af52010-12-14 10:36:11 -0800207 } else if (mVoiceSearch == v) {
208 mUiController.startVoiceSearch();
Michael Kolbfe251992010-07-08 15:41:55 -0700209 }
210 }
211
Michael Kolb3f65c382010-08-20 15:31:16 -0700212 int getHeightWithoutProgress() {
213 return mContainer.getHeight();
214 }
215
Michael Kolba2b2ba82010-08-04 17:54:03 -0700216 @Override
217 void setFavicon(Bitmap icon) { }
Michael Kolbfe251992010-07-08 15:41:55 -0700218
Michael Kolb31d469b2010-12-09 20:49:54 -0800219 private void clearOrClose() {
220 if (TextUtils.isEmpty(mUrlInput.getText())) {
221 // close
222 setUrlMode(false);
223 } else {
224 // clear
225 mUrlInput.setText("");
226 }
227 }
228
Michael Kolbfe251992010-07-08 15:41:55 -0700229 // UrlInputListener implementation
230
Michael Kolb81b6f832010-12-12 12:44:27 -0800231 /**
232 * callback from suggestion dropdown
233 * user selected a suggestion
234 */
Michael Kolbfe251992010-07-08 15:41:55 -0700235 @Override
Michael Kolb257cc2c2010-12-09 09:45:52 -0800236 public void onAction(String text, String extra, String source) {
Michael Kolb8233fac2010-10-26 16:08:53 -0700237 mUiController.getCurrentTopWebView().requestFocus();
Michael Kolb66706532010-12-12 19:50:22 -0800238 mUi.hideFakeTitleBar();
Michael Kolbfe251992010-07-08 15:41:55 -0700239 Intent i = new Intent();
240 i.setAction(Intent.ACTION_SEARCH);
241 i.putExtra(SearchManager.QUERY, text);
John Reck40f720e2010-11-10 11:57:04 -0800242 if (extra != null) {
243 i.putExtra(SearchManager.EXTRA_DATA_KEY, extra);
244 }
Michael Kolb257cc2c2010-12-09 09:45:52 -0800245 if (source != null) {
246 Bundle appData = new Bundle();
247 appData.putString(com.android.common.Search.SOURCE, source);
248 i.putExtra(SearchManager.APP_DATA, appData);
249 }
Michael Kolb8233fac2010-10-26 16:08:53 -0700250 mUiController.handleNewIntent(i);
Michael Kolbb7b115e2010-09-25 16:59:37 -0700251 setUrlMode(false);
Michael Kolb513286f2010-09-09 12:55:12 -0700252 setDisplayTitle(text);
Michael Kolbfe251992010-07-08 15:41:55 -0700253 }
254
255 @Override
256 public void onDismiss() {
Michael Kolbb6bc32c2010-12-10 11:51:54 -0800257 WebView top = mUiController.getCurrentTopWebView();
258 if (top != null) {
259 mUiController.getCurrentTopWebView().requestFocus();
260 }
Michael Kolb66706532010-12-12 19:50:22 -0800261 mUi.hideFakeTitleBar();
Michael Kolbb7b115e2010-09-25 16:59:37 -0700262 setUrlMode(false);
Michael Kolbb6bc32c2010-12-10 11:51:54 -0800263 // if top != null current must be set
Michael Kolbcfa3af52010-12-14 10:36:11 -0800264 if ((top != null) && !mInVoiceMode) {
Michael Kolbb6bc32c2010-12-10 11:51:54 -0800265 setDisplayTitle(mUiController.getCurrentWebView().getUrl());
266 }
Michael Kolb513286f2010-09-09 12:55:12 -0700267 }
268
Michael Kolb81b6f832010-12-12 12:44:27 -0800269 /**
270 * callback from the suggestion dropdown
271 * copy text to input field and stay in edit mode
272 */
Michael Kolb513286f2010-09-09 12:55:12 -0700273 @Override
274 public void onEdit(String text) {
Michael Kolb7b20ddd2010-10-14 15:03:28 -0700275 setDisplayTitle(text, true);
Michael Kolb513286f2010-09-09 12:55:12 -0700276 if (text != null) {
Michael Kolb31d469b2010-12-09 20:49:54 -0800277 mUrlInput.setSelection(text.length());
Michael Kolb513286f2010-09-09 12:55:12 -0700278 }
279 }
280
Michael Kolb81b6f832010-12-12 12:44:27 -0800281 void setUrlMode(boolean focused) {
Michael Kolbb7b115e2010-09-25 16:59:37 -0700282 if (focused) {
Michael Kolb31d469b2010-12-09 20:49:54 -0800283 mUrlInput.setDropDownWidth(mUrlContainer.getWidth());
284 mUrlInput.setDropDownHorizontalOffset(-mUrlInput.getLeft());
Michael Kolbb7b115e2010-09-25 16:59:37 -0700285 mSearchButton.setVisibility(View.GONE);
Michael Kolb31d469b2010-12-09 20:49:54 -0800286 mStar.setVisibility(View.GONE);
287 mClearButton.setVisibility(View.VISIBLE);
Michael Kolbcfa3af52010-12-14 10:36:11 -0800288 if (mInVoiceMode) {
289 mVoiceSearchIndicator.setVisibility(View.VISIBLE);
290 }
Michael Kolb31d469b2010-12-09 20:49:54 -0800291 updateSearchMode();
Michael Kolbb7b115e2010-09-25 16:59:37 -0700292 } else {
Michael Kolb31d469b2010-12-09 20:49:54 -0800293 mUrlInput.clearFocus();
Michael Kolbb7b115e2010-09-25 16:59:37 -0700294 mSearchButton.setVisibility(View.VISIBLE);
295 mGoButton.setVisibility(View.GONE);
Michael Kolb31d469b2010-12-09 20:49:54 -0800296 mVoiceSearch.setVisibility(View.GONE);
297 mStar.setVisibility(View.VISIBLE);
298 mClearButton.setVisibility(View.GONE);
Michael Kolbcfa3af52010-12-14 10:36:11 -0800299 mVoiceSearchIndicator.setVisibility(View.GONE);
Michael Kolbb7b115e2010-09-25 16:59:37 -0700300 }
301 }
302
Michael Kolba2b2ba82010-08-04 17:54:03 -0700303 private void stopOrRefresh() {
304 if (mInLoad) {
Michael Kolb8233fac2010-10-26 16:08:53 -0700305 mUiController.stopLoading();
Michael Kolba2b2ba82010-08-04 17:54:03 -0700306 } else {
Michael Kolb8233fac2010-10-26 16:08:53 -0700307 mUiController.getCurrentTopWebView().reload();
Michael Kolba2b2ba82010-08-04 17:54:03 -0700308 }
Leon Scroggins571b3762010-05-26 10:25:01 -0400309 }
310
311 /**
Michael Kolbfe251992010-07-08 15:41:55 -0700312 * Update the progress, from 0 to 100.
Leon Scroggins571b3762010-05-26 10:25:01 -0400313 */
Michael Kolbfe251992010-07-08 15:41:55 -0700314 @Override
Michael Kolba2b2ba82010-08-04 17:54:03 -0700315 void setProgress(int newProgress) {
316 if (newProgress >= PROGRESS_MAX) {
Michael Kolbb7b115e2010-09-25 16:59:37 -0700317 mProgressView.setProgress(PageProgressView.MAX_PROGRESS);
Michael Kolba2b2ba82010-08-04 17:54:03 -0700318 mProgressView.setVisibility(View.GONE);
319 mInLoad = false;
320 mStopButton.setImageDrawable(mReloadDrawable);
321 } else {
322 if (!mInLoad) {
323 mProgressView.setVisibility(View.VISIBLE);
324 mInLoad = true;
325 mStopButton.setImageDrawable(mStopDrawable);
326 }
Michael Kolbb7b115e2010-09-25 16:59:37 -0700327 mProgressView.setProgress(newProgress * PageProgressView.MAX_PROGRESS
328 / PROGRESS_MAX);
Michael Kolba2b2ba82010-08-04 17:54:03 -0700329 }
Michael Kolbfe251992010-07-08 15:41:55 -0700330 }
331
Michael Kolb31d469b2010-12-09 20:49:54 -0800332 private void updateSearchMode() {
333 setSearchMode(TextUtils.isEmpty(mUrlInput.getText()));
334 }
335
336 private void setSearchMode(boolean voiceSearchEnabled) {
337 mVoiceSearch.setVisibility(voiceSearchEnabled ? View.VISIBLE :
338 View.GONE);
339 mGoButton.setVisibility(voiceSearchEnabled ? View.GONE :
340 View.VISIBLE);
341 }
342
Michael Kolbfe251992010-07-08 15:41:55 -0700343 @Override
Leon Scroggins571b3762010-05-26 10:25:01 -0400344 /* package */ void setDisplayTitle(String title) {
Michael Kolb31d469b2010-12-09 20:49:54 -0800345 mUrlInput.setText(title, false);
Leon Scroggins571b3762010-05-26 10:25:01 -0400346 }
347
Michael Kolb7b20ddd2010-10-14 15:03:28 -0700348 void setDisplayTitle(String title, boolean filter) {
Michael Kolb31d469b2010-12-09 20:49:54 -0800349 mUrlInput.setText(title, filter);
Michael Kolb7b20ddd2010-10-14 15:03:28 -0700350 }
351
Michael Kolb31d469b2010-12-09 20:49:54 -0800352 // UrlInput text watcher
Leon Scroggins4cd97792010-12-03 15:31:56 -0500353
Michael Kolb31d469b2010-12-09 20:49:54 -0800354 @Override
355 public void afterTextChanged(Editable s) {
356 if (mUrlInput.hasFocus()) {
Michael Kolb81b6f832010-12-12 12:44:27 -0800357 // check if input field is empty and adjust voice search state
Michael Kolb31d469b2010-12-09 20:49:54 -0800358 updateSearchMode();
Michael Kolbcfa3af52010-12-14 10:36:11 -0800359 // clear voice mode when user types
360 setInVoiceMode(false, null);
Leon Scroggins4cd97792010-12-03 15:31:56 -0500361 }
362 }
Michael Kolb31d469b2010-12-09 20:49:54 -0800363
364 @Override
365 public void beforeTextChanged(CharSequence s, int start, int count, int after) {
366 }
367
368 @Override
369 public void onTextChanged(CharSequence s, int start, int before, int count) {
370 }
371
Michael Kolbcfa3af52010-12-14 10:36:11 -0800372 // voicesearch
373
374 @Override
375 public void setInVoiceMode(boolean voicemode) {
376 setInVoiceMode(voicemode, null);
377 }
378
379 public void setInVoiceMode(boolean voicemode, List<String> voiceResults) {
380 mInVoiceMode = voicemode;
381 mUrlInput.setVoiceResults(voiceResults);
382 mVoiceSearchIndicator.setVisibility(mInVoiceMode
383 ? View.VISIBLE : View.GONE);
384 }
385
Leon Scroggins571b3762010-05-26 10:25:01 -0400386}