blob: e19515e6bee79e1992f9b150a1980eeacffc2e08 [file] [log] [blame]
Michael Kolb66706532010-12-12 19:50:22 -08001/*
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
John Reckb9a051b2011-03-18 11:55:48 -070019import com.android.browser.BrowserWebView.ScrollListener;
Michael Kolb66706532010-12-12 19:50:22 -080020
John Recke5c21d92011-03-11 15:09:46 -080021import android.animation.Animator;
22import android.animation.Animator.AnimatorListener;
23import android.animation.ObjectAnimator;
Michael Kolb66706532010-12-12 19:50:22 -080024import android.app.ActionBar;
25import android.app.Activity;
Michael Kolbac35bdc2011-01-17 17:06:04 -080026import android.os.Bundle;
Michael Kolbba238702011-03-08 10:40:50 -080027import android.os.Handler;
Michael Kolb376b5412010-12-15 11:52:57 -080028import android.util.Log;
Michael Kolb66706532010-12-12 19:50:22 -080029import android.view.ActionMode;
Michael Kolb376b5412010-12-15 11:52:57 -080030import android.view.Gravity;
Michael Kolba4183062011-01-16 10:43:21 -080031import android.view.KeyEvent;
Michael Kolb1acef692011-03-08 14:12:06 -080032import android.view.Menu;
John Reckd73c5a22010-12-22 10:22:50 -080033import android.view.View;
34import android.webkit.WebChromeClient.CustomViewCallback;
Michael Kolb66706532010-12-12 19:50:22 -080035import android.webkit.WebView;
Michael Kolb2a56eca2011-02-25 09:45:06 -080036import android.widget.FrameLayout;
Michael Kolb66706532010-12-12 19:50:22 -080037
38import java.util.List;
39
40/**
41 * Ui for xlarge screen sizes
42 */
43public class XLargeUi extends BaseUi implements ScrollListener {
44
45 private static final String LOGTAG = "XLargeUi";
46
Michael Kolb376b5412010-12-15 11:52:57 -080047 private ActionBar mActionBar;
Michael Kolb66706532010-12-12 19:50:22 -080048 private TabBar mTabBar;
49
50 private TitleBarXLarge mTitleBar;
John Recke5c21d92011-03-11 15:09:46 -080051 private Animator mTitleBarAnimator;
John Reck6e8d2e92011-03-14 11:29:56 -070052 private boolean mSkipTitleBarAnimations;
Michael Kolb66706532010-12-12 19:50:22 -080053
Michael Kolb376b5412010-12-15 11:52:57 -080054 private boolean mUseQuickControls;
55 private PieControl mPieControl;
Michael Kolbba238702011-03-08 10:40:50 -080056 private Handler mHandler;
Michael Kolb376b5412010-12-15 11:52:57 -080057
Michael Kolb66706532010-12-12 19:50:22 -080058 /**
59 * @param browser
60 * @param controller
61 */
62 public XLargeUi(Activity browser, UiController controller) {
63 super(browser, controller);
Michael Kolbba238702011-03-08 10:40:50 -080064 mHandler = new Handler();
Michael Kolb66706532010-12-12 19:50:22 -080065 mTitleBar = new TitleBarXLarge(mActivity, mUiController, this);
66 mTitleBar.setProgress(100);
Michael Kolb66706532010-12-12 19:50:22 -080067 mTabBar = new TabBar(mActivity, mUiController, this);
Michael Kolb376b5412010-12-15 11:52:57 -080068 mActionBar = mActivity.getActionBar();
John Reckb3417f02011-01-14 11:01:05 -080069 setupActionBar();
70 setUseQuickControls(BrowserSettings.getInstance().useQuickControls());
71 }
72
73 private void setupActionBar() {
74 mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
Michael Kolb376b5412010-12-15 11:52:57 -080075 mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
76 mActionBar.setCustomView(mTabBar);
John Reckb3417f02011-01-14 11:01:05 -080077 }
78
79 @Override
Michael Kolbac35bdc2011-01-17 17:06:04 -080080 public void showComboView(boolean startWithHistory, Bundle extras) {
81 super.showComboView(startWithHistory, extras);
82 if (mUseQuickControls) {
83 mActionBar.show();
84 }
85 }
86
87 @Override
John Reckb3417f02011-01-14 11:01:05 -080088 public void hideComboView() {
Michael Kolbba238702011-03-08 10:40:50 -080089 if (isComboViewShowing()) {
90 super.hideComboView();
91 // ComboView changes the action bar, set it back up to what we want
92 setupActionBar();
93 checkTabCount();
94 }
Michael Kolb376b5412010-12-15 11:52:57 -080095 }
96
97 private void setUseQuickControls(boolean useQuickControls) {
98 mUseQuickControls = useQuickControls;
Michael Kolb7cdc4902011-02-03 17:54:40 -080099 mTitleBar.setUseQuickControls(mUseQuickControls);
Michael Kolb376b5412010-12-15 11:52:57 -0800100 if (useQuickControls) {
101 checkTabCount();
102 mPieControl = new PieControl(mActivity, mUiController, this);
103 mPieControl.attachToContainer(mContentView);
Michael Kolb7cdc4902011-02-03 17:54:40 -0800104 Tab tab = getActiveTab();
105 if ((tab != null) && (tab.getWebView() != null)) {
106 tab.getWebView().setEmbeddedTitleBar(null);
Michael Kolb376b5412010-12-15 11:52:57 -0800107 }
108 } else {
109 mActivity.getActionBar().show();
110 if (mPieControl != null) {
111 mPieControl.removeFromContainer(mContentView);
112 }
Michael Kolb376b5412010-12-15 11:52:57 -0800113 WebView web = mTabControl.getCurrentWebView();
Michael Kolb7cdc4902011-02-03 17:54:40 -0800114 if (web != null) {
Michael Kolb376b5412010-12-15 11:52:57 -0800115 web.setEmbeddedTitleBar(mTitleBar);
116 }
Michael Kolb8a4c3822011-03-15 14:52:05 -0700117 setTitleGravity(Gravity.NO_GRAVITY);
Michael Kolb376b5412010-12-15 11:52:57 -0800118 }
119 mTabBar.setUseQuickControls(mUseQuickControls);
Michael Kolb376b5412010-12-15 11:52:57 -0800120 }
121
122 private void checkTabCount() {
123 if (mUseQuickControls) {
Michael Kolbeb95db42011-03-03 10:38:40 -0800124 mHandler.post(new Runnable() {
125 public void run() {
126 mActionBar.hide();
127 }
128 });
Michael Kolb376b5412010-12-15 11:52:57 -0800129 }
Michael Kolb66706532010-12-12 19:50:22 -0800130 }
131
132 @Override
Narayan Kamath67b8c1b2011-03-09 20:47:52 +0000133 public void onResume() {
134 super.onResume();
135 if (!BrowserSettings.getInstance().useInstant()) {
136 mTitleBar.clearCompletions();
137 }
138 }
139
140 @Override
Michael Kolb66706532010-12-12 19:50:22 -0800141 public void onDestroy() {
Michael Kolb7cdc4902011-02-03 17:54:40 -0800142 hideTitleBar();
Michael Kolb66706532010-12-12 19:50:22 -0800143 }
144
145 // webview factory
146
147 @Override
148 public WebView createWebView(boolean privateBrowsing) {
149 // Create a new WebView
John Reckb9a051b2011-03-18 11:55:48 -0700150 BrowserWebView w = (BrowserWebView) super.createWebView(privateBrowsing);
Michael Kolb66706532010-12-12 19:50:22 -0800151 w.setScrollListener(this);
Michael Kolb66706532010-12-12 19:50:22 -0800152 return w;
153 }
154
155 @Override
156 public WebView createSubWebView(boolean privateBrowsing) {
John Reckb9a051b2011-03-18 11:55:48 -0700157 return super.createWebView(privateBrowsing);
Michael Kolb66706532010-12-12 19:50:22 -0800158 }
159
160 @Override
Michael Kolb5ee018e2011-02-18 15:47:21 -0800161 public void onScroll(int visibleTitleHeight, boolean userInitiated) {
162 mTabBar.onScroll(visibleTitleHeight, userInitiated);
Michael Kolb66706532010-12-12 19:50:22 -0800163 }
164
165 void stopWebViewScrolling() {
John Reckb9a051b2011-03-18 11:55:48 -0700166 BrowserWebView web = (BrowserWebView) mUiController.getCurrentWebView();
Michael Kolb66706532010-12-12 19:50:22 -0800167 if (web != null) {
168 web.stopScroll();
169 }
170 }
171
172 // WebView callbacks
173
174 @Override
John Reck30c714c2010-12-16 17:30:34 -0800175 public void onProgressChanged(Tab tab) {
176 int progress = tab.getLoadProgress();
Michael Kolb66706532010-12-12 19:50:22 -0800177 mTabBar.onProgress(tab, progress);
178 if (tab.inForeground()) {
Michael Kolb7cdc4902011-02-03 17:54:40 -0800179 mTitleBar.setProgress(progress);
Michael Kolb66706532010-12-12 19:50:22 -0800180 if (progress == 100) {
Michael Kolb8a4c3822011-03-15 14:52:05 -0700181 if (!mTitleBar.isEditingUrl() && !mTitleBar.inAutoLogin()) {
Michael Kolb7cdc4902011-02-03 17:54:40 -0800182 hideTitleBar();
Michael Kolbbd018d42010-12-15 15:43:39 -0800183 if (mUseQuickControls) {
Michael Kolb7cdc4902011-02-03 17:54:40 -0800184 mTitleBar.setShowProgressOnly(false);
Michael Kolbbd018d42010-12-15 15:43:39 -0800185 }
Michael Kolb376b5412010-12-15 11:52:57 -0800186 }
Michael Kolb66706532010-12-12 19:50:22 -0800187 } else {
Michael Kolb7cdc4902011-02-03 17:54:40 -0800188 if (!isTitleBarShowing()) {
189 if (mUseQuickControls && !mTitleBar.isEditingUrl()) {
190 mTitleBar.setShowProgressOnly(true);
191 setTitleGravity(Gravity.TOP);
Michael Kolb376b5412010-12-15 11:52:57 -0800192 }
Michael Kolb7cdc4902011-02-03 17:54:40 -0800193 showTitleBar();
Michael Kolb376b5412010-12-15 11:52:57 -0800194 }
Michael Kolb66706532010-12-12 19:50:22 -0800195 }
196 }
197 }
198
199 @Override
200 public boolean needsRestoreAllTabs() {
201 return true;
202 }
203
204 @Override
205 public void addTab(Tab tab) {
206 mTabBar.onNewTab(tab);
Michael Kolb8814d732011-01-26 11:22:30 -0800207 }
208
209 protected void onAddTabCompleted(Tab tab) {
Michael Kolb376b5412010-12-15 11:52:57 -0800210 checkTabCount();
Michael Kolb66706532010-12-12 19:50:22 -0800211 }
212
213 @Override
Michael Kolb377ea312011-02-17 14:36:56 -0800214 public void setActiveTab(final Tab tab) {
John Reck6e8d2e92011-03-14 11:29:56 -0700215 cancelTitleBarAnimation(true);
216 mSkipTitleBarAnimations = true;
Michael Kolbeb95db42011-03-03 10:38:40 -0800217 if (mUseQuickControls) {
218 if (mActiveTab != null) {
219 captureTab(mActiveTab);
220 }
221 }
Michael Kolbf2628922011-03-09 17:15:28 -0800222 super.setActiveTab(tab, true);
223 setActiveTab(tab, true);
John Reck6e8d2e92011-03-14 11:29:56 -0700224 mSkipTitleBarAnimations = false;
Michael Kolb377ea312011-02-17 14:36:56 -0800225 }
226
227 @Override
228 void setActiveTab(Tab tab, boolean needsAttaching) {
John Reckb9a051b2011-03-18 11:55:48 -0700229 BrowserWebView view = (BrowserWebView) tab.getWebView();
Michael Kolb376b5412010-12-15 11:52:57 -0800230 // TabControl.setCurrentTab has been called before this,
231 // so the tab is guaranteed to have a webview
232 if (view == null) {
233 Log.e(LOGTAG, "active tab with no webview detected");
234 return;
235 }
236 // Request focus on the top window.
237 if (mUseQuickControls) {
238 mPieControl.forceToTop(mContentView);
239 view.setScrollListener(null);
240 mTabBar.showTitleBarIndicator(false);
241 } else {
Michael Kolb377ea312011-02-17 14:36:56 -0800242 // check if title bar is already attached by animation
243 if (mTitleBar.getParent() == null) {
244 view.setEmbeddedTitleBar(mTitleBar);
245 }
Michael Kolb376b5412010-12-15 11:52:57 -0800246 view.setScrollListener(this);
247 }
Michael Kolb66706532010-12-12 19:50:22 -0800248 mTabBar.onSetActiveTab(tab);
Michael Kolb376b5412010-12-15 11:52:57 -0800249 if (tab.isInVoiceSearchMode()) {
Michael Kolb11d19782011-03-20 10:17:40 -0700250 showVoiceTitleBar(tab.getVoiceDisplayTitle(), tab.getVoiceSearchResults());
Michael Kolb376b5412010-12-15 11:52:57 -0800251 } else {
252 revertVoiceTitleBar(tab);
253 }
Michael Kolb376b5412010-12-15 11:52:57 -0800254 updateLockIconToLatest(tab);
255 tab.getTopWindow().requestFocus();
Michael Kolb66706532010-12-12 19:50:22 -0800256 }
257
Michael Kolbeb95db42011-03-03 10:38:40 -0800258
Michael Kolb66706532010-12-12 19:50:22 -0800259 @Override
260 public void updateTabs(List<Tab> tabs) {
261 mTabBar.updateTabs(tabs);
Michael Kolb376b5412010-12-15 11:52:57 -0800262 checkTabCount();
Michael Kolb66706532010-12-12 19:50:22 -0800263 }
264
265 @Override
266 public void removeTab(Tab tab) {
John Reck6e8d2e92011-03-14 11:29:56 -0700267 cancelTitleBarAnimation(true);
268 mSkipTitleBarAnimations = true;
Michael Kolb66706532010-12-12 19:50:22 -0800269 super.removeTab(tab);
270 mTabBar.onRemoveTab(tab);
John Reck6e8d2e92011-03-14 11:29:56 -0700271 mSkipTitleBarAnimations = false;
Michael Kolb8814d732011-01-26 11:22:30 -0800272 }
273
274 protected void onRemoveTabCompleted(Tab tab) {
Michael Kolb376b5412010-12-15 11:52:57 -0800275 checkTabCount();
Michael Kolb66706532010-12-12 19:50:22 -0800276 }
277
Michael Kolb376b5412010-12-15 11:52:57 -0800278 int getContentWidth() {
279 if (mContentView != null) {
280 return mContentView.getWidth();
Michael Kolb66706532010-12-12 19:50:22 -0800281 }
282 return 0;
283 }
284
Michael Kolbdc2ee1b2011-02-14 14:34:40 -0800285 @Override
286 public void editUrl(boolean clearInput) {
Michael Kolbd72ea3b2011-01-09 15:56:37 -0800287 if (mUiController.isInCustomActionMode()) {
288 mUiController.endActionMode();
289 }
Michael Kolb7cdc4902011-02-03 17:54:40 -0800290 showTitleBar();
Michael Kolbdc2ee1b2011-02-14 14:34:40 -0800291 mTitleBar.startEditingUrl(clearInput);
Michael Kolb66706532010-12-12 19:50:22 -0800292 }
293
Michael Kolbc16c5952011-03-29 15:37:03 -0700294 @Override
Michael Kolb7cdc4902011-02-03 17:54:40 -0800295 void showTitleBarAndEdit() {
296 mTitleBar.setShowProgressOnly(false);
Michael Kolbc16c5952011-03-29 15:37:03 -0700297 super.showTitleBarAndEdit();
Michael Kolb7cdc4902011-02-03 17:54:40 -0800298 }
299
300 void stopEditingUrl() {
301 mTitleBar.stopEditingUrl();
302 }
303
304 @Override
305 protected void showTitleBar() {
306 if (canShowTitleBar()) {
307 if (mUseQuickControls) {
Michael Kolb7cdc4902011-02-03 17:54:40 -0800308 mContentView.addView(mTitleBar);
309 } else {
John Reck6e8d2e92011-03-14 11:29:56 -0700310 if (!mSkipTitleBarAnimations) {
311 cancelTitleBarAnimation(false);
312 int visibleHeight = getVisibleTitleHeight();
313 float startPos = (-mTitleBar.getEmbeddedHeight() + visibleHeight);
314 if (mTitleBar.getTranslationY() != 0) {
315 startPos = Math.max(startPos, mTitleBar.getTranslationY());
316 }
317 mTitleBarAnimator = ObjectAnimator.ofFloat(mTitleBar,
318 "translationY",
319 startPos, 0);
320 mTitleBarAnimator.start();
John Recke5c21d92011-03-11 15:09:46 -0800321 }
Michael Kolb7cdc4902011-02-03 17:54:40 -0800322 setTitleGravity(Gravity.TOP);
323 }
324 super.showTitleBar();
325 mTabBar.onShowTitleBar();
Michael Kolb376b5412010-12-15 11:52:57 -0800326 }
Michael Kolb376b5412010-12-15 11:52:57 -0800327 }
328
Michael Kolb66706532010-12-12 19:50:22 -0800329 @Override
Michael Kolb7cdc4902011-02-03 17:54:40 -0800330 protected void hideTitleBar() {
331 if (isTitleBarShowing()) {
Michael Kolb66706532010-12-12 19:50:22 -0800332 mTabBar.onHideTitleBar();
Michael Kolb7cdc4902011-02-03 17:54:40 -0800333 if (mUseQuickControls) {
334 mContentView.removeView(mTitleBar);
Michael Kolb2a56eca2011-02-25 09:45:06 -0800335 } else {
John Reck6e8d2e92011-03-14 11:29:56 -0700336 if (!mSkipTitleBarAnimations) {
337 cancelTitleBarAnimation(false);
338 int visibleHeight = getVisibleTitleHeight();
339 mTitleBarAnimator = ObjectAnimator.ofFloat(mTitleBar,
340 "translationY", mTitleBar.getTranslationY(),
341 (-mTitleBar.getEmbeddedHeight() + visibleHeight));
342 mTitleBarAnimator.addListener(mHideTileBarAnimatorListener);
343 mTitleBarAnimator.start();
344 } else {
345 setTitleGravity(Gravity.NO_GRAVITY);
John Recke5c21d92011-03-11 15:09:46 -0800346 }
Michael Kolb7cdc4902011-02-03 17:54:40 -0800347 }
348 super.hideTitleBar();
Michael Kolb66706532010-12-12 19:50:22 -0800349 }
350 }
351
John Reck6e8d2e92011-03-14 11:29:56 -0700352 private void cancelTitleBarAnimation(boolean reset) {
353 if (mTitleBarAnimator != null) {
354 mTitleBarAnimator.cancel();
355 mTitleBarAnimator = null;
356 }
357 if (reset) {
358 mTitleBar.setTranslationY(0);
359 }
360 }
361
John Recke5c21d92011-03-11 15:09:46 -0800362 private int getVisibleTitleHeight() {
363 WebView webview = mActiveTab != null ? mActiveTab.getWebView() : null;
364 return webview != null ? webview.getVisibleTitleHeight() : 0;
365 }
366
367 private AnimatorListener mHideTileBarAnimatorListener = new AnimatorListener() {
368
369 boolean mWasCanceled;
370 @Override
371 public void onAnimationStart(Animator animation) {
372 mWasCanceled = false;
373 }
374
375 @Override
376 public void onAnimationRepeat(Animator animation) {
377 }
378
379 @Override
380 public void onAnimationEnd(Animator animation) {
381 if (!mWasCanceled) {
382 mTitleBar.setTranslationY(0);
John Recke5c21d92011-03-11 15:09:46 -0800383 }
John Reck6e8d2e92011-03-14 11:29:56 -0700384 setTitleGravity(Gravity.NO_GRAVITY);
John Recke5c21d92011-03-11 15:09:46 -0800385 }
386
387 @Override
388 public void onAnimationCancel(Animator animation) {
389 mWasCanceled = true;
390 }
391 };
392
Michael Kolb5ee018e2011-02-18 15:47:21 -0800393 public boolean isEditingUrl() {
394 return mTitleBar.isEditingUrl();
395 }
396
Michael Kolb66706532010-12-12 19:50:22 -0800397 @Override
Michael Kolb7cdc4902011-02-03 17:54:40 -0800398 protected TitleBarBase getTitleBar() {
Michael Kolb66706532010-12-12 19:50:22 -0800399 return mTitleBar;
400 }
401
Michael Kolb2a56eca2011-02-25 09:45:06 -0800402 @Override
403 protected void setTitleGravity(int gravity) {
404 if (mUseQuickControls) {
405 FrameLayout.LayoutParams lp =
406 (FrameLayout.LayoutParams) mTitleBar.getLayoutParams();
407 lp.gravity = gravity;
408 mTitleBar.setLayoutParams(lp);
409 } else {
410 super.setTitleGravity(gravity);
411 }
412 }
413
Michael Kolb66706532010-12-12 19:50:22 -0800414 // action mode callbacks
415
416 @Override
417 public void onActionModeStarted(ActionMode mode) {
Michael Kolb7cdc4902011-02-03 17:54:40 -0800418 if (!mTitleBar.isEditingUrl()) {
Michael Kolb66706532010-12-12 19:50:22 -0800419 // hide the fake title bar when CAB is shown
Michael Kolb7cdc4902011-02-03 17:54:40 -0800420 hideTitleBar();
Michael Kolb66706532010-12-12 19:50:22 -0800421 }
422 }
423
424 @Override
Michael Kolb376b5412010-12-15 11:52:57 -0800425 public void onActionModeFinished(boolean inLoad) {
426 checkTabCount();
427 if (inLoad) {
428 // the titlebar was removed when the CAB was shown
429 // if the page is loading, show it again
Michael Kolb1544f3b2011-03-10 09:06:10 -0800430 if (mUseQuickControls) {
431 mTitleBar.setShowProgressOnly(true);
Michael Kolb376b5412010-12-15 11:52:57 -0800432 }
Michael Kolb7cdc4902011-02-03 17:54:40 -0800433 showTitleBar();
Michael Kolb376b5412010-12-15 11:52:57 -0800434 }
435 }
436
437 @Override
Michael Kolb5a72f182011-01-13 20:35:06 -0800438 protected void updateNavigationState(Tab tab) {
439 mTitleBar.updateNavigationState(tab);
Michael Kolb5a72f182011-01-13 20:35:06 -0800440 }
441
442 @Override
John Reck30c714c2010-12-16 17:30:34 -0800443 public void setUrlTitle(Tab tab) {
444 super.setUrlTitle(tab);
445 mTabBar.onUrlAndTitle(tab, tab.getUrl(), tab.getTitle());
Michael Kolb66706532010-12-12 19:50:22 -0800446 }
447
448 // Set the favicon in the title bar.
449 @Override
John Reck30c714c2010-12-16 17:30:34 -0800450 public void setFavicon(Tab tab) {
451 super.setFavicon(tab);
452 mTabBar.onFavicon(tab, tab.getFavicon());
Michael Kolb66706532010-12-12 19:50:22 -0800453 }
454
Michael Kolbcfa3af52010-12-14 10:36:11 -0800455 @Override
Michael Kolb11d19782011-03-20 10:17:40 -0700456 public void showVoiceTitleBar(String title, List<String> vsresults) {
Michael Kolb3a2a1642011-02-15 10:52:07 -0800457 mTitleBar.setInVoiceMode(true, vsresults);
Michael Kolbcfa3af52010-12-14 10:36:11 -0800458 mTitleBar.setDisplayTitle(title);
Michael Kolbcfa3af52010-12-14 10:36:11 -0800459 }
460
461 @Override
462 public void revertVoiceTitleBar(Tab tab) {
463 mTitleBar.setInVoiceMode(false, null);
John Reck30c714c2010-12-16 17:30:34 -0800464 String url = tab.getUrl();
Michael Kolbcfa3af52010-12-14 10:36:11 -0800465 mTitleBar.setDisplayTitle(url);
Michael Kolbcfa3af52010-12-14 10:36:11 -0800466 }
467
John Reckd73c5a22010-12-22 10:22:50 -0800468 @Override
469 public void showCustomView(View view, CustomViewCallback callback) {
470 super.showCustomView(view, callback);
471 mActivity.getActionBar().hide();
472 }
Michael Kolbcfa3af52010-12-14 10:36:11 -0800473
John Reckd73c5a22010-12-22 10:22:50 -0800474 @Override
475 public void onHideCustomView() {
476 super.onHideCustomView();
477 if (mUseQuickControls) {
478 checkTabCount();
479 } else {
480 mActivity.getActionBar().show();
481 }
482 }
Michael Kolba4183062011-01-16 10:43:21 -0800483
484 @Override
485 public boolean dispatchKey(int code, KeyEvent event) {
Michael Kolbdfe99a12011-03-08 11:45:40 -0800486 if (mActiveTab != null) {
487 WebView web = mActiveTab.getWebView();
488 if (event.getAction() == KeyEvent.ACTION_DOWN) {
489 switch (code) {
490 case KeyEvent.KEYCODE_TAB:
491 case KeyEvent.KEYCODE_DPAD_UP:
492 case KeyEvent.KEYCODE_DPAD_LEFT:
493 if ((web != null) && web.hasFocus() && !mTitleBar.hasFocus()) {
494 editUrl(false);
495 return true;
496 }
497 }
498 boolean ctrl = event.hasModifiers(KeyEvent.META_CTRL_ON);
499 if (!ctrl && isTypingKey(event) && !mTitleBar.isEditingUrl()) {
500 editUrl(true);
501 return mContentView.dispatchKeyEvent(event);
502 }
Michael Kolbdc2ee1b2011-02-14 14:34:40 -0800503 }
Michael Kolba4183062011-01-16 10:43:21 -0800504 }
505 return false;
506 }
507
Michael Kolbdc2ee1b2011-02-14 14:34:40 -0800508 private boolean isTypingKey(KeyEvent evt) {
509 return evt.getUnicodeChar() > 0;
510 }
511
512 TabBar getTabBar() {
513 return mTabBar;
514 }
515
Narayan Kamath5119edd2011-02-23 15:49:17 +0000516 @Override
Michael Kolb1acef692011-03-08 14:12:06 -0800517 public boolean onPrepareOptionsMenu(Menu menu) {
518 if (mUseQuickControls) {
519 mPieControl.onMenuOpened(menu);
520 return false;
521 } else {
522 return true;
523 }
524 }
525
Michael Kolb66706532010-12-12 19:50:22 -0800526}