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