BaseUi.java revision 11d1978d8d16004598347abc93918b54a5ef760b
18233facddcc51865d612a919d450db6954aa48e3Michael Kolb/* 28233facddcc51865d612a919d450db6954aa48e3Michael Kolb * Copyright (C) 2010 The Android Open Source Project 38233facddcc51865d612a919d450db6954aa48e3Michael Kolb * 48233facddcc51865d612a919d450db6954aa48e3Michael Kolb * Licensed under the Apache License, Version 2.0 (the "License"); 58233facddcc51865d612a919d450db6954aa48e3Michael Kolb * you may not use this file except in compliance with the License. 68233facddcc51865d612a919d450db6954aa48e3Michael Kolb * You may obtain a copy of the License at 78233facddcc51865d612a919d450db6954aa48e3Michael Kolb * 88233facddcc51865d612a919d450db6954aa48e3Michael Kolb * http://www.apache.org/licenses/LICENSE-2.0 98233facddcc51865d612a919d450db6954aa48e3Michael Kolb * 108233facddcc51865d612a919d450db6954aa48e3Michael Kolb * Unless required by applicable law or agreed to in writing, software 118233facddcc51865d612a919d450db6954aa48e3Michael Kolb * distributed under the License is distributed on an "AS IS" BASIS, 128233facddcc51865d612a919d450db6954aa48e3Michael Kolb * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 138233facddcc51865d612a919d450db6954aa48e3Michael Kolb * See the License for the specific language governing permissions and 148233facddcc51865d612a919d450db6954aa48e3Michael Kolb * limitations under the License. 158233facddcc51865d612a919d450db6954aa48e3Michael Kolb */ 168233facddcc51865d612a919d450db6954aa48e3Michael Kolb 178233facddcc51865d612a919d450db6954aa48e3Michael Kolbpackage com.android.browser; 188233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1930c714c853a4239e72ab1e238ce2a92472d06ab0John Reckimport com.android.browser.Tab.LockIcon; 2074830e168f578bb511240f95d373667565f0623fJohn Reckimport com.android.browser.UI.DropdownChangeListener; 2130c714c853a4239e72ab1e238ce2a92472d06ab0John Reck 2274830e168f578bb511240f95d373667565f0623fJohn Reckimport android.animation.Animator; 2374830e168f578bb511240f95d373667565f0623fJohn Reckimport android.animation.Animator.AnimatorListener; 2474830e168f578bb511240f95d373667565f0623fJohn Reckimport android.animation.ObjectAnimator; 258233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.app.Activity; 26b9a051bd9ed974c4d3d29a549bb7e00d8a95c33cJohn Reckimport android.content.pm.PackageManager; 278233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.content.res.Configuration; 288233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.content.res.Resources; 298233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.graphics.Bitmap; 308233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.graphics.BitmapFactory; 318233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.graphics.drawable.Drawable; 328233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.os.Bundle; 338233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.text.TextUtils; 348233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.util.Log; 358233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.view.Gravity; 368233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.view.LayoutInflater; 378233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.view.Menu; 388233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.view.View; 391514bb7ed5656316a8dac966cee21653f3c59affMichael Kolbimport android.view.View.OnClickListener; 408233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.view.ViewGroup; 411514bb7ed5656316a8dac966cee21653f3c59affMichael Kolbimport android.view.ViewGroup.LayoutParams; 428233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.view.WindowManager; 433a696280cba53eea153c9d5707b236997d193328Michael Kolbimport android.view.inputmethod.InputMethodManager; 448233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.webkit.WebChromeClient; 4511d1978d8d16004598347abc93918b54a5ef760bMichael Kolbimport android.webkit.WebSettings.ZoomDensity; 468233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.webkit.WebView; 478233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.widget.FrameLayout; 481514bb7ed5656316a8dac966cee21653f3c59affMichael Kolbimport android.widget.ImageButton; 498233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.widget.LinearLayout; 508233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.widget.Toast; 518233facddcc51865d612a919d450db6954aa48e3Michael Kolb 521bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolbimport java.util.List; 531bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb 548233facddcc51865d612a919d450db6954aa48e3Michael Kolb/** 558233facddcc51865d612a919d450db6954aa48e3Michael Kolb * UI interface definitions 568233facddcc51865d612a919d450db6954aa48e3Michael Kolb */ 576670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolbpublic abstract class BaseUi implements UI, WebViewFactory { 588233facddcc51865d612a919d450db6954aa48e3Michael Kolb 598233facddcc51865d612a919d450db6954aa48e3Michael Kolb private static final String LOGTAG = "BaseUi"; 608233facddcc51865d612a919d450db6954aa48e3Michael Kolb 616670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb protected static final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = 628233facddcc51865d612a919d450db6954aa48e3Michael Kolb new FrameLayout.LayoutParams( 638233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup.LayoutParams.MATCH_PARENT, 648233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup.LayoutParams.MATCH_PARENT); 658233facddcc51865d612a919d450db6954aa48e3Michael Kolb 666670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb protected static final FrameLayout.LayoutParams COVER_SCREEN_GRAVITY_CENTER = 678233facddcc51865d612a919d450db6954aa48e3Michael Kolb new FrameLayout.LayoutParams( 688233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup.LayoutParams.MATCH_PARENT, 698233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup.LayoutParams.MATCH_PARENT, 708233facddcc51865d612a919d450db6954aa48e3Michael Kolb Gravity.CENTER); 718233facddcc51865d612a919d450db6954aa48e3Michael Kolb 728233facddcc51865d612a919d450db6954aa48e3Michael Kolb Activity mActivity; 738233facddcc51865d612a919d450db6954aa48e3Michael Kolb UiController mUiController; 748233facddcc51865d612a919d450db6954aa48e3Michael Kolb TabControl mTabControl; 75377ea31324391e7878f6f5b7a991c74988c18403Michael Kolb protected Tab mActiveTab; 763a696280cba53eea153c9d5707b236997d193328Michael Kolb private InputMethodManager mInputManager; 778233facddcc51865d612a919d450db6954aa48e3Michael Kolb 788233facddcc51865d612a919d450db6954aa48e3Michael Kolb private Drawable mSecLockIcon; 798233facddcc51865d612a919d450db6954aa48e3Michael Kolb private Drawable mMixLockIcon; 808233facddcc51865d612a919d450db6954aa48e3Michael Kolb 818233facddcc51865d612a919d450db6954aa48e3Michael Kolb private FrameLayout mBrowserFrameLayout; 826670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb protected FrameLayout mContentView; 838233facddcc51865d612a919d450db6954aa48e3Michael Kolb private FrameLayout mCustomViewContainer; 848233facddcc51865d612a919d450db6954aa48e3Michael Kolb 858233facddcc51865d612a919d450db6954aa48e3Michael Kolb private View mCustomView; 868233facddcc51865d612a919d450db6954aa48e3Michael Kolb private WebChromeClient.CustomViewCallback mCustomViewCallback; 878233facddcc51865d612a919d450db6954aa48e3Michael Kolb 888233facddcc51865d612a919d450db6954aa48e3Michael Kolb private CombinedBookmarkHistoryView mComboView; 898233facddcc51865d612a919d450db6954aa48e3Michael Kolb 908233facddcc51865d612a919d450db6954aa48e3Michael Kolb private LinearLayout mErrorConsoleContainer = null; 918233facddcc51865d612a919d450db6954aa48e3Michael Kolb 928233facddcc51865d612a919d450db6954aa48e3Michael Kolb private Toast mStopToast; 938233facddcc51865d612a919d450db6954aa48e3Michael Kolb 947cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb private boolean mTitleShowing; 957cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb 968233facddcc51865d612a919d450db6954aa48e3Michael Kolb // the default <video> poster 978233facddcc51865d612a919d450db6954aa48e3Michael Kolb private Bitmap mDefaultVideoPoster; 988233facddcc51865d612a919d450db6954aa48e3Michael Kolb // the video progress view 998233facddcc51865d612a919d450db6954aa48e3Michael Kolb private View mVideoProgressView; 1008233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1018233facddcc51865d612a919d450db6954aa48e3Michael Kolb private boolean mActivityPaused; 1028233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1038233facddcc51865d612a919d450db6954aa48e3Michael Kolb public BaseUi(Activity browser, UiController controller) { 1048233facddcc51865d612a919d450db6954aa48e3Michael Kolb mActivity = browser; 1058233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController = controller; 1068233facddcc51865d612a919d450db6954aa48e3Michael Kolb mTabControl = controller.getTabControl(); 1078233facddcc51865d612a919d450db6954aa48e3Michael Kolb Resources res = mActivity.getResources(); 1083a696280cba53eea153c9d5707b236997d193328Michael Kolb mInputManager = (InputMethodManager) 1093a696280cba53eea153c9d5707b236997d193328Michael Kolb browser.getSystemService(Activity.INPUT_METHOD_SERVICE); 1105a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb mSecLockIcon = res.getDrawable(R.drawable.ic_secure_holo_dark); 1118233facddcc51865d612a919d450db6954aa48e3Michael Kolb mMixLockIcon = res.getDrawable(R.drawable.ic_partial_secure); 1128233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1138233facddcc51865d612a919d450db6954aa48e3Michael Kolb FrameLayout frameLayout = (FrameLayout) mActivity.getWindow() 1148233facddcc51865d612a919d450db6954aa48e3Michael Kolb .getDecorView().findViewById(android.R.id.content); 1158233facddcc51865d612a919d450db6954aa48e3Michael Kolb mBrowserFrameLayout = (FrameLayout) LayoutInflater.from(mActivity) 1168233facddcc51865d612a919d450db6954aa48e3Michael Kolb .inflate(R.layout.custom_screen, null); 1178233facddcc51865d612a919d450db6954aa48e3Michael Kolb mContentView = (FrameLayout) mBrowserFrameLayout.findViewById( 1188233facddcc51865d612a919d450db6954aa48e3Michael Kolb R.id.main_content); 1198233facddcc51865d612a919d450db6954aa48e3Michael Kolb mErrorConsoleContainer = (LinearLayout) mBrowserFrameLayout 1208233facddcc51865d612a919d450db6954aa48e3Michael Kolb .findViewById(R.id.error_console); 1218233facddcc51865d612a919d450db6954aa48e3Michael Kolb mCustomViewContainer = (FrameLayout) mBrowserFrameLayout 1228233facddcc51865d612a919d450db6954aa48e3Michael Kolb .findViewById(R.id.fullscreen_custom_content); 1238233facddcc51865d612a919d450db6954aa48e3Michael Kolb frameLayout.addView(mBrowserFrameLayout, COVER_SCREEN_PARAMS); 1247cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb mTitleShowing = false; 1258233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1268233facddcc51865d612a919d450db6954aa48e3Michael Kolb 127b9a051bd9ed974c4d3d29a549bb7e00d8a95c33cJohn Reck @Override 128b9a051bd9ed974c4d3d29a549bb7e00d8a95c33cJohn Reck public WebView createWebView(boolean privateBrowsing) { 129b9a051bd9ed974c4d3d29a549bb7e00d8a95c33cJohn Reck // Create a new WebView 130b9a051bd9ed974c4d3d29a549bb7e00d8a95c33cJohn Reck BrowserWebView w = new BrowserWebView(mActivity, null, 131b9a051bd9ed974c4d3d29a549bb7e00d8a95c33cJohn Reck android.R.attr.webViewStyle, privateBrowsing); 132b9a051bd9ed974c4d3d29a549bb7e00d8a95c33cJohn Reck initWebViewSettings(w); 133b9a051bd9ed974c4d3d29a549bb7e00d8a95c33cJohn Reck return w; 134b9a051bd9ed974c4d3d29a549bb7e00d8a95c33cJohn Reck } 135b9a051bd9ed974c4d3d29a549bb7e00d8a95c33cJohn Reck 136b9a051bd9ed974c4d3d29a549bb7e00d8a95c33cJohn Reck @Override 137b9a051bd9ed974c4d3d29a549bb7e00d8a95c33cJohn Reck public WebView createSubWebView(boolean privateBrowsing) { 138b9a051bd9ed974c4d3d29a549bb7e00d8a95c33cJohn Reck return createWebView(privateBrowsing); 139b9a051bd9ed974c4d3d29a549bb7e00d8a95c33cJohn Reck } 140b9a051bd9ed974c4d3d29a549bb7e00d8a95c33cJohn Reck 1416670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb /** 1426670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb * common webview initialization 1436670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb * @param w the webview to initialize 1446670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb */ 1456670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb protected void initWebViewSettings(WebView w) { 1468233facddcc51865d612a919d450db6954aa48e3Michael Kolb w.setScrollbarFadingEnabled(true); 1478233facddcc51865d612a919d450db6954aa48e3Michael Kolb w.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); 1488233facddcc51865d612a919d450db6954aa48e3Michael Kolb w.setMapTrackballToArrowKeys(false); // use trackball directly 1498233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Enable the built-in zoom 1508233facddcc51865d612a919d450db6954aa48e3Michael Kolb w.getSettings().setBuiltInZoomControls(true); 151b9a051bd9ed974c4d3d29a549bb7e00d8a95c33cJohn Reck boolean supportsMultiTouch = mActivity.getPackageManager() 152b9a051bd9ed974c4d3d29a549bb7e00d8a95c33cJohn Reck .hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH); 153b9a051bd9ed974c4d3d29a549bb7e00d8a95c33cJohn Reck w.getSettings().setDisplayZoomControls(!supportsMultiTouch); 154b9a051bd9ed974c4d3d29a549bb7e00d8a95c33cJohn Reck w.setExpandedTileBounds(true); // smoother scrolling 1558233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1568233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Add this WebView to the settings observer list and update the 1578233facddcc51865d612a919d450db6954aa48e3Michael Kolb // settings 1588233facddcc51865d612a919d450db6954aa48e3Michael Kolb final BrowserSettings s = BrowserSettings.getInstance(); 1598233facddcc51865d612a919d450db6954aa48e3Michael Kolb s.addObserver(w.getSettings()).update(s, null); 1608233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1618233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1628233facddcc51865d612a919d450db6954aa48e3Michael Kolb private void cancelStopToast() { 1638233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mStopToast != null) { 1648233facddcc51865d612a919d450db6954aa48e3Michael Kolb mStopToast.cancel(); 1658233facddcc51865d612a919d450db6954aa48e3Michael Kolb mStopToast = null; 1668233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1678233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1688233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1698233facddcc51865d612a919d450db6954aa48e3Michael Kolb // lifecycle 1708233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1718233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onPause() { 1727a5cf4714453bd982afc662f373d0c38cddfb023Michael Kolb if (isCustomViewShowing()) { 1737a5cf4714453bd982afc662f373d0c38cddfb023Michael Kolb onHideCustomView(); 1747a5cf4714453bd982afc662f373d0c38cddfb023Michael Kolb } 1758233facddcc51865d612a919d450db6954aa48e3Michael Kolb cancelStopToast(); 1768233facddcc51865d612a919d450db6954aa48e3Michael Kolb mActivityPaused = true; 1778233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1788233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1798233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onResume() { 1808233facddcc51865d612a919d450db6954aa48e3Michael Kolb mActivityPaused = false; 1818233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1828233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1836670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb protected boolean isActivityPaused() { 1846670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb return mActivityPaused; 1858233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1868233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1878233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onConfigurationChanged(Configuration config) { 1888233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1898233facddcc51865d612a919d450db6954aa48e3Michael Kolb 190dc2ee1bfb50b7bec0cf3215e3d298b246dc71101Michael Kolb public abstract void editUrl(boolean clearInput); 191dc2ee1bfb50b7bec0cf3215e3d298b246dc71101Michael Kolb 1928233facddcc51865d612a919d450db6954aa48e3Michael Kolb // key handling 1938233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1948233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 1958233facddcc51865d612a919d450db6954aa48e3Michael Kolb public boolean onBackKey() { 1968233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mComboView != null) { 1978233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (!mComboView.onBackPressed()) { 1988233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.removeComboView(); 1998233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2008233facddcc51865d612a919d450db6954aa48e3Michael Kolb return true; 2018233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2028233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mCustomView != null) { 2038233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.hideCustomView(); 2048233facddcc51865d612a919d450db6954aa48e3Michael Kolb return true; 2058233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2068233facddcc51865d612a919d450db6954aa48e3Michael Kolb return false; 2078233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2088233facddcc51865d612a919d450db6954aa48e3Michael Kolb 20930c714c853a4239e72ab1e238ce2a92472d06ab0John Reck // Tab callbacks 2108233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 21130c714c853a4239e72ab1e238ce2a92472d06ab0John Reck public void onTabDataChanged(Tab tab) { 21230c714c853a4239e72ab1e238ce2a92472d06ab0John Reck setUrlTitle(tab); 21330c714c853a4239e72ab1e238ce2a92472d06ab0John Reck setFavicon(tab); 21430c714c853a4239e72ab1e238ce2a92472d06ab0John Reck updateLockIconToLatest(tab); 2155a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb updateNavigationState(tab); 2168233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2178233facddcc51865d612a919d450db6954aa48e3Michael Kolb 2188233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 2194cd97793901e8f5681cf642d0b2684697964a37aLeon Scroggins public void bookmarkedStatusHasChanged(Tab tab) { 22094b7e04932d77d73f348efecf7f2dd6b4ee5e5a1John Reck if (tab.inForeground()) { 22194b7e04932d77d73f348efecf7f2dd6b4ee5e5a1John Reck boolean isBookmark = tab.isBookmarkedSite(); 22294b7e04932d77d73f348efecf7f2dd6b4ee5e5a1John Reck getTitleBar().setCurrentUrlIsBookmark(isBookmark); 22394b7e04932d77d73f348efecf7f2dd6b4ee5e5a1John Reck } 2244cd97793901e8f5681cf642d0b2684697964a37aLeon Scroggins } 2254cd97793901e8f5681cf642d0b2684697964a37aLeon Scroggins 2264cd97793901e8f5681cf642d0b2684697964a37aLeon Scroggins @Override 2278233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onPageStopped(Tab tab) { 2288233facddcc51865d612a919d450db6954aa48e3Michael Kolb cancelStopToast(); 2298233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (tab.inForeground()) { 2308233facddcc51865d612a919d450db6954aa48e3Michael Kolb mStopToast = Toast 2318233facddcc51865d612a919d450db6954aa48e3Michael Kolb .makeText(mActivity, R.string.stopping, Toast.LENGTH_SHORT); 2328233facddcc51865d612a919d450db6954aa48e3Michael Kolb mStopToast.show(); 2338233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2348233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2358233facddcc51865d612a919d450db6954aa48e3Michael Kolb 2368233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 2371bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb public boolean needsRestoreAllTabs() { 2386670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb return false; 2391bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb } 2401bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb 2411bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb @Override 2428233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void addTab(Tab tab) { 2438233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2448233facddcc51865d612a919d450db6954aa48e3Michael Kolb 2458233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 246377ea31324391e7878f6f5b7a991c74988c18403Michael Kolb public void setActiveTab(final Tab tab) { 247377ea31324391e7878f6f5b7a991c74988c18403Michael Kolb setActiveTab(tab, true); 248377ea31324391e7878f6f5b7a991c74988c18403Michael Kolb } 249377ea31324391e7878f6f5b7a991c74988c18403Michael Kolb 250377ea31324391e7878f6f5b7a991c74988c18403Michael Kolb void setActiveTab(Tab tab, boolean needsAttaching) { 25177df4568331d527f993f4d69168218ddf5acdddaMichael Kolb if ((tab != mActiveTab) && (mActiveTab != null)) { 25277df4568331d527f993f4d69168218ddf5acdddaMichael Kolb removeTabFromContentView(mActiveTab); 2538233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 25477df4568331d527f993f4d69168218ddf5acdddaMichael Kolb mActiveTab = tab; 255377ea31324391e7878f6f5b7a991c74988c18403Michael Kolb if (needsAttaching) { 256377ea31324391e7878f6f5b7a991c74988c18403Michael Kolb attachTabToContentView(tab); 257377ea31324391e7878f6f5b7a991c74988c18403Michael Kolb } 2588233facddcc51865d612a919d450db6954aa48e3Michael Kolb setShouldShowErrorConsole(tab, mUiController.shouldShowErrorConsole()); 25930c714c853a4239e72ab1e238ce2a92472d06ab0John Reck onTabDataChanged(tab); 26030c714c853a4239e72ab1e238ce2a92472d06ab0John Reck onProgressChanged(tab); 261117f07d08e3e25e3c920a1dabe31dcd7643bacb2John Reck boolean incognito = mActiveTab.getWebView().isPrivateBrowsingEnabled(); 2627cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb getTitleBar().setIncognitoMode(incognito); 2639206677e461328f15854c5fcb1366d0e261534c6Patrick Scott updateAutoLogin(tab, false); 2648233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2658233facddcc51865d612a919d450db6954aa48e3Michael Kolb 266cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb Tab getActiveTab() { 267cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb return mActiveTab; 268cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb } 269cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb 2708233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 2711bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb public void updateTabs(List<Tab> tabs) { 2721bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb } 2731bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb 2741bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb @Override 2758233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void removeTab(Tab tab) { 27677df4568331d527f993f4d69168218ddf5acdddaMichael Kolb if (mActiveTab == tab) { 2778233facddcc51865d612a919d450db6954aa48e3Michael Kolb removeTabFromContentView(tab); 27877df4568331d527f993f4d69168218ddf5acdddaMichael Kolb mActiveTab = null; 2798233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2808233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2818233facddcc51865d612a919d450db6954aa48e3Michael Kolb 2828233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 2838233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void detachTab(Tab tab) { 2848233facddcc51865d612a919d450db6954aa48e3Michael Kolb removeTabFromContentView(tab); 2858233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2868233facddcc51865d612a919d450db6954aa48e3Michael Kolb 2878233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 2888233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void attachTab(Tab tab) { 2898233facddcc51865d612a919d450db6954aa48e3Michael Kolb attachTabToContentView(tab); 2908233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2918233facddcc51865d612a919d450db6954aa48e3Michael Kolb 292377ea31324391e7878f6f5b7a991c74988c18403Michael Kolb protected void attachTabToContentView(Tab tab) { 293d1e2ccc38a2d5318a4ab06b2349cb43303fd6cebMichael Kolb if ((tab == null) || (tab.getWebView() == null)) { 2948233facddcc51865d612a919d450db6954aa48e3Michael Kolb return; 2958233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2968233facddcc51865d612a919d450db6954aa48e3Michael Kolb View container = tab.getViewContainer(); 2978233facddcc51865d612a919d450db6954aa48e3Michael Kolb WebView mainView = tab.getWebView(); 2988233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Attach the WebView to the container and then attach the 2998233facddcc51865d612a919d450db6954aa48e3Michael Kolb // container to the content view. 3008233facddcc51865d612a919d450db6954aa48e3Michael Kolb FrameLayout wrapper = 3018233facddcc51865d612a919d450db6954aa48e3Michael Kolb (FrameLayout) container.findViewById(R.id.webview_wrapper); 3028233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup parent = (ViewGroup) mainView.getParent(); 3038233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (parent != wrapper) { 3048233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (parent != null) { 3058233facddcc51865d612a919d450db6954aa48e3Michael Kolb Log.w(LOGTAG, "mMainView already has a parent in" 3068233facddcc51865d612a919d450db6954aa48e3Michael Kolb + " attachTabToContentView!"); 3078233facddcc51865d612a919d450db6954aa48e3Michael Kolb parent.removeView(mainView); 3088233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3098233facddcc51865d612a919d450db6954aa48e3Michael Kolb wrapper.addView(mainView); 3108233facddcc51865d612a919d450db6954aa48e3Michael Kolb } else { 3118233facddcc51865d612a919d450db6954aa48e3Michael Kolb Log.w(LOGTAG, "mMainView is already attached to wrapper in" 3128233facddcc51865d612a919d450db6954aa48e3Michael Kolb + " attachTabToContentView!"); 3138233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3148233facddcc51865d612a919d450db6954aa48e3Michael Kolb parent = (ViewGroup) container.getParent(); 3158233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (parent != mContentView) { 3168233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (parent != null) { 3178233facddcc51865d612a919d450db6954aa48e3Michael Kolb Log.w(LOGTAG, "mContainer already has a parent in" 3188233facddcc51865d612a919d450db6954aa48e3Michael Kolb + " attachTabToContentView!"); 3198233facddcc51865d612a919d450db6954aa48e3Michael Kolb parent.removeView(container); 3208233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3218233facddcc51865d612a919d450db6954aa48e3Michael Kolb mContentView.addView(container, COVER_SCREEN_PARAMS); 3228233facddcc51865d612a919d450db6954aa48e3Michael Kolb } else { 3238233facddcc51865d612a919d450db6954aa48e3Michael Kolb Log.w(LOGTAG, "mContainer is already attached to content in" 3248233facddcc51865d612a919d450db6954aa48e3Michael Kolb + " attachTabToContentView!"); 3258233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3268233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.attachSubWindow(tab); 3278233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3288233facddcc51865d612a919d450db6954aa48e3Michael Kolb 3298233facddcc51865d612a919d450db6954aa48e3Michael Kolb private void removeTabFromContentView(Tab tab) { 3307cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb hideTitleBar(); 3318233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Remove the container that contains the main WebView. 3328233facddcc51865d612a919d450db6954aa48e3Michael Kolb WebView mainView = tab.getWebView(); 3338233facddcc51865d612a919d450db6954aa48e3Michael Kolb View container = tab.getViewContainer(); 3348233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mainView == null) { 3358233facddcc51865d612a919d450db6954aa48e3Michael Kolb return; 3368233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3378233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Remove the container from the content and then remove the 3388233facddcc51865d612a919d450db6954aa48e3Michael Kolb // WebView from the container. This will trigger a focus change 3398233facddcc51865d612a919d450db6954aa48e3Michael Kolb // needed by WebView. 34020776cc370cf1f092b73c356c02a0df966cfd185Michael Kolb mainView.setEmbeddedTitleBar(null); 3418233facddcc51865d612a919d450db6954aa48e3Michael Kolb FrameLayout wrapper = 3428233facddcc51865d612a919d450db6954aa48e3Michael Kolb (FrameLayout) container.findViewById(R.id.webview_wrapper); 3438233facddcc51865d612a919d450db6954aa48e3Michael Kolb wrapper.removeView(mainView); 3448233facddcc51865d612a919d450db6954aa48e3Michael Kolb mContentView.removeView(container); 3458233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.endActionMode(); 3468233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.removeSubWindow(tab); 3478233facddcc51865d612a919d450db6954aa48e3Michael Kolb ErrorConsoleView errorConsole = tab.getErrorConsole(false); 3488233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (errorConsole != null) { 3498233facddcc51865d612a919d450db6954aa48e3Michael Kolb mErrorConsoleContainer.removeView(errorConsole); 3508233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3518233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3528233facddcc51865d612a919d450db6954aa48e3Michael Kolb 353a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb @Override 354a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb public void onSetWebView(Tab tab, WebView webView) { 355a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb View container = tab.getViewContainer(); 356a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb if (container == null) { 357a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb // The tab consists of a container view, which contains the main 358a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb // WebView, as well as any other UI elements associated with the tab. 359a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb container = mActivity.getLayoutInflater().inflate(R.layout.tab, 360a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb null); 361a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb tab.setViewContainer(container); 362a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb } 363a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb if (tab.getWebView() != webView) { 364a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb // Just remove the old one. 365a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb FrameLayout wrapper = 366a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb (FrameLayout) container.findViewById(R.id.webview_wrapper); 367a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb wrapper.removeView(tab.getWebView()); 368a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb } 369a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb } 370a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb 3718233facddcc51865d612a919d450db6954aa48e3Michael Kolb /** 3721514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb * create a sub window container and webview for the tab 3731514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb * Note: this methods operates through side-effects for now 3741514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb * it sets both the subView and subViewContainer for the given tab 3751514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb * @param tab tab to create the sub window for 3761514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb * @param subView webview to be set as a subwindow for the tab 3771514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb */ 3781514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb @Override 3791514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb public void createSubWindow(Tab tab, WebView subView) { 3801514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb View subViewContainer = mActivity.getLayoutInflater().inflate( 3811514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb R.layout.browser_subwindow, null); 3821514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb ViewGroup inner = (ViewGroup) subViewContainer 3831514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb .findViewById(R.id.inner_container); 3841514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb inner.addView(subView, new LayoutParams(LayoutParams.MATCH_PARENT, 3851514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb LayoutParams.MATCH_PARENT)); 3861514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb final ImageButton cancel = (ImageButton) subViewContainer 3871514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb .findViewById(R.id.subwindow_close); 3881514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb final WebView cancelSubView = subView; 3891514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb cancel.setOnClickListener(new OnClickListener() { 3901514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb public void onClick(View v) { 3911514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb cancelSubView.getWebChromeClient().onCloseWindow(cancelSubView); 3921514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb } 3931514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb }); 3941514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb tab.setSubWebView(subView); 3951514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb tab.setSubViewContainer(subViewContainer); 3961514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb } 3971514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb 3981514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb /** 3998233facddcc51865d612a919d450db6954aa48e3Michael Kolb * Remove the sub window from the content view. 4008233facddcc51865d612a919d450db6954aa48e3Michael Kolb */ 4018233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 4028233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void removeSubWindow(View subviewContainer) { 4038233facddcc51865d612a919d450db6954aa48e3Michael Kolb mContentView.removeView(subviewContainer); 4048233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.endActionMode(); 4058233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 4068233facddcc51865d612a919d450db6954aa48e3Michael Kolb 4078233facddcc51865d612a919d450db6954aa48e3Michael Kolb /** 4088233facddcc51865d612a919d450db6954aa48e3Michael Kolb * Attach the sub window to the content view. 4098233facddcc51865d612a919d450db6954aa48e3Michael Kolb */ 4108233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 4118233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void attachSubWindow(View container) { 4121514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb if (container.getParent() != null) { 4131514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb // already attached, remove first 4141514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb ((ViewGroup) container.getParent()).removeView(container); 4151514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb } 4168233facddcc51865d612a919d450db6954aa48e3Michael Kolb mContentView.addView(container, COVER_SCREEN_PARAMS); 4178233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 4188233facddcc51865d612a919d450db6954aa48e3Michael Kolb 41911d1978d8d16004598347abc93918b54a5ef760bMichael Kolb protected void refreshWebView() { 42011d1978d8d16004598347abc93918b54a5ef760bMichael Kolb Tab tab = getActiveTab(); 42111d1978d8d16004598347abc93918b54a5ef760bMichael Kolb if ((tab != null) && (tab.getWebView() != null)) { 42211d1978d8d16004598347abc93918b54a5ef760bMichael Kolb tab.getWebView().invalidate(); 42311d1978d8d16004598347abc93918b54a5ef760bMichael Kolb } 42411d1978d8d16004598347abc93918b54a5ef760bMichael Kolb } 42511d1978d8d16004598347abc93918b54a5ef760bMichael Kolb 4267cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb boolean canShowTitleBar() { 4277cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb return !isTitleBarShowing() 4287cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb && !isActivityPaused() 4297cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb && (getActiveTab() != null) 4307cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb && (getActiveTab().getWebView() != null) 4317cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb && !mUiController.isInCustomActionMode(); 4328233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 4338233facddcc51865d612a919d450db6954aa48e3Michael Kolb 4347cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb void showTitleBar() { 4357cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb mTitleShowing = true; 4367cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb } 4376670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 4387cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb protected void hideTitleBar() { 4397cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb mTitleShowing = false; 4407cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb } 4416670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 4427cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb protected boolean isTitleBarShowing() { 4437cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb return mTitleShowing; 4447cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb } 4456670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 4467cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb protected abstract TitleBarBase getTitleBar(); 4476670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 4487cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb protected void setTitleGravity(int gravity) { 4497cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb getTitleBar().setTitleGravity(gravity); 4507cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb Tab tab = getActiveTab(); 4517cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb if ((tab != null) && (tab.getWebView() != null)) { 4527cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb tab.getWebView().setTitleBarGravity(gravity); 4537cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb } 4547cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb } 4556670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 4566670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb @Override 45711d1978d8d16004598347abc93918b54a5ef760bMichael Kolb public void showVoiceTitleBar(String title, List<String> results) { 45811d1978d8d16004598347abc93918b54a5ef760bMichael Kolb getTitleBar().setInVoiceMode(true, results); 4597cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb getTitleBar().setDisplayTitle(title); 4608233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 4618233facddcc51865d612a919d450db6954aa48e3Michael Kolb 4626670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb @Override 4636670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb public void revertVoiceTitleBar(Tab tab) { 46411d1978d8d16004598347abc93918b54a5ef760bMichael Kolb getTitleBar().setInVoiceMode(false, null); 46530c714c853a4239e72ab1e238ce2a92472d06ab0John Reck String url = tab.getUrl(); 4667cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb getTitleBar().setDisplayTitle(url); 4678233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 4688233facddcc51865d612a919d450db6954aa48e3Michael Kolb 4698233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 47011d1978d8d16004598347abc93918b54a5ef760bMichael Kolb public void registerDropdownChangeListener(DropdownChangeListener d) { 47111d1978d8d16004598347abc93918b54a5ef760bMichael Kolb getTitleBar().registerDropdownChangeListener(d); 47211d1978d8d16004598347abc93918b54a5ef760bMichael Kolb } 47311d1978d8d16004598347abc93918b54a5ef760bMichael Kolb 47411d1978d8d16004598347abc93918b54a5ef760bMichael Kolb @Override 4758233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void showComboView(boolean startWithHistory, Bundle extras) { 476439c9a58765aa6aab95d55422ee61ea8360e912dJohn Reck if (mComboView != null) { 477439c9a58765aa6aab95d55422ee61ea8360e912dJohn Reck return; 478439c9a58765aa6aab95d55422ee61ea8360e912dJohn Reck } 4798233facddcc51865d612a919d450db6954aa48e3Michael Kolb mComboView = new CombinedBookmarkHistoryView(mActivity, 4808233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController, 4818233facddcc51865d612a919d450db6954aa48e3Michael Kolb startWithHistory ? 4828233facddcc51865d612a919d450db6954aa48e3Michael Kolb CombinedBookmarkHistoryView.FRAGMENT_ID_HISTORY 4838233facddcc51865d612a919d450db6954aa48e3Michael Kolb : CombinedBookmarkHistoryView.FRAGMENT_ID_BOOKMARKS, 4848233facddcc51865d612a919d450db6954aa48e3Michael Kolb extras); 48547d63f843cf6973c7cb59db99888df7485bfee39Michael Kolb FrameLayout wrapper = 48647d63f843cf6973c7cb59db99888df7485bfee39Michael Kolb (FrameLayout) mContentView.findViewById(R.id.webview_wrapper); 48747d63f843cf6973c7cb59db99888df7485bfee39Michael Kolb wrapper.setVisibility(View.GONE); 4887cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb hideTitleBar(); 4893a696280cba53eea153c9d5707b236997d193328Michael Kolb dismissIME(); 4903a696280cba53eea153c9d5707b236997d193328Michael Kolb if (mActiveTab != null) { 4913a696280cba53eea153c9d5707b236997d193328Michael Kolb WebView web = mActiveTab.getWebView(); 4923a696280cba53eea153c9d5707b236997d193328Michael Kolb mActiveTab.putInBackground(); 4933a696280cba53eea153c9d5707b236997d193328Michael Kolb } 49474830e168f578bb511240f95d373667565f0623fJohn Reck mComboView.setAlpha(0f); 49574830e168f578bb511240f95d373667565f0623fJohn Reck ObjectAnimator anim = ObjectAnimator.ofFloat(mComboView, "alpha", 0f, 1f); 49674830e168f578bb511240f95d373667565f0623fJohn Reck Resources res = mActivity.getResources(); 49774830e168f578bb511240f95d373667565f0623fJohn Reck anim.setDuration(res.getInteger(R.integer.comboViewFadeInDuration)); 49874830e168f578bb511240f95d373667565f0623fJohn Reck anim.start(); 4998233facddcc51865d612a919d450db6954aa48e3Michael Kolb mContentView.addView(mComboView, COVER_SCREEN_PARAMS); 5008233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5018233facddcc51865d612a919d450db6954aa48e3Michael Kolb 502ba23870babf7041e72f7d1119ad59d9bb32c6634Michael Kolb public boolean isComboViewShowing() { 503ba23870babf7041e72f7d1119ad59d9bb32c6634Michael Kolb return (mComboView != null); 504ba23870babf7041e72f7d1119ad59d9bb32c6634Michael Kolb } 505ba23870babf7041e72f7d1119ad59d9bb32c6634Michael Kolb 5068233facddcc51865d612a919d450db6954aa48e3Michael Kolb /** 5078233facddcc51865d612a919d450db6954aa48e3Michael Kolb * dismiss the ComboPage 5088233facddcc51865d612a919d450db6954aa48e3Michael Kolb */ 5098233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 5108233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void hideComboView() { 5118233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mComboView != null) { 5128233facddcc51865d612a919d450db6954aa48e3Michael Kolb mContentView.removeView(mComboView); 51347d63f843cf6973c7cb59db99888df7485bfee39Michael Kolb FrameLayout wrapper = 51447d63f843cf6973c7cb59db99888df7485bfee39Michael Kolb (FrameLayout) mContentView.findViewById(R.id.webview_wrapper); 51547d63f843cf6973c7cb59db99888df7485bfee39Michael Kolb wrapper.setVisibility(View.VISIBLE); 5168233facddcc51865d612a919d450db6954aa48e3Michael Kolb mComboView = null; 5178233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5183a696280cba53eea153c9d5707b236997d193328Michael Kolb if (mActiveTab != null) { 5193a696280cba53eea153c9d5707b236997d193328Michael Kolb mActiveTab.putInForeground(); 5203a696280cba53eea153c9d5707b236997d193328Michael Kolb } 521b3417f0a68a1efc64604ea354ae7f856ce79cb16John Reck mActivity.invalidateOptionsMenu(); 5228233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5238233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5248233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 5258233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void showCustomView(View view, 5268233facddcc51865d612a919d450db6954aa48e3Michael Kolb WebChromeClient.CustomViewCallback callback) { 5278233facddcc51865d612a919d450db6954aa48e3Michael Kolb // if a view already exists then immediately terminate the new one 5288233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mCustomView != null) { 5298233facddcc51865d612a919d450db6954aa48e3Michael Kolb callback.onCustomViewHidden(); 5308233facddcc51865d612a919d450db6954aa48e3Michael Kolb return; 5318233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5328233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5338233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Add the custom view to its container. 5348233facddcc51865d612a919d450db6954aa48e3Michael Kolb mCustomViewContainer.addView(view, COVER_SCREEN_GRAVITY_CENTER); 5358233facddcc51865d612a919d450db6954aa48e3Michael Kolb mCustomView = view; 5368233facddcc51865d612a919d450db6954aa48e3Michael Kolb mCustomViewCallback = callback; 5378233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Hide the content view. 5388233facddcc51865d612a919d450db6954aa48e3Michael Kolb mContentView.setVisibility(View.GONE); 5398233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Finally show the custom view container. 5408233facddcc51865d612a919d450db6954aa48e3Michael Kolb setStatusBarVisibility(false); 5418233facddcc51865d612a919d450db6954aa48e3Michael Kolb mCustomViewContainer.setVisibility(View.VISIBLE); 5428233facddcc51865d612a919d450db6954aa48e3Michael Kolb mCustomViewContainer.bringToFront(); 5438233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5448233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5458233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 5468233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onHideCustomView() { 5478233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mCustomView == null) 5488233facddcc51865d612a919d450db6954aa48e3Michael Kolb return; 5498233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5508233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Hide the custom view. 5518233facddcc51865d612a919d450db6954aa48e3Michael Kolb mCustomView.setVisibility(View.GONE); 5528233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Remove the custom view from its container. 5538233facddcc51865d612a919d450db6954aa48e3Michael Kolb mCustomViewContainer.removeView(mCustomView); 5548233facddcc51865d612a919d450db6954aa48e3Michael Kolb mCustomView = null; 5558233facddcc51865d612a919d450db6954aa48e3Michael Kolb mCustomViewContainer.setVisibility(View.GONE); 5568233facddcc51865d612a919d450db6954aa48e3Michael Kolb mCustomViewCallback.onCustomViewHidden(); 5578233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Show the content view. 5588233facddcc51865d612a919d450db6954aa48e3Michael Kolb setStatusBarVisibility(true); 5598233facddcc51865d612a919d450db6954aa48e3Michael Kolb mContentView.setVisibility(View.VISIBLE); 5608233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5618233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5628233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 5638233facddcc51865d612a919d450db6954aa48e3Michael Kolb public boolean isCustomViewShowing() { 5648233facddcc51865d612a919d450db6954aa48e3Michael Kolb return mCustomView != null; 5658233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5668233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5676670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb protected void dismissIME() { 5683a696280cba53eea153c9d5707b236997d193328Michael Kolb if (mInputManager.isActive()) { 5693a696280cba53eea153c9d5707b236997d193328Michael Kolb mInputManager.hideSoftInputFromWindow(mContentView.getWindowToken(), 5703a696280cba53eea153c9d5707b236997d193328Michael Kolb 0); 5713a696280cba53eea153c9d5707b236997d193328Michael Kolb } 5723a696280cba53eea153c9d5707b236997d193328Michael Kolb } 5733a696280cba53eea153c9d5707b236997d193328Michael Kolb 5746670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb @Override 5756670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb public boolean showsWeb() { 5766670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb return mCustomView == null 5776670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb && mComboView == null; 5786670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb } 5796670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 5809206677e461328f15854c5fcb1366d0e261534c6Patrick Scott @Override 5819206677e461328f15854c5fcb1366d0e261534c6Patrick Scott public void showAutoLogin(Tab tab) { 5829206677e461328f15854c5fcb1366d0e261534c6Patrick Scott updateAutoLogin(tab, true); 5839206677e461328f15854c5fcb1366d0e261534c6Patrick Scott } 5849206677e461328f15854c5fcb1366d0e261534c6Patrick Scott 5859206677e461328f15854c5fcb1366d0e261534c6Patrick Scott @Override 5869206677e461328f15854c5fcb1366d0e261534c6Patrick Scott public void hideAutoLogin(Tab tab) { 5879206677e461328f15854c5fcb1366d0e261534c6Patrick Scott updateAutoLogin(tab, true); 5889206677e461328f15854c5fcb1366d0e261534c6Patrick Scott } 5899206677e461328f15854c5fcb1366d0e261534c6Patrick Scott 5908233facddcc51865d612a919d450db6954aa48e3Michael Kolb // ------------------------------------------------------------------------- 5918233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5925a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb protected void updateNavigationState(Tab tab) { 5935a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb } 5945a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb 59511d1978d8d16004598347abc93918b54a5ef760bMichael Kolb protected void updateAutoLogin(Tab tab, boolean animate) { 59611d1978d8d16004598347abc93918b54a5ef760bMichael Kolb getTitleBar().updateAutoLogin(tab, animate); 59711d1978d8d16004598347abc93918b54a5ef760bMichael Kolb } 5989206677e461328f15854c5fcb1366d0e261534c6Patrick Scott 5998233facddcc51865d612a919d450db6954aa48e3Michael Kolb /** 6008233facddcc51865d612a919d450db6954aa48e3Michael Kolb * Update the lock icon to correspond to our latest state. 6018233facddcc51865d612a919d450db6954aa48e3Michael Kolb */ 6026670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb protected void updateLockIconToLatest(Tab t) { 60330c714c853a4239e72ab1e238ce2a92472d06ab0John Reck if (t != null && t.inForeground()) { 6048233facddcc51865d612a919d450db6954aa48e3Michael Kolb updateLockIconImage(t.getLockIconType()); 6058233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6068233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6078233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6088233facddcc51865d612a919d450db6954aa48e3Michael Kolb /** 6098233facddcc51865d612a919d450db6954aa48e3Michael Kolb * Updates the lock-icon image in the title-bar. 6108233facddcc51865d612a919d450db6954aa48e3Michael Kolb */ 61130c714c853a4239e72ab1e238ce2a92472d06ab0John Reck private void updateLockIconImage(LockIcon lockIconType) { 6128233facddcc51865d612a919d450db6954aa48e3Michael Kolb Drawable d = null; 61330c714c853a4239e72ab1e238ce2a92472d06ab0John Reck if (lockIconType == LockIcon.LOCK_ICON_SECURE) { 6148233facddcc51865d612a919d450db6954aa48e3Michael Kolb d = mSecLockIcon; 61530c714c853a4239e72ab1e238ce2a92472d06ab0John Reck } else if (lockIconType == LockIcon.LOCK_ICON_MIXED) { 6168233facddcc51865d612a919d450db6954aa48e3Michael Kolb d = mMixLockIcon; 6178233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6187cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb getTitleBar().setLock(d); 6198233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6208233facddcc51865d612a919d450db6954aa48e3Michael Kolb 62130c714c853a4239e72ab1e238ce2a92472d06ab0John Reck protected void setUrlTitle(Tab tab) { 62230c714c853a4239e72ab1e238ce2a92472d06ab0John Reck String url = tab.getUrl(); 62330c714c853a4239e72ab1e238ce2a92472d06ab0John Reck String title = tab.getTitle(); 6246670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb if (TextUtils.isEmpty(title)) { 6256670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb title = url; 6266670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb } 6276670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb if (tab.isInVoiceSearchMode()) return; 6286670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb if (tab.inForeground()) { 6297cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb getTitleBar().setDisplayTitle(url); 6306670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb } 6318233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6328233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6336670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb // Set the favicon in the title bar. 63430c714c853a4239e72ab1e238ce2a92472d06ab0John Reck protected void setFavicon(Tab tab) { 63530c714c853a4239e72ab1e238ce2a92472d06ab0John Reck if (tab.inForeground()) { 63630c714c853a4239e72ab1e238ce2a92472d06ab0John Reck Bitmap icon = tab.getFavicon(); 6377cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb getTitleBar().setFavicon(icon); 63830c714c853a4239e72ab1e238ce2a92472d06ab0John Reck } 6398233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6408233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6418233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6428233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onActionModeFinished(boolean inLoad) { 6438233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6448233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6456670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb // active tabs page 6466670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 6476670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb public void showActiveTabsPage() { 6486670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb } 6496670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 6506670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb /** 6516670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb * Remove the active tabs page. 6526670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb */ 6536670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb public void removeActiveTabsPage() { 6546670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb } 6556670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 6568233facddcc51865d612a919d450db6954aa48e3Michael Kolb // menu handling callbacks 6578233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6588233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6591acef69ffc079d1bc029ff7eb1f5043f7efd7f36Michael Kolb public boolean onPrepareOptionsMenu(Menu menu) { 6601acef69ffc079d1bc029ff7eb1f5043f7efd7f36Michael Kolb return true; 6611acef69ffc079d1bc029ff7eb1f5043f7efd7f36Michael Kolb } 6621acef69ffc079d1bc029ff7eb1f5043f7efd7f36Michael Kolb 6631acef69ffc079d1bc029ff7eb1f5043f7efd7f36Michael Kolb @Override 6648233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onOptionsMenuOpened() { 6658233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6668233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6678233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6688233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onExtendedMenuOpened() { 6698233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6708233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6718233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6728233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onOptionsMenuClosed(boolean inLoad) { 6738233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6748233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6758233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6768233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onExtendedMenuClosed(boolean inLoad) { 6778233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6788233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6798233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6808233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onContextMenuCreated(Menu menu) { 6818233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6828233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6838233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6848233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onContextMenuClosed(Menu menu, boolean inLoad) { 6858233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6868233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6878233facddcc51865d612a919d450db6954aa48e3Michael Kolb // error console 6888233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6898233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6908233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void setShouldShowErrorConsole(Tab tab, boolean flag) { 6919fcefd19ee20ec9f792ddc84be9a871550e82997Michael Kolb if (tab == null) return; 6928233facddcc51865d612a919d450db6954aa48e3Michael Kolb ErrorConsoleView errorConsole = tab.getErrorConsole(true); 6938233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (flag) { 6948233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Setting the show state of the console will cause it's the layout 6958233facddcc51865d612a919d450db6954aa48e3Michael Kolb // to be inflated. 6968233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (errorConsole.numberOfErrors() > 0) { 6978233facddcc51865d612a919d450db6954aa48e3Michael Kolb errorConsole.showConsole(ErrorConsoleView.SHOW_MINIMIZED); 6988233facddcc51865d612a919d450db6954aa48e3Michael Kolb } else { 6998233facddcc51865d612a919d450db6954aa48e3Michael Kolb errorConsole.showConsole(ErrorConsoleView.SHOW_NONE); 7008233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7018233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (errorConsole.getParent() != null) { 7028233facddcc51865d612a919d450db6954aa48e3Michael Kolb mErrorConsoleContainer.removeView(errorConsole); 7038233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7048233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Now we can add it to the main view. 7058233facddcc51865d612a919d450db6954aa48e3Michael Kolb mErrorConsoleContainer.addView(errorConsole, 7068233facddcc51865d612a919d450db6954aa48e3Michael Kolb new LinearLayout.LayoutParams( 7078233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup.LayoutParams.MATCH_PARENT, 7088233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup.LayoutParams.WRAP_CONTENT)); 7098233facddcc51865d612a919d450db6954aa48e3Michael Kolb } else { 7108233facddcc51865d612a919d450db6954aa48e3Michael Kolb mErrorConsoleContainer.removeView(errorConsole); 7118233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7128233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7138233facddcc51865d612a919d450db6954aa48e3Michael Kolb 7148233facddcc51865d612a919d450db6954aa48e3Michael Kolb private void setStatusBarVisibility(boolean visible) { 715d3bf86fd84f4f1a75cc9cd26f818ae157c806d9bJoe Onorato WindowManager.LayoutParams params = mActivity.getWindow().getAttributes(); 716d3bf86fd84f4f1a75cc9cd26f818ae157c806d9bJoe Onorato params.systemUiVisibility = visible ? View.STATUS_BAR_VISIBLE : View.STATUS_BAR_HIDDEN; 717d3bf86fd84f4f1a75cc9cd26f818ae157c806d9bJoe Onorato mActivity.getWindow().setAttributes(params); 7188233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7198233facddcc51865d612a919d450db6954aa48e3Michael Kolb 7208233facddcc51865d612a919d450db6954aa48e3Michael Kolb // ------------------------------------------------------------------------- 7218233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Helper function for WebChromeClient 7228233facddcc51865d612a919d450db6954aa48e3Michael Kolb // ------------------------------------------------------------------------- 7238233facddcc51865d612a919d450db6954aa48e3Michael Kolb 7248233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 7258233facddcc51865d612a919d450db6954aa48e3Michael Kolb public Bitmap getDefaultVideoPoster() { 7268233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mDefaultVideoPoster == null) { 7278233facddcc51865d612a919d450db6954aa48e3Michael Kolb mDefaultVideoPoster = BitmapFactory.decodeResource( 7288233facddcc51865d612a919d450db6954aa48e3Michael Kolb mActivity.getResources(), R.drawable.default_video_poster); 7298233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7308233facddcc51865d612a919d450db6954aa48e3Michael Kolb return mDefaultVideoPoster; 7318233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7328233facddcc51865d612a919d450db6954aa48e3Michael Kolb 7338233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 7348233facddcc51865d612a919d450db6954aa48e3Michael Kolb public View getVideoLoadingProgressView() { 7358233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mVideoProgressView == null) { 7368233facddcc51865d612a919d450db6954aa48e3Michael Kolb LayoutInflater inflater = LayoutInflater.from(mActivity); 7378233facddcc51865d612a919d450db6954aa48e3Michael Kolb mVideoProgressView = inflater.inflate( 7388233facddcc51865d612a919d450db6954aa48e3Michael Kolb R.layout.video_loading_progress, null); 7398233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7408233facddcc51865d612a919d450db6954aa48e3Michael Kolb return mVideoProgressView; 7418233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7428233facddcc51865d612a919d450db6954aa48e3Michael Kolb 743843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb @Override 744843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb public void showMaxTabsWarning() { 745843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb Toast warning = Toast.makeText(mActivity, 746843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb mActivity.getString(R.string.max_tabs_warning), 747843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb Toast.LENGTH_SHORT); 748843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb warning.show(); 749843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb } 750843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb 7518233facddcc51865d612a919d450db6954aa48e3Michael Kolb} 752