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 | |
| 19 | import com.android.browser.ScrollWebView.ScrollListener; |
| 20 | |
| 21 | import android.app.ActionBar; |
| 22 | import android.app.Activity; |
Michael Kolb | ac35bdc | 2011-01-17 17:06:04 -0800 | [diff] [blame] | 23 | import android.os.Bundle; |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 24 | import android.util.Log; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 25 | import android.view.ActionMode; |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 26 | import android.view.Gravity; |
Michael Kolb | a418306 | 2011-01-16 10:43:21 -0800 | [diff] [blame] | 27 | import android.view.KeyEvent; |
John Reck | d73c5a2 | 2010-12-22 10:22:50 -0800 | [diff] [blame] | 28 | import android.view.View; |
| 29 | import android.webkit.WebChromeClient.CustomViewCallback; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 30 | import android.webkit.WebView; |
| 31 | |
| 32 | import java.util.List; |
| 33 | |
| 34 | /** |
| 35 | * Ui for xlarge screen sizes |
| 36 | */ |
| 37 | public class XLargeUi extends BaseUi implements ScrollListener { |
| 38 | |
| 39 | private static final String LOGTAG = "XLargeUi"; |
| 40 | |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 41 | private ActionBar mActionBar; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 42 | private TabBar mTabBar; |
| 43 | |
| 44 | private TitleBarXLarge mTitleBar; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 45 | |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 46 | private boolean mUseQuickControls; |
| 47 | private PieControl mPieControl; |
| 48 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 49 | /** |
| 50 | * @param browser |
| 51 | * @param controller |
| 52 | */ |
| 53 | public XLargeUi(Activity browser, UiController controller) { |
| 54 | super(browser, controller); |
| 55 | mTitleBar = new TitleBarXLarge(mActivity, mUiController, this); |
| 56 | mTitleBar.setProgress(100); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 57 | mTabBar = new TabBar(mActivity, mUiController, this); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 58 | mActionBar = mActivity.getActionBar(); |
John Reck | b3417f0 | 2011-01-14 11:01:05 -0800 | [diff] [blame] | 59 | setupActionBar(); |
| 60 | setUseQuickControls(BrowserSettings.getInstance().useQuickControls()); |
| 61 | } |
| 62 | |
| 63 | private void setupActionBar() { |
| 64 | mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 65 | mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); |
| 66 | mActionBar.setCustomView(mTabBar); |
John Reck | b3417f0 | 2011-01-14 11:01:05 -0800 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | @Override |
Michael Kolb | ac35bdc | 2011-01-17 17:06:04 -0800 | [diff] [blame] | 70 | public void showComboView(boolean startWithHistory, Bundle extras) { |
| 71 | super.showComboView(startWithHistory, extras); |
| 72 | if (mUseQuickControls) { |
| 73 | mActionBar.show(); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | @Override |
John Reck | b3417f0 | 2011-01-14 11:01:05 -0800 | [diff] [blame] | 78 | public void hideComboView() { |
Michael Kolb | 8814d73 | 2011-01-26 11:22:30 -0800 | [diff] [blame] | 79 | checkTabCount(); |
John Reck | b3417f0 | 2011-01-14 11:01:05 -0800 | [diff] [blame] | 80 | super.hideComboView(); |
| 81 | // ComboView changes the action bar, set it back up to what we want |
| 82 | setupActionBar(); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | private void setUseQuickControls(boolean useQuickControls) { |
| 86 | mUseQuickControls = useQuickControls; |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame^] | 87 | mTitleBar.setUseQuickControls(mUseQuickControls); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 88 | if (useQuickControls) { |
| 89 | checkTabCount(); |
| 90 | mPieControl = new PieControl(mActivity, mUiController, this); |
| 91 | mPieControl.attachToContainer(mContentView); |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame^] | 92 | Tab tab = getActiveTab(); |
| 93 | if ((tab != null) && (tab.getWebView() != null)) { |
| 94 | tab.getWebView().setEmbeddedTitleBar(null); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 95 | } |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame^] | 96 | setTitleGravity(Gravity.BOTTOM); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 97 | } else { |
| 98 | mActivity.getActionBar().show(); |
| 99 | if (mPieControl != null) { |
| 100 | mPieControl.removeFromContainer(mContentView); |
| 101 | } |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame^] | 102 | setTitleGravity(Gravity.TOP); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 103 | WebView web = mTabControl.getCurrentWebView(); |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame^] | 104 | if (web != null) { |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 105 | web.setEmbeddedTitleBar(mTitleBar); |
| 106 | } |
| 107 | } |
| 108 | mTabBar.setUseQuickControls(mUseQuickControls); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | private void checkTabCount() { |
| 112 | if (mUseQuickControls) { |
| 113 | int n = mTabBar.getTabCount(); |
| 114 | if (n >= 2) { |
| 115 | mActivity.getActionBar().show(); |
| 116 | } else if (n == 1) { |
| 117 | mActivity.getActionBar().hide(); |
| 118 | } |
| 119 | } |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | @Override |
| 123 | public void onDestroy() { |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame^] | 124 | hideTitleBar(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | // webview factory |
| 128 | |
| 129 | @Override |
| 130 | public WebView createWebView(boolean privateBrowsing) { |
| 131 | // Create a new WebView |
| 132 | ScrollWebView w = new ScrollWebView(mActivity, null, |
| 133 | android.R.attr.webViewStyle, privateBrowsing); |
| 134 | initWebViewSettings(w); |
| 135 | w.setScrollListener(this); |
| 136 | w.getSettings().setDisplayZoomControls(false); |
Dave Burke | 20b6f1f | 2011-02-01 12:59:04 +0000 | [diff] [blame] | 137 | w.setExpandedTileBounds(true); // smoother scrolling |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 138 | return w; |
| 139 | } |
| 140 | |
| 141 | @Override |
| 142 | public WebView createSubWebView(boolean privateBrowsing) { |
| 143 | ScrollWebView web = (ScrollWebView) createWebView(privateBrowsing); |
| 144 | // no scroll listener for subview |
| 145 | web.setScrollListener(null); |
| 146 | return web; |
| 147 | } |
| 148 | |
| 149 | @Override |
| 150 | public void onScroll(int visibleTitleHeight) { |
| 151 | mTabBar.onScroll(visibleTitleHeight); |
| 152 | } |
| 153 | |
| 154 | void stopWebViewScrolling() { |
| 155 | ScrollWebView web = (ScrollWebView) mUiController.getCurrentWebView(); |
| 156 | if (web != null) { |
| 157 | web.stopScroll(); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | // WebView callbacks |
| 162 | |
| 163 | @Override |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 164 | public void bookmarkedStatusHasChanged(Tab tab) { |
| 165 | if (tab.inForeground()) { |
| 166 | boolean isBookmark = tab.isBookmarkedSite(); |
| 167 | mTitleBar.setCurrentUrlIsBookmark(isBookmark); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 168 | } |
| 169 | } |
| 170 | |
| 171 | @Override |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 172 | public void onProgressChanged(Tab tab) { |
| 173 | int progress = tab.getLoadProgress(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 174 | mTabBar.onProgress(tab, progress); |
| 175 | if (tab.inForeground()) { |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame^] | 176 | mTitleBar.setProgress(progress); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 177 | if (progress == 100) { |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame^] | 178 | if (!mTitleBar.isEditingUrl()) { |
| 179 | hideTitleBar(); |
Michael Kolb | bd018d4 | 2010-12-15 15:43:39 -0800 | [diff] [blame] | 180 | if (mUseQuickControls) { |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame^] | 181 | mTitleBar.setShowProgressOnly(false); |
| 182 | setTitleGravity(Gravity.BOTTOM); |
Michael Kolb | bd018d4 | 2010-12-15 15:43:39 -0800 | [diff] [blame] | 183 | } |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 184 | } |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 185 | } else { |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame^] | 186 | if (!isTitleBarShowing()) { |
| 187 | if (mUseQuickControls && !mTitleBar.isEditingUrl()) { |
| 188 | mTitleBar.setShowProgressOnly(true); |
| 189 | setTitleGravity(Gravity.TOP); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 190 | } |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame^] | 191 | showTitleBar(); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 192 | } |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 193 | } |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | @Override |
| 198 | public boolean needsRestoreAllTabs() { |
| 199 | return true; |
| 200 | } |
| 201 | |
| 202 | @Override |
| 203 | public void addTab(Tab tab) { |
| 204 | mTabBar.onNewTab(tab); |
Michael Kolb | 8814d73 | 2011-01-26 11:22:30 -0800 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | protected void onAddTabCompleted(Tab tab) { |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 208 | checkTabCount(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | @Override |
| 212 | public void setActiveTab(Tab tab) { |
| 213 | super.setActiveTab(tab); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 214 | ScrollWebView view = (ScrollWebView) tab.getWebView(); |
| 215 | // TabControl.setCurrentTab has been called before this, |
| 216 | // so the tab is guaranteed to have a webview |
| 217 | if (view == null) { |
| 218 | Log.e(LOGTAG, "active tab with no webview detected"); |
| 219 | return; |
| 220 | } |
| 221 | // Request focus on the top window. |
| 222 | if (mUseQuickControls) { |
| 223 | mPieControl.forceToTop(mContentView); |
| 224 | view.setScrollListener(null); |
| 225 | mTabBar.showTitleBarIndicator(false); |
| 226 | } else { |
| 227 | view.setEmbeddedTitleBar(mTitleBar); |
| 228 | view.setScrollListener(this); |
| 229 | } |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 230 | mTabBar.onSetActiveTab(tab); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 231 | if (tab.isInVoiceSearchMode()) { |
| 232 | showVoiceTitleBar(tab.getVoiceDisplayTitle()); |
| 233 | } else { |
| 234 | revertVoiceTitleBar(tab); |
| 235 | } |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 236 | updateLockIconToLatest(tab); |
| 237 | tab.getTopWindow().requestFocus(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | @Override |
| 241 | public void updateTabs(List<Tab> tabs) { |
| 242 | mTabBar.updateTabs(tabs); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 243 | checkTabCount(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | @Override |
| 247 | public void removeTab(Tab tab) { |
| 248 | super.removeTab(tab); |
| 249 | mTabBar.onRemoveTab(tab); |
Michael Kolb | 8814d73 | 2011-01-26 11:22:30 -0800 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | protected void onRemoveTabCompleted(Tab tab) { |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 253 | checkTabCount(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 254 | } |
| 255 | |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 256 | int getContentWidth() { |
| 257 | if (mContentView != null) { |
| 258 | return mContentView.getWidth(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 259 | } |
| 260 | return 0; |
| 261 | } |
| 262 | |
| 263 | void editUrl(boolean clearInput) { |
Michael Kolb | d72ea3b | 2011-01-09 15:56:37 -0800 | [diff] [blame] | 264 | if (mUiController.isInCustomActionMode()) { |
| 265 | mUiController.endActionMode(); |
| 266 | } |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame^] | 267 | showTitleBar(); |
| 268 | mTitleBar.onEditUrl(clearInput); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 269 | } |
| 270 | |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame^] | 271 | void showTitleBarAndEdit() { |
| 272 | mTitleBar.setShowProgressOnly(false); |
| 273 | showTitleBar(); |
| 274 | mTitleBar.onEditUrl(false); |
| 275 | } |
| 276 | |
| 277 | void stopEditingUrl() { |
| 278 | mTitleBar.stopEditingUrl(); |
| 279 | } |
| 280 | |
| 281 | @Override |
| 282 | protected void showTitleBar() { |
| 283 | if (canShowTitleBar()) { |
| 284 | if (mUseQuickControls) { |
| 285 | setTitleGravity(Gravity.BOTTOM); |
| 286 | mContentView.addView(mTitleBar); |
| 287 | } else { |
| 288 | setTitleGravity(Gravity.TOP); |
| 289 | } |
| 290 | super.showTitleBar(); |
| 291 | mTabBar.onShowTitleBar(); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 292 | } |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 293 | } |
| 294 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 295 | @Override |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame^] | 296 | protected void hideTitleBar() { |
| 297 | if (isTitleBarShowing()) { |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 298 | mTabBar.onHideTitleBar(); |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame^] | 299 | setTitleGravity(Gravity.NO_GRAVITY); |
| 300 | if (mUseQuickControls) { |
| 301 | mContentView.removeView(mTitleBar); |
| 302 | } |
| 303 | super.hideTitleBar(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 304 | } |
| 305 | } |
| 306 | |
| 307 | @Override |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame^] | 308 | protected TitleBarBase getTitleBar() { |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 309 | return mTitleBar; |
| 310 | } |
| 311 | |
| 312 | // action mode callbacks |
| 313 | |
| 314 | @Override |
| 315 | public void onActionModeStarted(ActionMode mode) { |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame^] | 316 | if (!mTitleBar.isEditingUrl()) { |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 317 | // hide the fake title bar when CAB is shown |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame^] | 318 | hideTitleBar(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 319 | } |
| 320 | } |
| 321 | |
| 322 | @Override |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 323 | public void onActionModeFinished(boolean inLoad) { |
| 324 | checkTabCount(); |
| 325 | if (inLoad) { |
| 326 | // the titlebar was removed when the CAB was shown |
| 327 | // if the page is loading, show it again |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame^] | 328 | mTitleBar.setShowProgressOnly(true); |
| 329 | if (!isTitleBarShowing()) { |
| 330 | setTitleGravity(Gravity.TOP); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 331 | } |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame^] | 332 | showTitleBar(); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 333 | } |
| 334 | } |
| 335 | |
| 336 | @Override |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 337 | protected void updateNavigationState(Tab tab) { |
| 338 | mTitleBar.updateNavigationState(tab); |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | @Override |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 342 | public void setUrlTitle(Tab tab) { |
| 343 | super.setUrlTitle(tab); |
| 344 | mTabBar.onUrlAndTitle(tab, tab.getUrl(), tab.getTitle()); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | // Set the favicon in the title bar. |
| 348 | @Override |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 349 | public void setFavicon(Tab tab) { |
| 350 | super.setFavicon(tab); |
| 351 | mTabBar.onFavicon(tab, tab.getFavicon()); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 352 | } |
| 353 | |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 354 | @Override |
| 355 | public void showVoiceTitleBar(String title) { |
| 356 | List<String> vsresults = null; |
| 357 | if (getActiveTab() != null) { |
| 358 | vsresults = getActiveTab().getVoiceSearchResults(); |
| 359 | } |
| 360 | mTitleBar.setInVoiceMode(true, null); |
| 361 | mTitleBar.setDisplayTitle(title); |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | @Override |
| 365 | public void revertVoiceTitleBar(Tab tab) { |
| 366 | mTitleBar.setInVoiceMode(false, null); |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 367 | String url = tab.getUrl(); |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 368 | mTitleBar.setDisplayTitle(url); |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 369 | } |
| 370 | |
John Reck | d73c5a2 | 2010-12-22 10:22:50 -0800 | [diff] [blame] | 371 | @Override |
| 372 | public void showCustomView(View view, CustomViewCallback callback) { |
| 373 | super.showCustomView(view, callback); |
| 374 | mActivity.getActionBar().hide(); |
| 375 | } |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 376 | |
John Reck | d73c5a2 | 2010-12-22 10:22:50 -0800 | [diff] [blame] | 377 | @Override |
| 378 | public void onHideCustomView() { |
| 379 | super.onHideCustomView(); |
| 380 | if (mUseQuickControls) { |
| 381 | checkTabCount(); |
| 382 | } else { |
| 383 | mActivity.getActionBar().show(); |
| 384 | } |
| 385 | } |
Michael Kolb | a418306 | 2011-01-16 10:43:21 -0800 | [diff] [blame] | 386 | |
| 387 | @Override |
| 388 | public boolean dispatchKey(int code, KeyEvent event) { |
| 389 | WebView web = getActiveTab().getWebView(); |
| 390 | switch (code) { |
| 391 | case KeyEvent.KEYCODE_TAB: |
| 392 | case KeyEvent.KEYCODE_DPAD_UP: |
| 393 | case KeyEvent.KEYCODE_DPAD_LEFT: |
| 394 | if ((web != null) && web.hasFocus()) { |
| 395 | editUrl(true); |
| 396 | return true; |
| 397 | } |
| 398 | } |
Michael Kolb | 47171d8 | 2011-01-28 10:34:15 -0800 | [diff] [blame] | 399 | boolean ctrl = event.hasModifiers(KeyEvent.META_CTRL_ON); |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame^] | 400 | if (!ctrl && event.isPrintingKey() && !mTitleBar.isEditingUrl()) { |
Michael Kolb | a418306 | 2011-01-16 10:43:21 -0800 | [diff] [blame] | 401 | editUrl(true); |
| 402 | return mContentView.dispatchKeyEvent(event); |
| 403 | } |
| 404 | return false; |
| 405 | } |
| 406 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 407 | } |