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 | |
Bijan Amirzada | 41242f2 | 2014-03-21 12:12:18 -0700 | [diff] [blame] | 17 | package com.android.browser; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 18 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 19 | import android.app.Activity; |
Michael Kolb | 53ed62c | 2011-10-04 16:18:44 -0700 | [diff] [blame] | 20 | import android.content.Context; |
John Reck | d3e4d5b | 2011-07-13 15:48:43 -0700 | [diff] [blame] | 21 | import android.content.Intent; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 22 | import android.content.res.Configuration; |
| 23 | import android.content.res.Resources; |
| 24 | import android.graphics.Bitmap; |
| 25 | import android.graphics.BitmapFactory; |
Michael Kolb | 5a4372f | 2011-04-29 13:53:10 -0700 | [diff] [blame] | 26 | import android.graphics.Color; |
| 27 | import android.graphics.drawable.BitmapDrawable; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 28 | import android.graphics.drawable.Drawable; |
Michael Kolb | 5a4372f | 2011-04-29 13:53:10 -0700 | [diff] [blame] | 29 | import android.graphics.drawable.LayerDrawable; |
| 30 | import android.graphics.drawable.PaintDrawable; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 31 | import android.os.Bundle; |
John Reck | 5d43ce8 | 2011-06-21 17:16:51 -0700 | [diff] [blame] | 32 | import android.os.Handler; |
| 33 | import android.os.Message; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 34 | import android.text.TextUtils; |
Bijan Amirzada | 357ec8a | 2014-04-08 14:19:10 -0700 | [diff] [blame] | 35 | import android.view.ActionMode; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 36 | import android.view.Gravity; |
| 37 | import android.view.LayoutInflater; |
| 38 | import android.view.Menu; |
Michael Kolb | 3ca1275 | 2011-07-20 13:52:25 -0700 | [diff] [blame] | 39 | import android.view.MenuItem; |
Michael Kolb | 31065b1 | 2011-10-06 13:51:32 -0700 | [diff] [blame] | 40 | import android.view.MotionEvent; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 41 | import android.view.View; |
Michael Kolb | 1514bb7 | 2010-11-22 09:11:48 -0800 | [diff] [blame] | 42 | import android.view.View.OnClickListener; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 43 | import android.view.ViewGroup; |
Michael Kolb | 1514bb7 | 2010-11-22 09:11:48 -0800 | [diff] [blame] | 44 | import android.view.ViewGroup.LayoutParams; |
Michael Kolb | c5675ad | 2011-10-21 13:34:28 -0700 | [diff] [blame] | 45 | import android.view.Window; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 46 | import android.view.WindowManager; |
Michael Kolb | 3a69628 | 2010-12-05 13:23:24 -0800 | [diff] [blame] | 47 | import android.view.inputmethod.InputMethodManager; |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 48 | import android.webkit.WebChromeClient.CustomViewCallback; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 49 | import android.widget.FrameLayout; |
Michael Kolb | 1514bb7 | 2010-11-22 09:11:48 -0800 | [diff] [blame] | 50 | import android.widget.ImageButton; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 51 | import android.widget.LinearLayout; |
| 52 | import android.widget.Toast; |
| 53 | |
Bijan Amirzada | 41242f2 | 2014-03-21 12:12:18 -0700 | [diff] [blame] | 54 | import com.android.browser.R; |
| 55 | import com.android.browser.Tab.SecurityState; |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 56 | |
| 57 | import org.codeaurora.swe.WebView; |
John Reck | bf2ec20 | 2011-06-29 17:47:38 -0700 | [diff] [blame] | 58 | |
Michael Kolb | 1bf2313 | 2010-11-19 12:55:12 -0800 | [diff] [blame] | 59 | import java.util.List; |
| 60 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 61 | /** |
| 62 | * UI interface definitions |
| 63 | */ |
John Reck | 718a24d | 2011-08-12 11:08:30 -0700 | [diff] [blame] | 64 | public abstract class BaseUi implements UI { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 65 | |
| 66 | private static final String LOGTAG = "BaseUi"; |
| 67 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 68 | protected static final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 69 | new FrameLayout.LayoutParams( |
| 70 | ViewGroup.LayoutParams.MATCH_PARENT, |
| 71 | ViewGroup.LayoutParams.MATCH_PARENT); |
| 72 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 73 | protected static final FrameLayout.LayoutParams COVER_SCREEN_GRAVITY_CENTER = |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 74 | new FrameLayout.LayoutParams( |
| 75 | ViewGroup.LayoutParams.MATCH_PARENT, |
| 76 | ViewGroup.LayoutParams.MATCH_PARENT, |
| 77 | Gravity.CENTER); |
| 78 | |
John Reck | 5d43ce8 | 2011-06-21 17:16:51 -0700 | [diff] [blame] | 79 | private static final int MSG_HIDE_TITLEBAR = 1; |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 80 | public static final int HIDE_TITLEBAR_DELAY = 1500; // in ms |
John Reck | 5d43ce8 | 2011-06-21 17:16:51 -0700 | [diff] [blame] | 81 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 82 | Activity mActivity; |
| 83 | UiController mUiController; |
| 84 | TabControl mTabControl; |
Michael Kolb | 377ea31 | 2011-02-17 14:36:56 -0800 | [diff] [blame] | 85 | protected Tab mActiveTab; |
Michael Kolb | 3a69628 | 2010-12-05 13:23:24 -0800 | [diff] [blame] | 86 | private InputMethodManager mInputManager; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 87 | |
Steve Block | 2466eff | 2011-10-03 15:33:09 +0100 | [diff] [blame] | 88 | private Drawable mLockIconSecure; |
| 89 | private Drawable mLockIconMixed; |
Michael Kolb | 5a4372f | 2011-04-29 13:53:10 -0700 | [diff] [blame] | 90 | protected Drawable mGenericFavicon; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 91 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 92 | protected FrameLayout mContentView; |
Michael Kolb | f205560 | 2011-04-09 17:20:03 -0700 | [diff] [blame] | 93 | protected FrameLayout mCustomViewContainer; |
Michael Kolb | 31065b1 | 2011-10-06 13:51:32 -0700 | [diff] [blame] | 94 | protected FrameLayout mFullscreenContainer; |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 95 | private FrameLayout mFixedTitlebarContainer; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 96 | |
Michael Kolb | 31065b1 | 2011-10-06 13:51:32 -0700 | [diff] [blame] | 97 | private View mCustomView; |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 98 | private CustomViewCallback mCustomViewCallback; |
Derek Sollenberger | 2d4f1e2 | 2011-06-01 14:50:42 -0400 | [diff] [blame] | 99 | private int mOriginalOrientation; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 100 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 101 | private LinearLayout mErrorConsoleContainer = null; |
| 102 | |
John Reck | 718a24d | 2011-08-12 11:08:30 -0700 | [diff] [blame] | 103 | private UrlBarAutoShowManager mUrlBarAutoShowManager; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 104 | |
John Reck | 718a24d | 2011-08-12 11:08:30 -0700 | [diff] [blame] | 105 | private Toast mStopToast; |
Michael Kolb | 5a4372f | 2011-04-29 13:53:10 -0700 | [diff] [blame] | 106 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 107 | // the default <video> poster |
| 108 | private Bitmap mDefaultVideoPoster; |
| 109 | // the video progress view |
| 110 | private View mVideoProgressView; |
| 111 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 112 | private boolean mActivityPaused; |
John Reck | bf2ec20 | 2011-06-29 17:47:38 -0700 | [diff] [blame] | 113 | protected boolean mUseQuickControls; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 114 | protected TitleBar mTitleBar; |
| 115 | private NavigationBarBase mNavigationBar; |
Michael Kolb | da58063 | 2012-04-16 13:30:28 -0700 | [diff] [blame] | 116 | protected PieControl mPieControl; |
Michael Kolb | bae0cb2 | 2012-05-29 11:15:27 -0700 | [diff] [blame] | 117 | private boolean mBlockFocusAnimations; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 118 | |
| 119 | public BaseUi(Activity browser, UiController controller) { |
| 120 | mActivity = browser; |
| 121 | mUiController = controller; |
| 122 | mTabControl = controller.getTabControl(); |
| 123 | Resources res = mActivity.getResources(); |
Michael Kolb | 3a69628 | 2010-12-05 13:23:24 -0800 | [diff] [blame] | 124 | mInputManager = (InputMethodManager) |
| 125 | browser.getSystemService(Activity.INPUT_METHOD_SERVICE); |
Steve Block | 2466eff | 2011-10-03 15:33:09 +0100 | [diff] [blame] | 126 | mLockIconSecure = res.getDrawable(R.drawable.ic_secure_holo_dark); |
| 127 | mLockIconMixed = res.getDrawable(R.drawable.ic_secure_partial_holo_dark); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 128 | FrameLayout frameLayout = (FrameLayout) mActivity.getWindow() |
| 129 | .getDecorView().findViewById(android.R.id.content); |
John Reck | 7c6e1c9 | 2011-06-30 11:55:55 -0700 | [diff] [blame] | 130 | LayoutInflater.from(mActivity) |
| 131 | .inflate(R.layout.custom_screen, frameLayout); |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 132 | mFixedTitlebarContainer = (FrameLayout) frameLayout.findViewById( |
| 133 | R.id.fixed_titlebar_container); |
John Reck | 7c6e1c9 | 2011-06-30 11:55:55 -0700 | [diff] [blame] | 134 | mContentView = (FrameLayout) frameLayout.findViewById( |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 135 | R.id.main_content); |
Michael Kolb | 53ed62c | 2011-10-04 16:18:44 -0700 | [diff] [blame] | 136 | mCustomViewContainer = (FrameLayout) frameLayout.findViewById( |
| 137 | R.id.fullscreen_custom_content); |
John Reck | 7c6e1c9 | 2011-06-30 11:55:55 -0700 | [diff] [blame] | 138 | mErrorConsoleContainer = (LinearLayout) frameLayout |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 139 | .findViewById(R.id.error_console); |
Michael Kolb | c38c604 | 2011-04-27 10:46:06 -0700 | [diff] [blame] | 140 | setFullscreen(BrowserSettings.getInstance().useFullscreen()); |
Michael Kolb | 5a4372f | 2011-04-29 13:53:10 -0700 | [diff] [blame] | 141 | mGenericFavicon = res.getDrawable( |
| 142 | R.drawable.app_web_browser_sm); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 143 | mTitleBar = new TitleBar(mActivity, mUiController, this, |
| 144 | mContentView); |
| 145 | mTitleBar.setProgress(100); |
| 146 | mNavigationBar = mTitleBar.getNavigationBar(); |
John Reck | 718a24d | 2011-08-12 11:08:30 -0700 | [diff] [blame] | 147 | mUrlBarAutoShowManager = new UrlBarAutoShowManager(this); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 148 | } |
| 149 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 150 | private void cancelStopToast() { |
| 151 | if (mStopToast != null) { |
| 152 | mStopToast.cancel(); |
| 153 | mStopToast = null; |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | // lifecycle |
| 158 | |
| 159 | public void onPause() { |
Michael Kolb | 7a5cf47 | 2010-11-30 13:23:53 -0800 | [diff] [blame] | 160 | if (isCustomViewShowing()) { |
| 161 | onHideCustomView(); |
| 162 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 163 | cancelStopToast(); |
| 164 | mActivityPaused = true; |
| 165 | } |
| 166 | |
| 167 | public void onResume() { |
| 168 | mActivityPaused = false; |
Michael Kolb | 2ae6ef7 | 2011-08-22 14:49:34 -0700 | [diff] [blame] | 169 | // check if we exited without setting active tab |
| 170 | // b: 5188145 |
Michael Kolb | 1a4625a | 2011-08-24 13:40:44 -0700 | [diff] [blame] | 171 | final Tab ct = mTabControl.getCurrentTab(); |
| 172 | if (ct != null) { |
| 173 | setActiveTab(ct); |
| 174 | } |
John Reck | 1cc1d1d | 2012-09-04 18:13:51 -0700 | [diff] [blame] | 175 | mTitleBar.onResume(); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 176 | } |
| 177 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 178 | protected boolean isActivityPaused() { |
| 179 | return mActivityPaused; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | public void onConfigurationChanged(Configuration config) { |
| 183 | } |
| 184 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 185 | public Activity getActivity() { |
| 186 | return mActivity; |
| 187 | } |
| 188 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 189 | // key handling |
| 190 | |
| 191 | @Override |
| 192 | public boolean onBackKey() { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 193 | if (mCustomView != null) { |
| 194 | mUiController.hideCustomView(); |
| 195 | return true; |
| 196 | } |
| 197 | return false; |
| 198 | } |
| 199 | |
Michael Kolb | 2814a36 | 2011-05-19 15:49:41 -0700 | [diff] [blame] | 200 | @Override |
| 201 | public boolean onMenuKey() { |
| 202 | return false; |
| 203 | } |
| 204 | |
Michael Kolb | da58063 | 2012-04-16 13:30:28 -0700 | [diff] [blame] | 205 | @Override |
| 206 | public void setUseQuickControls(boolean useQuickControls) { |
| 207 | mUseQuickControls = useQuickControls; |
| 208 | mTitleBar.setUseQuickControls(mUseQuickControls); |
| 209 | if (useQuickControls) { |
| 210 | mPieControl = new PieControl(mActivity, mUiController, this); |
| 211 | mPieControl.attachToContainer(mContentView); |
| 212 | } else { |
| 213 | if (mPieControl != null) { |
| 214 | mPieControl.removeFromContainer(mContentView); |
| 215 | } |
| 216 | } |
| 217 | updateUrlBarAutoShowManagerTarget(); |
| 218 | } |
| 219 | |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 220 | // Tab callbacks |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 221 | @Override |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 222 | public void onTabDataChanged(Tab tab) { |
| 223 | setUrlTitle(tab); |
| 224 | setFavicon(tab); |
| 225 | updateLockIconToLatest(tab); |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 226 | updateNavigationState(tab); |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 227 | mTitleBar.onTabDataChanged(tab); |
John Reck | 419f6b4 | 2011-08-16 16:10:51 -0700 | [diff] [blame] | 228 | mNavigationBar.onTabDataChanged(tab); |
Michael Kolb | a53c989 | 2011-10-05 13:31:40 -0700 | [diff] [blame] | 229 | onProgressChanged(tab); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | @Override |
Michael Kolb | e8a8233 | 2012-04-25 14:14:26 -0700 | [diff] [blame] | 233 | public void onProgressChanged(Tab tab) { |
| 234 | int progress = tab.getLoadProgress(); |
| 235 | if (tab.inForeground()) { |
| 236 | mTitleBar.setProgress(progress); |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | @Override |
Leon Scroggins | 4cd9779 | 2010-12-03 15:31:56 -0500 | [diff] [blame] | 241 | public void bookmarkedStatusHasChanged(Tab tab) { |
John Reck | 94b7e04 | 2011-02-15 15:02:33 -0800 | [diff] [blame] | 242 | if (tab.inForeground()) { |
| 243 | boolean isBookmark = tab.isBookmarkedSite(); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 244 | mNavigationBar.setCurrentUrlIsBookmark(isBookmark); |
John Reck | 94b7e04 | 2011-02-15 15:02:33 -0800 | [diff] [blame] | 245 | } |
Leon Scroggins | 4cd9779 | 2010-12-03 15:31:56 -0500 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | @Override |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 249 | public void onPageStopped(Tab tab) { |
| 250 | cancelStopToast(); |
| 251 | if (tab.inForeground()) { |
| 252 | mStopToast = Toast |
| 253 | .makeText(mActivity, R.string.stopping, Toast.LENGTH_SHORT); |
| 254 | mStopToast.show(); |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | @Override |
Michael Kolb | 1bf2313 | 2010-11-19 12:55:12 -0800 | [diff] [blame] | 259 | public boolean needsRestoreAllTabs() { |
John Reck | 847b532 | 2011-04-14 17:02:18 -0700 | [diff] [blame] | 260 | return true; |
Michael Kolb | 1bf2313 | 2010-11-19 12:55:12 -0800 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | @Override |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 264 | public void addTab(Tab tab) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | @Override |
Michael Kolb | 377ea31 | 2011-02-17 14:36:56 -0800 | [diff] [blame] | 268 | public void setActiveTab(final Tab tab) { |
Michael Kolb | 7ac63b6 | 2011-12-16 09:52:29 -0800 | [diff] [blame] | 269 | if (tab == null) return; |
Matthew Hui | b7f2e9c | 2014-04-16 11:12:37 -0400 | [diff] [blame] | 270 | Tab tabToRemove = null; |
Vivek Sekhar | 943f067 | 2014-05-01 18:35:22 -0700 | [diff] [blame] | 271 | Tab tabToWaitFor = null; |
Matthew Hui | b7f2e9c | 2014-04-16 11:12:37 -0400 | [diff] [blame] | 272 | |
Michael Kolb | bae0cb2 | 2012-05-29 11:15:27 -0700 | [diff] [blame] | 273 | // block unnecessary focus change animations during tab switch |
| 274 | mBlockFocusAnimations = true; |
John Reck | 5d43ce8 | 2011-06-21 17:16:51 -0700 | [diff] [blame] | 275 | mHandler.removeMessages(MSG_HIDE_TITLEBAR); |
Michael Kolb | 77df456 | 2010-11-19 14:49:34 -0800 | [diff] [blame] | 276 | if ((tab != mActiveTab) && (mActiveTab != null)) { |
Matthew Hui | b7f2e9c | 2014-04-16 11:12:37 -0400 | [diff] [blame] | 277 | tabToRemove = mActiveTab; |
John Reck | bf2ec20 | 2011-06-29 17:47:38 -0700 | [diff] [blame] | 278 | WebView web = mActiveTab.getWebView(); |
| 279 | if (web != null) { |
| 280 | web.setOnTouchListener(null); |
| 281 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 282 | } |
Michael Kolb | 77df456 | 2010-11-19 14:49:34 -0800 | [diff] [blame] | 283 | mActiveTab = tab; |
Michael Kolb | da58063 | 2012-04-16 13:30:28 -0700 | [diff] [blame] | 284 | BrowserWebView web = (BrowserWebView) mActiveTab.getWebView(); |
John Reck | 718a24d | 2011-08-12 11:08:30 -0700 | [diff] [blame] | 285 | updateUrlBarAutoShowManagerTarget(); |
John Reck | 5d43ce8 | 2011-06-21 17:16:51 -0700 | [diff] [blame] | 286 | attachTabToContentView(tab); |
Michael Kolb | da58063 | 2012-04-16 13:30:28 -0700 | [diff] [blame] | 287 | if (web != null) { |
| 288 | // Request focus on the top window. |
| 289 | if (mUseQuickControls) { |
| 290 | mPieControl.forceToTop(mContentView); |
| 291 | web.setTitleBar(null); |
Michael Kolb | e8a8233 | 2012-04-25 14:14:26 -0700 | [diff] [blame] | 292 | mTitleBar.hide(); |
Michael Kolb | da58063 | 2012-04-16 13:30:28 -0700 | [diff] [blame] | 293 | } else { |
| 294 | web.setTitleBar(mTitleBar); |
| 295 | mTitleBar.onScrollChanged(); |
| 296 | } |
Vivek Sekhar | 943f067 | 2014-05-01 18:35:22 -0700 | [diff] [blame] | 297 | tabToWaitFor = mActiveTab; |
Michael Kolb | da58063 | 2012-04-16 13:30:28 -0700 | [diff] [blame] | 298 | } |
Michael Kolb | 4923c22 | 2012-04-02 16:18:36 -0700 | [diff] [blame] | 299 | mTitleBar.bringToFront(); |
Michael Kolb | f896352 | 2012-04-10 10:52:34 -0700 | [diff] [blame] | 300 | tab.getTopWindow().requestFocus(); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 301 | setShouldShowErrorConsole(tab, mUiController.shouldShowErrorConsole()); |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 302 | onTabDataChanged(tab); |
| 303 | onProgressChanged(tab); |
Michael Kolb | 03b6bc6 | 2011-09-02 16:19:53 -0700 | [diff] [blame] | 304 | mNavigationBar.setIncognitoMode(tab.isPrivateBrowsingEnabled()); |
Michael Kolb | bae0cb2 | 2012-05-29 11:15:27 -0700 | [diff] [blame] | 305 | mBlockFocusAnimations = false; |
Matthew Hui | b7f2e9c | 2014-04-16 11:12:37 -0400 | [diff] [blame] | 306 | |
Vivek Sekhar | 943f067 | 2014-05-01 18:35:22 -0700 | [diff] [blame] | 307 | scheduleRemoveTab(tabToRemove, tabToWaitFor); |
Matthew Hui | b7f2e9c | 2014-04-16 11:12:37 -0400 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | Tab mTabToRemove = null; |
Vivek Sekhar | 943f067 | 2014-05-01 18:35:22 -0700 | [diff] [blame] | 311 | Tab mTabToWaitFor = null; |
Matthew Hui | b7f2e9c | 2014-04-16 11:12:37 -0400 | [diff] [blame] | 312 | int mNumRemoveTries = 0; |
Vivek Sekhar | 943f067 | 2014-05-01 18:35:22 -0700 | [diff] [blame] | 313 | Runnable mRunnable = null; |
Matthew Hui | b7f2e9c | 2014-04-16 11:12:37 -0400 | [diff] [blame] | 314 | |
Vivek Sekhar | 943f067 | 2014-05-01 18:35:22 -0700 | [diff] [blame] | 315 | protected void scheduleRemoveTab(Tab tabToRemove, Tab tabToWaitFor) { |
Matthew Hui | b7f2e9c | 2014-04-16 11:12:37 -0400 | [diff] [blame] | 316 | //remove previously scehduled tab |
| 317 | if (mTabToRemove != null) { |
Vivek Sekhar | 943f067 | 2014-05-01 18:35:22 -0700 | [diff] [blame] | 318 | if (mRunnable != null) |
Axesh R. Ajmera | 2e24124 | 2014-05-19 15:53:38 -0700 | [diff] [blame^] | 319 | mTitleBar.removeCallbacks(mRunnable); |
Matthew Hui | b7f2e9c | 2014-04-16 11:12:37 -0400 | [diff] [blame] | 320 | removeTabFromContentView(mTabToRemove); |
| 321 | mTabToRemove.performPostponedDestroy(); |
Vivek Sekhar | 943f067 | 2014-05-01 18:35:22 -0700 | [diff] [blame] | 322 | mRunnable = null; |
Matthew Hui | b7f2e9c | 2014-04-16 11:12:37 -0400 | [diff] [blame] | 323 | } |
Vivek Sekhar | 943f067 | 2014-05-01 18:35:22 -0700 | [diff] [blame] | 324 | mTabToRemove = tabToRemove; |
| 325 | mTabToWaitFor = tabToWaitFor; |
Matthew Hui | b7f2e9c | 2014-04-16 11:12:37 -0400 | [diff] [blame] | 326 | mNumRemoveTries = 0; |
| 327 | |
| 328 | if (mTabToRemove != null) { |
| 329 | mTabToRemove.postponeDestroy(); |
Vivek Sekhar | 943f067 | 2014-05-01 18:35:22 -0700 | [diff] [blame] | 330 | tryRemoveTab(); |
Matthew Hui | b7f2e9c | 2014-04-16 11:12:37 -0400 | [diff] [blame] | 331 | } |
| 332 | } |
| 333 | |
| 334 | protected void tryRemoveTab() { |
| 335 | mNumRemoveTries++; |
Vivek Sekhar | 943f067 | 2014-05-01 18:35:22 -0700 | [diff] [blame] | 336 | // Ensure the webview is still valid |
| 337 | if (mNumRemoveTries < 20 && mTabToWaitFor.getWebView() != null) { |
| 338 | if (!mTabToWaitFor.getWebView().isReady()) { |
Axesh R. Ajmera | 2e24124 | 2014-05-19 15:53:38 -0700 | [diff] [blame^] | 339 | if (mRunnable == null) { |
Vivek Sekhar | 943f067 | 2014-05-01 18:35:22 -0700 | [diff] [blame] | 340 | mRunnable = new Runnable() { |
| 341 | public void run() { |
| 342 | tryRemoveTab(); |
| 343 | } |
| 344 | }; |
| 345 | } |
| 346 | /*if the new tab is still not ready, wait another 2 frames |
| 347 | before trying again. 1 frame for the tab to render the first |
| 348 | frame, another 1 frame to make sure the swap is done*/ |
Axesh R. Ajmera | 2e24124 | 2014-05-19 15:53:38 -0700 | [diff] [blame^] | 349 | mTitleBar.postDelayed(mRunnable, 33); |
Matthew Hui | b7f2e9c | 2014-04-16 11:12:37 -0400 | [diff] [blame] | 350 | return; |
| 351 | } |
| 352 | } |
| 353 | if (mTabToRemove != null) { |
Vivek Sekhar | 943f067 | 2014-05-01 18:35:22 -0700 | [diff] [blame] | 354 | if (mRunnable != null) |
Axesh R. Ajmera | 2e24124 | 2014-05-19 15:53:38 -0700 | [diff] [blame^] | 355 | mTitleBar.removeCallbacks(mRunnable); |
Matthew Hui | b7f2e9c | 2014-04-16 11:12:37 -0400 | [diff] [blame] | 356 | removeTabFromContentView(mTabToRemove); |
| 357 | mTabToRemove.performPostponedDestroy(); |
Vivek Sekhar | 943f067 | 2014-05-01 18:35:22 -0700 | [diff] [blame] | 358 | mRunnable = null; |
Matthew Hui | b7f2e9c | 2014-04-16 11:12:37 -0400 | [diff] [blame] | 359 | } |
| 360 | mTabToRemove = null; |
Vivek Sekhar | 943f067 | 2014-05-01 18:35:22 -0700 | [diff] [blame] | 361 | mTabToWaitFor = null; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 362 | } |
| 363 | |
John Reck | 718a24d | 2011-08-12 11:08:30 -0700 | [diff] [blame] | 364 | protected void updateUrlBarAutoShowManagerTarget() { |
| 365 | WebView web = mActiveTab != null ? mActiveTab.getWebView() : null; |
| 366 | if (!mUseQuickControls && web instanceof BrowserWebView) { |
| 367 | mUrlBarAutoShowManager.setTarget((BrowserWebView) web); |
| 368 | } else { |
| 369 | mUrlBarAutoShowManager.setTarget(null); |
| 370 | } |
| 371 | } |
| 372 | |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 373 | Tab getActiveTab() { |
| 374 | return mActiveTab; |
| 375 | } |
| 376 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 377 | @Override |
Michael Kolb | 1bf2313 | 2010-11-19 12:55:12 -0800 | [diff] [blame] | 378 | public void updateTabs(List<Tab> tabs) { |
Michael Kolb | 1bf2313 | 2010-11-19 12:55:12 -0800 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | @Override |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 382 | public void removeTab(Tab tab) { |
Michael Kolb | 77df456 | 2010-11-19 14:49:34 -0800 | [diff] [blame] | 383 | if (mActiveTab == tab) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 384 | removeTabFromContentView(tab); |
Michael Kolb | 77df456 | 2010-11-19 14:49:34 -0800 | [diff] [blame] | 385 | mActiveTab = null; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 386 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 387 | } |
| 388 | |
| 389 | @Override |
| 390 | public void detachTab(Tab tab) { |
| 391 | removeTabFromContentView(tab); |
| 392 | } |
| 393 | |
| 394 | @Override |
| 395 | public void attachTab(Tab tab) { |
| 396 | attachTabToContentView(tab); |
| 397 | } |
| 398 | |
Michael Kolb | 377ea31 | 2011-02-17 14:36:56 -0800 | [diff] [blame] | 399 | protected void attachTabToContentView(Tab tab) { |
Michael Kolb | d1e2ccc | 2011-01-24 11:38:31 -0800 | [diff] [blame] | 400 | if ((tab == null) || (tab.getWebView() == null)) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 401 | return; |
| 402 | } |
| 403 | View container = tab.getViewContainer(); |
| 404 | WebView mainView = tab.getWebView(); |
| 405 | // Attach the WebView to the container and then attach the |
| 406 | // container to the content view. |
| 407 | FrameLayout wrapper = |
| 408 | (FrameLayout) container.findViewById(R.id.webview_wrapper); |
| 409 | ViewGroup parent = (ViewGroup) mainView.getParent(); |
| 410 | if (parent != wrapper) { |
| 411 | if (parent != null) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 412 | parent.removeView(mainView); |
| 413 | } |
| 414 | wrapper.addView(mainView); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 415 | } |
| 416 | parent = (ViewGroup) container.getParent(); |
| 417 | if (parent != mContentView) { |
| 418 | if (parent != null) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 419 | parent.removeView(container); |
| 420 | } |
| 421 | mContentView.addView(container, COVER_SCREEN_PARAMS); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 422 | } |
| 423 | mUiController.attachSubWindow(tab); |
| 424 | } |
| 425 | |
| 426 | private void removeTabFromContentView(Tab tab) { |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 427 | hideTitleBar(); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 428 | // Remove the container that contains the main WebView. |
| 429 | WebView mainView = tab.getWebView(); |
| 430 | View container = tab.getViewContainer(); |
| 431 | if (mainView == null) { |
| 432 | return; |
| 433 | } |
| 434 | // Remove the container from the content and then remove the |
| 435 | // WebView from the container. This will trigger a focus change |
| 436 | // needed by WebView. |
| 437 | FrameLayout wrapper = |
| 438 | (FrameLayout) container.findViewById(R.id.webview_wrapper); |
| 439 | wrapper.removeView(mainView); |
| 440 | mContentView.removeView(container); |
| 441 | mUiController.endActionMode(); |
| 442 | mUiController.removeSubWindow(tab); |
| 443 | ErrorConsoleView errorConsole = tab.getErrorConsole(false); |
| 444 | if (errorConsole != null) { |
| 445 | mErrorConsoleContainer.removeView(errorConsole); |
| 446 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 447 | } |
| 448 | |
Michael Kolb | a713ec8 | 2010-11-29 17:27:06 -0800 | [diff] [blame] | 449 | @Override |
| 450 | public void onSetWebView(Tab tab, WebView webView) { |
| 451 | View container = tab.getViewContainer(); |
| 452 | if (container == null) { |
| 453 | // The tab consists of a container view, which contains the main |
| 454 | // WebView, as well as any other UI elements associated with the tab. |
| 455 | container = mActivity.getLayoutInflater().inflate(R.layout.tab, |
John Reck | 7c6e1c9 | 2011-06-30 11:55:55 -0700 | [diff] [blame] | 456 | mContentView, false); |
Michael Kolb | a713ec8 | 2010-11-29 17:27:06 -0800 | [diff] [blame] | 457 | tab.setViewContainer(container); |
| 458 | } |
| 459 | if (tab.getWebView() != webView) { |
| 460 | // Just remove the old one. |
| 461 | FrameLayout wrapper = |
| 462 | (FrameLayout) container.findViewById(R.id.webview_wrapper); |
| 463 | wrapper.removeView(tab.getWebView()); |
| 464 | } |
| 465 | } |
| 466 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 467 | /** |
Michael Kolb | 1514bb7 | 2010-11-22 09:11:48 -0800 | [diff] [blame] | 468 | * create a sub window container and webview for the tab |
| 469 | * Note: this methods operates through side-effects for now |
| 470 | * it sets both the subView and subViewContainer for the given tab |
| 471 | * @param tab tab to create the sub window for |
| 472 | * @param subView webview to be set as a subwindow for the tab |
| 473 | */ |
| 474 | @Override |
| 475 | public void createSubWindow(Tab tab, WebView subView) { |
| 476 | View subViewContainer = mActivity.getLayoutInflater().inflate( |
| 477 | R.layout.browser_subwindow, null); |
| 478 | ViewGroup inner = (ViewGroup) subViewContainer |
| 479 | .findViewById(R.id.inner_container); |
| 480 | inner.addView(subView, new LayoutParams(LayoutParams.MATCH_PARENT, |
| 481 | LayoutParams.MATCH_PARENT)); |
| 482 | final ImageButton cancel = (ImageButton) subViewContainer |
| 483 | .findViewById(R.id.subwindow_close); |
| 484 | final WebView cancelSubView = subView; |
| 485 | cancel.setOnClickListener(new OnClickListener() { |
Jonathan Dixon | e1d6dfc | 2012-12-17 13:39:17 -0800 | [diff] [blame] | 486 | @Override |
Michael Kolb | 1514bb7 | 2010-11-22 09:11:48 -0800 | [diff] [blame] | 487 | public void onClick(View v) { |
Jonathan Dixon | e1d6dfc | 2012-12-17 13:39:17 -0800 | [diff] [blame] | 488 | ((BrowserWebView) cancelSubView).getWebChromeClient().onCloseWindow(cancelSubView); |
Michael Kolb | 1514bb7 | 2010-11-22 09:11:48 -0800 | [diff] [blame] | 489 | } |
| 490 | }); |
| 491 | tab.setSubWebView(subView); |
| 492 | tab.setSubViewContainer(subViewContainer); |
| 493 | } |
| 494 | |
| 495 | /** |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 496 | * Remove the sub window from the content view. |
| 497 | */ |
| 498 | @Override |
| 499 | public void removeSubWindow(View subviewContainer) { |
| 500 | mContentView.removeView(subviewContainer); |
| 501 | mUiController.endActionMode(); |
| 502 | } |
| 503 | |
| 504 | /** |
| 505 | * Attach the sub window to the content view. |
| 506 | */ |
| 507 | @Override |
| 508 | public void attachSubWindow(View container) { |
Michael Kolb | 1514bb7 | 2010-11-22 09:11:48 -0800 | [diff] [blame] | 509 | if (container.getParent() != null) { |
| 510 | // already attached, remove first |
| 511 | ((ViewGroup) container.getParent()).removeView(container); |
| 512 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 513 | mContentView.addView(container, COVER_SCREEN_PARAMS); |
| 514 | } |
| 515 | |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 516 | protected void refreshWebView() { |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 517 | WebView web = getWebView(); |
| 518 | if (web != null) { |
| 519 | web.invalidate(); |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 520 | } |
| 521 | } |
| 522 | |
Michael Kolb | 1f9b356 | 2012-04-24 14:38:34 -0700 | [diff] [blame] | 523 | public void editUrl(boolean clearInput, boolean forceIME) { |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 524 | if (mUiController.isInCustomActionMode()) { |
| 525 | mUiController.endActionMode(); |
| 526 | } |
| 527 | showTitleBar(); |
Michael Kolb | ace2ff8 | 2011-08-12 13:36:07 -0700 | [diff] [blame] | 528 | if ((getActiveTab() != null) && !getActiveTab().isSnapshot()) { |
Michael Kolb | 1f9b356 | 2012-04-24 14:38:34 -0700 | [diff] [blame] | 529 | mNavigationBar.startEditingUrl(clearInput, forceIME); |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 530 | } |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 531 | } |
| 532 | |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 533 | boolean canShowTitleBar() { |
| 534 | return !isTitleBarShowing() |
| 535 | && !isActivityPaused() |
| 536 | && (getActiveTab() != null) |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 537 | && (getWebView() != null) |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 538 | && !mUiController.isInCustomActionMode(); |
| 539 | } |
| 540 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 541 | protected void showTitleBar() { |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 542 | mHandler.removeMessages(MSG_HIDE_TITLEBAR); |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 543 | if (canShowTitleBar()) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 544 | mTitleBar.show(); |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 545 | } |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 546 | } |
| 547 | |
| 548 | protected void hideTitleBar() { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 549 | if (mTitleBar.isShowing()) { |
| 550 | mTitleBar.hide(); |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 551 | } |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 552 | } |
| 553 | |
| 554 | protected boolean isTitleBarShowing() { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 555 | return mTitleBar.isShowing(); |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 556 | } |
| 557 | |
John Reck | 5d43ce8 | 2011-06-21 17:16:51 -0700 | [diff] [blame] | 558 | public boolean isEditingUrl() { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 559 | return mTitleBar.isEditingUrl(); |
John Reck | 5d43ce8 | 2011-06-21 17:16:51 -0700 | [diff] [blame] | 560 | } |
| 561 | |
Michael Kolb | 80f7508 | 2012-04-10 10:50:06 -0700 | [diff] [blame] | 562 | public void stopEditingUrl() { |
| 563 | mTitleBar.getNavigationBar().stopEditingUrl(); |
| 564 | } |
| 565 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 566 | public TitleBar getTitleBar() { |
| 567 | return mTitleBar; |
| 568 | } |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 569 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 570 | @Override |
John Reck | 2bc8042 | 2011-06-30 15:11:49 -0700 | [diff] [blame] | 571 | public void showComboView(ComboViews startingView, Bundle extras) { |
John Reck | d3e4d5b | 2011-07-13 15:48:43 -0700 | [diff] [blame] | 572 | Intent intent = new Intent(mActivity, ComboViewActivity.class); |
| 573 | intent.putExtra(ComboViewActivity.EXTRA_INITIAL_VIEW, startingView.name()); |
| 574 | intent.putExtra(ComboViewActivity.EXTRA_COMBO_ARGS, extras); |
| 575 | Tab t = getActiveTab(); |
| 576 | if (t != null) { |
| 577 | intent.putExtra(ComboViewActivity.EXTRA_CURRENT_URL, t.getUrl()); |
John Reck | 439c9a5 | 2010-12-14 10:04:39 -0800 | [diff] [blame] | 578 | } |
John Reck | d3e4d5b | 2011-07-13 15:48:43 -0700 | [diff] [blame] | 579 | mActivity.startActivityForResult(intent, Controller.COMBO_VIEW); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | @Override |
Derek Sollenberger | 2d4f1e2 | 2011-06-01 14:50:42 -0400 | [diff] [blame] | 583 | public void showCustomView(View view, int requestedOrientation, |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 584 | CustomViewCallback callback) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 585 | // if a view already exists then immediately terminate the new one |
| 586 | if (mCustomView != null) { |
| 587 | callback.onCustomViewHidden(); |
| 588 | return; |
| 589 | } |
| 590 | |
Derek Sollenberger | 2d4f1e2 | 2011-06-01 14:50:42 -0400 | [diff] [blame] | 591 | mOriginalOrientation = mActivity.getRequestedOrientation(); |
Michael Kolb | 31065b1 | 2011-10-06 13:51:32 -0700 | [diff] [blame] | 592 | FrameLayout decor = (FrameLayout) mActivity.getWindow().getDecorView(); |
| 593 | mFullscreenContainer = new FullscreenHolder(mActivity); |
| 594 | mFullscreenContainer.addView(view, COVER_SCREEN_PARAMS); |
| 595 | decor.addView(mFullscreenContainer, COVER_SCREEN_PARAMS); |
| 596 | mCustomView = view; |
Michael Kolb | c5675ad | 2011-10-21 13:34:28 -0700 | [diff] [blame] | 597 | setFullscreen(true); |
Michael Kolb | 54217b3 | 2012-05-15 13:24:24 -0700 | [diff] [blame] | 598 | ((BrowserWebView) getWebView()).setVisibility(View.INVISIBLE); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 599 | mCustomViewCallback = callback; |
Derek Sollenberger | 2d4f1e2 | 2011-06-01 14:50:42 -0400 | [diff] [blame] | 600 | mActivity.setRequestedOrientation(requestedOrientation); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 601 | } |
| 602 | |
| 603 | @Override |
| 604 | public void onHideCustomView() { |
Michael Kolb | 54217b3 | 2012-05-15 13:24:24 -0700 | [diff] [blame] | 605 | ((BrowserWebView) getWebView()).setVisibility(View.VISIBLE); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 606 | if (mCustomView == null) |
| 607 | return; |
Michael Kolb | c5675ad | 2011-10-21 13:34:28 -0700 | [diff] [blame] | 608 | setFullscreen(false); |
Michael Kolb | 31065b1 | 2011-10-06 13:51:32 -0700 | [diff] [blame] | 609 | FrameLayout decor = (FrameLayout) mActivity.getWindow().getDecorView(); |
| 610 | decor.removeView(mFullscreenContainer); |
| 611 | mFullscreenContainer = null; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 612 | mCustomView = null; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 613 | mCustomViewCallback.onCustomViewHidden(); |
| 614 | // Show the content view. |
Derek Sollenberger | 2d4f1e2 | 2011-06-01 14:50:42 -0400 | [diff] [blame] | 615 | mActivity.setRequestedOrientation(mOriginalOrientation); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | @Override |
| 619 | public boolean isCustomViewShowing() { |
| 620 | return mCustomView != null; |
| 621 | } |
| 622 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 623 | protected void dismissIME() { |
Michael Kolb | 3a69628 | 2010-12-05 13:23:24 -0800 | [diff] [blame] | 624 | if (mInputManager.isActive()) { |
| 625 | mInputManager.hideSoftInputFromWindow(mContentView.getWindowToken(), |
| 626 | 0); |
| 627 | } |
| 628 | } |
| 629 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 630 | @Override |
John Reck | 3ba4553 | 2011-08-11 16:26:53 -0700 | [diff] [blame] | 631 | public boolean isWebShowing() { |
John Reck | d3e4d5b | 2011-07-13 15:48:43 -0700 | [diff] [blame] | 632 | return mCustomView == null; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 633 | } |
| 634 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 635 | // ------------------------------------------------------------------------- |
| 636 | |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 637 | protected void updateNavigationState(Tab tab) { |
| 638 | } |
| 639 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 640 | /** |
| 641 | * Update the lock icon to correspond to our latest state. |
| 642 | */ |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 643 | protected void updateLockIconToLatest(Tab t) { |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 644 | if (t != null && t.inForeground()) { |
Steve Block | 2466eff | 2011-10-03 15:33:09 +0100 | [diff] [blame] | 645 | updateLockIconImage(t.getSecurityState()); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 646 | } |
| 647 | } |
| 648 | |
| 649 | /** |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 650 | * Updates the lock-icon image in the title-bar. |
| 651 | */ |
Steve Block | 2466eff | 2011-10-03 15:33:09 +0100 | [diff] [blame] | 652 | private void updateLockIconImage(SecurityState securityState) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 653 | Drawable d = null; |
Steve Block | 2466eff | 2011-10-03 15:33:09 +0100 | [diff] [blame] | 654 | if (securityState == SecurityState.SECURITY_STATE_SECURE) { |
| 655 | d = mLockIconSecure; |
Steve Block | 4895b01 | 2011-10-03 16:26:46 +0100 | [diff] [blame] | 656 | } else if (securityState == SecurityState.SECURITY_STATE_MIXED |
| 657 | || securityState == SecurityState.SECURITY_STATE_BAD_CERTIFICATE) { |
| 658 | // TODO: It would be good to have different icons for insecure vs mixed content. |
| 659 | // See http://b/5403800 |
Steve Block | 2466eff | 2011-10-03 15:33:09 +0100 | [diff] [blame] | 660 | d = mLockIconMixed; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 661 | } |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 662 | mNavigationBar.setLock(d); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 663 | } |
| 664 | |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 665 | protected void setUrlTitle(Tab tab) { |
| 666 | String url = tab.getUrl(); |
| 667 | String title = tab.getTitle(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 668 | if (TextUtils.isEmpty(title)) { |
| 669 | title = url; |
Michael Kolb | 81b6f83 | 2010-12-12 12:44:27 -0800 | [diff] [blame] | 670 | } |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 671 | if (tab.inForeground()) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 672 | mNavigationBar.setDisplayTitle(url); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 673 | } |
| 674 | } |
| 675 | |
| 676 | // Set the favicon in the title bar. |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 677 | protected void setFavicon(Tab tab) { |
| 678 | if (tab.inForeground()) { |
| 679 | Bitmap icon = tab.getFavicon(); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 680 | mNavigationBar.setFavicon(icon); |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 681 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 682 | } |
| 683 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 684 | // active tabs page |
| 685 | |
| 686 | public void showActiveTabsPage() { |
| 687 | } |
| 688 | |
| 689 | /** |
| 690 | * Remove the active tabs page. |
| 691 | */ |
| 692 | public void removeActiveTabsPage() { |
| 693 | } |
| 694 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 695 | // menu handling callbacks |
| 696 | |
| 697 | @Override |
Michael Kolb | 1acef69 | 2011-03-08 14:12:06 -0800 | [diff] [blame] | 698 | public boolean onPrepareOptionsMenu(Menu menu) { |
| 699 | return true; |
| 700 | } |
| 701 | |
| 702 | @Override |
Michael Kolb | 7bdee0b | 2011-08-01 11:55:38 -0700 | [diff] [blame] | 703 | public void updateMenuState(Tab tab, Menu menu) { |
| 704 | } |
| 705 | |
| 706 | @Override |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 707 | public void onOptionsMenuOpened() { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 708 | } |
| 709 | |
| 710 | @Override |
| 711 | public void onExtendedMenuOpened() { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 712 | } |
| 713 | |
| 714 | @Override |
Michael Kolb | 3ca1275 | 2011-07-20 13:52:25 -0700 | [diff] [blame] | 715 | public boolean onOptionsItemSelected(MenuItem item) { |
| 716 | return false; |
| 717 | } |
| 718 | |
| 719 | @Override |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 720 | public void onOptionsMenuClosed(boolean inLoad) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 721 | } |
| 722 | |
| 723 | @Override |
| 724 | public void onExtendedMenuClosed(boolean inLoad) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | @Override |
| 728 | public void onContextMenuCreated(Menu menu) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 729 | } |
| 730 | |
| 731 | @Override |
| 732 | public void onContextMenuClosed(Menu menu, boolean inLoad) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 733 | } |
| 734 | |
| 735 | // error console |
| 736 | |
| 737 | @Override |
| 738 | public void setShouldShowErrorConsole(Tab tab, boolean flag) { |
Michael Kolb | 9fcefd1 | 2011-02-17 10:55:59 -0800 | [diff] [blame] | 739 | if (tab == null) return; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 740 | ErrorConsoleView errorConsole = tab.getErrorConsole(true); |
| 741 | if (flag) { |
| 742 | // Setting the show state of the console will cause it's the layout |
| 743 | // to be inflated. |
| 744 | if (errorConsole.numberOfErrors() > 0) { |
| 745 | errorConsole.showConsole(ErrorConsoleView.SHOW_MINIMIZED); |
| 746 | } else { |
| 747 | errorConsole.showConsole(ErrorConsoleView.SHOW_NONE); |
| 748 | } |
| 749 | if (errorConsole.getParent() != null) { |
| 750 | mErrorConsoleContainer.removeView(errorConsole); |
| 751 | } |
| 752 | // Now we can add it to the main view. |
| 753 | mErrorConsoleContainer.addView(errorConsole, |
| 754 | new LinearLayout.LayoutParams( |
| 755 | ViewGroup.LayoutParams.MATCH_PARENT, |
| 756 | ViewGroup.LayoutParams.WRAP_CONTENT)); |
| 757 | } else { |
| 758 | mErrorConsoleContainer.removeView(errorConsole); |
| 759 | } |
| 760 | } |
| 761 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 762 | // ------------------------------------------------------------------------- |
| 763 | // Helper function for WebChromeClient |
| 764 | // ------------------------------------------------------------------------- |
| 765 | |
| 766 | @Override |
| 767 | public Bitmap getDefaultVideoPoster() { |
| 768 | if (mDefaultVideoPoster == null) { |
| 769 | mDefaultVideoPoster = BitmapFactory.decodeResource( |
| 770 | mActivity.getResources(), R.drawable.default_video_poster); |
| 771 | } |
| 772 | return mDefaultVideoPoster; |
| 773 | } |
| 774 | |
| 775 | @Override |
| 776 | public View getVideoLoadingProgressView() { |
| 777 | if (mVideoProgressView == null) { |
| 778 | LayoutInflater inflater = LayoutInflater.from(mActivity); |
| 779 | mVideoProgressView = inflater.inflate( |
| 780 | R.layout.video_loading_progress, null); |
| 781 | } |
| 782 | return mVideoProgressView; |
| 783 | } |
| 784 | |
Michael Kolb | 843510f | 2010-12-09 10:51:49 -0800 | [diff] [blame] | 785 | @Override |
| 786 | public void showMaxTabsWarning() { |
| 787 | Toast warning = Toast.makeText(mActivity, |
| 788 | mActivity.getString(R.string.max_tabs_warning), |
| 789 | Toast.LENGTH_SHORT); |
| 790 | warning.show(); |
| 791 | } |
| 792 | |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 793 | protected WebView getWebView() { |
| 794 | if (mActiveTab != null) { |
| 795 | return mActiveTab.getWebView(); |
| 796 | } else { |
| 797 | return null; |
| 798 | } |
Michael Kolb | fdb7024 | 2011-03-24 09:41:11 -0700 | [diff] [blame] | 799 | } |
| 800 | |
Michael Kolb | c38c604 | 2011-04-27 10:46:06 -0700 | [diff] [blame] | 801 | public void setFullscreen(boolean enabled) { |
Michael Kolb | c5675ad | 2011-10-21 13:34:28 -0700 | [diff] [blame] | 802 | Window win = mActivity.getWindow(); |
| 803 | WindowManager.LayoutParams winParams = win.getAttributes(); |
Michael Kolb | 76dff39 | 2011-12-06 09:51:18 -0800 | [diff] [blame] | 804 | final int bits = WindowManager.LayoutParams.FLAG_FULLSCREEN; |
Michael Kolb | c38c604 | 2011-04-27 10:46:06 -0700 | [diff] [blame] | 805 | if (enabled) { |
Michael Kolb | c5675ad | 2011-10-21 13:34:28 -0700 | [diff] [blame] | 806 | winParams.flags |= bits; |
Michael Kolb | c38c604 | 2011-04-27 10:46:06 -0700 | [diff] [blame] | 807 | } else { |
Michael Kolb | c5675ad | 2011-10-21 13:34:28 -0700 | [diff] [blame] | 808 | winParams.flags &= ~bits; |
| 809 | if (mCustomView != null) { |
| 810 | mCustomView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); |
| 811 | } else { |
| 812 | mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); |
| 813 | } |
Michael Kolb | c38c604 | 2011-04-27 10:46:06 -0700 | [diff] [blame] | 814 | } |
Michael Kolb | c5675ad | 2011-10-21 13:34:28 -0700 | [diff] [blame] | 815 | win.setAttributes(winParams); |
Michael Kolb | c38c604 | 2011-04-27 10:46:06 -0700 | [diff] [blame] | 816 | } |
| 817 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 818 | public Drawable getFaviconDrawable(Bitmap icon) { |
Michael Kolb | 5a4372f | 2011-04-29 13:53:10 -0700 | [diff] [blame] | 819 | Drawable[] array = new Drawable[3]; |
| 820 | array[0] = new PaintDrawable(Color.BLACK); |
| 821 | PaintDrawable p = new PaintDrawable(Color.WHITE); |
| 822 | array[1] = p; |
| 823 | if (icon == null) { |
| 824 | array[2] = mGenericFavicon; |
| 825 | } else { |
| 826 | array[2] = new BitmapDrawable(icon); |
| 827 | } |
| 828 | LayerDrawable d = new LayerDrawable(array); |
| 829 | d.setLayerInset(1, 1, 1, 1, 1); |
| 830 | d.setLayerInset(2, 2, 2, 2, 2); |
| 831 | return d; |
| 832 | } |
| 833 | |
John Reck | 5d43ce8 | 2011-06-21 17:16:51 -0700 | [diff] [blame] | 834 | public boolean isLoading() { |
| 835 | return mActiveTab != null ? mActiveTab.inPageLoad() : false; |
| 836 | } |
| 837 | |
| 838 | /** |
| 839 | * Suggest to the UI that the title bar can be hidden. The UI will then |
| 840 | * decide whether or not to hide based off a number of factors, such |
| 841 | * as if the user is editing the URL bar or if the page is loading |
| 842 | */ |
| 843 | public void suggestHideTitleBar() { |
John Reck | 5889190 | 2011-08-11 17:48:53 -0700 | [diff] [blame] | 844 | if (!isLoading() && !isEditingUrl() && !mTitleBar.wantsToBeVisible() |
| 845 | && !mNavigationBar.isMenuShowing()) { |
John Reck | 5d43ce8 | 2011-06-21 17:16:51 -0700 | [diff] [blame] | 846 | hideTitleBar(); |
| 847 | } |
| 848 | } |
| 849 | |
John Reck | bc6adb4 | 2011-09-01 18:03:20 -0700 | [diff] [blame] | 850 | protected final void showTitleBarForDuration() { |
| 851 | showTitleBarForDuration(HIDE_TITLEBAR_DELAY); |
| 852 | } |
| 853 | |
| 854 | protected final void showTitleBarForDuration(long duration) { |
John Reck | 6ac5bfd | 2011-07-01 17:02:55 -0700 | [diff] [blame] | 855 | showTitleBar(); |
| 856 | Message msg = Message.obtain(mHandler, MSG_HIDE_TITLEBAR); |
John Reck | bc6adb4 | 2011-09-01 18:03:20 -0700 | [diff] [blame] | 857 | mHandler.sendMessageDelayed(msg, duration); |
John Reck | 6ac5bfd | 2011-07-01 17:02:55 -0700 | [diff] [blame] | 858 | } |
| 859 | |
John Reck | 9c5004e | 2011-10-07 16:00:12 -0700 | [diff] [blame] | 860 | protected Handler mHandler = new Handler() { |
John Reck | 5d43ce8 | 2011-06-21 17:16:51 -0700 | [diff] [blame] | 861 | |
| 862 | @Override |
| 863 | public void handleMessage(Message msg) { |
| 864 | if (msg.what == MSG_HIDE_TITLEBAR) { |
| 865 | suggestHideTitleBar(); |
| 866 | } |
John Reck | 9c5004e | 2011-10-07 16:00:12 -0700 | [diff] [blame] | 867 | BaseUi.this.handleMessage(msg); |
John Reck | 5d43ce8 | 2011-06-21 17:16:51 -0700 | [diff] [blame] | 868 | } |
| 869 | }; |
John Reck | 3ba4553 | 2011-08-11 16:26:53 -0700 | [diff] [blame] | 870 | |
John Reck | 9c5004e | 2011-10-07 16:00:12 -0700 | [diff] [blame] | 871 | protected void handleMessage(Message msg) {} |
| 872 | |
John Reck | 3ba4553 | 2011-08-11 16:26:53 -0700 | [diff] [blame] | 873 | @Override |
| 874 | public void showWeb(boolean animate) { |
| 875 | mUiController.hideCustomView(); |
| 876 | } |
| 877 | |
Michael Kolb | 31065b1 | 2011-10-06 13:51:32 -0700 | [diff] [blame] | 878 | static class FullscreenHolder extends FrameLayout { |
Michael Kolb | 53ed62c | 2011-10-04 16:18:44 -0700 | [diff] [blame] | 879 | |
Michael Kolb | 31065b1 | 2011-10-06 13:51:32 -0700 | [diff] [blame] | 880 | public FullscreenHolder(Context ctx) { |
| 881 | super(ctx); |
| 882 | setBackgroundColor(ctx.getResources().getColor(R.color.black)); |
Michael Kolb | 53ed62c | 2011-10-04 16:18:44 -0700 | [diff] [blame] | 883 | } |
| 884 | |
Michael Kolb | 31065b1 | 2011-10-06 13:51:32 -0700 | [diff] [blame] | 885 | @Override |
| 886 | public boolean onTouchEvent(MotionEvent evt) { |
| 887 | return true; |
Michael Kolb | 53ed62c | 2011-10-04 16:18:44 -0700 | [diff] [blame] | 888 | } |
Michael Kolb | 31065b1 | 2011-10-06 13:51:32 -0700 | [diff] [blame] | 889 | |
Michael Kolb | 53ed62c | 2011-10-04 16:18:44 -0700 | [diff] [blame] | 890 | } |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 891 | |
| 892 | public void addFixedTitleBar(View view) { |
| 893 | mFixedTitlebarContainer.addView(view); |
| 894 | } |
| 895 | |
| 896 | public void setContentViewMarginTop(int margin) { |
| 897 | LinearLayout.LayoutParams params = |
| 898 | (LinearLayout.LayoutParams) mContentView.getLayoutParams(); |
| 899 | if (params.topMargin != margin) { |
| 900 | params.topMargin = margin; |
| 901 | mContentView.setLayoutParams(params); |
| 902 | } |
| 903 | } |
Michael Kolb | bae0cb2 | 2012-05-29 11:15:27 -0700 | [diff] [blame] | 904 | |
| 905 | @Override |
| 906 | public boolean blockFocusAnimations() { |
| 907 | return mBlockFocusAnimations; |
| 908 | } |
| 909 | |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 910 | @Override |
| 911 | public void onVoiceResult(String result) { |
| 912 | mNavigationBar.onVoiceResult(result); |
| 913 | } |
| 914 | |
kaiyiz | bb2db87 | 2013-08-01 22:24:07 -0400 | [diff] [blame] | 915 | protected UiController getUiController() { |
| 916 | return mUiController; |
| 917 | } |
Bijan Amirzada | 357ec8a | 2014-04-08 14:19:10 -0700 | [diff] [blame] | 918 | |
| 919 | @Override |
| 920 | public void onActionModeStarted(ActionMode mode) { |
| 921 | int fixedTbarHeight = mTitleBar.isFixed() ? mTitleBar.calculateEmbeddedHeight() : 0; |
| 922 | mFixedTitlebarContainer.setY(fixedTbarHeight); |
| 923 | setContentViewMarginTop(fixedTbarHeight); |
| 924 | } |
| 925 | |
| 926 | @Override |
| 927 | public void onActionModeFinished(boolean inLoad) { |
| 928 | mFixedTitlebarContainer.setY(0); |
| 929 | setContentViewMarginTop(0); |
| 930 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 931 | } |