John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.browser; |
| 18 | |
| 19 | import android.animation.Animator; |
| 20 | import android.animation.Animator.AnimatorListener; |
| 21 | import android.animation.ObjectAnimator; |
| 22 | import android.content.Context; |
Michael Kolb | 57059a8 | 2012-04-30 14:32:03 -0700 | [diff] [blame] | 23 | import android.content.res.Configuration; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 24 | import android.content.res.Resources; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 25 | import android.view.LayoutInflater; |
| 26 | import android.view.View; |
| 27 | import android.view.ViewGroup; |
Ben Murdoch | d51bb57 | 2011-08-17 20:42:02 +0100 | [diff] [blame] | 28 | import android.view.ViewStub; |
John Reck | 1cc1d1d | 2012-09-04 18:13:51 -0700 | [diff] [blame] | 29 | import android.view.accessibility.AccessibilityManager; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 30 | import android.view.animation.Animation; |
| 31 | import android.view.animation.Animation.AnimationListener; |
| 32 | import android.view.animation.AnimationUtils; |
| 33 | import android.view.animation.DecelerateInterpolator; |
| 34 | import android.webkit.WebView; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 35 | import android.widget.FrameLayout; |
| 36 | import android.widget.RelativeLayout; |
| 37 | |
| 38 | |
| 39 | /** |
| 40 | * Base class for a title bar used by the browser. |
| 41 | */ |
| 42 | public class TitleBar extends RelativeLayout { |
| 43 | |
| 44 | private static final int PROGRESS_MAX = 100; |
| 45 | private static final float ANIM_TITLEBAR_DECELERATE = 2.5f; |
| 46 | |
| 47 | private UiController mUiController; |
| 48 | private BaseUi mBaseUi; |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 49 | private FrameLayout mContentView; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 50 | private PageProgressView mProgress; |
John Reck | 1cc1d1d | 2012-09-04 18:13:51 -0700 | [diff] [blame] | 51 | private AccessibilityManager mAccessibilityManager; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 52 | |
| 53 | private AutologinBar mAutoLogin; |
| 54 | private NavigationBarBase mNavBar; |
| 55 | private boolean mUseQuickControls; |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 56 | private SnapshotBar mSnapshotBar; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 57 | |
| 58 | //state |
| 59 | private boolean mShowing; |
| 60 | private boolean mInLoad; |
| 61 | private boolean mSkipTitleBarAnimations; |
| 62 | private Animator mTitleBarAnimator; |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 63 | private boolean mIsFixedTitleBar; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 64 | |
| 65 | public TitleBar(Context context, UiController controller, BaseUi ui, |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 66 | FrameLayout contentView) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 67 | super(context, null); |
| 68 | mUiController = controller; |
| 69 | mBaseUi = ui; |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 70 | mContentView = contentView; |
John Reck | 1cc1d1d | 2012-09-04 18:13:51 -0700 | [diff] [blame] | 71 | mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 72 | initLayout(context); |
John Reck | 0f9aaeb | 2012-05-23 14:40:19 -0700 | [diff] [blame] | 73 | setFixedTitleBar(); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | private void initLayout(Context context) { |
| 77 | LayoutInflater factory = LayoutInflater.from(context); |
| 78 | factory.inflate(R.layout.title_bar, this); |
| 79 | mProgress = (PageProgressView) findViewById(R.id.progress); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 80 | mNavBar = (NavigationBarBase) findViewById(R.id.taburlbar); |
| 81 | mNavBar.setTitleBar(this); |
Ben Murdoch | d51bb57 | 2011-08-17 20:42:02 +0100 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | private void inflateAutoLoginBar() { |
| 85 | if (mAutoLogin != null) { |
| 86 | return; |
| 87 | } |
| 88 | |
| 89 | ViewStub stub = (ViewStub) findViewById(R.id.autologin_stub); |
| 90 | mAutoLogin = (AutologinBar) stub.inflate(); |
| 91 | mAutoLogin.setTitleBar(this); |
| 92 | } |
| 93 | |
| 94 | private void inflateSnapshotBar() { |
| 95 | if (mSnapshotBar != null) { |
| 96 | return; |
| 97 | } |
| 98 | |
| 99 | ViewStub stub = (ViewStub) findViewById(R.id.snapshotbar_stub); |
| 100 | mSnapshotBar = (SnapshotBar) stub.inflate(); |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 101 | mSnapshotBar.setTitleBar(this); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 102 | } |
| 103 | |
Michael Kolb | 57059a8 | 2012-04-30 14:32:03 -0700 | [diff] [blame] | 104 | @Override |
| 105 | protected void onConfigurationChanged(Configuration config) { |
| 106 | super.onConfigurationChanged(config); |
John Reck | 0f9aaeb | 2012-05-23 14:40:19 -0700 | [diff] [blame] | 107 | setFixedTitleBar(); |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | @Override |
| 111 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
| 112 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
| 113 | if (mIsFixedTitleBar) { |
| 114 | int margin = getMeasuredHeight() - calculateEmbeddedHeight(); |
| 115 | mBaseUi.setContentViewMarginTop(-margin); |
John Reck | 0f9aaeb | 2012-05-23 14:40:19 -0700 | [diff] [blame] | 116 | } else { |
| 117 | mBaseUi.setContentViewMarginTop(0); |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 118 | } |
| 119 | } |
| 120 | |
John Reck | 0f9aaeb | 2012-05-23 14:40:19 -0700 | [diff] [blame] | 121 | private void setFixedTitleBar() { |
| 122 | boolean isFixed = !mUseQuickControls |
| 123 | && !mContext.getResources().getBoolean(R.bool.hide_title); |
John Reck | 1cc1d1d | 2012-09-04 18:13:51 -0700 | [diff] [blame] | 124 | isFixed |= mAccessibilityManager.isEnabled(); |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 125 | // If getParent() returns null, we are initializing |
| 126 | ViewGroup parent = (ViewGroup)getParent(); |
| 127 | if (mIsFixedTitleBar == isFixed && parent != null) return; |
| 128 | mIsFixedTitleBar = isFixed; |
| 129 | setSkipTitleBarAnimations(true); |
| 130 | show(); |
| 131 | setSkipTitleBarAnimations(false); |
| 132 | if (parent != null) { |
| 133 | parent.removeView(this); |
| 134 | } |
| 135 | if (mIsFixedTitleBar) { |
| 136 | mBaseUi.addFixedTitleBar(this); |
| 137 | } else { |
| 138 | mContentView.addView(this, makeLayoutParams()); |
| 139 | mBaseUi.setContentViewMarginTop(0); |
Michael Kolb | 57059a8 | 2012-04-30 14:32:03 -0700 | [diff] [blame] | 140 | } |
| 141 | } |
| 142 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 143 | public BaseUi getUi() { |
| 144 | return mBaseUi; |
| 145 | } |
| 146 | |
| 147 | public UiController getUiController() { |
| 148 | return mUiController; |
| 149 | } |
| 150 | |
| 151 | public void setUseQuickControls(boolean use) { |
| 152 | mUseQuickControls = use; |
John Reck | 0f9aaeb | 2012-05-23 14:40:19 -0700 | [diff] [blame] | 153 | setFixedTitleBar(); |
Michael Kolb | 4923c22 | 2012-04-02 16:18:36 -0700 | [diff] [blame] | 154 | if (use) { |
| 155 | this.setVisibility(View.GONE); |
| 156 | } else { |
| 157 | this.setVisibility(View.VISIBLE); |
| 158 | } |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | void setShowProgressOnly(boolean progress) { |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 162 | if (progress && !wantsToBeVisible()) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 163 | mNavBar.setVisibility(View.GONE); |
| 164 | } else { |
| 165 | mNavBar.setVisibility(View.VISIBLE); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | void setSkipTitleBarAnimations(boolean skip) { |
| 170 | mSkipTitleBarAnimations = skip; |
| 171 | } |
| 172 | |
| 173 | void setupTitleBarAnimator(Animator animator) { |
| 174 | Resources res = mContext.getResources(); |
| 175 | int duration = res.getInteger(R.integer.titlebar_animation_duration); |
| 176 | animator.setInterpolator(new DecelerateInterpolator( |
| 177 | ANIM_TITLEBAR_DECELERATE)); |
| 178 | animator.setDuration(duration); |
| 179 | } |
| 180 | |
| 181 | void show() { |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 182 | cancelTitleBarAnimation(false); |
| 183 | if (mUseQuickControls || mSkipTitleBarAnimations) { |
Michael Kolb | 4923c22 | 2012-04-02 16:18:36 -0700 | [diff] [blame] | 184 | this.setVisibility(View.VISIBLE); |
| 185 | this.setTranslationY(0); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 186 | } else { |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 187 | int visibleHeight = getVisibleTitleHeight(); |
| 188 | float startPos = (-getEmbeddedHeight() + visibleHeight); |
| 189 | if (getTranslationY() != 0) { |
| 190 | startPos = Math.max(startPos, getTranslationY()); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 191 | } |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 192 | mTitleBarAnimator = ObjectAnimator.ofFloat(this, |
| 193 | "translationY", |
| 194 | startPos, 0); |
| 195 | setupTitleBarAnimator(mTitleBarAnimator); |
| 196 | mTitleBarAnimator.start(); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 197 | } |
| 198 | mShowing = true; |
| 199 | } |
| 200 | |
| 201 | void hide() { |
| 202 | if (mUseQuickControls) { |
Michael Kolb | 4923c22 | 2012-04-02 16:18:36 -0700 | [diff] [blame] | 203 | this.setVisibility(View.GONE); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 204 | } else { |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 205 | if (mIsFixedTitleBar) return; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 206 | if (!mSkipTitleBarAnimations) { |
| 207 | cancelTitleBarAnimation(false); |
| 208 | int visibleHeight = getVisibleTitleHeight(); |
| 209 | mTitleBarAnimator = ObjectAnimator.ofFloat(this, |
| 210 | "translationY", getTranslationY(), |
| 211 | (-getEmbeddedHeight() + visibleHeight)); |
| 212 | mTitleBarAnimator.addListener(mHideTileBarAnimatorListener); |
| 213 | setupTitleBarAnimator(mTitleBarAnimator); |
| 214 | mTitleBarAnimator.start(); |
| 215 | } else { |
Michael Kolb | 4923c22 | 2012-04-02 16:18:36 -0700 | [diff] [blame] | 216 | onScrollChanged(); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 217 | } |
| 218 | } |
| 219 | mShowing = false; |
| 220 | } |
| 221 | |
| 222 | boolean isShowing() { |
| 223 | return mShowing; |
| 224 | } |
| 225 | |
| 226 | void cancelTitleBarAnimation(boolean reset) { |
| 227 | if (mTitleBarAnimator != null) { |
| 228 | mTitleBarAnimator.cancel(); |
| 229 | mTitleBarAnimator = null; |
| 230 | } |
| 231 | if (reset) { |
| 232 | setTranslationY(0); |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | private AnimatorListener mHideTileBarAnimatorListener = new AnimatorListener() { |
| 237 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 238 | @Override |
| 239 | public void onAnimationStart(Animator animation) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | @Override |
| 243 | public void onAnimationRepeat(Animator animation) { |
| 244 | } |
| 245 | |
| 246 | @Override |
| 247 | public void onAnimationEnd(Animator animation) { |
Michael Kolb | 4923c22 | 2012-04-02 16:18:36 -0700 | [diff] [blame] | 248 | // update position |
| 249 | onScrollChanged(); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | @Override |
| 253 | public void onAnimationCancel(Animator animation) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 254 | } |
| 255 | }; |
| 256 | |
| 257 | private int getVisibleTitleHeight() { |
| 258 | Tab tab = mBaseUi.getActiveTab(); |
| 259 | WebView webview = tab != null ? tab.getWebView() : null; |
| 260 | return webview != null ? webview.getVisibleTitleHeight() : 0; |
| 261 | } |
| 262 | |
| 263 | /** |
| 264 | * Update the progress, from 0 to 100. |
| 265 | */ |
| 266 | public void setProgress(int newProgress) { |
| 267 | if (newProgress >= PROGRESS_MAX) { |
| 268 | mProgress.setProgress(PageProgressView.MAX_PROGRESS); |
| 269 | mProgress.setVisibility(View.GONE); |
| 270 | mInLoad = false; |
| 271 | mNavBar.onProgressStopped(); |
| 272 | // check if needs to be hidden |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 273 | if (!isEditingUrl() && !wantsToBeVisible()) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 274 | if (mUseQuickControls) { |
Michael Kolb | e8a8233 | 2012-04-25 14:14:26 -0700 | [diff] [blame] | 275 | hide(); |
John Reck | bc82ec9 | 2012-04-19 13:12:35 -0700 | [diff] [blame] | 276 | } else { |
| 277 | mBaseUi.showTitleBarForDuration(); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 278 | } |
| 279 | } |
| 280 | } else { |
| 281 | if (!mInLoad) { |
| 282 | mProgress.setVisibility(View.VISIBLE); |
| 283 | mInLoad = true; |
| 284 | mNavBar.onProgressStarted(); |
| 285 | } |
| 286 | mProgress.setProgress(newProgress * PageProgressView.MAX_PROGRESS |
| 287 | / PROGRESS_MAX); |
Michael Kolb | e8a8233 | 2012-04-25 14:14:26 -0700 | [diff] [blame] | 288 | if (mUseQuickControls && !isEditingUrl()) { |
| 289 | setShowProgressOnly(true); |
| 290 | } |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 291 | if (!mShowing) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 292 | show(); |
| 293 | } |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | public int getEmbeddedHeight() { |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 298 | if (mUseQuickControls || mIsFixedTitleBar) return 0; |
| 299 | return calculateEmbeddedHeight(); |
| 300 | } |
| 301 | |
| 302 | private int calculateEmbeddedHeight() { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 303 | int height = mNavBar.getHeight(); |
Ben Murdoch | d51bb57 | 2011-08-17 20:42:02 +0100 | [diff] [blame] | 304 | if (mAutoLogin != null && mAutoLogin.getVisibility() == View.VISIBLE) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 305 | height += mAutoLogin.getHeight(); |
| 306 | } |
| 307 | return height; |
| 308 | } |
| 309 | |
| 310 | public void updateAutoLogin(Tab tab, boolean animate) { |
Ben Murdoch | d51bb57 | 2011-08-17 20:42:02 +0100 | [diff] [blame] | 311 | if (mAutoLogin == null) { |
| 312 | if (tab.getDeviceAccountLogin() == null) { |
| 313 | return; |
| 314 | } |
| 315 | inflateAutoLoginBar(); |
| 316 | } |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 317 | mAutoLogin.updateAutoLogin(tab, animate); |
| 318 | } |
| 319 | |
| 320 | public void showAutoLogin(boolean animate) { |
| 321 | if (mUseQuickControls) { |
| 322 | mBaseUi.showTitleBar(); |
| 323 | } |
Ben Murdoch | d51bb57 | 2011-08-17 20:42:02 +0100 | [diff] [blame] | 324 | if (mAutoLogin == null) { |
| 325 | inflateAutoLoginBar(); |
| 326 | } |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 327 | mAutoLogin.setVisibility(View.VISIBLE); |
| 328 | if (animate) { |
| 329 | mAutoLogin.startAnimation(AnimationUtils.loadAnimation( |
| 330 | getContext(), R.anim.autologin_enter)); |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | public void hideAutoLogin(boolean animate) { |
| 335 | if (mUseQuickControls) { |
| 336 | mBaseUi.hideTitleBar(); |
| 337 | mAutoLogin.setVisibility(View.GONE); |
| 338 | mBaseUi.refreshWebView(); |
| 339 | } else { |
| 340 | if (animate) { |
| 341 | Animation anim = AnimationUtils.loadAnimation(getContext(), |
| 342 | R.anim.autologin_exit); |
| 343 | anim.setAnimationListener(new AnimationListener() { |
| 344 | @Override |
| 345 | public void onAnimationEnd(Animation a) { |
| 346 | mAutoLogin.setVisibility(View.GONE); |
| 347 | mBaseUi.refreshWebView(); |
| 348 | } |
| 349 | |
| 350 | @Override |
| 351 | public void onAnimationStart(Animation a) { |
| 352 | } |
| 353 | |
| 354 | @Override |
| 355 | public void onAnimationRepeat(Animation a) { |
| 356 | } |
| 357 | }); |
| 358 | mAutoLogin.startAnimation(anim); |
| 359 | } else if (mAutoLogin.getAnimation() == null) { |
| 360 | mAutoLogin.setVisibility(View.GONE); |
| 361 | mBaseUi.refreshWebView(); |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 366 | public boolean wantsToBeVisible() { |
| 367 | return inAutoLogin() |
Ben Murdoch | d51bb57 | 2011-08-17 20:42:02 +0100 | [diff] [blame] | 368 | || (mSnapshotBar != null && mSnapshotBar.getVisibility() == View.VISIBLE |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 369 | && mSnapshotBar.isAnimating()); |
| 370 | } |
| 371 | |
| 372 | private boolean inAutoLogin() { |
Ben Murdoch | d51bb57 | 2011-08-17 20:42:02 +0100 | [diff] [blame] | 373 | return mAutoLogin != null && mAutoLogin.getVisibility() == View.VISIBLE; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | public boolean isEditingUrl() { |
| 377 | return mNavBar.isEditingUrl(); |
| 378 | } |
| 379 | |
| 380 | public WebView getCurrentWebView() { |
| 381 | Tab t = mBaseUi.getActiveTab(); |
| 382 | if (t != null) { |
| 383 | return t.getWebView(); |
| 384 | } else { |
| 385 | return null; |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | public PageProgressView getProgressView() { |
| 390 | return mProgress; |
| 391 | } |
| 392 | |
| 393 | public NavigationBarBase getNavigationBar() { |
| 394 | return mNavBar; |
| 395 | } |
| 396 | |
| 397 | public boolean useQuickControls() { |
| 398 | return mUseQuickControls; |
| 399 | } |
| 400 | |
| 401 | public boolean isInLoad() { |
| 402 | return mInLoad; |
| 403 | } |
| 404 | |
| 405 | private ViewGroup.LayoutParams makeLayoutParams() { |
Michael Kolb | 4923c22 | 2012-04-02 16:18:36 -0700 | [diff] [blame] | 406 | return new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, |
| 407 | LayoutParams.WRAP_CONTENT); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | @Override |
| 411 | public View focusSearch(View focused, int dir) { |
John Reck | fcb6095 | 2012-05-30 09:45:28 -0700 | [diff] [blame] | 412 | WebView web = getCurrentWebView(); |
John Reck | d70419a | 2012-05-30 16:09:17 -0700 | [diff] [blame] | 413 | if (FOCUS_DOWN == dir && hasFocus() && web != null |
John Reck | fcb6095 | 2012-05-30 09:45:28 -0700 | [diff] [blame] | 414 | && web.hasFocusable() && web.getParent() != null) { |
| 415 | return web; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 416 | } |
| 417 | return super.focusSearch(focused, dir); |
| 418 | } |
| 419 | |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 420 | public void onTabDataChanged(Tab tab) { |
Ben Murdoch | d51bb57 | 2011-08-17 20:42:02 +0100 | [diff] [blame] | 421 | if (mSnapshotBar != null) { |
| 422 | mSnapshotBar.onTabDataChanged(tab); |
| 423 | } |
| 424 | |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 425 | if (tab.isSnapshot()) { |
Ben Murdoch | d51bb57 | 2011-08-17 20:42:02 +0100 | [diff] [blame] | 426 | inflateSnapshotBar(); |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 427 | mSnapshotBar.setVisibility(VISIBLE); |
| 428 | mNavBar.setVisibility(GONE); |
| 429 | } else { |
Ben Murdoch | d51bb57 | 2011-08-17 20:42:02 +0100 | [diff] [blame] | 430 | if (mSnapshotBar != null) { |
| 431 | mSnapshotBar.setVisibility(GONE); |
| 432 | } |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 433 | mNavBar.setVisibility(VISIBLE); |
| 434 | } |
| 435 | } |
| 436 | |
Michael Kolb | 4923c22 | 2012-04-02 16:18:36 -0700 | [diff] [blame] | 437 | public void onScrollChanged() { |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 438 | if (!mShowing && !mIsFixedTitleBar) { |
Michael Kolb | 4923c22 | 2012-04-02 16:18:36 -0700 | [diff] [blame] | 439 | setTranslationY(getVisibleTitleHeight() - getEmbeddedHeight()); |
| 440 | } |
| 441 | } |
| 442 | |
John Reck | 1cc1d1d | 2012-09-04 18:13:51 -0700 | [diff] [blame] | 443 | public void onResume() { |
| 444 | setFixedTitleBar(); |
| 445 | } |
| 446 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 447 | } |