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