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