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