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; |
Panos Thomas | 752ce59 | 2014-10-16 13:00:35 -0700 | [diff] [blame] | 25 | import android.graphics.Rect; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 26 | import android.view.LayoutInflater; |
| 27 | import android.view.View; |
| 28 | import android.view.ViewGroup; |
Ben Murdoch | d51bb57 | 2011-08-17 20:42:02 +0100 | [diff] [blame] | 29 | import android.view.ViewStub; |
John Reck | 1cc1d1d | 2012-09-04 18:13:51 -0700 | [diff] [blame] | 30 | import android.view.accessibility.AccessibilityManager; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 31 | import android.view.animation.Animation; |
| 32 | import android.view.animation.Animation.AnimationListener; |
| 33 | import android.view.animation.AnimationUtils; |
| 34 | import android.view.animation.DecelerateInterpolator; |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 35 | import org.codeaurora.swe.WebView; |
| 36 | |
Bijan Amirzada | 41242f2 | 2014-03-21 12:12:18 -0700 | [diff] [blame] | 37 | import com.android.browser.R; |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 38 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 39 | import android.widget.FrameLayout; |
| 40 | import android.widget.RelativeLayout; |
| 41 | |
| 42 | |
| 43 | /** |
| 44 | * Base class for a title bar used by the browser. |
| 45 | */ |
| 46 | public class TitleBar extends RelativeLayout { |
| 47 | |
| 48 | private static final int PROGRESS_MAX = 100; |
| 49 | private static final float ANIM_TITLEBAR_DECELERATE = 2.5f; |
| 50 | |
| 51 | private UiController mUiController; |
| 52 | private BaseUi mBaseUi; |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 53 | private FrameLayout mContentView; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 54 | private PageProgressView mProgress; |
John Reck | 1cc1d1d | 2012-09-04 18:13:51 -0700 | [diff] [blame] | 55 | private AccessibilityManager mAccessibilityManager; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 56 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 57 | private NavigationBarBase mNavBar; |
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() { |
Vivek Sekhar | 3bec6a3 | 2014-10-22 17:03:42 -0700 | [diff] [blame] | 115 | boolean isFixed = !getContext().getResources().getBoolean(R.bool.hide_title); |
Tarun Nainani | 8eb0091 | 2014-07-17 12:28:32 -0700 | [diff] [blame] | 116 | |
John Reck | 1cc1d1d | 2012-09-04 18:13:51 -0700 | [diff] [blame] | 117 | isFixed |= mAccessibilityManager.isEnabled(); |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 118 | // If getParent() returns null, we are initializing |
| 119 | ViewGroup parent = (ViewGroup)getParent(); |
| 120 | if (mIsFixedTitleBar == isFixed && parent != null) return; |
| 121 | mIsFixedTitleBar = isFixed; |
| 122 | setSkipTitleBarAnimations(true); |
| 123 | show(); |
| 124 | setSkipTitleBarAnimations(false); |
| 125 | if (parent != null) { |
| 126 | parent.removeView(this); |
| 127 | } |
Tarun Nainani | 8eb0091 | 2014-07-17 12:28:32 -0700 | [diff] [blame] | 128 | if (mIsFixedTitleBar) { |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 129 | mBaseUi.addFixedTitleBar(this); |
| 130 | } else { |
| 131 | mContentView.addView(this, makeLayoutParams()); |
| 132 | mBaseUi.setContentViewMarginTop(0); |
Michael Kolb | 57059a8 | 2012-04-30 14:32:03 -0700 | [diff] [blame] | 133 | } |
| 134 | } |
| 135 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 136 | public BaseUi getUi() { |
| 137 | return mBaseUi; |
| 138 | } |
| 139 | |
| 140 | public UiController getUiController() { |
| 141 | return mUiController; |
| 142 | } |
| 143 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 144 | void setShowProgressOnly(boolean progress) { |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 145 | if (progress && !wantsToBeVisible()) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 146 | mNavBar.setVisibility(View.GONE); |
| 147 | } else { |
| 148 | mNavBar.setVisibility(View.VISIBLE); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | void setSkipTitleBarAnimations(boolean skip) { |
| 153 | mSkipTitleBarAnimations = skip; |
| 154 | } |
| 155 | |
| 156 | void setupTitleBarAnimator(Animator animator) { |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 157 | Resources res = getContext().getResources(); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 158 | int duration = res.getInteger(R.integer.titlebar_animation_duration); |
| 159 | animator.setInterpolator(new DecelerateInterpolator( |
| 160 | ANIM_TITLEBAR_DECELERATE)); |
| 161 | animator.setDuration(duration); |
| 162 | } |
| 163 | |
Tarun Nainani | 8eb0091 | 2014-07-17 12:28:32 -0700 | [diff] [blame] | 164 | //Disable stock autohide behavior in favor of top controls |
| 165 | private static final boolean bOldStyleAutoHideDisabled = true; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 166 | void show() { |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 167 | cancelTitleBarAnimation(false); |
Vivek Sekhar | 3bec6a3 | 2014-10-22 17:03:42 -0700 | [diff] [blame] | 168 | if (mSkipTitleBarAnimations) { |
Michael Kolb | 4923c22 | 2012-04-02 16:18:36 -0700 | [diff] [blame] | 169 | this.setVisibility(View.VISIBLE); |
| 170 | this.setTranslationY(0); |
Tarun Nainani | 8eb0091 | 2014-07-17 12:28:32 -0700 | [diff] [blame] | 171 | hideTopControls(); |
| 172 | } else if (!bOldStyleAutoHideDisabled) { |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 173 | int visibleHeight = getVisibleTitleHeight(); |
| 174 | float startPos = (-getEmbeddedHeight() + visibleHeight); |
| 175 | if (getTranslationY() != 0) { |
| 176 | startPos = Math.max(startPos, getTranslationY()); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 177 | } |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 178 | mTitleBarAnimator = ObjectAnimator.ofFloat(this, |
| 179 | "translationY", |
| 180 | startPos, 0); |
| 181 | setupTitleBarAnimator(mTitleBarAnimator); |
| 182 | mTitleBarAnimator.start(); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 183 | } |
Tarun Nainani | 8eb0091 | 2014-07-17 12:28:32 -0700 | [diff] [blame] | 184 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 185 | mShowing = true; |
| 186 | } |
| 187 | |
| 188 | void hide() { |
Vivek Sekhar | 3bec6a3 | 2014-10-22 17:03:42 -0700 | [diff] [blame] | 189 | if (mIsFixedTitleBar || bOldStyleAutoHideDisabled) return; |
| 190 | if (!mSkipTitleBarAnimations) { |
| 191 | cancelTitleBarAnimation(false); |
| 192 | int visibleHeight = getVisibleTitleHeight(); |
| 193 | mTitleBarAnimator = ObjectAnimator.ofFloat(this, |
| 194 | "translationY", getTranslationY(), |
| 195 | (-getEmbeddedHeight() + visibleHeight)); |
| 196 | mTitleBarAnimator.addListener(mHideTileBarAnimatorListener); |
| 197 | setupTitleBarAnimator(mTitleBarAnimator); |
| 198 | mTitleBarAnimator.start(); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 199 | } else { |
Vivek Sekhar | 3bec6a3 | 2014-10-22 17:03:42 -0700 | [diff] [blame] | 200 | onScrollChanged(); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 201 | } |
| 202 | mShowing = false; |
| 203 | } |
| 204 | |
| 205 | boolean isShowing() { |
| 206 | return mShowing; |
| 207 | } |
| 208 | |
| 209 | void cancelTitleBarAnimation(boolean reset) { |
| 210 | if (mTitleBarAnimator != null) { |
| 211 | mTitleBarAnimator.cancel(); |
| 212 | mTitleBarAnimator = null; |
| 213 | } |
| 214 | if (reset) { |
| 215 | setTranslationY(0); |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | private AnimatorListener mHideTileBarAnimatorListener = new AnimatorListener() { |
| 220 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 221 | @Override |
| 222 | public void onAnimationStart(Animator animation) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | @Override |
| 226 | public void onAnimationRepeat(Animator animation) { |
| 227 | } |
| 228 | |
| 229 | @Override |
| 230 | public void onAnimationEnd(Animator animation) { |
Michael Kolb | 4923c22 | 2012-04-02 16:18:36 -0700 | [diff] [blame] | 231 | // update position |
| 232 | onScrollChanged(); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | @Override |
| 236 | public void onAnimationCancel(Animator animation) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 237 | } |
| 238 | }; |
| 239 | |
| 240 | private int getVisibleTitleHeight() { |
| 241 | Tab tab = mBaseUi.getActiveTab(); |
| 242 | WebView webview = tab != null ? tab.getWebView() : null; |
| 243 | return webview != null ? webview.getVisibleTitleHeight() : 0; |
| 244 | } |
| 245 | |
Tarun Nainani | 8eb0091 | 2014-07-17 12:28:32 -0700 | [diff] [blame] | 246 | private void hideTopControls() { |
| 247 | Tab tab = mBaseUi.getActiveTab(); |
| 248 | WebView view = tab != null ? tab.getWebView() : null; |
| 249 | if (view != null) |
| 250 | view.updateTopControls(true, false, true); |
| 251 | } |
| 252 | |
| 253 | private void showTopControls() { |
| 254 | Tab tab = mBaseUi.getActiveTab(); |
| 255 | WebView view = tab != null ? tab.getWebView() : null; |
| 256 | if (view != null) |
| 257 | view.updateTopControls(false, true, true); |
| 258 | } |
| 259 | |
| 260 | private void enableTopControls() { |
| 261 | Tab tab = mBaseUi.getActiveTab(); |
| 262 | WebView view = tab != null ? tab.getWebView() : null; |
| 263 | if (view != null) |
| 264 | view.updateTopControls(true, true, true); |
| 265 | } |
| 266 | |
| 267 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 268 | /** |
| 269 | * Update the progress, from 0 to 100. |
| 270 | */ |
| 271 | public void setProgress(int newProgress) { |
Tarun Nainani | 8eb0091 | 2014-07-17 12:28:32 -0700 | [diff] [blame] | 272 | Tab tab = mBaseUi.getActiveTab(); |
| 273 | WebView view = tab != null ? tab.getWebView() : null; |
| 274 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 275 | if (newProgress >= PROGRESS_MAX) { |
| 276 | mProgress.setProgress(PageProgressView.MAX_PROGRESS); |
| 277 | mProgress.setVisibility(View.GONE); |
| 278 | mInLoad = false; |
| 279 | mNavBar.onProgressStopped(); |
| 280 | // check if needs to be hidden |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 281 | if (!isEditingUrl() && !wantsToBeVisible()) { |
Vivek Sekhar | 3bec6a3 | 2014-10-22 17:03:42 -0700 | [diff] [blame] | 282 | mBaseUi.showTitleBarForDuration(); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 283 | } |
Tarun Nainani | 8eb0091 | 2014-07-17 12:28:32 -0700 | [diff] [blame] | 284 | |
| 285 | //onPageFinished |
Vivek Sekhar | 3bec6a3 | 2014-10-22 17:03:42 -0700 | [diff] [blame] | 286 | enableTopControls(); |
Tarun Nainani | 8eb0091 | 2014-07-17 12:28:32 -0700 | [diff] [blame] | 287 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 288 | } else { |
| 289 | if (!mInLoad) { |
| 290 | mProgress.setVisibility(View.VISIBLE); |
| 291 | mInLoad = true; |
| 292 | mNavBar.onProgressStarted(); |
Tarun Nainani | 8eb0091 | 2014-07-17 12:28:32 -0700 | [diff] [blame] | 293 | |
| 294 | //onPageStarted |
Vivek Sekhar | 3bec6a3 | 2014-10-22 17:03:42 -0700 | [diff] [blame] | 295 | showTopControls(); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 296 | } |
| 297 | mProgress.setProgress(newProgress * PageProgressView.MAX_PROGRESS |
| 298 | / PROGRESS_MAX); |
| 299 | if (!mShowing) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 300 | show(); |
| 301 | } |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | public int getEmbeddedHeight() { |
Vivek Sekhar | 3bec6a3 | 2014-10-22 17:03:42 -0700 | [diff] [blame] | 306 | if (mIsFixedTitleBar) return 0; |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 307 | return calculateEmbeddedHeight(); |
| 308 | } |
| 309 | |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 310 | public boolean isFixed() { |
| 311 | return mIsFixedTitleBar; |
| 312 | } |
| 313 | |
| 314 | int calculateEmbeddedHeight() { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 315 | int height = mNavBar.getHeight(); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 316 | return height; |
| 317 | } |
| 318 | |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 319 | public boolean wantsToBeVisible() { |
Bijan Amirzada | 289e1e6 | 2014-04-15 11:53:48 -0700 | [diff] [blame] | 320 | return (mSnapshotBar != null && mSnapshotBar.getVisibility() == View.VISIBLE |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 321 | && mSnapshotBar.isAnimating()); |
| 322 | } |
| 323 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 324 | public boolean isEditingUrl() { |
| 325 | return mNavBar.isEditingUrl(); |
| 326 | } |
| 327 | |
| 328 | public WebView getCurrentWebView() { |
| 329 | Tab t = mBaseUi.getActiveTab(); |
| 330 | if (t != null) { |
| 331 | return t.getWebView(); |
| 332 | } else { |
| 333 | return null; |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | public PageProgressView getProgressView() { |
| 338 | return mProgress; |
| 339 | } |
| 340 | |
| 341 | public NavigationBarBase getNavigationBar() { |
| 342 | return mNavBar; |
| 343 | } |
| 344 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 345 | public boolean isInLoad() { |
| 346 | return mInLoad; |
| 347 | } |
| 348 | |
| 349 | private ViewGroup.LayoutParams makeLayoutParams() { |
Michael Kolb | 4923c22 | 2012-04-02 16:18:36 -0700 | [diff] [blame] | 350 | return new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, |
| 351 | LayoutParams.WRAP_CONTENT); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | @Override |
Panos Thomas | 752ce59 | 2014-10-16 13:00:35 -0700 | [diff] [blame] | 355 | public boolean requestFocus(int direction, Rect previouslyFocusedRect) { |
| 356 | return mBaseUi.isCustomViewShowing() ? false : |
| 357 | super.requestFocus(direction, previouslyFocusedRect); |
| 358 | } |
| 359 | |
| 360 | @Override |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 361 | public View focusSearch(View focused, int dir) { |
John Reck | fcb6095 | 2012-05-30 09:45:28 -0700 | [diff] [blame] | 362 | WebView web = getCurrentWebView(); |
John Reck | d70419a | 2012-05-30 16:09:17 -0700 | [diff] [blame] | 363 | if (FOCUS_DOWN == dir && hasFocus() && web != null |
John Reck | fcb6095 | 2012-05-30 09:45:28 -0700 | [diff] [blame] | 364 | && web.hasFocusable() && web.getParent() != null) { |
| 365 | return web; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 366 | } |
| 367 | return super.focusSearch(focused, dir); |
| 368 | } |
| 369 | |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 370 | public void onTabDataChanged(Tab tab) { |
Ben Murdoch | d51bb57 | 2011-08-17 20:42:02 +0100 | [diff] [blame] | 371 | if (mSnapshotBar != null) { |
| 372 | mSnapshotBar.onTabDataChanged(tab); |
| 373 | } |
| 374 | |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 375 | if (tab.isSnapshot()) { |
Ben Murdoch | d51bb57 | 2011-08-17 20:42:02 +0100 | [diff] [blame] | 376 | inflateSnapshotBar(); |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 377 | mSnapshotBar.setVisibility(VISIBLE); |
| 378 | mNavBar.setVisibility(GONE); |
| 379 | } else { |
Ben Murdoch | d51bb57 | 2011-08-17 20:42:02 +0100 | [diff] [blame] | 380 | if (mSnapshotBar != null) { |
| 381 | mSnapshotBar.setVisibility(GONE); |
| 382 | } |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 383 | mNavBar.setVisibility(VISIBLE); |
| 384 | } |
| 385 | } |
| 386 | |
Michael Kolb | 4923c22 | 2012-04-02 16:18:36 -0700 | [diff] [blame] | 387 | public void onScrollChanged() { |
John Reck | 2711fab | 2012-05-18 21:38:59 -0700 | [diff] [blame] | 388 | if (!mShowing && !mIsFixedTitleBar) { |
Michael Kolb | 4923c22 | 2012-04-02 16:18:36 -0700 | [diff] [blame] | 389 | setTranslationY(getVisibleTitleHeight() - getEmbeddedHeight()); |
| 390 | } |
| 391 | } |
| 392 | |
John Reck | 1cc1d1d | 2012-09-04 18:13:51 -0700 | [diff] [blame] | 393 | public void onResume() { |
| 394 | setFixedTitleBar(); |
| 395 | } |
| 396 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 397 | } |