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 | |
Bijan Amirzada | 41242f2 | 2014-03-21 12:12:18 -0700 | [diff] [blame] | 17 | package com.android.browser; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 18 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 19 | import android.app.ActionBar; |
| 20 | import android.app.Activity; |
John Reck | 034637c | 2011-08-11 11:34:44 -0700 | [diff] [blame] | 21 | import android.content.res.Resources; |
| 22 | import android.graphics.Bitmap; |
| 23 | import android.graphics.drawable.BitmapDrawable; |
Pankaj Garg | 32e1b94 | 2015-06-03 18:13:24 -0700 | [diff] [blame^] | 24 | import android.graphics.drawable.ColorDrawable; |
John Reck | 034637c | 2011-08-11 11:34:44 -0700 | [diff] [blame] | 25 | import android.graphics.drawable.Drawable; |
| 26 | import android.graphics.drawable.LayerDrawable; |
| 27 | import android.graphics.drawable.PaintDrawable; |
Michael Kolb | ac35bdc | 2011-01-17 17:06:04 -0800 | [diff] [blame] | 28 | import android.os.Bundle; |
Michael Kolb | ba23870 | 2011-03-08 10:40:50 -0800 | [diff] [blame] | 29 | import android.os.Handler; |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 30 | import android.util.Log; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 31 | import android.view.ActionMode; |
Michael Kolb | a418306 | 2011-01-16 10:43:21 -0800 | [diff] [blame] | 32 | import android.view.KeyEvent; |
Michael Kolb | 0d0245f | 2011-12-05 16:36:05 -0800 | [diff] [blame] | 33 | import android.view.Menu; |
| 34 | import android.view.MenuItem; |
Pankaj Garg | 16053b4 | 2014-12-17 15:23:01 -0800 | [diff] [blame] | 35 | import android.view.View; |
Tarun Nainani | 87a8668 | 2015-02-05 11:47:35 -0800 | [diff] [blame] | 36 | import android.view.ViewStub; |
Pankaj Garg | 16053b4 | 2014-12-17 15:23:01 -0800 | [diff] [blame] | 37 | import android.webkit.WebChromeClient; |
| 38 | |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 39 | import org.codeaurora.swe.WebView; |
Pankaj Garg | 32e1b94 | 2015-06-03 18:13:24 -0700 | [diff] [blame^] | 40 | import org.codeaurora.swe.util.ColorUtils; |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 41 | |
Bijan Amirzada | 41242f2 | 2014-03-21 12:12:18 -0700 | [diff] [blame] | 42 | import com.android.browser.R; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 43 | |
| 44 | import java.util.List; |
| 45 | |
| 46 | /** |
| 47 | * Ui for xlarge screen sizes |
| 48 | */ |
Michael Kolb | b14ff2f | 2011-07-01 15:33:56 -0700 | [diff] [blame] | 49 | public class XLargeUi extends BaseUi { |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 50 | |
| 51 | private static final String LOGTAG = "XLargeUi"; |
| 52 | |
John Reck | 034637c | 2011-08-11 11:34:44 -0700 | [diff] [blame] | 53 | private PaintDrawable mFaviconBackground; |
| 54 | |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 55 | private ActionBar mActionBar; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 56 | private TabBar mTabBar; |
| 57 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 58 | private NavigationBarTablet mNavBar; |
Tarun Nainani | 87a8668 | 2015-02-05 11:47:35 -0800 | [diff] [blame] | 59 | private ComboView mComboView; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 60 | |
Michael Kolb | ba23870 | 2011-03-08 10:40:50 -0800 | [diff] [blame] | 61 | private Handler mHandler; |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 62 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 63 | /** |
| 64 | * @param browser |
| 65 | * @param controller |
| 66 | */ |
| 67 | public XLargeUi(Activity browser, UiController controller) { |
| 68 | super(browser, controller); |
Michael Kolb | ba23870 | 2011-03-08 10:40:50 -0800 | [diff] [blame] | 69 | mHandler = new Handler(); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 70 | mNavBar = (NavigationBarTablet) mTitleBar.getNavigationBar(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 71 | mTabBar = new TabBar(mActivity, mUiController, this); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 72 | mActionBar = mActivity.getActionBar(); |
John Reck | b3417f0 | 2011-01-14 11:01:05 -0800 | [diff] [blame] | 73 | setupActionBar(); |
John Reck | b3417f0 | 2011-01-14 11:01:05 -0800 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | private void setupActionBar() { |
Tarun Nainani | 87a8668 | 2015-02-05 11:47:35 -0800 | [diff] [blame] | 77 | mActionBar.setHomeButtonEnabled(false); |
John Reck | b3417f0 | 2011-01-14 11:01:05 -0800 | [diff] [blame] | 78 | mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 79 | mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); |
| 80 | mActionBar.setCustomView(mTabBar); |
John Reck | b3417f0 | 2011-01-14 11:01:05 -0800 | [diff] [blame] | 81 | } |
| 82 | |
John Reck | 2bc8042 | 2011-06-30 15:11:49 -0700 | [diff] [blame] | 83 | public void showComboView(ComboViews startWith, Bundle extras) { |
Tarun Nainani | 87a8668 | 2015-02-05 11:47:35 -0800 | [diff] [blame] | 84 | if (mComboView == null) { |
| 85 | ViewStub stub = (ViewStub) mActivity.getWindow().getDecorView().findViewById(R.id.combo_view_stub); |
| 86 | mComboView = (ComboView) stub.inflate(); |
| 87 | mComboView.setVisibility(View.GONE); |
| 88 | mComboView.setupViews(mActivity); |
| 89 | } |
| 90 | mNavBar.setVisibility(View.GONE); |
| 91 | if (mActionBar != null) |
| 92 | mActionBar.hide(); |
| 93 | Bundle b = new Bundle(); |
| 94 | b.putString(ComboViewActivity.EXTRA_INITIAL_VIEW, startWith.name()); |
| 95 | b.putBundle(ComboViewActivity.EXTRA_COMBO_ARGS, extras); |
| 96 | Tab t = getActiveTab(); |
| 97 | if (t != null) { |
| 98 | b.putString(ComboViewActivity.EXTRA_CURRENT_URL, t.getUrl()); |
| 99 | } |
| 100 | mComboView.showViews(mActivity, b); |
| 101 | } |
| 102 | |
| 103 | @Override |
| 104 | public void hideComboView() { |
| 105 | if (showingComboView()) { |
| 106 | mComboView.hideViews(); |
| 107 | mActionBar = mActivity.getActionBar(); |
| 108 | setupActionBar(); |
| 109 | if (mActionBar != null) |
| 110 | mActionBar.show(); |
| 111 | mNavBar.setVisibility(View.VISIBLE); |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | @Override |
| 116 | public boolean onBackKey() { |
| 117 | if (showingComboView()) { |
| 118 | hideComboView(); |
| 119 | return true; |
| 120 | } |
| 121 | return super.onBackKey(); |
| 122 | } |
| 123 | |
| 124 | private boolean showingComboView() { |
| 125 | return mComboView != null && mComboView.getVisibility() == View.VISIBLE; |
| 126 | } |
| 127 | |
| 128 | @Override |
| 129 | public boolean isComboViewShowing() { |
| 130 | return showingComboView(); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 131 | } |
| 132 | |
Michael Kolb | da58063 | 2012-04-16 13:30:28 -0700 | [diff] [blame] | 133 | private void checkHideActionBar() { |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | @Override |
Narayan Kamath | 67b8c1b | 2011-03-09 20:47:52 +0000 | [diff] [blame] | 137 | public void onResume() { |
| 138 | super.onResume(); |
Narayan Kamath | f3174a5 | 2011-11-17 14:43:32 +0000 | [diff] [blame] | 139 | mNavBar.clearCompletions(); |
Michael Kolb | da58063 | 2012-04-16 13:30:28 -0700 | [diff] [blame] | 140 | checkHideActionBar(); |
Narayan Kamath | 67b8c1b | 2011-03-09 20:47:52 +0000 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | @Override |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 144 | public void onDestroy() { |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 145 | hideTitleBar(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 146 | } |
| 147 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 148 | void stopWebViewScrolling() { |
John Reck | b9a051b | 2011-03-18 11:55:48 -0700 | [diff] [blame] | 149 | BrowserWebView web = (BrowserWebView) mUiController.getCurrentWebView(); |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 150 | if (web != null) { |
| 151 | web.stopScroll(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 152 | } |
| 153 | } |
| 154 | |
Michael Kolb | 0d0245f | 2011-12-05 16:36:05 -0800 | [diff] [blame] | 155 | @Override |
| 156 | public boolean onPrepareOptionsMenu(Menu menu) { |
| 157 | MenuItem bm = menu.findItem(R.id.bookmarks_menu_id); |
| 158 | if (bm != null) { |
| 159 | bm.setVisible(false); |
| 160 | } |
Enrico Ros | 1f5a095 | 2014-11-18 20:15:48 -0800 | [diff] [blame] | 161 | |
| 162 | menu.setGroupVisible(R.id.NAV_MENU, false); |
| 163 | |
Michael Kolb | 0d0245f | 2011-12-05 16:36:05 -0800 | [diff] [blame] | 164 | return true; |
| 165 | } |
| 166 | |
| 167 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 168 | // WebView callbacks |
| 169 | |
| 170 | @Override |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 171 | public void addTab(Tab tab) { |
| 172 | mTabBar.onNewTab(tab); |
Michael Kolb | 8814d73 | 2011-01-26 11:22:30 -0800 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | protected void onAddTabCompleted(Tab tab) { |
Michael Kolb | da58063 | 2012-04-16 13:30:28 -0700 | [diff] [blame] | 176 | checkHideActionBar(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | @Override |
Michael Kolb | 377ea31 | 2011-02-17 14:36:56 -0800 | [diff] [blame] | 180 | public void setActiveTab(final Tab tab) { |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 181 | mTitleBar.cancelTitleBarAnimation(true); |
| 182 | mTitleBar.setSkipTitleBarAnimations(true); |
John Reck | 5d43ce8 | 2011-06-21 17:16:51 -0700 | [diff] [blame] | 183 | super.setActiveTab(tab); |
John Reck | b9a051b | 2011-03-18 11:55:48 -0700 | [diff] [blame] | 184 | BrowserWebView view = (BrowserWebView) tab.getWebView(); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 185 | // TabControl.setCurrentTab has been called before this, |
| 186 | // so the tab is guaranteed to have a webview |
| 187 | if (view == null) { |
| 188 | Log.e(LOGTAG, "active tab with no webview detected"); |
| 189 | return; |
| 190 | } |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 191 | mTabBar.onSetActiveTab(tab); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 192 | updateLockIconToLatest(tab); |
John Reck | 5d43ce8 | 2011-06-21 17:16:51 -0700 | [diff] [blame] | 193 | mTitleBar.setSkipTitleBarAnimations(false); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | @Override |
| 197 | public void updateTabs(List<Tab> tabs) { |
| 198 | mTabBar.updateTabs(tabs); |
Michael Kolb | da58063 | 2012-04-16 13:30:28 -0700 | [diff] [blame] | 199 | checkHideActionBar(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | @Override |
| 203 | public void removeTab(Tab tab) { |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 204 | mTitleBar.cancelTitleBarAnimation(true); |
| 205 | mTitleBar.setSkipTitleBarAnimations(true); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 206 | super.removeTab(tab); |
| 207 | mTabBar.onRemoveTab(tab); |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 208 | mTitleBar.setSkipTitleBarAnimations(false); |
Michael Kolb | 8814d73 | 2011-01-26 11:22:30 -0800 | [diff] [blame] | 209 | } |
| 210 | |
Pankaj Garg | 16053b4 | 2014-12-17 15:23:01 -0800 | [diff] [blame] | 211 | @Override |
| 212 | public void showCustomView(View view, int requestedOrientation, |
| 213 | WebChromeClient.CustomViewCallback callback) { |
| 214 | super.showCustomView(view, requestedOrientation, callback); |
| 215 | if (mActionBar != null) |
| 216 | mActionBar.hide(); |
| 217 | } |
| 218 | |
Michael Kolb | 8814d73 | 2011-01-26 11:22:30 -0800 | [diff] [blame] | 219 | protected void onRemoveTabCompleted(Tab tab) { |
Michael Kolb | da58063 | 2012-04-16 13:30:28 -0700 | [diff] [blame] | 220 | checkHideActionBar(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 221 | } |
| 222 | |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 223 | int getContentWidth() { |
| 224 | if (mContentView != null) { |
| 225 | return mContentView.getWidth(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 226 | } |
| 227 | return 0; |
| 228 | } |
| 229 | |
Michael Kolb | dc2ee1b | 2011-02-14 14:34:40 -0800 | [diff] [blame] | 230 | @Override |
Michael Kolb | 1f9b356 | 2012-04-24 14:38:34 -0700 | [diff] [blame] | 231 | public void editUrl(boolean clearInput, boolean forceIME) { |
Michael Kolb | 1f9b356 | 2012-04-24 14:38:34 -0700 | [diff] [blame] | 232 | super.editUrl(clearInput, forceIME); |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 233 | } |
| 234 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 235 | // action mode callbacks |
| 236 | |
| 237 | @Override |
| 238 | public void onActionModeStarted(ActionMode mode) { |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 239 | if (!mTitleBar.isEditingUrl()) { |
Michael Kolb | b2e91fd | 2011-07-14 13:47:29 -0700 | [diff] [blame] | 240 | // hide the title bar when CAB is shown |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 241 | hideTitleBar(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 242 | } |
| 243 | } |
| 244 | |
| 245 | @Override |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 246 | public void onActionModeFinished(boolean inLoad) { |
Michael Kolb | da58063 | 2012-04-16 13:30:28 -0700 | [diff] [blame] | 247 | checkHideActionBar(); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 248 | if (inLoad) { |
| 249 | // the titlebar was removed when the CAB was shown |
| 250 | // if the page is loading, show it again |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 251 | showTitleBar(); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 252 | } |
| 253 | } |
| 254 | |
| 255 | @Override |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 256 | protected void updateNavigationState(Tab tab) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 257 | mNavBar.updateNavigationState(tab); |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | @Override |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 261 | public void setUrlTitle(Tab tab) { |
| 262 | super.setUrlTitle(tab); |
| 263 | mTabBar.onUrlAndTitle(tab, tab.getUrl(), tab.getTitle()); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | // Set the favicon in the title bar. |
| 267 | @Override |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 268 | public void setFavicon(Tab tab) { |
| 269 | super.setFavicon(tab); |
| 270 | mTabBar.onFavicon(tab, tab.getFavicon()); |
Pankaj Garg | 32e1b94 | 2015-06-03 18:13:24 -0700 | [diff] [blame^] | 271 | if (mActiveTab == tab) { |
| 272 | int color = NavigationBarBase.getSiteIconColor(tab.getUrl()); |
| 273 | if (tab.hasFavicon()) { |
| 274 | color = ColorUtils.getDominantColorForBitmap(tab.getFavicon()); |
| 275 | } |
| 276 | mActionBar.setBackgroundDrawable(new ColorDrawable(color)); |
| 277 | } |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 278 | } |
| 279 | |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 280 | @Override |
John Reck | d73c5a2 | 2010-12-22 10:22:50 -0800 | [diff] [blame] | 281 | public void onHideCustomView() { |
| 282 | super.onHideCustomView(); |
Michael Kolb | da58063 | 2012-04-16 13:30:28 -0700 | [diff] [blame] | 283 | checkHideActionBar(); |
Pankaj Garg | 16053b4 | 2014-12-17 15:23:01 -0800 | [diff] [blame] | 284 | if (mActionBar != null) |
| 285 | mActionBar.show(); |
John Reck | d73c5a2 | 2010-12-22 10:22:50 -0800 | [diff] [blame] | 286 | } |
Michael Kolb | a418306 | 2011-01-16 10:43:21 -0800 | [diff] [blame] | 287 | |
| 288 | @Override |
| 289 | public boolean dispatchKey(int code, KeyEvent event) { |
Michael Kolb | dfe99a1 | 2011-03-08 11:45:40 -0800 | [diff] [blame] | 290 | if (mActiveTab != null) { |
| 291 | WebView web = mActiveTab.getWebView(); |
| 292 | if (event.getAction() == KeyEvent.ACTION_DOWN) { |
| 293 | switch (code) { |
| 294 | case KeyEvent.KEYCODE_TAB: |
| 295 | case KeyEvent.KEYCODE_DPAD_UP: |
| 296 | case KeyEvent.KEYCODE_DPAD_LEFT: |
| 297 | if ((web != null) && web.hasFocus() && !mTitleBar.hasFocus()) { |
Michael Kolb | 1f9b356 | 2012-04-24 14:38:34 -0700 | [diff] [blame] | 298 | editUrl(false, false); |
Michael Kolb | dfe99a1 | 2011-03-08 11:45:40 -0800 | [diff] [blame] | 299 | return true; |
| 300 | } |
| 301 | } |
| 302 | boolean ctrl = event.hasModifiers(KeyEvent.META_CTRL_ON); |
| 303 | if (!ctrl && isTypingKey(event) && !mTitleBar.isEditingUrl()) { |
Michael Kolb | 1f9b356 | 2012-04-24 14:38:34 -0700 | [diff] [blame] | 304 | editUrl(true, false); |
Michael Kolb | dfe99a1 | 2011-03-08 11:45:40 -0800 | [diff] [blame] | 305 | return mContentView.dispatchKeyEvent(event); |
| 306 | } |
Michael Kolb | dc2ee1b | 2011-02-14 14:34:40 -0800 | [diff] [blame] | 307 | } |
Michael Kolb | a418306 | 2011-01-16 10:43:21 -0800 | [diff] [blame] | 308 | } |
| 309 | return false; |
| 310 | } |
| 311 | |
Michael Kolb | dc2ee1b | 2011-02-14 14:34:40 -0800 | [diff] [blame] | 312 | private boolean isTypingKey(KeyEvent evt) { |
| 313 | return evt.getUnicodeChar() > 0; |
| 314 | } |
| 315 | |
| 316 | TabBar getTabBar() { |
| 317 | return mTabBar; |
| 318 | } |
| 319 | |
John Reck | 1cf4b79 | 2011-07-26 10:22:22 -0700 | [diff] [blame] | 320 | @Override |
| 321 | public boolean shouldCaptureThumbnails() { |
Vivek Sekhar | 3bec6a3 | 2014-10-22 17:03:42 -0700 | [diff] [blame] | 322 | return false; |
John Reck | 1cf4b79 | 2011-07-26 10:22:22 -0700 | [diff] [blame] | 323 | } |
| 324 | |
John Reck | 034637c | 2011-08-11 11:34:44 -0700 | [diff] [blame] | 325 | private Drawable getFaviconBackground() { |
| 326 | if (mFaviconBackground == null) { |
| 327 | mFaviconBackground = new PaintDrawable(); |
| 328 | Resources res = mActivity.getResources(); |
| 329 | mFaviconBackground.getPaint().setColor( |
| 330 | res.getColor(R.color.tabFaviconBackground)); |
| 331 | mFaviconBackground.setCornerRadius( |
| 332 | res.getDimension(R.dimen.tab_favicon_corner_radius)); |
| 333 | } |
| 334 | return mFaviconBackground; |
| 335 | } |
| 336 | |
| 337 | @Override |
| 338 | public Drawable getFaviconDrawable(Bitmap icon) { |
Enrico Ros | 1f5a095 | 2014-11-18 20:15:48 -0800 | [diff] [blame] | 339 | if (ENABLE_BORDER_AROUND_FAVICON) { |
| 340 | Drawable[] array = new Drawable[2]; |
| 341 | array[0] = getFaviconBackground(); |
| 342 | if (icon == null) { |
| 343 | array[1] = getGenericFavicon(); |
| 344 | } else { |
| 345 | array[1] = new BitmapDrawable(mActivity.getResources(), icon); |
| 346 | } |
| 347 | LayerDrawable d = new LayerDrawable(array); |
| 348 | d.setLayerInset(1, 2, 2, 2, 2); |
| 349 | return d; |
John Reck | 034637c | 2011-08-11 11:34:44 -0700 | [diff] [blame] | 350 | } |
Enrico Ros | 1f5a095 | 2014-11-18 20:15:48 -0800 | [diff] [blame] | 351 | return icon == null ? getGenericFavicon() : new BitmapDrawable(mActivity.getResources(), icon); |
John Reck | 034637c | 2011-08-11 11:34:44 -0700 | [diff] [blame] | 352 | } |
| 353 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 354 | } |