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