Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.browser; |
| 18 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 19 | import android.app.ActionBar; |
| 20 | import android.app.Activity; |
Michael Kolb | ac35bdc | 2011-01-17 17:06:04 -0800 | [diff] [blame] | 21 | import android.os.Bundle; |
Michael Kolb | ba23870 | 2011-03-08 10:40:50 -0800 | [diff] [blame] | 22 | import android.os.Handler; |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 23 | import android.util.Log; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 24 | import android.view.ActionMode; |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 25 | import android.view.Gravity; |
Michael Kolb | a418306 | 2011-01-16 10:43:21 -0800 | [diff] [blame] | 26 | import android.view.KeyEvent; |
John Reck | d73c5a2 | 2010-12-22 10:22:50 -0800 | [diff] [blame] | 27 | import android.view.View; |
| 28 | import android.webkit.WebChromeClient.CustomViewCallback; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 29 | import android.webkit.WebView; |
| 30 | |
| 31 | import java.util.List; |
| 32 | |
| 33 | /** |
| 34 | * Ui for xlarge screen sizes |
| 35 | */ |
Michael Kolb | b14ff2f | 2011-07-01 15:33:56 -0700 | [diff] [blame] | 36 | public class XLargeUi extends BaseUi { |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 37 | |
| 38 | private static final String LOGTAG = "XLargeUi"; |
| 39 | |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 40 | private ActionBar mActionBar; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 41 | private TabBar mTabBar; |
| 42 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame^] | 43 | private NavigationBarTablet mNavBar; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 44 | |
Michael Kolb | 0241e75 | 2011-07-07 14:58:50 -0700 | [diff] [blame] | 45 | private PieControlXLarge mPieControl; |
Michael Kolb | ba23870 | 2011-03-08 10:40:50 -0800 | [diff] [blame] | 46 | private Handler mHandler; |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 47 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 48 | /** |
| 49 | * @param browser |
| 50 | * @param controller |
| 51 | */ |
| 52 | public XLargeUi(Activity browser, UiController controller) { |
| 53 | super(browser, controller); |
Michael Kolb | ba23870 | 2011-03-08 10:40:50 -0800 | [diff] [blame] | 54 | mHandler = new Handler(); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame^] | 55 | mNavBar = (NavigationBarTablet) mTitleBar.getNavigationBar(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 56 | mTabBar = new TabBar(mActivity, mUiController, this); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 57 | mActionBar = mActivity.getActionBar(); |
John Reck | b3417f0 | 2011-01-14 11:01:05 -0800 | [diff] [blame] | 58 | setupActionBar(); |
| 59 | setUseQuickControls(BrowserSettings.getInstance().useQuickControls()); |
| 60 | } |
| 61 | |
| 62 | private void setupActionBar() { |
| 63 | mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 64 | mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); |
| 65 | mActionBar.setCustomView(mTabBar); |
John Reck | b3417f0 | 2011-01-14 11:01:05 -0800 | [diff] [blame] | 66 | } |
| 67 | |
John Reck | 2bc8042 | 2011-06-30 15:11:49 -0700 | [diff] [blame] | 68 | public void showComboView(ComboViews startWith, Bundle extras) { |
| 69 | super.showComboView(startWith, extras); |
Michael Kolb | ac35bdc | 2011-01-17 17:06:04 -0800 | [diff] [blame] | 70 | if (mUseQuickControls) { |
| 71 | mActionBar.show(); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | @Override |
John Reck | b3417f0 | 2011-01-14 11:01:05 -0800 | [diff] [blame] | 76 | public void hideComboView() { |
Michael Kolb | ba23870 | 2011-03-08 10:40:50 -0800 | [diff] [blame] | 77 | if (isComboViewShowing()) { |
| 78 | super.hideComboView(); |
| 79 | // ComboView changes the action bar, set it back up to what we want |
| 80 | setupActionBar(); |
| 81 | checkTabCount(); |
| 82 | } |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 83 | } |
| 84 | |
Michael Kolb | 0241e75 | 2011-07-07 14:58:50 -0700 | [diff] [blame] | 85 | @Override |
| 86 | public void setUseQuickControls(boolean useQuickControls) { |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 87 | mUseQuickControls = useQuickControls; |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 88 | mTitleBar.setUseQuickControls(mUseQuickControls); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 89 | if (useQuickControls) { |
| 90 | checkTabCount(); |
Michael Kolb | 0241e75 | 2011-07-07 14:58:50 -0700 | [diff] [blame] | 91 | mPieControl = new PieControlXLarge(mActivity, mUiController, this); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 92 | mPieControl.attachToContainer(mContentView); |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 93 | WebView web = getWebView(); |
| 94 | if (web != null) { |
| 95 | web.setEmbeddedTitleBar(null); |
Michael Kolb | 0241e75 | 2011-07-07 14:58:50 -0700 | [diff] [blame] | 96 | // don't show url bar on scrolling |
| 97 | web.setOnTouchListener(null); |
| 98 | |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 99 | } |
| 100 | } else { |
| 101 | mActivity.getActionBar().show(); |
| 102 | if (mPieControl != null) { |
| 103 | mPieControl.removeFromContainer(mContentView); |
| 104 | } |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 105 | WebView web = getWebView(); |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 106 | if (web != null) { |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 107 | web.setEmbeddedTitleBar(mTitleBar); |
Michael Kolb | 0241e75 | 2011-07-07 14:58:50 -0700 | [diff] [blame] | 108 | // show url bar on scrolling |
| 109 | web.setOnTouchListener(this); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 110 | } |
Michael Kolb | 8a4c382 | 2011-03-15 14:52:05 -0700 | [diff] [blame] | 111 | setTitleGravity(Gravity.NO_GRAVITY); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 112 | } |
| 113 | mTabBar.setUseQuickControls(mUseQuickControls); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | private void checkTabCount() { |
| 117 | if (mUseQuickControls) { |
Michael Kolb | eb95db4 | 2011-03-03 10:38:40 -0800 | [diff] [blame] | 118 | mHandler.post(new Runnable() { |
| 119 | public void run() { |
| 120 | mActionBar.hide(); |
| 121 | } |
| 122 | }); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 123 | } |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | @Override |
Narayan Kamath | 67b8c1b | 2011-03-09 20:47:52 +0000 | [diff] [blame] | 127 | public void onResume() { |
| 128 | super.onResume(); |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 129 | if (!BrowserSettings.getInstance().useInstantSearch()) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame^] | 130 | mNavBar.clearCompletions(); |
Narayan Kamath | 67b8c1b | 2011-03-09 20:47:52 +0000 | [diff] [blame] | 131 | } |
| 132 | } |
| 133 | |
| 134 | @Override |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 135 | public void onDestroy() { |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 136 | hideTitleBar(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 137 | } |
| 138 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 139 | void stopWebViewScrolling() { |
John Reck | b9a051b | 2011-03-18 11:55:48 -0700 | [diff] [blame] | 140 | BrowserWebView web = (BrowserWebView) mUiController.getCurrentWebView(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 141 | if (web != null) { |
| 142 | web.stopScroll(); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | // WebView callbacks |
| 147 | |
| 148 | @Override |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 149 | public void onProgressChanged(Tab tab) { |
| 150 | int progress = tab.getLoadProgress(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 151 | mTabBar.onProgress(tab, progress); |
| 152 | if (tab.inForeground()) { |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 153 | mTitleBar.setProgress(progress); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 154 | } |
| 155 | } |
| 156 | |
| 157 | @Override |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 158 | public void addTab(Tab tab) { |
| 159 | mTabBar.onNewTab(tab); |
Michael Kolb | 8814d73 | 2011-01-26 11:22:30 -0800 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | protected void onAddTabCompleted(Tab tab) { |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 163 | checkTabCount(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | @Override |
Michael Kolb | 377ea31 | 2011-02-17 14:36:56 -0800 | [diff] [blame] | 167 | public void setActiveTab(final Tab tab) { |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 168 | mTitleBar.cancelTitleBarAnimation(true); |
| 169 | mTitleBar.setSkipTitleBarAnimations(true); |
Michael Kolb | eb95db4 | 2011-03-03 10:38:40 -0800 | [diff] [blame] | 170 | if (mUseQuickControls) { |
| 171 | if (mActiveTab != null) { |
| 172 | captureTab(mActiveTab); |
| 173 | } |
| 174 | } |
John Reck | 5d43ce8 | 2011-06-21 17:16:51 -0700 | [diff] [blame] | 175 | super.setActiveTab(tab); |
John Reck | b9a051b | 2011-03-18 11:55:48 -0700 | [diff] [blame] | 176 | BrowserWebView view = (BrowserWebView) tab.getWebView(); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 177 | // TabControl.setCurrentTab has been called before this, |
| 178 | // so the tab is guaranteed to have a webview |
| 179 | if (view == null) { |
| 180 | Log.e(LOGTAG, "active tab with no webview detected"); |
| 181 | return; |
| 182 | } |
| 183 | // Request focus on the top window. |
| 184 | if (mUseQuickControls) { |
| 185 | mPieControl.forceToTop(mContentView); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 186 | } else { |
Michael Kolb | 377ea31 | 2011-02-17 14:36:56 -0800 | [diff] [blame] | 187 | // check if title bar is already attached by animation |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame^] | 188 | if (mTitleBar.getParent() == null) { |
Michael Kolb | 377ea31 | 2011-02-17 14:36:56 -0800 | [diff] [blame] | 189 | view.setEmbeddedTitleBar(mTitleBar); |
| 190 | } |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 191 | } |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 192 | mTabBar.onSetActiveTab(tab); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 193 | if (tab.isInVoiceSearchMode()) { |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 194 | showVoiceTitleBar(tab.getVoiceDisplayTitle(), tab.getVoiceSearchResults()); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 195 | } else { |
| 196 | revertVoiceTitleBar(tab); |
| 197 | } |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 198 | updateLockIconToLatest(tab); |
| 199 | tab.getTopWindow().requestFocus(); |
John Reck | 5d43ce8 | 2011-06-21 17:16:51 -0700 | [diff] [blame] | 200 | mTitleBar.setSkipTitleBarAnimations(false); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | @Override |
| 204 | public void updateTabs(List<Tab> tabs) { |
| 205 | mTabBar.updateTabs(tabs); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 206 | checkTabCount(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | @Override |
| 210 | public void removeTab(Tab tab) { |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 211 | mTitleBar.cancelTitleBarAnimation(true); |
| 212 | mTitleBar.setSkipTitleBarAnimations(true); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 213 | super.removeTab(tab); |
| 214 | mTabBar.onRemoveTab(tab); |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 215 | mTitleBar.setSkipTitleBarAnimations(false); |
Michael Kolb | 8814d73 | 2011-01-26 11:22:30 -0800 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | protected void onRemoveTabCompleted(Tab tab) { |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 219 | checkTabCount(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 220 | } |
| 221 | |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 222 | int getContentWidth() { |
| 223 | if (mContentView != null) { |
| 224 | return mContentView.getWidth(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 225 | } |
| 226 | return 0; |
| 227 | } |
| 228 | |
Michael Kolb | dc2ee1b | 2011-02-14 14:34:40 -0800 | [diff] [blame] | 229 | @Override |
| 230 | public void editUrl(boolean clearInput) { |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 231 | if (mUseQuickControls) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame^] | 232 | mTitleBar.setShowProgressOnly(false); |
Michael Kolb | d72ea3b | 2011-01-09 15:56:37 -0800 | [diff] [blame] | 233 | } |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 234 | super.editUrl(clearInput); |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | void stopEditingUrl() { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame^] | 238 | mTitleBar.getNavigationBar().stopEditingUrl(); |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | @Override |
| 242 | protected void showTitleBar() { |
| 243 | if (canShowTitleBar()) { |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 244 | mTitleBar.show(); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 245 | } |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 246 | } |
| 247 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 248 | @Override |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 249 | protected void hideTitleBar() { |
| 250 | if (isTitleBarShowing()) { |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 251 | mTitleBar.hide(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 252 | } |
| 253 | } |
| 254 | |
| 255 | @Override |
Michael Kolb | 2a56eca | 2011-02-25 09:45:06 -0800 | [diff] [blame] | 256 | protected void setTitleGravity(int gravity) { |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 257 | if (!mUseQuickControls) { |
Michael Kolb | 2a56eca | 2011-02-25 09:45:06 -0800 | [diff] [blame] | 258 | super.setTitleGravity(gravity); |
| 259 | } |
| 260 | } |
| 261 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 262 | // action mode callbacks |
| 263 | |
| 264 | @Override |
| 265 | public void onActionModeStarted(ActionMode mode) { |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 266 | if (!mTitleBar.isEditingUrl()) { |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 267 | // hide the fake title bar when CAB is shown |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 268 | hideTitleBar(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 269 | } |
| 270 | } |
| 271 | |
| 272 | @Override |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 273 | public void onActionModeFinished(boolean inLoad) { |
| 274 | checkTabCount(); |
| 275 | if (inLoad) { |
| 276 | // the titlebar was removed when the CAB was shown |
| 277 | // if the page is loading, show it again |
Michael Kolb | 1544f3b | 2011-03-10 09:06:10 -0800 | [diff] [blame] | 278 | if (mUseQuickControls) { |
| 279 | mTitleBar.setShowProgressOnly(true); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 280 | } |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 281 | showTitleBar(); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 282 | } |
| 283 | } |
| 284 | |
| 285 | @Override |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 286 | protected void updateNavigationState(Tab tab) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame^] | 287 | mNavBar.updateNavigationState(tab); |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | @Override |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 291 | public void setUrlTitle(Tab tab) { |
| 292 | super.setUrlTitle(tab); |
| 293 | mTabBar.onUrlAndTitle(tab, tab.getUrl(), tab.getTitle()); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | // Set the favicon in the title bar. |
| 297 | @Override |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 298 | public void setFavicon(Tab tab) { |
| 299 | super.setFavicon(tab); |
| 300 | mTabBar.onFavicon(tab, tab.getFavicon()); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 301 | } |
| 302 | |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 303 | @Override |
Derek Sollenberger | 2d4f1e2 | 2011-06-01 14:50:42 -0400 | [diff] [blame] | 304 | public void showCustomView(View view, int requestedOrientation, |
| 305 | CustomViewCallback callback) { |
| 306 | super.showCustomView(view, requestedOrientation, callback); |
John Reck | d73c5a2 | 2010-12-22 10:22:50 -0800 | [diff] [blame] | 307 | mActivity.getActionBar().hide(); |
| 308 | } |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 309 | |
John Reck | d73c5a2 | 2010-12-22 10:22:50 -0800 | [diff] [blame] | 310 | @Override |
| 311 | public void onHideCustomView() { |
| 312 | super.onHideCustomView(); |
| 313 | if (mUseQuickControls) { |
| 314 | checkTabCount(); |
| 315 | } else { |
| 316 | mActivity.getActionBar().show(); |
| 317 | } |
| 318 | } |
Michael Kolb | a418306 | 2011-01-16 10:43:21 -0800 | [diff] [blame] | 319 | |
| 320 | @Override |
| 321 | public boolean dispatchKey(int code, KeyEvent event) { |
Michael Kolb | dfe99a1 | 2011-03-08 11:45:40 -0800 | [diff] [blame] | 322 | if (mActiveTab != null) { |
| 323 | WebView web = mActiveTab.getWebView(); |
| 324 | if (event.getAction() == KeyEvent.ACTION_DOWN) { |
| 325 | switch (code) { |
| 326 | case KeyEvent.KEYCODE_TAB: |
| 327 | case KeyEvent.KEYCODE_DPAD_UP: |
| 328 | case KeyEvent.KEYCODE_DPAD_LEFT: |
| 329 | if ((web != null) && web.hasFocus() && !mTitleBar.hasFocus()) { |
| 330 | editUrl(false); |
| 331 | return true; |
| 332 | } |
| 333 | } |
| 334 | boolean ctrl = event.hasModifiers(KeyEvent.META_CTRL_ON); |
| 335 | if (!ctrl && isTypingKey(event) && !mTitleBar.isEditingUrl()) { |
| 336 | editUrl(true); |
| 337 | return mContentView.dispatchKeyEvent(event); |
| 338 | } |
Michael Kolb | dc2ee1b | 2011-02-14 14:34:40 -0800 | [diff] [blame] | 339 | } |
Michael Kolb | a418306 | 2011-01-16 10:43:21 -0800 | [diff] [blame] | 340 | } |
| 341 | return false; |
| 342 | } |
| 343 | |
Michael Kolb | dc2ee1b | 2011-02-14 14:34:40 -0800 | [diff] [blame] | 344 | private boolean isTypingKey(KeyEvent evt) { |
| 345 | return evt.getUnicodeChar() > 0; |
| 346 | } |
| 347 | |
| 348 | TabBar getTabBar() { |
| 349 | return mTabBar; |
| 350 | } |
| 351 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 352 | } |