blob: 14ca554ebebed4498d0bd1702828fdedb664b629 [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 Kolb11d19782011-03-20 10:17:40 -070019import com.android.browser.UI.DropdownChangeListener;
John Reck92026732011-02-15 10:12:30 -080020import com.android.browser.UrlInputView.UrlInputListener;
Michael Kolb11d19782011-03-20 10:17:40 -070021import com.android.browser.autocomplete.SuggestedTextController.TextChangeWatcher;
John Reck92026732011-02-15 10:12:30 -080022
Michael Kolb46f987e2011-04-05 10:39:10 -070023import android.animation.Animator;
24import android.animation.Animator.AnimatorListener;
25import android.animation.ObjectAnimator;
John Reck92026732011-02-15 10:12:30 -080026import android.app.SearchManager;
Leon Scroggins571b3762010-05-26 10:25:01 -040027import android.content.Context;
John Reck92026732011-02-15 10:12:30 -080028import android.content.Intent;
Leon Scroggins571b3762010-05-26 10:25:01 -040029import android.graphics.Bitmap;
30import android.graphics.Color;
31import android.graphics.drawable.BitmapDrawable;
32import android.graphics.drawable.Drawable;
33import android.graphics.drawable.LayerDrawable;
34import android.graphics.drawable.PaintDrawable;
John Reck92026732011-02-15 10:12:30 -080035import android.os.Bundle;
36import android.speech.RecognizerResultsIntent;
Michael Kolb11d19782011-03-20 10:17:40 -070037import android.text.TextUtils;
38import android.view.ContextThemeWrapper;
Michael Kolb7cdc4902011-02-03 17:54:40 -080039import android.view.Gravity;
Michael Kolb11d19782011-03-20 10:17:40 -070040import android.view.KeyEvent;
41import android.view.LayoutInflater;
Leon Scroggins571b3762010-05-26 10:25:01 -040042import android.view.View;
Michael Kolb11d19782011-03-20 10:17:40 -070043import android.view.View.OnClickListener;
44import android.view.View.OnFocusChangeListener;
Michael Kolb46f987e2011-04-05 10:39:10 -070045import android.view.ViewGroup;
Michael Kolb11d19782011-03-20 10:17:40 -070046import android.view.animation.Animation;
47import android.view.animation.Animation.AnimationListener;
48import android.view.animation.AnimationUtils;
49import android.webkit.WebView;
Michael Kolb7cdc4902011-02-03 17:54:40 -080050import android.widget.AbsoluteLayout;
Michael Kolb11d19782011-03-20 10:17:40 -070051import android.widget.ArrayAdapter;
52import android.widget.Button;
Michael Kolb46f987e2011-04-05 10:39:10 -070053import android.widget.FrameLayout;
Michael Kolb11d19782011-03-20 10:17:40 -070054import android.widget.ImageButton;
Leon Scroggins571b3762010-05-26 10:25:01 -040055import android.widget.ImageView;
Michael Kolb11d19782011-03-20 10:17:40 -070056import android.widget.ProgressBar;
57import android.widget.RelativeLayout;
58import android.widget.Spinner;
59import android.widget.TextView;
60
61import java.util.List;
Leon Scroggins571b3762010-05-26 10:25:01 -040062
63/**
64 * Base class for a title bar used by the browser.
65 */
Michael Kolb11d19782011-03-20 10:17:40 -070066public class TitleBarBase extends RelativeLayout
67 implements OnClickListener, OnFocusChangeListener, UrlInputListener,
68 TextChangeWatcher, DeviceAccountLogin.AutoLoginCallback {
John Reck94b7e042011-02-15 15:02:33 -080069
70 protected static final int PROGRESS_MAX = 100;
71
Leon Scroggins571b3762010-05-26 10:25:01 -040072 // These need to be set by the subclass.
73 protected ImageView mFavicon;
74 protected ImageView mLockIcon;
75
Michael Kolbfe251992010-07-08 15:41:55 -070076 protected Drawable mGenericFavicon;
John Reck92026732011-02-15 10:12:30 -080077 protected UiController mUiController;
78 protected BaseUi mBaseUi;
Michael Kolb46f987e2011-04-05 10:39:10 -070079 protected FrameLayout mParent;
80 protected PageProgressView mProgress;
John Reck92026732011-02-15 10:12:30 -080081 protected UrlInputView mUrlInput;
82 protected boolean mInVoiceMode;
Michael Kolb46f987e2011-04-05 10:39:10 -070083 protected View mContainer;
84
Leon Scroggins571b3762010-05-26 10:25:01 -040085
Michael Kolb11d19782011-03-20 10:17:40 -070086 // Auto-login UI
87 protected View mAutoLogin;
88 protected Spinner mAutoLoginAccount;
89 protected Button mAutoLoginLogin;
90 protected ProgressBar mAutoLoginProgress;
91 protected TextView mAutoLoginError;
92 protected ImageButton mAutoLoginCancel;
93 protected DeviceAccountLogin mAutoLoginHandler;
94 protected ArrayAdapter<String> mAccountsAdapter;
Michael Kolbfdb70242011-03-24 09:41:11 -070095 protected boolean mUseQuickControls;
Michael Kolb11d19782011-03-20 10:17:40 -070096
Michael Kolb46f987e2011-04-05 10:39:10 -070097 //state
98 protected boolean mShowing;
99 protected boolean mInLoad;
100 protected boolean mSkipTitleBarAnimations;
101 private Animator mTitleBarAnimator;
102
103 public TitleBarBase(Context context, UiController controller, BaseUi ui,
104 FrameLayout parent) {
Leon Scroggins571b3762010-05-26 10:25:01 -0400105 super(context, null);
John Reck92026732011-02-15 10:12:30 -0800106 mUiController = controller;
107 mBaseUi = ui;
Michael Kolb46f987e2011-04-05 10:39:10 -0700108 mParent = parent;
Leon Scroggins571b3762010-05-26 10:25:01 -0400109 mGenericFavicon = context.getResources().getDrawable(
110 R.drawable.app_web_browser_sm);
111 }
112
Michael Kolb11d19782011-03-20 10:17:40 -0700113 protected void initLayout(Context context, int layoutId) {
114 LayoutInflater factory = LayoutInflater.from(context);
115 factory.inflate(layoutId, this);
Michael Kolb46f987e2011-04-05 10:39:10 -0700116 mContainer = findViewById(R.id.taburlbar);
117 mProgress = (PageProgressView) findViewById(R.id.progress);
Michael Kolb11d19782011-03-20 10:17:40 -0700118 mUrlInput = (UrlInputView) findViewById(R.id.url);
119 mLockIcon = (ImageView) findViewById(R.id.lock);
120 mUrlInput.setUrlInputListener(this);
121 mUrlInput.setController(mUiController);
122 mUrlInput.setOnFocusChangeListener(this);
123 mUrlInput.setSelectAllOnFocus(true);
124 mUrlInput.addQueryTextWatcher(this);
125 mAutoLogin = findViewById(R.id.autologin);
126 mAutoLoginAccount = (Spinner) findViewById(R.id.autologin_account);
127 mAutoLoginLogin = (Button) findViewById(R.id.autologin_login);
128 mAutoLoginLogin.setOnClickListener(this);
129 mAutoLoginProgress = (ProgressBar) findViewById(R.id.autologin_progress);
130 mAutoLoginError = (TextView) findViewById(R.id.autologin_error);
131 mAutoLoginCancel = (ImageButton) mAutoLogin.findViewById(R.id.autologin_close);
132 mAutoLoginCancel.setOnClickListener(this);
133 }
134
135 protected void setupUrlInput() {
136 }
137
Michael Kolbfdb70242011-03-24 09:41:11 -0700138 protected void setUseQuickControls(boolean use) {
139 mUseQuickControls = use;
Michael Kolb46f987e2011-04-05 10:39:10 -0700140 setLayoutParams(makeLayoutParams());
Michael Kolbfdb70242011-03-24 09:41:11 -0700141 }
142
Michael Kolb46f987e2011-04-05 10:39:10 -0700143 void setShowProgressOnly(boolean progress) {
144 if (progress && !inAutoLogin()) {
145 mContainer.setVisibility(View.GONE);
146 } else {
147 mContainer.setVisibility(View.VISIBLE);
148 }
149 }
150
151 void setSkipTitleBarAnimations(boolean skip) {
152 mSkipTitleBarAnimations = skip;
153 }
154
Michael Kolbeb049822011-04-07 14:09:28 -0700155 void setTitleGravity(int gravity) {
156 int newTop = 0;
157 if (gravity != Gravity.NO_GRAVITY) {
158 View parent = (View) getParent();
159 if (parent != null) {
160 if (gravity == Gravity.TOP) {
161 newTop = parent.getScrollY();
162 }
163 }
164 }
165 AbsoluteLayout.LayoutParams lp = (AbsoluteLayout.LayoutParams)
166 getLayoutParams();
167 if (lp != null) {
168 lp.y = newTop;
169 setLayoutParams(lp);
170 }
171 }
172
Michael Kolb46f987e2011-04-05 10:39:10 -0700173 void show() {
174 if (mUseQuickControls) {
175 mParent.addView(this);
176 } else {
177 if (!mSkipTitleBarAnimations) {
178 cancelTitleBarAnimation(false);
179 int visibleHeight = getVisibleTitleHeight();
180 float startPos = (-getEmbeddedHeight() + visibleHeight);
181 if (getTranslationY() != 0) {
182 startPos = Math.max(startPos, getTranslationY());
183 }
184 mTitleBarAnimator = ObjectAnimator.ofFloat(this,
185 "translationY",
186 startPos, 0);
187 mTitleBarAnimator.start();
188 }
189 mBaseUi.setTitleGravity(Gravity.TOP);
190 }
191 mShowing = true;
192 }
193
194 void hide() {
195 if (mUseQuickControls) {
196 mParent.removeView(this);
197 } else {
198 if (!mSkipTitleBarAnimations) {
199 cancelTitleBarAnimation(false);
200 int visibleHeight = getVisibleTitleHeight();
201 mTitleBarAnimator = ObjectAnimator.ofFloat(this,
202 "translationY", getTranslationY(),
203 (-getEmbeddedHeight() + visibleHeight));
204 mTitleBarAnimator.addListener(mHideTileBarAnimatorListener);
205 mTitleBarAnimator.start();
206 } else {
207 mBaseUi.setTitleGravity(Gravity.NO_GRAVITY);
208 }
209 }
210 mShowing = false;
211 }
212
213 boolean isShowing() {
214 return mShowing;
215 }
216
217 void cancelTitleBarAnimation(boolean reset) {
218 if (mTitleBarAnimator != null) {
219 mTitleBarAnimator.cancel();
220 mTitleBarAnimator = null;
221 }
222 if (reset) {
223 setTranslationY(0);
224 }
225 }
226
227 private AnimatorListener mHideTileBarAnimatorListener = new AnimatorListener() {
228
229 boolean mWasCanceled;
230 @Override
231 public void onAnimationStart(Animator animation) {
232 mWasCanceled = false;
233 }
234
235 @Override
236 public void onAnimationRepeat(Animator animation) {
237 }
238
239 @Override
240 public void onAnimationEnd(Animator animation) {
241 if (!mWasCanceled) {
242 setTranslationY(0);
243 }
244 mBaseUi.setTitleGravity(Gravity.NO_GRAVITY);
245 }
246
247 @Override
248 public void onAnimationCancel(Animator animation) {
249 mWasCanceled = true;
250 }
251 };
252
253 private int getVisibleTitleHeight() {
254 Tab tab = mBaseUi.getActiveTab();
255 WebView webview = tab != null ? tab.getWebView() : null;
256 return webview != null ? webview.getVisibleTitleHeight() : 0;
257 }
258
259 /**
260 * Update the progress, from 0 to 100.
261 */
262 void setProgress(int newProgress) {
263 if (newProgress >= PROGRESS_MAX) {
264 mProgress.setProgress(PageProgressView.MAX_PROGRESS);
265 mProgress.setVisibility(View.GONE);
266 mInLoad = false;
267 onProgressStopped();
268 // check if needs to be hidden
269 if (!isEditingUrl() && !inAutoLogin()) {
270 hide();
271 if (mUseQuickControls) {
272 setShowProgressOnly(false);
273 }
274 }
275 } else {
276 if (!mInLoad) {
277 mProgress.setVisibility(View.VISIBLE);
278 mInLoad = true;
279 onProgressStarted();
280 }
281 mProgress.setProgress(newProgress * PageProgressView.MAX_PROGRESS
282 / PROGRESS_MAX);
283 if (!mShowing) {
284 if (mUseQuickControls && !isEditingUrl()) {
285 setShowProgressOnly(true);
286 }
287 show();
288 }
289 }
290 }
291
292 protected void onProgressStarted() {
293 }
294
295 protected void onProgressStopped() {
296 }
Leon Scroggins571b3762010-05-26 10:25:01 -0400297
298 /* package */ void setLock(Drawable d) {
299 assert mLockIcon != null;
300 if (null == d) {
301 mLockIcon.setVisibility(View.GONE);
302 } else {
303 mLockIcon.setImageDrawable(d);
304 mLockIcon.setVisibility(View.VISIBLE);
305 }
306 }
307
308 /* package */ void setFavicon(Bitmap icon) {
309 assert mFavicon != null;
310 Drawable[] array = new Drawable[3];
311 array[0] = new PaintDrawable(Color.BLACK);
312 PaintDrawable p = new PaintDrawable(Color.WHITE);
313 array[1] = p;
314 if (icon == null) {
315 array[2] = mGenericFavicon;
316 } else {
317 array[2] = new BitmapDrawable(icon);
318 }
319 LayerDrawable d = new LayerDrawable(array);
320 d.setLayerInset(1, 1, 1, 1, 1);
321 d.setLayerInset(2, 2, 2, 2, 2);
322 mFavicon.setImageDrawable(d);
323 }
324
Michael Kolb29ccf8a2011-02-23 16:13:24 -0800325 public int getEmbeddedHeight() {
Michael Kolb46f987e2011-04-05 10:39:10 -0700326 int height = mContainer.getHeight();
327 if (mAutoLogin.getVisibility() == View.VISIBLE) {
328 height += mAutoLogin.getHeight();
329 }
330 return height;
Michael Kolb29ccf8a2011-02-23 16:13:24 -0800331 }
332
Michael Kolb11d19782011-03-20 10:17:40 -0700333 protected void updateAutoLogin(Tab tab, boolean animate) {
334 DeviceAccountLogin login = tab.getDeviceAccountLogin();
335 if (login != null) {
336 mAutoLoginHandler = login;
337 ContextThemeWrapper wrapper = new ContextThemeWrapper(mContext,
338 android.R.style.Theme_Holo_Light);
339 mAccountsAdapter = new ArrayAdapter<String>(wrapper,
340 android.R.layout.simple_spinner_item, login.getAccountNames());
341 mAccountsAdapter.setDropDownViewResource(
342 android.R.layout.simple_spinner_dropdown_item);
343 mAutoLoginAccount.setAdapter(mAccountsAdapter);
344 mAutoLoginAccount.setSelection(0);
345 mAutoLoginAccount.setEnabled(true);
346 mAutoLoginLogin.setEnabled(true);
347 mAutoLoginProgress.setVisibility(View.GONE);
348 mAutoLoginError.setVisibility(View.GONE);
349 switch (login.getState()) {
350 case DeviceAccountLogin.PROCESSING:
351 mAutoLoginAccount.setEnabled(false);
352 mAutoLoginLogin.setEnabled(false);
353 mAutoLoginProgress.setVisibility(View.VISIBLE);
354 break;
355 case DeviceAccountLogin.FAILED:
356 mAutoLoginProgress.setVisibility(View.GONE);
357 mAutoLoginError.setVisibility(View.VISIBLE);
358 break;
359 case DeviceAccountLogin.INITIAL:
360 break;
361 default:
362 throw new IllegalStateException();
363 }
364 showAutoLogin(animate);
Michael Kolb43909f22011-03-23 13:18:36 -0700365 } else {
366 hideAutoLogin(animate);
Michael Kolb11d19782011-03-20 10:17:40 -0700367 }
368 }
369
370 protected void showAutoLogin(boolean animate) {
Michael Kolb46f987e2011-04-05 10:39:10 -0700371 if (mUseQuickControls) {
372 mBaseUi.showTitleBar();
373 }
Michael Kolb11d19782011-03-20 10:17:40 -0700374 mAutoLogin.setVisibility(View.VISIBLE);
375 if (animate) {
376 mAutoLogin.startAnimation(AnimationUtils.loadAnimation(
377 getContext(), R.anim.autologin_enter));
378 }
379 }
380
381 protected void hideAutoLogin(boolean animate) {
382 mAutoLoginHandler = null;
Michael Kolb46f987e2011-04-05 10:39:10 -0700383 if (mUseQuickControls) {
384 mBaseUi.hideTitleBar();
Michael Kolb11d19782011-03-20 10:17:40 -0700385 mAutoLogin.setVisibility(View.GONE);
386 mBaseUi.refreshWebView();
Michael Kolb46f987e2011-04-05 10:39:10 -0700387 } else {
388 if (animate) {
389 Animation anim = AnimationUtils.loadAnimation(getContext(),
390 R.anim.autologin_exit);
391 anim.setAnimationListener(new AnimationListener() {
392 @Override
393 public void onAnimationEnd(Animation a) {
394 mAutoLogin.setVisibility(View.GONE);
395 mBaseUi.refreshWebView();
396 }
397
398 @Override
399 public void onAnimationStart(Animation a) {
400 }
401
402 @Override
403 public void onAnimationRepeat(Animation a) {
404 }
405 });
406 mAutoLogin.startAnimation(anim);
407 } else if (mAutoLogin.getAnimation() == null) {
408 mAutoLogin.setVisibility(View.GONE);
409 mBaseUi.refreshWebView();
410 }
Michael Kolb11d19782011-03-20 10:17:40 -0700411 }
412 }
413
414 @Override
415 public void loginFailed() {
416 mAutoLoginAccount.setEnabled(true);
417 mAutoLoginLogin.setEnabled(true);
418 mAutoLoginProgress.setVisibility(View.GONE);
419 mAutoLoginError.setVisibility(View.VISIBLE);
420 }
421
422
423 protected boolean inAutoLogin() {
424 return mAutoLoginHandler != null;
425 }
426
427 @Override
428 public void onClick(View v) {
429 if (mAutoLoginCancel == v) {
430 if (mAutoLoginHandler != null) {
431 mAutoLoginHandler.cancel();
432 mAutoLoginHandler = null;
433 }
434 hideAutoLogin(true);
435 } else if (mAutoLoginLogin == v) {
436 if (mAutoLoginHandler != null) {
437 mAutoLoginAccount.setEnabled(false);
438 mAutoLoginLogin.setEnabled(false);
439 mAutoLoginProgress.setVisibility(View.VISIBLE);
440 mAutoLoginError.setVisibility(View.GONE);
441 mAutoLoginHandler.login(
442 mAutoLoginAccount.getSelectedItemPosition(), this);
443 }
444 }
445 }
446
447 @Override
448 public void onFocusChange(View view, boolean hasFocus) {
449 // if losing focus and not in touch mode, leave as is
450 if (hasFocus || view.isInTouchMode() || mUrlInput.needsUpdate()) {
451 setFocusState(hasFocus);
452 }
453 if (hasFocus) {
454 mUrlInput.forceIme();
455 if (mInVoiceMode) {
456 mUrlInput.forceFilter();
457 }
458 } else if (!mUrlInput.needsUpdate()) {
459 mUrlInput.dismissDropDown();
460 mUrlInput.hideIME();
461 if (mUrlInput.getText().length() == 0) {
462 Tab currentTab = mUiController.getTabControl().getCurrentTab();
463 if (currentTab != null) {
464 mUrlInput.setText(currentTab.getUrl(), false);
465 }
466 }
467 }
468 mUrlInput.clearNeedsUpdate();
469 }
470
471 protected void setFocusState(boolean focus) {
472 if (focus) {
473 updateSearchMode(false);
474 }
475 }
476
477 protected void updateSearchMode(boolean userEdited) {
478 setSearchMode(!userEdited || TextUtils.isEmpty(mUrlInput.getUserText()));
479 }
480
481 protected void setSearchMode(boolean voiceSearchEnabled) {}
482
483 boolean isEditingUrl() {
484 return mUrlInput.hasFocus();
485 }
486
487 void stopEditingUrl() {
488 mUrlInput.clearFocus();
489 }
490
491 void setDisplayTitle(String title) {
492 if (!isEditingUrl()) {
493 mUrlInput.setText(title, false);
494 }
495 }
496
497 // UrlInput text watcher
498
499 @Override
500 public void onTextChanged(String newText) {
501 if (mUrlInput.hasFocus()) {
502 // check if input field is empty and adjust voice search state
503 updateSearchMode(true);
504 // clear voice mode when user types
505 setInVoiceMode(false, null);
506 }
507 }
508
509 // voicesearch
510
511 public void setInVoiceMode(boolean voicemode, List<String> voiceResults) {
512 mInVoiceMode = voicemode;
513 mUrlInput.setVoiceResults(voiceResults);
514 }
515
516 void setIncognitoMode(boolean incognito) {
517 mUrlInput.setIncognitoMode(incognito);
518 }
519
520 void clearCompletions() {
521 mUrlInput.setSuggestedText(null);
522 }
523
John Reck92026732011-02-15 10:12:30 -0800524 // UrlInputListener implementation
525
526 /**
527 * callback from suggestion dropdown
528 * user selected a suggestion
529 */
530 @Override
531 public void onAction(String text, String extra, String source) {
532 mUiController.getCurrentTopWebView().requestFocus();
533 mBaseUi.hideTitleBar();
534 Intent i = new Intent();
535 String action = null;
536 if (UrlInputView.VOICE.equals(source)) {
537 action = RecognizerResultsIntent.ACTION_VOICE_SEARCH_RESULTS;
538 source = null;
539 } else {
540 action = Intent.ACTION_SEARCH;
541 }
542 i.setAction(action);
543 i.putExtra(SearchManager.QUERY, text);
544 if (extra != null) {
545 i.putExtra(SearchManager.EXTRA_DATA_KEY, extra);
546 }
547 if (source != null) {
548 Bundle appData = new Bundle();
549 appData.putString(com.android.common.Search.SOURCE, source);
550 i.putExtra(SearchManager.APP_DATA, appData);
551 }
552 mUiController.handleNewIntent(i);
553 setDisplayTitle(text);
554 }
555
556 @Override
557 public void onDismiss() {
558 final Tab currentTab = mBaseUi.getActiveTab();
559 mBaseUi.hideTitleBar();
560 post(new Runnable() {
561 public void run() {
562 clearFocus();
563 if ((currentTab != null) && !mInVoiceMode) {
564 setDisplayTitle(currentTab.getUrl());
565 }
566 }
567 });
568 }
569
570 /**
571 * callback from the suggestion dropdown
572 * copy text to input field and stay in edit mode
573 */
574 @Override
575 public void onCopySuggestion(String text) {
576 mUrlInput.setText(text, true);
577 if (text != null) {
578 mUrlInput.setSelection(text.length());
579 }
580 }
581
John Reck94b7e042011-02-15 15:02:33 -0800582 public void setCurrentUrlIsBookmark(boolean isBookmark) {
583 }
584
Michael Kolb11d19782011-03-20 10:17:40 -0700585 @Override
586 public boolean dispatchKeyEventPreIme(KeyEvent evt) {
587 if (evt.getKeyCode() == KeyEvent.KEYCODE_BACK) {
588 // catch back key in order to do slightly more cleanup than usual
589 mUrlInput.clearFocus();
590 return true;
591 }
592 return super.dispatchKeyEventPreIme(evt);
593 }
594
595 protected WebView getCurrentWebView() {
596 Tab t = mBaseUi.getActiveTab();
597 if (t != null) {
598 return t.getWebView();
599 } else {
600 return null;
601 }
602 }
603
604 void registerDropdownChangeListener(DropdownChangeListener d) {
605 mUrlInput.registerDropdownChangeListener(d);
606 }
607
Michael Kolbfdb70242011-03-24 09:41:11 -0700608 /**
609 * called from the Ui when the user wants to edit
610 * @param clearInput clear the input field
611 */
Michael Kolb46f987e2011-04-05 10:39:10 -0700612 void startEditingUrl(boolean clearInput) {
613 // editing takes preference of progress
614 mContainer.setVisibility(View.VISIBLE);
615 if (mUseQuickControls) {
616 mProgress.setVisibility(View.GONE);
617 }
618 if (!mUrlInput.hasFocus()) {
619 mUrlInput.requestFocus();
620 }
621 if (clearInput) {
622 mUrlInput.setText("");
623 } else if (mInVoiceMode) {
624 mUrlInput.showDropDown();
625 }
626 }
627
628 private ViewGroup.LayoutParams makeLayoutParams() {
629 if (mUseQuickControls) {
630 return new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
631 LayoutParams.WRAP_CONTENT);
632 } else {
633 return new AbsoluteLayout.LayoutParams(
634 LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT,
635 0, 0);
636 }
637 }
Michael Kolbfdb70242011-03-24 09:41:11 -0700638
Leon Scroggins571b3762010-05-26 10:25:01 -0400639}