Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [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 | |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 19 | import com.android.browser.Tab.LockIcon; |
| 20 | |
John Reck | 74830e1 | 2011-03-14 11:43:05 -0700 | [diff] [blame] | 21 | import android.animation.ObjectAnimator; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 22 | import android.app.Activity; |
John Reck | b9a051b | 2011-03-18 11:55:48 -0700 | [diff] [blame] | 23 | import android.content.pm.PackageManager; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 24 | import android.content.res.Configuration; |
| 25 | import android.content.res.Resources; |
| 26 | import android.graphics.Bitmap; |
| 27 | import android.graphics.BitmapFactory; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 28 | import android.graphics.drawable.Drawable; |
| 29 | import android.os.Bundle; |
| 30 | import android.text.TextUtils; |
| 31 | import android.util.Log; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 32 | import android.view.Gravity; |
| 33 | import android.view.LayoutInflater; |
| 34 | import android.view.Menu; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 35 | import android.view.View; |
Michael Kolb | 1514bb7 | 2010-11-22 09:11:48 -0800 | [diff] [blame] | 36 | import android.view.View.OnClickListener; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 37 | import android.view.ViewGroup; |
Michael Kolb | 1514bb7 | 2010-11-22 09:11:48 -0800 | [diff] [blame] | 38 | import android.view.ViewGroup.LayoutParams; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 39 | import android.view.WindowManager; |
Michael Kolb | 3a69628 | 2010-12-05 13:23:24 -0800 | [diff] [blame] | 40 | import android.view.inputmethod.InputMethodManager; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 41 | import android.webkit.WebChromeClient; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 42 | import android.webkit.WebView; |
| 43 | import android.widget.FrameLayout; |
Michael Kolb | 1514bb7 | 2010-11-22 09:11:48 -0800 | [diff] [blame] | 44 | import android.widget.ImageButton; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 45 | import android.widget.LinearLayout; |
| 46 | import android.widget.Toast; |
| 47 | |
Michael Kolb | 1bf2313 | 2010-11-19 12:55:12 -0800 | [diff] [blame] | 48 | import java.util.List; |
| 49 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 50 | /** |
| 51 | * UI interface definitions |
| 52 | */ |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 53 | public abstract class BaseUi implements UI, WebViewFactory { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 54 | |
| 55 | private static final String LOGTAG = "BaseUi"; |
| 56 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 57 | protected static final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 58 | new FrameLayout.LayoutParams( |
| 59 | ViewGroup.LayoutParams.MATCH_PARENT, |
| 60 | ViewGroup.LayoutParams.MATCH_PARENT); |
| 61 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 62 | protected static final FrameLayout.LayoutParams COVER_SCREEN_GRAVITY_CENTER = |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 63 | new FrameLayout.LayoutParams( |
| 64 | ViewGroup.LayoutParams.MATCH_PARENT, |
| 65 | ViewGroup.LayoutParams.MATCH_PARENT, |
| 66 | Gravity.CENTER); |
| 67 | |
| 68 | Activity mActivity; |
| 69 | UiController mUiController; |
| 70 | TabControl mTabControl; |
Michael Kolb | 377ea31 | 2011-02-17 14:36:56 -0800 | [diff] [blame] | 71 | protected Tab mActiveTab; |
Michael Kolb | 3a69628 | 2010-12-05 13:23:24 -0800 | [diff] [blame] | 72 | private InputMethodManager mInputManager; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 73 | |
| 74 | private Drawable mSecLockIcon; |
| 75 | private Drawable mMixLockIcon; |
| 76 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 77 | private FrameLayout mBrowserFrameLayout; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 78 | protected FrameLayout mContentView; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 79 | private FrameLayout mCustomViewContainer; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 80 | |
| 81 | private View mCustomView; |
| 82 | private WebChromeClient.CustomViewCallback mCustomViewCallback; |
| 83 | |
| 84 | private CombinedBookmarkHistoryView mComboView; |
| 85 | |
| 86 | private LinearLayout mErrorConsoleContainer = null; |
| 87 | |
| 88 | private Toast mStopToast; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 89 | |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 90 | private boolean mTitleShowing; |
| 91 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 92 | // the default <video> poster |
| 93 | private Bitmap mDefaultVideoPoster; |
| 94 | // the video progress view |
| 95 | private View mVideoProgressView; |
| 96 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 97 | private boolean mActivityPaused; |
| 98 | |
| 99 | public BaseUi(Activity browser, UiController controller) { |
| 100 | mActivity = browser; |
| 101 | mUiController = controller; |
| 102 | mTabControl = controller.getTabControl(); |
| 103 | Resources res = mActivity.getResources(); |
Michael Kolb | 3a69628 | 2010-12-05 13:23:24 -0800 | [diff] [blame] | 104 | mInputManager = (InputMethodManager) |
| 105 | browser.getSystemService(Activity.INPUT_METHOD_SERVICE); |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 106 | mSecLockIcon = res.getDrawable(R.drawable.ic_secure_holo_dark); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 107 | mMixLockIcon = res.getDrawable(R.drawable.ic_partial_secure); |
| 108 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 109 | FrameLayout frameLayout = (FrameLayout) mActivity.getWindow() |
| 110 | .getDecorView().findViewById(android.R.id.content); |
| 111 | mBrowserFrameLayout = (FrameLayout) LayoutInflater.from(mActivity) |
| 112 | .inflate(R.layout.custom_screen, null); |
| 113 | mContentView = (FrameLayout) mBrowserFrameLayout.findViewById( |
| 114 | R.id.main_content); |
| 115 | mErrorConsoleContainer = (LinearLayout) mBrowserFrameLayout |
| 116 | .findViewById(R.id.error_console); |
| 117 | mCustomViewContainer = (FrameLayout) mBrowserFrameLayout |
| 118 | .findViewById(R.id.fullscreen_custom_content); |
| 119 | frameLayout.addView(mBrowserFrameLayout, COVER_SCREEN_PARAMS); |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 120 | mTitleShowing = false; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 121 | } |
| 122 | |
John Reck | b9a051b | 2011-03-18 11:55:48 -0700 | [diff] [blame] | 123 | @Override |
| 124 | public WebView createWebView(boolean privateBrowsing) { |
| 125 | // Create a new WebView |
| 126 | BrowserWebView w = new BrowserWebView(mActivity, null, |
| 127 | android.R.attr.webViewStyle, privateBrowsing); |
| 128 | initWebViewSettings(w); |
| 129 | return w; |
| 130 | } |
| 131 | |
| 132 | @Override |
| 133 | public WebView createSubWebView(boolean privateBrowsing) { |
| 134 | return createWebView(privateBrowsing); |
| 135 | } |
| 136 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 137 | /** |
| 138 | * common webview initialization |
| 139 | * @param w the webview to initialize |
| 140 | */ |
| 141 | protected void initWebViewSettings(WebView w) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 142 | w.setScrollbarFadingEnabled(true); |
| 143 | w.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); |
| 144 | w.setMapTrackballToArrowKeys(false); // use trackball directly |
| 145 | // Enable the built-in zoom |
| 146 | w.getSettings().setBuiltInZoomControls(true); |
John Reck | b9a051b | 2011-03-18 11:55:48 -0700 | [diff] [blame] | 147 | boolean supportsMultiTouch = mActivity.getPackageManager() |
| 148 | .hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH); |
| 149 | w.getSettings().setDisplayZoomControls(!supportsMultiTouch); |
| 150 | w.setExpandedTileBounds(true); // smoother scrolling |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 151 | |
| 152 | // Add this WebView to the settings observer list and update the |
| 153 | // settings |
| 154 | final BrowserSettings s = BrowserSettings.getInstance(); |
| 155 | s.addObserver(w.getSettings()).update(s, null); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | private void cancelStopToast() { |
| 159 | if (mStopToast != null) { |
| 160 | mStopToast.cancel(); |
| 161 | mStopToast = null; |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | // lifecycle |
| 166 | |
| 167 | public void onPause() { |
Michael Kolb | 7a5cf47 | 2010-11-30 13:23:53 -0800 | [diff] [blame] | 168 | if (isCustomViewShowing()) { |
| 169 | onHideCustomView(); |
| 170 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 171 | cancelStopToast(); |
| 172 | mActivityPaused = true; |
| 173 | } |
| 174 | |
| 175 | public void onResume() { |
| 176 | mActivityPaused = false; |
| 177 | } |
| 178 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 179 | protected boolean isActivityPaused() { |
| 180 | return mActivityPaused; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | public void onConfigurationChanged(Configuration config) { |
| 184 | } |
| 185 | |
Michael Kolb | dc2ee1b | 2011-02-14 14:34:40 -0800 | [diff] [blame] | 186 | public abstract void editUrl(boolean clearInput); |
| 187 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 188 | // key handling |
| 189 | |
| 190 | @Override |
| 191 | public boolean onBackKey() { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 192 | if (mComboView != null) { |
| 193 | if (!mComboView.onBackPressed()) { |
| 194 | mUiController.removeComboView(); |
| 195 | } |
| 196 | return true; |
| 197 | } |
| 198 | if (mCustomView != null) { |
| 199 | mUiController.hideCustomView(); |
| 200 | return true; |
| 201 | } |
| 202 | return false; |
| 203 | } |
| 204 | |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 205 | // Tab callbacks |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 206 | @Override |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 207 | public void onTabDataChanged(Tab tab) { |
| 208 | setUrlTitle(tab); |
| 209 | setFavicon(tab); |
| 210 | updateLockIconToLatest(tab); |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 211 | updateNavigationState(tab); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | @Override |
Leon Scroggins | 4cd9779 | 2010-12-03 15:31:56 -0500 | [diff] [blame] | 215 | public void bookmarkedStatusHasChanged(Tab tab) { |
John Reck | 94b7e04 | 2011-02-15 15:02:33 -0800 | [diff] [blame] | 216 | if (tab.inForeground()) { |
| 217 | boolean isBookmark = tab.isBookmarkedSite(); |
| 218 | getTitleBar().setCurrentUrlIsBookmark(isBookmark); |
| 219 | } |
Leon Scroggins | 4cd9779 | 2010-12-03 15:31:56 -0500 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | @Override |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 223 | public void onPageStopped(Tab tab) { |
| 224 | cancelStopToast(); |
| 225 | if (tab.inForeground()) { |
| 226 | mStopToast = Toast |
| 227 | .makeText(mActivity, R.string.stopping, Toast.LENGTH_SHORT); |
| 228 | mStopToast.show(); |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | @Override |
Michael Kolb | 1bf2313 | 2010-11-19 12:55:12 -0800 | [diff] [blame] | 233 | public boolean needsRestoreAllTabs() { |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 234 | return false; |
Michael Kolb | 1bf2313 | 2010-11-19 12:55:12 -0800 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | @Override |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 238 | public void addTab(Tab tab) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | @Override |
Michael Kolb | 377ea31 | 2011-02-17 14:36:56 -0800 | [diff] [blame] | 242 | public void setActiveTab(final Tab tab) { |
| 243 | setActiveTab(tab, true); |
| 244 | } |
| 245 | |
| 246 | void setActiveTab(Tab tab, boolean needsAttaching) { |
Michael Kolb | 77df456 | 2010-11-19 14:49:34 -0800 | [diff] [blame] | 247 | if ((tab != mActiveTab) && (mActiveTab != null)) { |
| 248 | removeTabFromContentView(mActiveTab); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 249 | } |
Michael Kolb | 77df456 | 2010-11-19 14:49:34 -0800 | [diff] [blame] | 250 | mActiveTab = tab; |
Michael Kolb | 377ea31 | 2011-02-17 14:36:56 -0800 | [diff] [blame] | 251 | if (needsAttaching) { |
| 252 | attachTabToContentView(tab); |
| 253 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 254 | setShouldShowErrorConsole(tab, mUiController.shouldShowErrorConsole()); |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 255 | onTabDataChanged(tab); |
| 256 | onProgressChanged(tab); |
John Reck | 117f07d | 2011-01-24 09:39:03 -0800 | [diff] [blame] | 257 | boolean incognito = mActiveTab.getWebView().isPrivateBrowsingEnabled(); |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 258 | getTitleBar().setIncognitoMode(incognito); |
Patrick Scott | 9206677 | 2011-03-10 08:46:27 -0500 | [diff] [blame] | 259 | updateAutoLogin(tab, false); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 260 | } |
| 261 | |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 262 | Tab getActiveTab() { |
| 263 | return mActiveTab; |
| 264 | } |
| 265 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 266 | @Override |
Michael Kolb | 1bf2313 | 2010-11-19 12:55:12 -0800 | [diff] [blame] | 267 | public void updateTabs(List<Tab> tabs) { |
Michael Kolb | 1bf2313 | 2010-11-19 12:55:12 -0800 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | @Override |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 271 | public void removeTab(Tab tab) { |
Michael Kolb | 77df456 | 2010-11-19 14:49:34 -0800 | [diff] [blame] | 272 | if (mActiveTab == tab) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 273 | removeTabFromContentView(tab); |
Michael Kolb | 77df456 | 2010-11-19 14:49:34 -0800 | [diff] [blame] | 274 | mActiveTab = null; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 275 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | @Override |
| 279 | public void detachTab(Tab tab) { |
| 280 | removeTabFromContentView(tab); |
| 281 | } |
| 282 | |
| 283 | @Override |
| 284 | public void attachTab(Tab tab) { |
| 285 | attachTabToContentView(tab); |
| 286 | } |
| 287 | |
Michael Kolb | 377ea31 | 2011-02-17 14:36:56 -0800 | [diff] [blame] | 288 | protected void attachTabToContentView(Tab tab) { |
Michael Kolb | d1e2ccc | 2011-01-24 11:38:31 -0800 | [diff] [blame] | 289 | if ((tab == null) || (tab.getWebView() == null)) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 290 | return; |
| 291 | } |
| 292 | View container = tab.getViewContainer(); |
| 293 | WebView mainView = tab.getWebView(); |
| 294 | // Attach the WebView to the container and then attach the |
| 295 | // container to the content view. |
| 296 | FrameLayout wrapper = |
| 297 | (FrameLayout) container.findViewById(R.id.webview_wrapper); |
| 298 | ViewGroup parent = (ViewGroup) mainView.getParent(); |
| 299 | if (parent != wrapper) { |
| 300 | if (parent != null) { |
| 301 | Log.w(LOGTAG, "mMainView already has a parent in" |
| 302 | + " attachTabToContentView!"); |
| 303 | parent.removeView(mainView); |
| 304 | } |
| 305 | wrapper.addView(mainView); |
| 306 | } else { |
| 307 | Log.w(LOGTAG, "mMainView is already attached to wrapper in" |
| 308 | + " attachTabToContentView!"); |
| 309 | } |
| 310 | parent = (ViewGroup) container.getParent(); |
| 311 | if (parent != mContentView) { |
| 312 | if (parent != null) { |
| 313 | Log.w(LOGTAG, "mContainer already has a parent in" |
| 314 | + " attachTabToContentView!"); |
| 315 | parent.removeView(container); |
| 316 | } |
| 317 | mContentView.addView(container, COVER_SCREEN_PARAMS); |
| 318 | } else { |
| 319 | Log.w(LOGTAG, "mContainer is already attached to content in" |
| 320 | + " attachTabToContentView!"); |
| 321 | } |
| 322 | mUiController.attachSubWindow(tab); |
| 323 | } |
| 324 | |
| 325 | private void removeTabFromContentView(Tab tab) { |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 326 | hideTitleBar(); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 327 | // Remove the container that contains the main WebView. |
| 328 | WebView mainView = tab.getWebView(); |
| 329 | View container = tab.getViewContainer(); |
| 330 | if (mainView == null) { |
| 331 | return; |
| 332 | } |
| 333 | // Remove the container from the content and then remove the |
| 334 | // WebView from the container. This will trigger a focus change |
| 335 | // needed by WebView. |
Michael Kolb | 20776cc | 2011-01-31 10:19:05 -0800 | [diff] [blame] | 336 | mainView.setEmbeddedTitleBar(null); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 337 | FrameLayout wrapper = |
| 338 | (FrameLayout) container.findViewById(R.id.webview_wrapper); |
| 339 | wrapper.removeView(mainView); |
| 340 | mContentView.removeView(container); |
| 341 | mUiController.endActionMode(); |
| 342 | mUiController.removeSubWindow(tab); |
| 343 | ErrorConsoleView errorConsole = tab.getErrorConsole(false); |
| 344 | if (errorConsole != null) { |
| 345 | mErrorConsoleContainer.removeView(errorConsole); |
| 346 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 347 | } |
| 348 | |
Michael Kolb | a713ec8 | 2010-11-29 17:27:06 -0800 | [diff] [blame] | 349 | @Override |
| 350 | public void onSetWebView(Tab tab, WebView webView) { |
| 351 | View container = tab.getViewContainer(); |
| 352 | if (container == null) { |
| 353 | // The tab consists of a container view, which contains the main |
| 354 | // WebView, as well as any other UI elements associated with the tab. |
| 355 | container = mActivity.getLayoutInflater().inflate(R.layout.tab, |
| 356 | null); |
| 357 | tab.setViewContainer(container); |
| 358 | } |
| 359 | if (tab.getWebView() != webView) { |
| 360 | // Just remove the old one. |
| 361 | FrameLayout wrapper = |
| 362 | (FrameLayout) container.findViewById(R.id.webview_wrapper); |
| 363 | wrapper.removeView(tab.getWebView()); |
| 364 | } |
| 365 | } |
| 366 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 367 | /** |
Michael Kolb | 1514bb7 | 2010-11-22 09:11:48 -0800 | [diff] [blame] | 368 | * create a sub window container and webview for the tab |
| 369 | * Note: this methods operates through side-effects for now |
| 370 | * it sets both the subView and subViewContainer for the given tab |
| 371 | * @param tab tab to create the sub window for |
| 372 | * @param subView webview to be set as a subwindow for the tab |
| 373 | */ |
| 374 | @Override |
| 375 | public void createSubWindow(Tab tab, WebView subView) { |
| 376 | View subViewContainer = mActivity.getLayoutInflater().inflate( |
| 377 | R.layout.browser_subwindow, null); |
| 378 | ViewGroup inner = (ViewGroup) subViewContainer |
| 379 | .findViewById(R.id.inner_container); |
| 380 | inner.addView(subView, new LayoutParams(LayoutParams.MATCH_PARENT, |
| 381 | LayoutParams.MATCH_PARENT)); |
| 382 | final ImageButton cancel = (ImageButton) subViewContainer |
| 383 | .findViewById(R.id.subwindow_close); |
| 384 | final WebView cancelSubView = subView; |
| 385 | cancel.setOnClickListener(new OnClickListener() { |
| 386 | public void onClick(View v) { |
| 387 | cancelSubView.getWebChromeClient().onCloseWindow(cancelSubView); |
| 388 | } |
| 389 | }); |
| 390 | tab.setSubWebView(subView); |
| 391 | tab.setSubViewContainer(subViewContainer); |
| 392 | } |
| 393 | |
| 394 | /** |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 395 | * Remove the sub window from the content view. |
| 396 | */ |
| 397 | @Override |
| 398 | public void removeSubWindow(View subviewContainer) { |
| 399 | mContentView.removeView(subviewContainer); |
| 400 | mUiController.endActionMode(); |
| 401 | } |
| 402 | |
| 403 | /** |
| 404 | * Attach the sub window to the content view. |
| 405 | */ |
| 406 | @Override |
| 407 | public void attachSubWindow(View container) { |
Michael Kolb | 1514bb7 | 2010-11-22 09:11:48 -0800 | [diff] [blame] | 408 | if (container.getParent() != null) { |
| 409 | // already attached, remove first |
| 410 | ((ViewGroup) container.getParent()).removeView(container); |
| 411 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 412 | mContentView.addView(container, COVER_SCREEN_PARAMS); |
| 413 | } |
| 414 | |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 415 | protected void refreshWebView() { |
| 416 | Tab tab = getActiveTab(); |
| 417 | if ((tab != null) && (tab.getWebView() != null)) { |
| 418 | tab.getWebView().invalidate(); |
| 419 | } |
| 420 | } |
| 421 | |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 422 | boolean canShowTitleBar() { |
| 423 | return !isTitleBarShowing() |
| 424 | && !isActivityPaused() |
| 425 | && (getActiveTab() != null) |
| 426 | && (getActiveTab().getWebView() != null) |
| 427 | && !mUiController.isInCustomActionMode(); |
| 428 | } |
| 429 | |
| 430 | void showTitleBar() { |
| 431 | mTitleShowing = true; |
| 432 | } |
| 433 | |
| 434 | protected void hideTitleBar() { |
| 435 | mTitleShowing = false; |
| 436 | } |
| 437 | |
| 438 | protected boolean isTitleBarShowing() { |
| 439 | return mTitleShowing; |
| 440 | } |
| 441 | |
| 442 | protected abstract TitleBarBase getTitleBar(); |
| 443 | |
| 444 | protected void setTitleGravity(int gravity) { |
| 445 | getTitleBar().setTitleGravity(gravity); |
| 446 | Tab tab = getActiveTab(); |
| 447 | if ((tab != null) && (tab.getWebView() != null)) { |
| 448 | tab.getWebView().setTitleBarGravity(gravity); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 449 | } |
| 450 | } |
| 451 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 452 | @Override |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 453 | public void showVoiceTitleBar(String title, List<String> results) { |
| 454 | getTitleBar().setInVoiceMode(true, results); |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 455 | getTitleBar().setDisplayTitle(title); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 456 | } |
| 457 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 458 | @Override |
| 459 | public void revertVoiceTitleBar(Tab tab) { |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 460 | getTitleBar().setInVoiceMode(false, null); |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 461 | String url = tab.getUrl(); |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 462 | getTitleBar().setDisplayTitle(url); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | @Override |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 466 | public void registerDropdownChangeListener(DropdownChangeListener d) { |
| 467 | getTitleBar().registerDropdownChangeListener(d); |
| 468 | } |
| 469 | |
| 470 | @Override |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 471 | public void showComboView(boolean startWithHistory, Bundle extras) { |
John Reck | 439c9a5 | 2010-12-14 10:04:39 -0800 | [diff] [blame] | 472 | if (mComboView != null) { |
| 473 | return; |
| 474 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 475 | mComboView = new CombinedBookmarkHistoryView(mActivity, |
| 476 | mUiController, |
| 477 | startWithHistory ? |
| 478 | CombinedBookmarkHistoryView.FRAGMENT_ID_HISTORY |
| 479 | : CombinedBookmarkHistoryView.FRAGMENT_ID_BOOKMARKS, |
| 480 | extras); |
Michael Kolb | 47d63f8 | 2011-01-18 10:48:40 -0800 | [diff] [blame] | 481 | FrameLayout wrapper = |
| 482 | (FrameLayout) mContentView.findViewById(R.id.webview_wrapper); |
| 483 | wrapper.setVisibility(View.GONE); |
Michael Kolb | c16c595 | 2011-03-29 15:37:03 -0700 | [diff] [blame^] | 484 | getTitleBar().stopEditingUrl(); |
Michael Kolb | 3a69628 | 2010-12-05 13:23:24 -0800 | [diff] [blame] | 485 | dismissIME(); |
Michael Kolb | c16c595 | 2011-03-29 15:37:03 -0700 | [diff] [blame^] | 486 | hideTitleBar(); |
Michael Kolb | 3a69628 | 2010-12-05 13:23:24 -0800 | [diff] [blame] | 487 | if (mActiveTab != null) { |
| 488 | WebView web = mActiveTab.getWebView(); |
| 489 | mActiveTab.putInBackground(); |
| 490 | } |
John Reck | 74830e1 | 2011-03-14 11:43:05 -0700 | [diff] [blame] | 491 | mComboView.setAlpha(0f); |
| 492 | ObjectAnimator anim = ObjectAnimator.ofFloat(mComboView, "alpha", 0f, 1f); |
| 493 | Resources res = mActivity.getResources(); |
| 494 | anim.setDuration(res.getInteger(R.integer.comboViewFadeInDuration)); |
| 495 | anim.start(); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 496 | mContentView.addView(mComboView, COVER_SCREEN_PARAMS); |
| 497 | } |
| 498 | |
Michael Kolb | ba23870 | 2011-03-08 10:40:50 -0800 | [diff] [blame] | 499 | public boolean isComboViewShowing() { |
| 500 | return (mComboView != null); |
| 501 | } |
| 502 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 503 | /** |
| 504 | * dismiss the ComboPage |
| 505 | */ |
| 506 | @Override |
| 507 | public void hideComboView() { |
| 508 | if (mComboView != null) { |
| 509 | mContentView.removeView(mComboView); |
Michael Kolb | 47d63f8 | 2011-01-18 10:48:40 -0800 | [diff] [blame] | 510 | FrameLayout wrapper = |
| 511 | (FrameLayout) mContentView.findViewById(R.id.webview_wrapper); |
| 512 | wrapper.setVisibility(View.VISIBLE); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 513 | mComboView = null; |
| 514 | } |
Michael Kolb | 3a69628 | 2010-12-05 13:23:24 -0800 | [diff] [blame] | 515 | if (mActiveTab != null) { |
| 516 | mActiveTab.putInForeground(); |
| 517 | } |
John Reck | b3417f0 | 2011-01-14 11:01:05 -0800 | [diff] [blame] | 518 | mActivity.invalidateOptionsMenu(); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 519 | } |
| 520 | |
| 521 | @Override |
| 522 | public void showCustomView(View view, |
| 523 | WebChromeClient.CustomViewCallback callback) { |
| 524 | // if a view already exists then immediately terminate the new one |
| 525 | if (mCustomView != null) { |
| 526 | callback.onCustomViewHidden(); |
| 527 | return; |
| 528 | } |
| 529 | |
| 530 | // Add the custom view to its container. |
| 531 | mCustomViewContainer.addView(view, COVER_SCREEN_GRAVITY_CENTER); |
| 532 | mCustomView = view; |
| 533 | mCustomViewCallback = callback; |
| 534 | // Hide the content view. |
| 535 | mContentView.setVisibility(View.GONE); |
| 536 | // Finally show the custom view container. |
| 537 | setStatusBarVisibility(false); |
| 538 | mCustomViewContainer.setVisibility(View.VISIBLE); |
| 539 | mCustomViewContainer.bringToFront(); |
| 540 | } |
| 541 | |
| 542 | @Override |
| 543 | public void onHideCustomView() { |
| 544 | if (mCustomView == null) |
| 545 | return; |
| 546 | |
| 547 | // Hide the custom view. |
| 548 | mCustomView.setVisibility(View.GONE); |
| 549 | // Remove the custom view from its container. |
| 550 | mCustomViewContainer.removeView(mCustomView); |
| 551 | mCustomView = null; |
| 552 | mCustomViewContainer.setVisibility(View.GONE); |
| 553 | mCustomViewCallback.onCustomViewHidden(); |
| 554 | // Show the content view. |
| 555 | setStatusBarVisibility(true); |
| 556 | mContentView.setVisibility(View.VISIBLE); |
| 557 | } |
| 558 | |
| 559 | @Override |
| 560 | public boolean isCustomViewShowing() { |
| 561 | return mCustomView != null; |
| 562 | } |
| 563 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 564 | protected void dismissIME() { |
Michael Kolb | 3a69628 | 2010-12-05 13:23:24 -0800 | [diff] [blame] | 565 | if (mInputManager.isActive()) { |
| 566 | mInputManager.hideSoftInputFromWindow(mContentView.getWindowToken(), |
| 567 | 0); |
| 568 | } |
| 569 | } |
| 570 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 571 | @Override |
| 572 | public boolean showsWeb() { |
| 573 | return mCustomView == null |
| 574 | && mComboView == null; |
| 575 | } |
| 576 | |
Patrick Scott | 9206677 | 2011-03-10 08:46:27 -0500 | [diff] [blame] | 577 | @Override |
| 578 | public void showAutoLogin(Tab tab) { |
| 579 | updateAutoLogin(tab, true); |
| 580 | } |
| 581 | |
| 582 | @Override |
| 583 | public void hideAutoLogin(Tab tab) { |
| 584 | updateAutoLogin(tab, true); |
| 585 | } |
| 586 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 587 | // ------------------------------------------------------------------------- |
| 588 | |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 589 | protected void updateNavigationState(Tab tab) { |
| 590 | } |
| 591 | |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 592 | protected void updateAutoLogin(Tab tab, boolean animate) { |
| 593 | getTitleBar().updateAutoLogin(tab, animate); |
| 594 | } |
Patrick Scott | 9206677 | 2011-03-10 08:46:27 -0500 | [diff] [blame] | 595 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 596 | /** |
| 597 | * Update the lock icon to correspond to our latest state. |
| 598 | */ |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 599 | protected void updateLockIconToLatest(Tab t) { |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 600 | if (t != null && t.inForeground()) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 601 | updateLockIconImage(t.getLockIconType()); |
| 602 | } |
| 603 | } |
| 604 | |
| 605 | /** |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 606 | * Updates the lock-icon image in the title-bar. |
| 607 | */ |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 608 | private void updateLockIconImage(LockIcon lockIconType) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 609 | Drawable d = null; |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 610 | if (lockIconType == LockIcon.LOCK_ICON_SECURE) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 611 | d = mSecLockIcon; |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 612 | } else if (lockIconType == LockIcon.LOCK_ICON_MIXED) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 613 | d = mMixLockIcon; |
| 614 | } |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 615 | getTitleBar().setLock(d); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 616 | } |
| 617 | |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 618 | protected void setUrlTitle(Tab tab) { |
| 619 | String url = tab.getUrl(); |
| 620 | String title = tab.getTitle(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 621 | if (TextUtils.isEmpty(title)) { |
| 622 | title = url; |
Michael Kolb | 81b6f83 | 2010-12-12 12:44:27 -0800 | [diff] [blame] | 623 | } |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 624 | if (tab.isInVoiceSearchMode()) return; |
| 625 | if (tab.inForeground()) { |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 626 | getTitleBar().setDisplayTitle(url); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 627 | } |
| 628 | } |
| 629 | |
| 630 | // Set the favicon in the title bar. |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 631 | protected void setFavicon(Tab tab) { |
| 632 | if (tab.inForeground()) { |
| 633 | Bitmap icon = tab.getFavicon(); |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 634 | getTitleBar().setFavicon(icon); |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 635 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 636 | } |
| 637 | |
| 638 | @Override |
| 639 | public void onActionModeFinished(boolean inLoad) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 640 | } |
| 641 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 642 | // active tabs page |
| 643 | |
| 644 | public void showActiveTabsPage() { |
| 645 | } |
| 646 | |
| 647 | /** |
| 648 | * Remove the active tabs page. |
| 649 | */ |
| 650 | public void removeActiveTabsPage() { |
| 651 | } |
| 652 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 653 | // menu handling callbacks |
| 654 | |
| 655 | @Override |
Michael Kolb | 1acef69 | 2011-03-08 14:12:06 -0800 | [diff] [blame] | 656 | public boolean onPrepareOptionsMenu(Menu menu) { |
| 657 | return true; |
| 658 | } |
| 659 | |
| 660 | @Override |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 661 | public void onOptionsMenuOpened() { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | @Override |
| 665 | public void onExtendedMenuOpened() { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 666 | } |
| 667 | |
| 668 | @Override |
| 669 | public void onOptionsMenuClosed(boolean inLoad) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 670 | } |
| 671 | |
| 672 | @Override |
| 673 | public void onExtendedMenuClosed(boolean inLoad) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 674 | } |
| 675 | |
| 676 | @Override |
| 677 | public void onContextMenuCreated(Menu menu) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 678 | } |
| 679 | |
| 680 | @Override |
| 681 | public void onContextMenuClosed(Menu menu, boolean inLoad) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 682 | } |
| 683 | |
| 684 | // error console |
| 685 | |
| 686 | @Override |
| 687 | public void setShouldShowErrorConsole(Tab tab, boolean flag) { |
Michael Kolb | 9fcefd1 | 2011-02-17 10:55:59 -0800 | [diff] [blame] | 688 | if (tab == null) return; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 689 | ErrorConsoleView errorConsole = tab.getErrorConsole(true); |
| 690 | if (flag) { |
| 691 | // Setting the show state of the console will cause it's the layout |
| 692 | // to be inflated. |
| 693 | if (errorConsole.numberOfErrors() > 0) { |
| 694 | errorConsole.showConsole(ErrorConsoleView.SHOW_MINIMIZED); |
| 695 | } else { |
| 696 | errorConsole.showConsole(ErrorConsoleView.SHOW_NONE); |
| 697 | } |
| 698 | if (errorConsole.getParent() != null) { |
| 699 | mErrorConsoleContainer.removeView(errorConsole); |
| 700 | } |
| 701 | // Now we can add it to the main view. |
| 702 | mErrorConsoleContainer.addView(errorConsole, |
| 703 | new LinearLayout.LayoutParams( |
| 704 | ViewGroup.LayoutParams.MATCH_PARENT, |
| 705 | ViewGroup.LayoutParams.WRAP_CONTENT)); |
| 706 | } else { |
| 707 | mErrorConsoleContainer.removeView(errorConsole); |
| 708 | } |
| 709 | } |
| 710 | |
| 711 | private void setStatusBarVisibility(boolean visible) { |
Joe Onorato | d3bf86f | 2011-01-25 20:07:10 -0800 | [diff] [blame] | 712 | WindowManager.LayoutParams params = mActivity.getWindow().getAttributes(); |
| 713 | params.systemUiVisibility = visible ? View.STATUS_BAR_VISIBLE : View.STATUS_BAR_HIDDEN; |
| 714 | mActivity.getWindow().setAttributes(params); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 715 | } |
| 716 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 717 | // ------------------------------------------------------------------------- |
| 718 | // Helper function for WebChromeClient |
| 719 | // ------------------------------------------------------------------------- |
| 720 | |
| 721 | @Override |
| 722 | public Bitmap getDefaultVideoPoster() { |
| 723 | if (mDefaultVideoPoster == null) { |
| 724 | mDefaultVideoPoster = BitmapFactory.decodeResource( |
| 725 | mActivity.getResources(), R.drawable.default_video_poster); |
| 726 | } |
| 727 | return mDefaultVideoPoster; |
| 728 | } |
| 729 | |
| 730 | @Override |
| 731 | public View getVideoLoadingProgressView() { |
| 732 | if (mVideoProgressView == null) { |
| 733 | LayoutInflater inflater = LayoutInflater.from(mActivity); |
| 734 | mVideoProgressView = inflater.inflate( |
| 735 | R.layout.video_loading_progress, null); |
| 736 | } |
| 737 | return mVideoProgressView; |
| 738 | } |
| 739 | |
Michael Kolb | 843510f | 2010-12-09 10:51:49 -0800 | [diff] [blame] | 740 | @Override |
| 741 | public void showMaxTabsWarning() { |
| 742 | Toast warning = Toast.makeText(mActivity, |
| 743 | mActivity.getString(R.string.max_tabs_warning), |
| 744 | Toast.LENGTH_SHORT); |
| 745 | warning.show(); |
| 746 | } |
| 747 | |
Michael Kolb | fdb7024 | 2011-03-24 09:41:11 -0700 | [diff] [blame] | 748 | protected void captureTab(final Tab tab) { |
| 749 | captureTab(tab, |
| 750 | (int) mActivity.getResources() |
| 751 | .getDimension(R.dimen.qc_thumb_width), |
| 752 | (int) mActivity.getResources() |
| 753 | .getDimension(R.dimen.qc_thumb_height)); |
| 754 | } |
| 755 | |
| 756 | protected void captureTab(final Tab tab, int width, int height) { |
| 757 | if ((tab == null) || (tab.getWebView() == null)) return; |
| 758 | Bitmap sshot = Controller.createScreenshot(tab, width, height); |
| 759 | tab.setScreenshot(sshot); |
| 760 | } |
| 761 | |
| 762 | void showTitleBarAndEdit() { |
| 763 | showTitleBar(); |
| 764 | getTitleBar().startEditingUrl(false); |
| 765 | } |
| 766 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 767 | } |