OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.toolbar; | 5 package org.chromium.chrome.browser.toolbar; |
6 | 6 |
7 import android.animation.Animator; | 7 import android.animation.Animator; |
8 import android.animation.AnimatorListenerAdapter; | 8 import android.animation.AnimatorListenerAdapter; |
9 import android.animation.AnimatorSet; | 9 import android.animation.AnimatorSet; |
10 import android.animation.ObjectAnimator; | 10 import android.animation.ObjectAnimator; |
11 import android.animation.ValueAnimator; | 11 import android.animation.ValueAnimator; |
12 import android.animation.ValueAnimator.AnimatorUpdateListener; | 12 import android.animation.ValueAnimator.AnimatorUpdateListener; |
13 import android.annotation.SuppressLint; | 13 import android.annotation.SuppressLint; |
14 import android.content.Context; | 14 import android.content.Context; |
15 import android.content.res.ColorStateList; | 15 import android.content.res.ColorStateList; |
16 import android.content.res.Resources; | 16 import android.content.res.Resources; |
17 import android.graphics.Canvas; | 17 import android.graphics.Canvas; |
18 import android.graphics.Color; | 18 import android.graphics.Color; |
19 import android.graphics.Point; | 19 import android.graphics.Point; |
20 import android.graphics.PorterDuff; | 20 import android.graphics.PorterDuff; |
21 import android.graphics.Rect; | 21 import android.graphics.Rect; |
22 import android.graphics.drawable.BitmapDrawable; | 22 import android.graphics.drawable.BitmapDrawable; |
23 import android.graphics.drawable.ColorDrawable; | 23 import android.graphics.drawable.ColorDrawable; |
24 import android.graphics.drawable.Drawable; | 24 import android.graphics.drawable.Drawable; |
25 import android.graphics.drawable.TransitionDrawable; | 25 import android.graphics.drawable.TransitionDrawable; |
26 import android.os.Build; | 26 import android.os.Build; |
27 import android.os.SystemClock; | 27 import android.os.SystemClock; |
| 28 import android.support.v4.view.animation.FastOutSlowInInterpolator; |
28 import android.text.TextUtils; | 29 import android.text.TextUtils; |
29 import android.util.AttributeSet; | 30 import android.util.AttributeSet; |
30 import android.util.Property; | 31 import android.util.Property; |
31 import android.view.Gravity; | 32 import android.view.Gravity; |
32 import android.view.MotionEvent; | 33 import android.view.MotionEvent; |
33 import android.view.View; | 34 import android.view.View; |
34 import android.view.View.OnClickListener; | 35 import android.view.View.OnClickListener; |
35 import android.view.View.OnLongClickListener; | 36 import android.view.View.OnLongClickListener; |
36 import android.view.ViewDebug; | 37 import android.view.ViewDebug; |
37 import android.view.ViewGroup; | 38 import android.view.ViewGroup; |
38 import android.view.WindowManager; | 39 import android.view.WindowManager; |
| 40 import android.view.animation.Interpolator; |
39 import android.view.animation.LinearInterpolator; | 41 import android.view.animation.LinearInterpolator; |
40 import android.widget.FrameLayout; | 42 import android.widget.FrameLayout; |
41 import android.widget.ImageView; | 43 import android.widget.ImageView; |
42 import android.widget.PopupWindow.OnDismissListener; | 44 import android.widget.PopupWindow.OnDismissListener; |
43 import android.widget.TextView; | 45 import android.widget.TextView; |
44 | 46 |
45 import org.chromium.base.ApiCompatibilityUtils; | 47 import org.chromium.base.ApiCompatibilityUtils; |
46 import org.chromium.base.SysUtils; | 48 import org.chromium.base.SysUtils; |
47 import org.chromium.base.VisibleForTesting; | 49 import org.chromium.base.VisibleForTesting; |
48 import org.chromium.base.metrics.RecordUserAction; | 50 import org.chromium.base.metrics.RecordUserAction; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 private static final int URL_CLEAR_FOCUS_TABSTACK_DELAY_MS = 200; | 87 private static final int URL_CLEAR_FOCUS_TABSTACK_DELAY_MS = 200; |
86 private static final int URL_CLEAR_FOCUS_MENU_DELAY_MS = 250; | 88 private static final int URL_CLEAR_FOCUS_MENU_DELAY_MS = 250; |
87 | 89 |
88 private static final int TAB_SWITCHER_MODE_ENTER_ANIMATION_DURATION_MS = 200
; | 90 private static final int TAB_SWITCHER_MODE_ENTER_ANIMATION_DURATION_MS = 200
; |
89 private static final int TAB_SWITCHER_MODE_EXIT_NORMAL_ANIMATION_DURATION_MS
= 200; | 91 private static final int TAB_SWITCHER_MODE_EXIT_NORMAL_ANIMATION_DURATION_MS
= 200; |
90 private static final int TAB_SWITCHER_MODE_EXIT_FADE_ANIMATION_DURATION_MS =
100; | 92 private static final int TAB_SWITCHER_MODE_EXIT_FADE_ANIMATION_DURATION_MS =
100; |
91 private static final int TAB_SWITCHER_MODE_POST_EXIT_ANIMATION_DURATION_MS =
100; | 93 private static final int TAB_SWITCHER_MODE_POST_EXIT_ANIMATION_DURATION_MS =
100; |
92 | 94 |
93 private static final float UNINITIALIZED_PERCENT = -1f; | 95 private static final float UNINITIALIZED_PERCENT = -1f; |
94 | 96 |
95 private static final String TAG = "ToolbarPhone"; | |
96 | |
97 static final int LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA = 51; | 97 static final int LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA = 51; |
98 | 98 |
99 private LocationBarPhone mPhoneLocationBar; | 99 private static final Interpolator NTP_SEARCH_BOX_EXPANSION_INTERPOLATOR = |
| 100 new FastOutSlowInInterpolator(); |
| 101 |
| 102 private LocationBarPhone mLocationBar; |
100 | 103 |
101 private ViewGroup mToolbarButtonsContainer; | 104 private ViewGroup mToolbarButtonsContainer; |
102 private ImageView mToggleTabStackButton; | 105 private ImageView mToggleTabStackButton; |
103 private NewTabButton mNewTabButton; | 106 private NewTabButton mNewTabButton; |
104 private TintedImageButton mReturnButton; | 107 private TintedImageButton mReturnButton; |
105 private TintedImageButton mHomeButton; | 108 private TintedImageButton mHomeButton; |
106 private TextView mUrlBar; | 109 private TextView mUrlBar; |
107 private View mUrlActionsContainer; | 110 private View mUrlActionContainer; |
108 private ImageView mToolbarShadow; | 111 private ImageView mToolbarShadow; |
109 | 112 |
110 private final int mProgressBackBackgroundColorWhite; | 113 private final int mProgressBackBackgroundColorWhite; |
111 | 114 |
112 private ObjectAnimator mTabSwitcherModeAnimation; | 115 private ObjectAnimator mTabSwitcherModeAnimation; |
113 private ObjectAnimator mDelayedTabSwitcherModeAnimation; | 116 private ObjectAnimator mDelayedTabSwitcherModeAnimation; |
114 | 117 |
115 private final List<View> mTabSwitcherModeViews = new ArrayList<View>(); | 118 private final List<View> mTabSwitcherModeViews = new ArrayList<View>(); |
116 private final Set<View> mBrowsingModeViews = new HashSet<View>(); | 119 private final Set<View> mBrowsingModeViews = new HashSet<View>(); |
117 @ViewDebug.ExportedProperty(category = "chrome") | 120 @ViewDebug.ExportedProperty(category = "chrome") |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 */ | 170 */ |
168 @ViewDebug.ExportedProperty(category = "chrome") | 171 @ViewDebug.ExportedProperty(category = "chrome") |
169 private float mUrlExpansionPercent; | 172 private float mUrlExpansionPercent; |
170 private AnimatorSet mUrlFocusLayoutAnimator; | 173 private AnimatorSet mUrlFocusLayoutAnimator; |
171 private boolean mDisableLocationBarRelayout; | 174 private boolean mDisableLocationBarRelayout; |
172 private boolean mLayoutLocationBarInFocusedMode; | 175 private boolean mLayoutLocationBarInFocusedMode; |
173 private int mUnfocusedLocationBarLayoutWidth; | 176 private int mUnfocusedLocationBarLayoutWidth; |
174 private int mUnfocusedLocationBarLayoutLeft; | 177 private int mUnfocusedLocationBarLayoutLeft; |
175 private boolean mUnfocusedLocationBarUsesTransparentBg; | 178 private boolean mUnfocusedLocationBarUsesTransparentBg; |
176 | 179 |
177 private int mUrlBackgroundAlpha = 255; | 180 private int mLocationBarBackgroundAlpha = 255; |
178 private float mNtpSearchBoxScrollPercent = UNINITIALIZED_PERCENT; | 181 private float mNtpSearchBoxScrollPercent = UNINITIALIZED_PERCENT; |
179 private ColorDrawable mToolbarBackground; | 182 private ColorDrawable mToolbarBackground; |
180 | 183 |
181 // The omnibox background (white with a shadow). | 184 /** The omnibox background (white with a shadow). */ |
182 private Drawable mLocationBarBackground; | 185 private Drawable mLocationBarBackground; |
| 186 |
183 private boolean mForceDrawLocationBarBackground; | 187 private boolean mForceDrawLocationBarBackground; |
184 private TabSwitcherDrawable mTabSwitcherButtonDrawable; | 188 private TabSwitcherDrawable mTabSwitcherButtonDrawable; |
185 private TabSwitcherDrawable mTabSwitcherButtonDrawableLight; | 189 private TabSwitcherDrawable mTabSwitcherButtonDrawableLight; |
186 | 190 |
187 private final int mLightModeDefaultColor; | 191 private final int mLightModeDefaultColor; |
188 private final int mDarkModeDefaultColor; | 192 private final int mDarkModeDefaultColor; |
189 | 193 |
190 private final Rect mUrlViewportBounds = new Rect(); | 194 /** The boundaries of the omnibox, without the NTP-specific offset applied.
*/ |
191 private final Rect mUrlBackgroundPadding = new Rect(); | 195 private final Rect mLocationBarBackgroundBounds = new Rect(); |
| 196 |
| 197 private final Rect mLocationBarBackgroundPadding = new Rect(); |
192 private final Rect mBackgroundOverlayBounds = new Rect(); | 198 private final Rect mBackgroundOverlayBounds = new Rect(); |
193 private final Rect mLocationBarBackgroundOffset = new Rect(); | |
194 | 199 |
195 private final Rect mNtpSearchBoxOriginalBounds = new Rect(); | 200 /** Offset applied to the bounds of the omnibox if we are showing a New Tab
Page. */ |
196 private final Rect mNtpSearchBoxTransformedBounds = new Rect(); | 201 private final Rect mLocationBarBackgroundNtpOffset = new Rect(); |
197 | 202 |
198 private final int mLocationBarInsets; | 203 /** |
| 204 * Offsets applied to the <i>contents</i> of the omnibox if we are showing a
New Tab Page. |
| 205 * This can be different from {@link #mLocationBarBackgroundNtpOffset} due t
o the fact that we |
| 206 * extend the omnibox horizontally beyond the screen boundaries when focused
, to hide its |
| 207 * rounded corners. |
| 208 */ |
| 209 private float mLocationBarNtpOffsetLeft; |
| 210 private float mLocationBarNtpOffsetRight; |
| 211 |
| 212 private final Rect mNtpSearchBoxBounds = new Rect(); |
| 213 private final Point mNtpSearchBoxTranslation = new Point(); |
| 214 |
199 private final int mToolbarSidePadding; | 215 private final int mToolbarSidePadding; |
| 216 private final int mLocationBarVerticalMargin; |
| 217 private final int mLocationBarBackgroundCornerRadius; |
200 | 218 |
201 private ValueAnimator mBrandColorTransitionAnimation; | 219 private ValueAnimator mBrandColorTransitionAnimation; |
202 private boolean mBrandColorTransitionActive; | 220 private boolean mBrandColorTransitionActive; |
203 | 221 |
204 private View.OnClickListener mReturnButtonListener; | 222 private View.OnClickListener mReturnButtonListener; |
205 private boolean mIsHomeButtonEnabled; | 223 private boolean mIsHomeButtonEnabled; |
206 | 224 |
207 private LayoutUpdateHost mLayoutUpdateHost; | 225 private LayoutUpdateHost mLayoutUpdateHost; |
208 | 226 |
209 /** Callout for the tab switcher button. */ | 227 /** Callout for the tab switcher button. */ |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 288 |
271 /** | 289 /** |
272 * Constructs a ToolbarPhone object. | 290 * Constructs a ToolbarPhone object. |
273 * @param context The Context in which this View object is created. | 291 * @param context The Context in which this View object is created. |
274 * @param attrs The AttributeSet that was specified with this View. | 292 * @param attrs The AttributeSet that was specified with this View. |
275 */ | 293 */ |
276 public ToolbarPhone(Context context, AttributeSet attrs) { | 294 public ToolbarPhone(Context context, AttributeSet attrs) { |
277 super(context, attrs); | 295 super(context, attrs); |
278 mToolbarSidePadding = getResources().getDimensionPixelOffset( | 296 mToolbarSidePadding = getResources().getDimensionPixelOffset( |
279 R.dimen.toolbar_edge_padding); | 297 R.dimen.toolbar_edge_padding); |
280 // Insets used for the PhoneLocatioBar background drawable. | 298 mLocationBarVerticalMargin = |
281 mLocationBarInsets = getResources().getDimensionPixelSize(R.dimen.locati
on_bar_margin_top) | 299 getResources().getDimensionPixelOffset(R.dimen.location_bar_vert
ical_margin); |
282 + getResources().getDimensionPixelSize(R.dimen.location_bar_marg
in_bottom); | 300 mLocationBarBackgroundCornerRadius = |
| 301 getResources().getDimensionPixelOffset(R.dimen.location_bar_corn
er_radius); |
283 mProgressBackBackgroundColorWhite = ApiCompatibilityUtils.getColor(getRe
sources(), | 302 mProgressBackBackgroundColorWhite = ApiCompatibilityUtils.getColor(getRe
sources(), |
284 R.color.progress_bar_background_white); | 303 R.color.progress_bar_background_white); |
285 mLightModeDefaultColor = | 304 mLightModeDefaultColor = |
286 ApiCompatibilityUtils.getColor(getResources(), R.color.light_mod
e_tint); | 305 ApiCompatibilityUtils.getColor(getResources(), R.color.light_mod
e_tint); |
287 mDarkModeDefaultColor = | 306 mDarkModeDefaultColor = |
288 ApiCompatibilityUtils.getColor(getResources(), R.color.dark_mode
_tint); | 307 ApiCompatibilityUtils.getColor(getResources(), R.color.dark_mode
_tint); |
289 } | 308 } |
290 | 309 |
291 @Override | 310 @Override |
292 public void onFinishInflate() { | 311 public void onFinishInflate() { |
293 super.onFinishInflate(); | 312 super.onFinishInflate(); |
294 mPhoneLocationBar = (LocationBarPhone) findViewById(R.id.location_bar); | 313 mLocationBar = (LocationBarPhone) findViewById(R.id.location_bar); |
295 | 314 |
296 mToolbarButtonsContainer = (ViewGroup) findViewById(R.id.toolbar_buttons
); | 315 mToolbarButtonsContainer = (ViewGroup) findViewById(R.id.toolbar_buttons
); |
297 | 316 |
298 mReturnButton = (TintedImageButton) findViewById(R.id.return_button); | 317 mReturnButton = (TintedImageButton) findViewById(R.id.return_button); |
299 mHomeButton = (TintedImageButton) findViewById(R.id.home_button); | 318 mHomeButton = (TintedImageButton) findViewById(R.id.home_button); |
300 | 319 |
301 mUrlBar = (TextView) findViewById(R.id.url_bar); | 320 mUrlBar = (TextView) findViewById(R.id.url_bar); |
302 | 321 |
303 mUrlActionsContainer = findViewById(R.id.url_action_container); | 322 mUrlActionContainer = findViewById(R.id.url_action_container); |
304 | 323 |
305 mBrowsingModeViews.add(mPhoneLocationBar); | 324 mBrowsingModeViews.add(mLocationBar); |
306 | 325 |
307 mToolbarBackground = new ColorDrawable(getToolbarColorForVisualState(Vis
ualState.NORMAL)); | 326 mToolbarBackground = new ColorDrawable(getToolbarColorForVisualState(Vis
ualState.NORMAL)); |
308 mTabSwitcherAnimationBgOverlay = | 327 mTabSwitcherAnimationBgOverlay = |
309 new ColorDrawable(getToolbarColorForVisualState(VisualState.NORM
AL)); | 328 new ColorDrawable(getToolbarColorForVisualState(VisualState.NORM
AL)); |
310 | 329 |
311 mLocationBarBackground = | 330 mLocationBarBackground = |
312 ApiCompatibilityUtils.getDrawable(getResources(), R.drawable.ins
et_textbox); | 331 ApiCompatibilityUtils.getDrawable(getResources(), R.drawable.tex
tbox); |
313 mLocationBarBackground.getPadding(mUrlBackgroundPadding); | 332 mLocationBarBackground.getPadding(mLocationBarBackgroundPadding); |
314 mPhoneLocationBar.setPadding( | 333 mLocationBar.setPadding( |
315 mUrlBackgroundPadding.left, mUrlBackgroundPadding.top, | 334 mLocationBarBackgroundPadding.left, mLocationBarBackgroundPaddin
g.top, |
316 mUrlBackgroundPadding.right, mUrlBackgroundPadding.bottom); | 335 mLocationBarBackgroundPadding.right, mLocationBarBackgroundPaddi
ng.bottom); |
317 | 336 |
318 setLayoutTransition(null); | 337 setLayoutTransition(null); |
319 | 338 |
320 mMenuButtonWrapper.setVisibility(shouldShowMenuButton() ? View.VISIBLE :
View.GONE); | 339 mMenuButtonWrapper.setVisibility(shouldShowMenuButton() ? View.VISIBLE :
View.GONE); |
321 if (FeatureUtilities.isDocumentMode(getContext())) { | 340 if (FeatureUtilities.isDocumentMode(getContext())) { |
322 ApiCompatibilityUtils.setMarginEnd( | 341 ApiCompatibilityUtils.setMarginEnd( |
323 (MarginLayoutParams) mMenuButtonWrapper.getLayoutParams(), | 342 (MarginLayoutParams) mMenuButtonWrapper.getLayoutParams(), |
324 getResources().getDimensionPixelSize(R.dimen.document_toolba
r_menu_offset)); | 343 getResources().getDimensionPixelSize(R.dimen.document_toolba
r_menu_offset)); |
325 hideTabSwitchingResources(); | 344 hideTabSwitchingResources(); |
326 } else { | 345 } else { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 return mToggleTabStackButton; | 452 return mToggleTabStackButton; |
434 } | 453 } |
435 | 454 |
436 @Override | 455 @Override |
437 protected boolean handleEnterKeyPress() { | 456 protected boolean handleEnterKeyPress() { |
438 return getMenuButtonHelper().onEnterKeyPress(mMenuButton); | 457 return getMenuButtonHelper().onEnterKeyPress(mMenuButton); |
439 } | 458 } |
440 }); | 459 }); |
441 onHomeButtonUpdate(HomepageManager.isHomepageEnabled(getContext())); | 460 onHomeButtonUpdate(HomepageManager.isHomepageEnabled(getContext())); |
442 | 461 |
443 updateVisualsForToolbarState(mIsInTabSwitcherMode); | 462 updateVisualsForToolbarState(); |
444 } | 463 } |
445 | 464 |
446 @Override | 465 @Override |
447 public boolean onInterceptTouchEvent(MotionEvent ev) { | 466 public boolean onInterceptTouchEvent(MotionEvent ev) { |
448 // If the NTP is partially scrolled, prevent all touch events to the chi
ld views. This | 467 // If the NTP is partially scrolled, prevent all touch events to the chi
ld views. This |
449 // is to not allow a secondary touch event to trigger entering the tab s
witcher, which | 468 // is to not allow a secondary touch event to trigger entering the tab s
witcher, which |
450 // can lead to really odd snapshots and transitions to the switcher. | 469 // can lead to really odd snapshots and transitions to the switcher. |
451 if (mNtpSearchBoxScrollPercent != 0f | 470 if (mNtpSearchBoxScrollPercent != 0f |
452 && mNtpSearchBoxScrollPercent != 1f | 471 && mNtpSearchBoxScrollPercent != 1f |
453 && mNtpSearchBoxScrollPercent != UNINITIALIZED_PERCENT) { | 472 && mNtpSearchBoxScrollPercent != UNINITIALIZED_PERCENT) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 if (!changed) return; | 522 if (!changed) return; |
504 } else { | 523 } else { |
505 updateUnfocusedLocationBarLayoutParams(); | 524 updateUnfocusedLocationBarLayoutParams(); |
506 } | 525 } |
507 | 526 |
508 super.onMeasure(widthMeasureSpec, heightMeasureSpec); | 527 super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
509 } | 528 } |
510 | 529 |
511 private void updateUnfocusedLocationBarLayoutParams() { | 530 private void updateUnfocusedLocationBarLayoutParams() { |
512 boolean hasVisibleViewPriorToUrlBar = false; | 531 boolean hasVisibleViewPriorToUrlBar = false; |
513 for (int i = 0; i < mPhoneLocationBar.getChildCount(); i++) { | 532 for (int i = 0; i < mLocationBar.getChildCount(); i++) { |
514 View child = mPhoneLocationBar.getChildAt(i); | 533 View child = mLocationBar.getChildAt(i); |
515 if (child == mUrlBar) break; | 534 if (child == mUrlBar) break; |
516 if (child.getVisibility() != GONE) { | 535 if (child.getVisibility() != GONE) { |
517 hasVisibleViewPriorToUrlBar = true; | 536 hasVisibleViewPriorToUrlBar = true; |
518 break; | 537 break; |
519 } | 538 } |
520 } | 539 } |
521 | 540 |
522 int leftViewBounds = getViewBoundsLeftOfLocationBar(mVisualState); | 541 int leftViewBounds = getViewBoundsLeftOfLocationBar(mVisualState); |
523 if (!hasVisibleViewPriorToUrlBar) leftViewBounds += mToolbarSidePadding; | |
524 int rightViewBounds = getViewBoundsRightOfLocationBar(mVisualState); | 542 int rightViewBounds = getViewBoundsRightOfLocationBar(mVisualState); |
525 | 543 |
526 if (!mPhoneLocationBar.hasVisibleViewsAfterUrlBarWhenUnfocused()) { | 544 if (!hasVisibleViewPriorToUrlBar) { |
| 545 if (ApiCompatibilityUtils.isLayoutRtl(mLocationBar)) { |
| 546 rightViewBounds -= mToolbarSidePadding; |
| 547 } else { |
| 548 leftViewBounds += mToolbarSidePadding; |
| 549 } |
| 550 } |
| 551 |
| 552 if (!mLocationBar.hasVisibleViewsAfterUrlBarWhenUnfocused()) { |
527 // Add spacing between the end of the URL and the edge of the omnibo
x drawable. | 553 // Add spacing between the end of the URL and the edge of the omnibo
x drawable. |
528 // This only applies if there is no end aligned view that should be
visible | 554 // This only applies if there is no end aligned view that should be
visible |
529 // while the omnibox is unfocused. | 555 // while the omnibox is unfocused. |
530 if (ApiCompatibilityUtils.isLayoutRtl(mPhoneLocationBar)) { | 556 if (ApiCompatibilityUtils.isLayoutRtl(mLocationBar)) { |
531 leftViewBounds += mToolbarSidePadding; | 557 leftViewBounds += mToolbarSidePadding; |
532 } else { | 558 } else { |
533 rightViewBounds -= mToolbarSidePadding; | 559 rightViewBounds -= mToolbarSidePadding; |
534 } | 560 } |
535 } | 561 } |
536 | 562 |
537 mUnfocusedLocationBarLayoutWidth = rightViewBounds - leftViewBounds; | 563 mUnfocusedLocationBarLayoutWidth = rightViewBounds - leftViewBounds; |
538 mUnfocusedLocationBarLayoutLeft = leftViewBounds; | 564 mUnfocusedLocationBarLayoutLeft = leftViewBounds; |
539 } | 565 } |
540 | 566 |
(...skipping 26 matching lines...) Expand all Loading... |
567 | 593 |
568 int width = 0; | 594 int width = 0; |
569 int leftMargin = 0; | 595 int leftMargin = 0; |
570 | 596 |
571 // Always update the unfocused layout params regardless of whether we ar
e using | 597 // Always update the unfocused layout params regardless of whether we ar
e using |
572 // those in this current layout pass as they are needed for animations. | 598 // those in this current layout pass as they are needed for animations. |
573 updateUnfocusedLocationBarLayoutParams(); | 599 updateUnfocusedLocationBarLayoutParams(); |
574 | 600 |
575 if (mLayoutLocationBarInFocusedMode || mVisualState == VisualState.NEW_T
AB_NORMAL) { | 601 if (mLayoutLocationBarInFocusedMode || mVisualState == VisualState.NEW_T
AB_NORMAL) { |
576 int priorVisibleWidth = 0; | 602 int priorVisibleWidth = 0; |
577 for (int i = 0; i < mPhoneLocationBar.getChildCount(); i++) { | 603 for (int i = 0; i < mLocationBar.getChildCount(); i++) { |
578 View child = mPhoneLocationBar.getChildAt(i); | 604 View child = mLocationBar.getChildAt(i); |
579 if (child == mPhoneLocationBar.getFirstViewVisibleWhenFocused())
break; | 605 if (child == mLocationBar.getFirstViewVisibleWhenFocused()) brea
k; |
580 if (child.getVisibility() == GONE) continue; | 606 if (child.getVisibility() == GONE) continue; |
581 priorVisibleWidth += child.getMeasuredWidth(); | 607 priorVisibleWidth += child.getMeasuredWidth(); |
582 } | 608 } |
583 | 609 |
584 width = containerWidth - (2 * mToolbarSidePadding) + priorVisibleWid
th; | 610 width = containerWidth - (2 * mToolbarSidePadding) + priorVisibleWid
th; |
585 if (ApiCompatibilityUtils.isLayoutRtl(mPhoneLocationBar)) { | 611 if (ApiCompatibilityUtils.isLayoutRtl(mLocationBar)) { |
586 leftMargin = mToolbarSidePadding; | 612 leftMargin = mToolbarSidePadding; |
587 } else { | 613 } else { |
588 leftMargin = -priorVisibleWidth + mToolbarSidePadding; | 614 leftMargin = -priorVisibleWidth + mToolbarSidePadding; |
589 } | 615 } |
590 } else { | 616 } else { |
591 width = mUnfocusedLocationBarLayoutWidth; | 617 width = mUnfocusedLocationBarLayoutWidth; |
592 leftMargin = mUnfocusedLocationBarLayoutLeft; | 618 leftMargin = mUnfocusedLocationBarLayoutLeft; |
593 } | 619 } |
594 | 620 |
595 boolean changed = false; | 621 boolean changed = false; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 | 696 |
671 @Override | 697 @Override |
672 protected void dispatchDraw(Canvas canvas) { | 698 protected void dispatchDraw(Canvas canvas) { |
673 if (!mTextureCaptureMode && mToolbarBackground.getColor() != Color.TRANS
PARENT) { | 699 if (!mTextureCaptureMode && mToolbarBackground.getColor() != Color.TRANS
PARENT) { |
674 // Update to compensate for orientation changes. | 700 // Update to compensate for orientation changes. |
675 mToolbarBackground.setBounds(0, 0, getWidth(), getHeight()); | 701 mToolbarBackground.setBounds(0, 0, getWidth(), getHeight()); |
676 mToolbarBackground.draw(canvas); | 702 mToolbarBackground.draw(canvas); |
677 } | 703 } |
678 | 704 |
679 if (mLocationBarBackground != null | 705 if (mLocationBarBackground != null |
680 && (mPhoneLocationBar.getVisibility() == VISIBLE || mTextureCapt
ureMode)) { | 706 && (mLocationBar.getVisibility() == VISIBLE || mTextureCaptureMo
de)) { |
681 updateUrlViewportBounds(mUrlViewportBounds, mVisualState, false); | 707 updateLocationBarBackgroundBounds(mLocationBarBackgroundBounds, mVis
ualState); |
682 } | 708 } |
683 | 709 |
684 if (mTextureCaptureMode) { | 710 if (mTextureCaptureMode) { |
685 drawTabSwitcherAnimationOverlay(canvas, 0.f); | 711 drawTabSwitcherAnimationOverlay(canvas, 0.f); |
686 } else { | 712 } else { |
687 boolean tabSwitcherAnimationFinished = false; | 713 boolean tabSwitcherAnimationFinished = false; |
688 if (mTabSwitcherModeAnimation != null) { | 714 if (mTabSwitcherModeAnimation != null) { |
689 tabSwitcherAnimationFinished = !mTabSwitcherModeAnimation.isRunn
ing(); | 715 tabSwitcherAnimationFinished = !mTabSwitcherModeAnimation.isRunn
ing(); |
690 | 716 |
691 // Perform the fade logic before super.dispatchDraw(canvas) so t
hat we can properly | 717 // Perform the fade logic before super.dispatchDraw(canvas) so t
hat we can properly |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 && !getToolbarDataProvider().getNewTabPageForCurrentTab().isCard
sUiEnabled()) { | 751 && !getToolbarDataProvider().getNewTabPageForCurrentTab().isCard
sUiEnabled()) { |
726 return; | 752 return; |
727 } | 753 } |
728 | 754 |
729 mNtpSearchBoxScrollPercent = scrollPercentage; | 755 mNtpSearchBoxScrollPercent = scrollPercentage; |
730 updateUrlExpansionPercent(); | 756 updateUrlExpansionPercent(); |
731 updateUrlExpansionAnimation(); | 757 updateUrlExpansionAnimation(); |
732 } | 758 } |
733 | 759 |
734 /** | 760 /** |
735 * Calculate the bounds for UrlViewport and set them to out rect. | 761 * Calculate the bounds for the location bar background and set them to {@co
de out}. |
736 */ | 762 */ |
737 private void updateUrlViewportBounds(Rect out, VisualState visualState, | 763 private void updateLocationBarBackgroundBounds(Rect out, VisualState visualS
tate) { |
738 boolean ignoreTranslationY) { | 764 // Calculate the visible boundaries of the left and right most child vie
ws of the |
739 // Calculate the visible boundaries of the left and right most child vie
ws | 765 // location bar. |
740 // of the location bar. | 766 float expansion = visualState == VisualState.NEW_TAB_NORMAL ? 1 : mUrlEx
pansionPercent; |
741 int leftViewPosition = (int) MathUtils.interpolate( | 767 int leftViewPosition = (int) MathUtils.interpolate( |
742 getViewBoundsLeftOfLocationBar(visualState), 0f, mUrlExpansionPe
rcent) | 768 getViewBoundsLeftOfLocationBar(visualState), |
743 - mUrlBackgroundPadding.left; | 769 -mLocationBarBackgroundCornerRadius, |
| 770 expansion); |
744 int rightViewPosition = (int) MathUtils.interpolate( | 771 int rightViewPosition = (int) MathUtils.interpolate( |
745 getViewBoundsRightOfLocationBar(visualState), getWidth(), mUrlEx
pansionPercent) | 772 getViewBoundsRightOfLocationBar(visualState), |
746 + mUrlBackgroundPadding.right; | 773 getWidth() + mLocationBarBackgroundCornerRadius, |
| 774 expansion); |
747 | 775 |
748 // The bounds are set by the following: | 776 // The bounds are set by the following: |
749 // - The left most visible location bar child view. | 777 // - The left most visible location bar child view. |
750 // - The top of the viewport is aligned with the top of the location bar
. | 778 // - The top of the viewport is aligned with the top of the location bar
. |
751 // - The right most visible location bar child view. | 779 // - The right most visible location bar child view. |
752 // - The bottom of the viewport is aligned with the bottom of the locati
on bar. | 780 // - The bottom of the viewport is aligned with the bottom of the locati
on bar. |
753 // Additional padding can be applied for use during animations. | 781 // Additional padding can be applied for use during animations. |
754 float yOffset = ignoreTranslationY ? mPhoneLocationBar.getTop() : mPhone
LocationBar.getY(); | 782 int verticalMargin = (int) MathUtils.interpolate(mLocationBarVerticalMar
gin, 0, expansion); |
755 | |
756 out.set(leftViewPosition, | 783 out.set(leftViewPosition, |
757 (int) (yOffset - (mUrlBackgroundPadding.top * mUrlExpansionPerce
nt)), | 784 mLocationBar.getTop() + verticalMargin, |
758 rightViewPosition, | 785 rightViewPosition, |
759 (int) (yOffset + MathUtils.interpolate(mPhoneLocationBar.getMeas
uredHeight(), | 786 mLocationBar.getBottom() - verticalMargin); |
760 getHeight() + mUrlBackgroundPadding.bottom, mUrlExpansio
nPercent))); | |
761 } | 787 } |
762 | 788 |
763 /** | 789 /** |
764 * Updates percentage of current the URL focus change animation. | 790 * Updates percentage of current the URL focus change animation. |
765 * @param percent 1.0 is 100% focused, 0 is completely unfocused. | 791 * @param percent 1.0 is 100% focused, 0 is completely unfocused. |
766 */ | 792 */ |
767 private void setUrlFocusChangePercent(float percent) { | 793 private void setUrlFocusChangePercent(float percent) { |
768 mUrlFocusChangePercent = percent; | 794 mUrlFocusChangePercent = percent; |
769 updateUrlExpansionPercent(); | 795 updateUrlExpansionPercent(); |
770 updateUrlExpansionAnimation(); | 796 updateUrlExpansionAnimation(); |
771 } | 797 } |
772 | 798 |
773 private void updateUrlExpansionPercent() { | 799 private void updateUrlExpansionPercent() { |
774 mUrlExpansionPercent = Math.max(mNtpSearchBoxScrollPercent, mUrlFocusCha
ngePercent); | 800 mUrlExpansionPercent = Math.max(mNtpSearchBoxScrollPercent, mUrlFocusCha
ngePercent); |
775 assert mUrlExpansionPercent >= 0; | 801 assert mUrlExpansionPercent >= 0; |
776 assert mUrlExpansionPercent <= 1; | 802 assert mUrlExpansionPercent <= 1; |
777 } | 803 } |
778 | 804 |
| 805 /** |
| 806 * Updates the parameters relating to expanding the location bar, as the res
ult of either a |
| 807 * focus change or scrolling the New Tab Page. |
| 808 */ |
779 private void updateUrlExpansionAnimation() { | 809 private void updateUrlExpansionAnimation() { |
780 if (mIsInTabSwitcherMode || isTabSwitcherAnimationRunning()) { | 810 if (mIsInTabSwitcherMode || isTabSwitcherAnimationRunning()) { |
781 mToolbarButtonsContainer.setVisibility(VISIBLE); | 811 mToolbarButtonsContainer.setVisibility(VISIBLE); |
782 return; | 812 return; |
783 } | 813 } |
784 | 814 |
785 mLocationBarBackgroundOffset.setEmpty(); | 815 FrameLayout.LayoutParams locationBarLayoutParams = getFrameLayoutParams(
mLocationBar); |
786 | |
787 FrameLayout.LayoutParams locationBarLayoutParams = | |
788 getFrameLayoutParams(mPhoneLocationBar); | |
789 int currentLeftMargin = locationBarLayoutParams.leftMargin; | 816 int currentLeftMargin = locationBarLayoutParams.leftMargin; |
790 int currentWidth = locationBarLayoutParams.width; | 817 int currentWidth = locationBarLayoutParams.width; |
791 | 818 |
792 float inversePercent = 1f - mUrlExpansionPercent; | 819 float locationBarBaseTranslationX = mUnfocusedLocationBarLayoutLeft - cu
rrentLeftMargin; |
793 float locationBarTranslationX = mUnfocusedLocationBarLayoutLeft - curren
tLeftMargin; | 820 boolean isLocationBarRtl = ApiCompatibilityUtils.isLayoutRtl(mLocationBa
r); |
794 boolean isLocationBarRtl = ApiCompatibilityUtils.isLayoutRtl(mPhoneLocat
ionBar); | |
795 if (isLocationBarRtl) { | 821 if (isLocationBarRtl) { |
796 locationBarTranslationX += mUnfocusedLocationBarLayoutWidth - curren
tWidth; | 822 locationBarBaseTranslationX += mUnfocusedLocationBarLayoutWidth - cu
rrentWidth; |
797 } | 823 } |
798 locationBarTranslationX *= inversePercent; | 824 locationBarBaseTranslationX *= 1f - mUrlExpansionPercent; |
799 | 825 |
800 mPhoneLocationBar.setTranslationX(locationBarTranslationX); | 826 mLocationBarBackgroundNtpOffset.setEmpty(); |
| 827 mLocationBarNtpOffsetLeft = 0; |
| 828 mLocationBarNtpOffsetRight = 0; |
| 829 |
| 830 Tab currentTab = getToolbarDataProvider().getTab(); |
| 831 if (currentTab != null) { |
| 832 NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab
(); |
| 833 // Explicitly use the focus change percentage here because it applie
s scroll |
| 834 // compensation that only applies during focus animations. |
| 835 if (ntp != null && mUrlFocusChangeInProgress) { |
| 836 ntp.setUrlFocusChangeAnimationPercent(mUrlFocusChangePercent); |
| 837 } |
| 838 |
| 839 if (isLocationBarShownInNTP()) { |
| 840 updateNtpTransitionAnimation(); |
| 841 } else { |
| 842 // Reset these values in case we transitioned to a different pag
e during the |
| 843 // transition. |
| 844 resetNtpAnimationValues(); |
| 845 } |
| 846 } |
| 847 |
| 848 boolean isRtl = ApiCompatibilityUtils.isLayoutRtl(this); |
| 849 |
| 850 float locationBarTranslationX; |
| 851 // Get the padding straight from the location bar instead of |
| 852 // |mLocationBarBackgroundPadding|, because it might be different in inc
ognito mode. |
| 853 if (isRtl) { |
| 854 locationBarTranslationX = locationBarBaseTranslationX |
| 855 + mLocationBarNtpOffsetRight - mLocationBar.getPaddingRight(
); |
| 856 } else { |
| 857 locationBarTranslationX = locationBarBaseTranslationX |
| 858 + mLocationBarNtpOffsetLeft + mLocationBar.getPaddingLeft(); |
| 859 } |
| 860 mLocationBar.setTranslationX(locationBarTranslationX); |
801 | 861 |
802 // Negate the location bar translation to keep the URL action container
in the same | 862 // Negate the location bar translation to keep the URL action container
in the same |
803 // place during the focus expansion. | 863 // place during the focus expansion. |
804 if (!isLocationBarRtl || ApiCompatibilityUtils.isLayoutRtl(this)) { | 864 float urlActionsTranslationX = 0; |
805 mUrlActionsContainer.setTranslationX(-locationBarTranslationX); | 865 if (!isLocationBarRtl || isRtl) { |
| 866 urlActionsTranslationX = -locationBarBaseTranslationX; |
806 } | 867 } |
807 | 868 |
808 mPhoneLocationBar.setUrlFocusChangePercent(mUrlExpansionPercent); | 869 if (isRtl) { |
| 870 urlActionsTranslationX += mLocationBarNtpOffsetLeft - mLocationBarNt
pOffsetRight; |
| 871 } else { |
| 872 urlActionsTranslationX += mLocationBarNtpOffsetRight - mLocationBarN
tpOffsetLeft; |
| 873 } |
| 874 mUrlActionContainer.setTranslationX(urlActionsTranslationX); |
| 875 |
| 876 mLocationBar.setUrlFocusChangePercent(mUrlExpansionPercent); |
809 | 877 |
810 // Ensure the buttons are invisible after focusing the omnibox to preven
t them from | 878 // Ensure the buttons are invisible after focusing the omnibox to preven
t them from |
811 // accepting click events. | 879 // accepting click events. |
812 int toolbarButtonVisibility = mUrlExpansionPercent == 1f ? INVISIBLE : V
ISIBLE; | 880 int toolbarButtonVisibility = mUrlExpansionPercent == 1f ? INVISIBLE : V
ISIBLE; |
813 mToolbarButtonsContainer.setVisibility(toolbarButtonVisibility); | 881 mToolbarButtonsContainer.setVisibility(toolbarButtonVisibility); |
814 if (mReturnButton.getVisibility() != GONE) { | 882 if (mReturnButton.getVisibility() != GONE) { |
815 mReturnButton.setVisibility(toolbarButtonVisibility); | 883 mReturnButton.setVisibility(toolbarButtonVisibility); |
816 } | 884 } |
817 if (mHomeButton.getVisibility() != GONE) { | 885 if (mHomeButton.getVisibility() != GONE) { |
818 mHomeButton.setVisibility(toolbarButtonVisibility); | 886 mHomeButton.setVisibility(toolbarButtonVisibility); |
819 } | 887 } |
820 | 888 |
821 // Force an invalidation of the location bar to properly handle the clip
ping of the URL | 889 // Force an invalidation of the location bar to properly handle the clip
ping of the URL |
822 // bar text as a result of the url action container translations. | 890 // bar text as a result of the url action container translations. |
823 mPhoneLocationBar.invalidate(); | 891 mLocationBar.invalidate(); |
824 invalidate(); | 892 invalidate(); |
825 | |
826 Tab currentTab = getToolbarDataProvider().getTab(); | |
827 if (currentTab == null) return; | |
828 | |
829 NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab(); | |
830 // Explicitly use the focus change percentage here because it applies sc
roll compensation | |
831 // that only applies during focus animations. | |
832 if (ntp != null && mUrlFocusChangeInProgress) { | |
833 ntp.setUrlFocusChangeAnimationPercent(mUrlFocusChangePercent); | |
834 } | |
835 | |
836 if (!isLocationBarShownInNTP()) { | |
837 // Reset these values in case we transitioned to a different page du
ring the | |
838 // transition. | |
839 resetNtpAnimationValues(); | |
840 return; | |
841 } | |
842 | |
843 updateNtpTransitionAnimation(); | |
844 } | 893 } |
845 | 894 |
| 895 /** |
| 896 * Reset the parameters for the New Tab Page transition animation (expanding
the location bar as |
| 897 * a result of scrolling the New Tab Page) to their default values. |
| 898 */ |
846 private void resetNtpAnimationValues() { | 899 private void resetNtpAnimationValues() { |
847 mLocationBarBackgroundOffset.setEmpty(); | 900 mLocationBarBackgroundNtpOffset.setEmpty(); |
848 mPhoneLocationBar.setTranslationY(0); | 901 mLocationBar.setTranslationY(0); |
849 if (!mUrlFocusChangeInProgress) { | 902 if (!mUrlFocusChangeInProgress) { |
850 mToolbarButtonsContainer.setTranslationY(0); | 903 mToolbarButtonsContainer.setTranslationY(0); |
851 mReturnButton.setTranslationY(0); | 904 mReturnButton.setTranslationY(0); |
852 mHomeButton.setTranslationY(0); | 905 mHomeButton.setTranslationY(0); |
853 } | 906 } |
854 mToolbarShadow.setAlpha(1f); | 907 mToolbarShadow.setAlpha(1f); |
855 mPhoneLocationBar.setAlpha(1); | 908 mLocationBar.setAlpha(1); |
856 mForceDrawLocationBarBackground = false; | 909 mForceDrawLocationBarBackground = false; |
857 mUrlBackgroundAlpha = isIncognito() | 910 mLocationBarBackgroundAlpha = 255; |
858 || (mUnfocusedLocationBarUsesTransparentBg | 911 if (isIncognito() |
859 && !mUrlFocusChangeInProgress | 912 || (mUnfocusedLocationBarUsesTransparentBg && !mUrlFocusChangeIn
Progress |
860 && !mPhoneLocationBar.hasFocus()) | 913 && !mLocationBar.hasFocus())) { |
861 ? LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA : 255; | 914 mLocationBarBackgroundAlpha = LOCATION_BAR_TRANSPARENT_BACKGROUND_AL
PHA; |
| 915 } |
862 setAncestorsShouldClipChildren(true); | 916 setAncestorsShouldClipChildren(true); |
863 mNtpSearchBoxScrollPercent = UNINITIALIZED_PERCENT; | 917 mNtpSearchBoxScrollPercent = UNINITIALIZED_PERCENT; |
864 updateUrlExpansionPercent(); | 918 updateUrlExpansionPercent(); |
865 } | 919 } |
866 | 920 |
| 921 /** |
| 922 * Updates the parameters of the New Tab Page transition animation (expandin
g the location bar |
| 923 * as a result of scrolling the New Tab Page). |
| 924 */ |
867 private void updateNtpTransitionAnimation() { | 925 private void updateNtpTransitionAnimation() { |
868 if (mIsInTabSwitcherMode) return; | 926 if (mIsInTabSwitcherMode) return; |
869 | 927 |
870 NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab(); | |
871 | |
872 setAncestorsShouldClipChildren(mUrlExpansionPercent == 0f); | 928 setAncestorsShouldClipChildren(mUrlExpansionPercent == 0f); |
873 mToolbarShadow.setAlpha(0f); | 929 mToolbarShadow.setAlpha(0f); |
874 | 930 |
875 float growthPercent = 0f; | 931 NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab(); |
876 if (ntp.isCardsUiEnabled() || mUrlExpansionPercent == 0f || mUrlExpansio
nPercent == 1f) { | 932 ntp.getSearchBoxBounds(mNtpSearchBoxBounds, mNtpSearchBoxTranslation); |
877 growthPercent = 1f - mUrlExpansionPercent; | 933 int locationBarTranslationY = |
878 } else { | 934 Math.max(0, (mNtpSearchBoxBounds.top - mLocationBar.getTop())); |
879 // During the transition from search box to omnibox, keep the omnibo
x drawing | 935 mLocationBar.setTranslationY(locationBarTranslationY); |
880 // at the same size of the search box for first 40% of the scroll tr
ansition. | |
881 growthPercent = mUrlExpansionPercent <= 0.4f | |
882 ? 1f : Math.min(1f, (1f - mUrlExpansionPercent) * 1.66667f); | |
883 } | |
884 | |
885 int paddingTop = mPhoneLocationBar.getPaddingTop(); | |
886 int paddingBottom = mPhoneLocationBar.getPaddingBottom(); | |
887 | |
888 ntp.getSearchBoxBounds(mNtpSearchBoxOriginalBounds, mNtpSearchBoxTransfo
rmedBounds); | |
889 float halfHeightDifference = (mNtpSearchBoxTransformedBounds.height() | |
890 - (mPhoneLocationBar.getMeasuredHeight() - paddingTop - paddingB
ottom | |
891 + mLocationBarInsets)) / 2f; | |
892 mPhoneLocationBar.setTranslationY(growthPercent == 0f ? 0 : Math.max(0, | |
893 (mNtpSearchBoxTransformedBounds.top - mPhoneLocationBar.getTop() | |
894 + halfHeightDifference))); | |
895 if (!mUrlFocusChangeInProgress) { | 936 if (!mUrlFocusChangeInProgress) { |
896 setButtonsTranslationY(); | 937 setButtonsTranslationY(); |
897 } | 938 } |
898 | 939 |
899 mLocationBarBackgroundOffset.set( | 940 // Linearly interpolate between the bounds of the search box on the NTP
and the omnibox |
900 (int) ((mNtpSearchBoxTransformedBounds.left - mUrlViewportBounds
.left | 941 // background bounds. |shrinkage| is the scaling factor for the offset -
- if it's 1, we are |
901 - mPhoneLocationBar.getPaddingLeft()) * growthPercent), | 942 // shrinking the omnibox down to the size of the search box. |
902 (int) ((-halfHeightDifference - paddingTop) * growthPercent), | 943 float shrinkage; |
903 (int) ((mNtpSearchBoxTransformedBounds.right - mUrlViewportBound
s.right | 944 if (ntp.isCardsUiEnabled()) { |
904 + mPhoneLocationBar.getPaddingRight()) * growthPercent), | 945 shrinkage = 1f |
905 (int) ((halfHeightDifference - paddingBottom + mLocationBarInset
s) | 946 - NTP_SEARCH_BOX_EXPANSION_INTERPOLATOR.getInterpolation(mUr
lExpansionPercent); |
906 * growthPercent)); | |
907 | |
908 // The transparency of the location bar is dependent on how different it
s size is | |
909 // from the final value. This is based on how much growth is applied be
tween the | |
910 // desired size of the location bar to its drawn size. The location bar
then only | |
911 // starts becoming opaque once the growth is at least half done. | |
912 if (growthPercent >= 0.5f) { | |
913 mPhoneLocationBar.setAlpha(0); | |
914 } else { | 947 } else { |
915 mPhoneLocationBar.setAlpha(1f - growthPercent * 2); | 948 // During the transition from middle of the NTP to the top, keep the
omnibox drawing |
| 949 // at the same size of the search box for first 40% of the scroll tr
ansition. |
| 950 shrinkage = Math.min(1f, (1f - mUrlExpansionPercent) * 1.66667f); |
916 } | 951 } |
917 | 952 |
918 // Go from a transparent url background to a fully opaque one in the fir
st 40% of the | 953 int leftBoundDifference = mNtpSearchBoxBounds.left - mLocationBarBackgro
undBounds.left; |
919 // scroll transition. | 954 int rightBoundDifference = mNtpSearchBoxBounds.right - mLocationBarBackg
roundBounds.right; |
920 mUrlBackgroundAlpha = | 955 mLocationBarBackgroundNtpOffset.set( |
921 mUrlExpansionPercent >= 0.4f ? 255 : (int) ((mUrlExpansionPercen
t * 2.5f) * 255); | 956 (int) Math.round(leftBoundDifference * shrinkage), |
922 if (mUrlExpansionPercent == 1f) mUrlBackgroundAlpha = 255; | 957 locationBarTranslationY, |
923 mForceDrawLocationBarBackground = mUrlExpansionPercent != 0f; | 958 (int) Math.round(rightBoundDifference * shrinkage), |
| 959 locationBarTranslationY); |
| 960 |
| 961 // The omnibox background bounds are outset by |mLocationBarBackgroundCo
rnerRadius| in the |
| 962 // fully expanded state (and only there!) to hide the rounded corners, s
o undo that before |
| 963 // applying the shrinkage factor. |
| 964 mLocationBarNtpOffsetLeft = |
| 965 (leftBoundDifference - mLocationBarBackgroundCornerRadius) * shr
inkage; |
| 966 mLocationBarNtpOffsetRight = |
| 967 (rightBoundDifference + mLocationBarBackgroundCornerRadius) * sh
rinkage; |
| 968 |
| 969 mLocationBarBackgroundAlpha = mUrlExpansionPercent > 0f ? 255 : 0; |
| 970 mForceDrawLocationBarBackground = mLocationBarBackgroundAlpha > 0; |
| 971 float relativeAlpha = mLocationBarBackgroundAlpha / 255f; |
| 972 mLocationBar.setAlpha(relativeAlpha); |
| 973 |
| 974 // The search box on the NTP is visible if our omnibox is invisible, and
vice-versa. |
| 975 ntp.setSearchBoxAlpha(1f - relativeAlpha); |
| 976 |
| 977 if (!ntp.isCardsUiEnabled()) { |
| 978 ntp.setSearchProviderLogoAlpha(Math.max(1f - mUrlExpansionPercent *
2.5f, 0f)); |
| 979 } |
924 } | 980 } |
925 | 981 |
926 private void setButtonsTranslationY() { | 982 private void setButtonsTranslationY() { |
927 float searchBoxTranslationY = | 983 int searchBoxTranslationY = Math.min(mNtpSearchBoxTranslation.y, 0); |
928 mNtpSearchBoxTransformedBounds.top - mNtpSearchBoxOriginalBounds
.top; | |
929 searchBoxTranslationY = Math.min(searchBoxTranslationY, 0); | |
930 mToolbarButtonsContainer.setTranslationY(searchBoxTranslationY); | 984 mToolbarButtonsContainer.setTranslationY(searchBoxTranslationY); |
931 mReturnButton.setTranslationY(searchBoxTranslationY); | 985 mReturnButton.setTranslationY(searchBoxTranslationY); |
932 mHomeButton.setTranslationY(searchBoxTranslationY); | 986 mHomeButton.setTranslationY(searchBoxTranslationY); |
933 } | 987 } |
934 | 988 |
935 private void setAncestorsShouldClipChildren(boolean clip) { | 989 private void setAncestorsShouldClipChildren(boolean clip) { |
936 if (!isLocationBarShownInNTP()) return; | 990 if (!isLocationBarShownInNTP()) return; |
937 ViewGroup parent = this; | 991 ViewGroup parent = this; |
938 while (parent != null) { | 992 while (parent != null) { |
939 parent.setClipChildren(clip); | 993 parent.setClipChildren(clip); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 } | 1030 } |
977 if (mHomeButton.getVisibility() != View.GONE) { | 1031 if (mHomeButton.getVisibility() != View.GONE) { |
978 // Draw the New Tab button used in the URL view. | 1032 // Draw the New Tab button used in the URL view. |
979 previousAlpha = mHomeButton.getAlpha(); | 1033 previousAlpha = mHomeButton.getAlpha(); |
980 mHomeButton.setAlpha(previousAlpha * floatAlpha); | 1034 mHomeButton.setAlpha(previousAlpha * floatAlpha); |
981 drawChild(canvas, mHomeButton, SystemClock.uptimeMillis()); | 1035 drawChild(canvas, mHomeButton, SystemClock.uptimeMillis()); |
982 mHomeButton.setAlpha(previousAlpha); | 1036 mHomeButton.setAlpha(previousAlpha); |
983 } | 1037 } |
984 | 1038 |
985 // Draw the location/URL bar. | 1039 // Draw the location/URL bar. |
986 previousAlpha = mPhoneLocationBar.getAlpha(); | 1040 previousAlpha = mLocationBar.getAlpha(); |
987 mPhoneLocationBar.setAlpha(previousAlpha * floatAlpha); | 1041 mLocationBar.setAlpha(previousAlpha * floatAlpha); |
988 // If the location bar is now fully transparent, do not bother drawing i
t. | 1042 // If the location bar is now fully transparent, do not bother drawing i
t. |
989 if (mPhoneLocationBar.getAlpha() != 0) { | 1043 if (mLocationBar.getAlpha() != 0) { |
990 drawChild(canvas, mPhoneLocationBar, SystemClock.uptimeMillis()); | 1044 drawChild(canvas, mLocationBar, SystemClock.uptimeMillis()); |
991 } | 1045 } |
992 mPhoneLocationBar.setAlpha(previousAlpha); | 1046 mLocationBar.setAlpha(previousAlpha); |
993 | 1047 |
994 // Draw the tab stack button and associated text. | 1048 // Draw the tab stack button and associated text. |
995 translateCanvasToView(this, mToolbarButtonsContainer, canvas); | 1049 translateCanvasToView(this, mToolbarButtonsContainer, canvas); |
996 | 1050 |
997 if (mTabSwitcherAnimationTabStackDrawable != null && mToggleTabStackButt
on != null | 1051 if (mTabSwitcherAnimationTabStackDrawable != null && mToggleTabStackButt
on != null |
998 && mUrlExpansionPercent != 1f) { | 1052 && mUrlExpansionPercent != 1f) { |
999 // Draw the tab stack button image. | 1053 // Draw the tab stack button image. |
1000 canvas.save(); | 1054 canvas.save(); |
1001 translateCanvasToView(mToolbarButtonsContainer, mToggleTabStackButto
n, canvas); | 1055 translateCanvasToView(mToolbarButtonsContainer, mToggleTabStackButto
n, canvas); |
1002 | 1056 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1074 canvas.translate(to.getLeft(), to.getTop()); | 1128 canvas.translate(to.getLeft(), to.getTop()); |
1075 if (!(to.getParent() instanceof View)) { | 1129 if (!(to.getParent() instanceof View)) { |
1076 throw new IllegalArgumentException("View 'to' was not a desenden
t of 'from'."); | 1130 throw new IllegalArgumentException("View 'to' was not a desenden
t of 'from'."); |
1077 } | 1131 } |
1078 to = (View) to.getParent(); | 1132 to = (View) to.getParent(); |
1079 } | 1133 } |
1080 } | 1134 } |
1081 | 1135 |
1082 @Override | 1136 @Override |
1083 protected boolean drawChild(Canvas canvas, View child, long drawingTime) { | 1137 protected boolean drawChild(Canvas canvas, View child, long drawingTime) { |
1084 if (child == mPhoneLocationBar) return drawLocationBar(canvas, drawingTi
me); | 1138 if (child == mLocationBar) return drawLocationBar(canvas, drawingTime); |
1085 boolean clipped = false; | 1139 boolean clipped = false; |
1086 | 1140 |
1087 if (mLocationBarBackground != null | 1141 if (mLocationBarBackground != null |
1088 && ((!mIsInTabSwitcherMode && !mTabSwitcherModeViews.contains(ch
ild)) | 1142 && ((!mIsInTabSwitcherMode && !mTabSwitcherModeViews.contains(ch
ild)) |
1089 || (mIsInTabSwitcherMode && mBrowsingModeViews.contains(
child)))) { | 1143 || (mIsInTabSwitcherMode && mBrowsingModeViews.contains(
child)))) { |
1090 canvas.save(); | 1144 canvas.save(); |
1091 if (mUrlExpansionPercent != 0f && mUrlViewportBounds.top < child.get
Bottom()) { | 1145 |
| 1146 int translationY = (int) mLocationBar.getTranslationY(); |
| 1147 int clipTop = mLocationBarBackgroundBounds.top - mLocationBarBackgro
undPadding.top |
| 1148 + translationY; |
| 1149 if (mUrlExpansionPercent != 0f && clipTop < child.getBottom()) { |
1092 // For other child views, use the inverse clipping of the URL vi
ewport. | 1150 // For other child views, use the inverse clipping of the URL vi
ewport. |
1093 // Only necessary during animations. | 1151 // Only necessary during animations. |
1094 // Hardware mode does not support unioned clip regions, so clip
using the | 1152 // Hardware mode does not support unioned clip regions, so clip
using the |
1095 // appropriate bounds based on whether the child is to the left
or right of the | 1153 // appropriate bounds based on whether the child is to the left
or right of the |
1096 // location bar. | 1154 // location bar. |
1097 boolean isLeft = (child == mNewTabButton || child == mReturnButt
on | 1155 boolean isLeft = (child == mNewTabButton || child == mReturnButt
on |
1098 || child == mHomeButton) ^ LocalizationUtils.isLayoutRtl
(); | 1156 || child == mHomeButton) ^ LocalizationUtils.isLayoutRtl
(); |
1099 | 1157 |
1100 int clipTop = mUrlViewportBounds.top; | 1158 int clipBottom = mLocationBarBackgroundBounds.bottom |
1101 int clipBottom = mUrlViewportBounds.bottom; | 1159 + mLocationBarBackgroundPadding.bottom + translationY; |
1102 boolean verticalClip = false; | 1160 boolean verticalClip = false; |
1103 if (mPhoneLocationBar.getTranslationY() > 0f) { | 1161 if (translationY > 0f) { |
1104 clipTop = child.getTop(); | 1162 clipTop = child.getTop(); |
1105 clipBottom = mUrlViewportBounds.top; | 1163 clipBottom = clipTop; |
1106 verticalClip = true; | 1164 verticalClip = true; |
1107 } | 1165 } |
1108 | 1166 |
1109 if (isLeft) { | 1167 if (isLeft) { |
1110 canvas.clipRect( | 1168 int clipRight = verticalClip ? child.getMeasuredWidth() |
1111 0, clipTop, | 1169 : mLocationBarBackgroundBounds.left |
1112 verticalClip ? child.getMeasuredWidth() : mUrlViewpo
rtBounds.left, | 1170 - mLocationBarBackgroundPadding.left; |
1113 clipBottom); | 1171 canvas.clipRect(0, clipTop, clipRight, clipBottom); |
1114 } else { | 1172 } else { |
1115 canvas.clipRect( | 1173 int clipLeft = verticalClip ? 0 : mLocationBarBackgroundBoun
ds.right |
1116 verticalClip ? 0 : mUrlViewportBounds.right, | 1174 + mLocationBarBackgroundPadding.right; |
1117 clipTop, getMeasuredWidth(), clipBottom); | 1175 canvas.clipRect(clipLeft, clipTop, getMeasuredWidth(), clipB
ottom); |
1118 } | 1176 } |
1119 } | 1177 } |
1120 clipped = true; | 1178 clipped = true; |
1121 } | 1179 } |
1122 boolean retVal = super.drawChild(canvas, child, drawingTime); | 1180 boolean retVal = super.drawChild(canvas, child, drawingTime); |
1123 if (clipped) canvas.restore(); | 1181 if (clipped) canvas.restore(); |
1124 return retVal; | 1182 return retVal; |
1125 } | 1183 } |
1126 | 1184 |
1127 private boolean drawLocationBar(Canvas canvas, long drawingTime) { | 1185 private boolean drawLocationBar(Canvas canvas, long drawingTime) { |
1128 boolean clipped = false; | 1186 boolean clipped = false; |
1129 | 1187 |
1130 if (mLocationBarBackground != null && (!mIsInTabSwitcherMode || mTexture
CaptureMode)) { | 1188 if (mLocationBarBackground != null && (!mIsInTabSwitcherMode || mTexture
CaptureMode)) { |
1131 canvas.save(); | 1189 canvas.save(); |
1132 int backgroundAlpha; | 1190 int backgroundAlpha; |
1133 if (mTabSwitcherModeAnimation != null) { | 1191 if (mTabSwitcherModeAnimation != null) { |
1134 // Fade out/in the location bar towards the beginning of the ani
mations to avoid | 1192 // Fade out/in the location bar towards the beginning of the ani
mations to avoid |
1135 // large jumps of stark white. | 1193 // large jumps of stark white. |
1136 backgroundAlpha = | 1194 backgroundAlpha = |
1137 (int) (Math.pow(mPhoneLocationBar.getAlpha(), 3) * mUrlB
ackgroundAlpha); | 1195 (int) (Math.pow(mLocationBar.getAlpha(), 3) * mLocationB
arBackgroundAlpha); |
1138 } else if (getToolbarDataProvider().isUsingBrandColor() | 1196 } else if (getToolbarDataProvider().isUsingBrandColor() |
1139 && !mBrandColorTransitionActive) { | 1197 && !mBrandColorTransitionActive) { |
1140 backgroundAlpha = mUnfocusedLocationBarUsesTransparentBg | 1198 backgroundAlpha = mUnfocusedLocationBarUsesTransparentBg |
1141 ? (int) (MathUtils.interpolate(LOCATION_BAR_TRANSPARENT_
BACKGROUND_ALPHA, | 1199 ? (int) (MathUtils.interpolate(LOCATION_BAR_TRANSPARENT_
BACKGROUND_ALPHA, |
1142 255, mUrlExpansionPercent)) | 1200 255, mUrlExpansionPercent)) |
1143 : 255; | 1201 : 255; |
1144 } else { | 1202 } else { |
1145 backgroundAlpha = mUrlBackgroundAlpha; | 1203 backgroundAlpha = mLocationBarBackgroundAlpha; |
1146 } | 1204 } |
1147 mLocationBarBackground.setAlpha(backgroundAlpha); | 1205 mLocationBarBackground.setAlpha(backgroundAlpha); |
1148 | 1206 |
1149 if ((mPhoneLocationBar.getAlpha() > 0 || mForceDrawLocationBarBackgr
ound) | 1207 if ((mLocationBar.getAlpha() > 0 || mForceDrawLocationBarBackground) |
1150 && !mTextureCaptureMode) { | 1208 && !mTextureCaptureMode) { |
1151 mLocationBarBackground.setBounds( | 1209 mLocationBarBackground.setBounds( |
1152 mUrlViewportBounds.left + mLocationBarBackgroundOffset.l
eft, | 1210 mLocationBarBackgroundBounds.left + mLocationBarBackgrou
ndNtpOffset.left |
1153 mUrlViewportBounds.top + mLocationBarBackgroundOffset.to
p, | 1211 - mLocationBarBackgroundPadding.left, |
1154 mUrlViewportBounds.right + mLocationBarBackgroundOffset.
right, | 1212 mLocationBarBackgroundBounds.top + mLocationBarBackgroun
dNtpOffset.top |
1155 mUrlViewportBounds.bottom + mLocationBarBackgroundOffset
.bottom); | 1213 - mLocationBarBackgroundPadding.top, |
| 1214 mLocationBarBackgroundBounds.right + mLocationBarBackgro
undNtpOffset.right |
| 1215 + mLocationBarBackgroundPadding.right, |
| 1216 mLocationBarBackgroundBounds.bottom + mLocationBarBackgr
oundNtpOffset.bottom |
| 1217 + mLocationBarBackgroundPadding.bottom); |
1156 mLocationBarBackground.draw(canvas); | 1218 mLocationBarBackground.draw(canvas); |
1157 } | 1219 } |
1158 | 1220 |
1159 float locationBarClipLeft = mUrlViewportBounds.left | 1221 float locationBarClipLeft = |
1160 + mPhoneLocationBar.getPaddingLeft() + mLocationBarBackgroun
dOffset.left; | 1222 mLocationBarBackgroundBounds.left + mLocationBarBackgroundNt
pOffset.left; |
1161 float locationBarClipRight = mUrlViewportBounds.right | 1223 float locationBarClipRight = |
1162 - mPhoneLocationBar.getPaddingRight() + mLocationBarBackgrou
ndOffset.right; | 1224 mLocationBarBackgroundBounds.right + mLocationBarBackgroundN
tpOffset.right; |
1163 float locationBarClipTop = mUrlViewportBounds.top + mPhoneLocationBa
r.getPaddingTop() | 1225 float locationBarClipTop = |
1164 + mLocationBarBackgroundOffset.top; | 1226 mLocationBarBackgroundBounds.top + mLocationBarBackgroundNtp
Offset.top; |
1165 float locationBarClipBottom = mUrlViewportBounds.bottom | 1227 float locationBarClipBottom = |
1166 - mPhoneLocationBar.getPaddingBottom() + mLocationBarBackgro
undOffset.bottom; | 1228 mLocationBarBackgroundBounds.bottom + mLocationBarBackground
NtpOffset.bottom; |
1167 | 1229 |
1168 // When unexpanded, the location bar's visible content boundaries ar
e inset from the | 1230 // When unexpanded, the location bar's visible content boundaries ar
e inset from the |
1169 // viewport used to draw the background. During expansion transitio
ns, compensation | 1231 // viewport used to draw the background. During expansion transitio
ns, compensation |
1170 // is applied to increase the clip regions such that when the locati
on bar converts | 1232 // is applied to increase the clip regions such that when the locati
on bar converts |
1171 // to the narrower collapsed layout that the visible content is the
same. | 1233 // to the narrower collapsed layout that the visible content is the
same. |
1172 if (mUrlExpansionPercent != 1f) { | 1234 if (mUrlExpansionPercent != 1f) { |
1173 int leftDelta = mUnfocusedLocationBarLayoutLeft | 1235 int leftDelta = mUnfocusedLocationBarLayoutLeft |
1174 - getViewBoundsLeftOfLocationBar(mVisualState); | 1236 - getViewBoundsLeftOfLocationBar(mVisualState); |
1175 int rightDelta = getViewBoundsRightOfLocationBar(mVisualState) | 1237 int rightDelta = getViewBoundsRightOfLocationBar(mVisualState) |
1176 - mUnfocusedLocationBarLayoutLeft | 1238 - mUnfocusedLocationBarLayoutLeft |
1177 - mUnfocusedLocationBarLayoutWidth; | 1239 - mUnfocusedLocationBarLayoutWidth; |
1178 float inversePercent = 1f - mUrlExpansionPercent; | 1240 float inversePercent = 1f - mUrlExpansionPercent; |
1179 locationBarClipLeft += leftDelta * inversePercent; | 1241 locationBarClipLeft += leftDelta * inversePercent; |
1180 locationBarClipRight -= rightDelta * inversePercent; | 1242 locationBarClipRight -= rightDelta * inversePercent; |
1181 } | 1243 } |
1182 | 1244 |
1183 // Clip the location bar child to the URL viewport calculated in onD
raw. | 1245 // Clip the location bar child to the URL viewport calculated in onD
raw. |
1184 canvas.clipRect( | 1246 canvas.clipRect( |
1185 locationBarClipLeft, locationBarClipTop, | 1247 locationBarClipLeft, locationBarClipTop, |
1186 locationBarClipRight, locationBarClipBottom); | 1248 locationBarClipRight, locationBarClipBottom); |
1187 clipped = true; | 1249 clipped = true; |
1188 } | 1250 } |
1189 | 1251 |
1190 boolean retVal = super.drawChild(canvas, mPhoneLocationBar, drawingTime)
; | 1252 boolean retVal = super.drawChild(canvas, mLocationBar, drawingTime); |
1191 | 1253 |
1192 if (clipped) canvas.restore(); | 1254 if (clipped) canvas.restore(); |
1193 return retVal; | 1255 return retVal; |
1194 } | 1256 } |
1195 | 1257 |
1196 @Override | 1258 @Override |
1197 protected void onSizeChanged(int w, int h, int oldw, int oldh) { | 1259 protected void onSizeChanged(int w, int h, int oldw, int oldh) { |
1198 mBackgroundOverlayBounds.set(0, 0, w, mToolbarHeightWithoutShadow); | 1260 mBackgroundOverlayBounds.set(0, 0, w, mToolbarHeightWithoutShadow); |
1199 super.onSizeChanged(w, h, oldw, oldh); | 1261 super.onSizeChanged(w, h, oldw, oldh); |
1200 } | 1262 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 mTabSwitcherModeAnimation = null; | 1339 mTabSwitcherModeAnimation = null; |
1278 } | 1340 } |
1279 if (mDelayedTabSwitcherModeAnimation != null) { | 1341 if (mDelayedTabSwitcherModeAnimation != null) { |
1280 mDelayedTabSwitcherModeAnimation.end(); | 1342 mDelayedTabSwitcherModeAnimation.end(); |
1281 mDelayedTabSwitcherModeAnimation = null; | 1343 mDelayedTabSwitcherModeAnimation = null; |
1282 } | 1344 } |
1283 | 1345 |
1284 // The Android framework calls onAnimationEnd() on listeners before Anim
ator#isRunning() | 1346 // The Android framework calls onAnimationEnd() on listeners before Anim
ator#isRunning() |
1285 // returns false. Sometimes this causes the progress bar visibility to b
e set incorrectly. | 1347 // returns false. Sometimes this causes the progress bar visibility to b
e set incorrectly. |
1286 // Update the visibility now that animations are set to null. (see crbug
.com/606419) | 1348 // Update the visibility now that animations are set to null. (see crbug
.com/606419) |
1287 updateProgressBarVisibility(mIsInTabSwitcherMode); | 1349 updateProgressBarVisibility(); |
1288 } | 1350 } |
1289 | 1351 |
1290 @Override | 1352 @Override |
1291 public void getLocationBarContentRect(Rect outRect) { | 1353 public void getLocationBarContentRect(Rect outRect) { |
1292 mLocationBarBackground.getPadding(outRect); | 1354 updateLocationBarBackgroundBounds(outRect, VisualState.NORMAL); |
1293 int paddingLeft = outRect.left; | |
1294 int paddingTop = outRect.top; | |
1295 int paddingRight = outRect.right; | |
1296 int paddingBottom = outRect.bottom; | |
1297 | |
1298 updateUrlViewportBounds(outRect, VisualState.NORMAL, true); | |
1299 | |
1300 outRect.set(outRect.left + paddingLeft, | |
1301 outRect.top + paddingTop, | |
1302 outRect.right - paddingRight, | |
1303 outRect.bottom - paddingBottom); | |
1304 } | 1355 } |
1305 | 1356 |
1306 @Override | 1357 @Override |
1307 protected void onHomeButtonUpdate(boolean homeButtonEnabled) { | 1358 protected void onHomeButtonUpdate(boolean homeButtonEnabled) { |
1308 mIsHomeButtonEnabled = homeButtonEnabled; | 1359 mIsHomeButtonEnabled = homeButtonEnabled; |
1309 updateButtonVisibility(); | 1360 updateButtonVisibility(); |
1310 } | 1361 } |
1311 | 1362 |
1312 @Override | 1363 @Override |
1313 public void onWindowVisibilityChanged(int visibility) { | 1364 public void onWindowVisibilityChanged(int visibility) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 final boolean animateNormalToolbar) { | 1409 final boolean animateNormalToolbar) { |
1359 ObjectAnimator exitAnimation = | 1410 ObjectAnimator exitAnimation = |
1360 ObjectAnimator.ofFloat(this, mTabSwitcherModePercentProperty, 0.
f); | 1411 ObjectAnimator.ofFloat(this, mTabSwitcherModePercentProperty, 0.
f); |
1361 exitAnimation.setDuration(animateNormalToolbar | 1412 exitAnimation.setDuration(animateNormalToolbar |
1362 ? TAB_SWITCHER_MODE_EXIT_NORMAL_ANIMATION_DURATION_MS | 1413 ? TAB_SWITCHER_MODE_EXIT_NORMAL_ANIMATION_DURATION_MS |
1363 : TAB_SWITCHER_MODE_EXIT_FADE_ANIMATION_DURATION_MS); | 1414 : TAB_SWITCHER_MODE_EXIT_FADE_ANIMATION_DURATION_MS); |
1364 exitAnimation.setInterpolator(new LinearInterpolator()); | 1415 exitAnimation.setInterpolator(new LinearInterpolator()); |
1365 exitAnimation.addListener(new AnimatorListenerAdapter() { | 1416 exitAnimation.addListener(new AnimatorListenerAdapter() { |
1366 @Override | 1417 @Override |
1367 public void onAnimationEnd(Animator animation) { | 1418 public void onAnimationEnd(Animator animation) { |
1368 updateViewsForTabSwitcherMode(mIsInTabSwitcherMode); | 1419 updateViewsForTabSwitcherMode(); |
1369 } | 1420 } |
1370 }); | 1421 }); |
1371 | 1422 |
1372 return exitAnimation; | 1423 return exitAnimation; |
1373 } | 1424 } |
1374 | 1425 |
1375 private ObjectAnimator createPostExitTabSwitcherAnimation() { | 1426 private ObjectAnimator createPostExitTabSwitcherAnimation() { |
1376 ObjectAnimator exitAnimation = ObjectAnimator.ofFloat( | 1427 ObjectAnimator exitAnimation = ObjectAnimator.ofFloat( |
1377 this, View.TRANSLATION_Y, -getHeight(), 0.f); | 1428 this, View.TRANSLATION_Y, -getHeight(), 0.f); |
1378 exitAnimation.setDuration(TAB_SWITCHER_MODE_POST_EXIT_ANIMATION_DURATION
_MS); | 1429 exitAnimation.setDuration(TAB_SWITCHER_MODE_POST_EXIT_ANIMATION_DURATION
_MS); |
1379 exitAnimation.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); | 1430 exitAnimation.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); |
1380 exitAnimation.addListener(new AnimatorListenerAdapter() { | 1431 exitAnimation.addListener(new AnimatorListenerAdapter() { |
1381 @Override | 1432 @Override |
1382 public void onAnimationStart(Animator animation) { | 1433 public void onAnimationStart(Animator animation) { |
1383 updateViewsForTabSwitcherMode(mIsInTabSwitcherMode); | 1434 updateViewsForTabSwitcherMode(); |
1384 // On older builds, force an update to ensure the new visuals ar
e used | 1435 // On older builds, force an update to ensure the new visuals ar
e used |
1385 // when bringing in the toolbar. crbug.com/404571 | 1436 // when bringing in the toolbar. crbug.com/404571 |
1386 if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN) { | 1437 if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN) { |
1387 requestLayout(); | 1438 requestLayout(); |
1388 } | 1439 } |
1389 } | 1440 } |
1390 | 1441 |
1391 @Override | 1442 @Override |
1392 public void onAnimationEnd(Animator animation) { | 1443 public void onAnimationEnd(Animator animation) { |
1393 mDelayedTabSwitcherModeAnimation = null; | 1444 mDelayedTabSwitcherModeAnimation = null; |
1394 updateShadowVisibility(mIsInTabSwitcherMode); | 1445 updateShadowVisibility(); |
1395 updateViewsForTabSwitcherMode(mIsInTabSwitcherMode); | 1446 updateViewsForTabSwitcherMode(); |
1396 } | 1447 } |
1397 }); | 1448 }); |
1398 | 1449 |
1399 return exitAnimation; | 1450 return exitAnimation; |
1400 } | 1451 } |
1401 | 1452 |
1402 @Override | 1453 @Override |
1403 public void setTextureCaptureMode(boolean textureMode) { | 1454 public void setTextureCaptureMode(boolean textureMode) { |
1404 assert mTextureCaptureMode != textureMode; | 1455 assert mTextureCaptureMode != textureMode; |
1405 mTextureCaptureMode = textureMode; | 1456 mTextureCaptureMode = textureMode; |
1406 if (mTextureCaptureMode) { | 1457 if (mTextureCaptureMode) { |
1407 mToolbarShadow.setVisibility(VISIBLE); | 1458 mToolbarShadow.setVisibility(VISIBLE); |
1408 mPreTextureCaptureAlpha = getAlpha(); | 1459 mPreTextureCaptureAlpha = getAlpha(); |
1409 setAlpha(1); | 1460 setAlpha(1); |
1410 } else { | 1461 } else { |
1411 setAlpha(mPreTextureCaptureAlpha); | 1462 setAlpha(mPreTextureCaptureAlpha); |
1412 updateShadowVisibility(mIsInTabSwitcherMode); | 1463 updateShadowVisibility(); |
1413 mPreTextureCaptureAlpha = 1f; | 1464 mPreTextureCaptureAlpha = 1f; |
1414 } | 1465 } |
1415 } | 1466 } |
1416 | 1467 |
1417 private boolean isTabSwitcherAnimationRunning() { | 1468 private boolean isTabSwitcherAnimationRunning() { |
1418 return mUIAnimatingTabSwitcherTransition | 1469 return mUIAnimatingTabSwitcherTransition |
1419 || (mTabSwitcherModeAnimation != null && mTabSwitcherModeAnimati
on.isRunning()) | 1470 || (mTabSwitcherModeAnimation != null && mTabSwitcherModeAnimati
on.isRunning()) |
1420 || (mDelayedTabSwitcherModeAnimation != null | 1471 || (mDelayedTabSwitcherModeAnimation != null |
1421 && mDelayedTabSwitcherModeAnimation.isRunning())
; | 1472 && mDelayedTabSwitcherModeAnimation.isRunning())
; |
1422 } | 1473 } |
1423 | 1474 |
1424 private void updateViewsForTabSwitcherMode(boolean isInTabSwitcherMode) { | 1475 private void updateViewsForTabSwitcherMode() { |
1425 int tabSwitcherViewsVisibility = isInTabSwitcherMode ? VISIBLE : INVISIB
LE; | 1476 int tabSwitcherViewsVisibility = mIsInTabSwitcherMode ? VISIBLE : INVISI
BLE; |
1426 int browsingViewsVisibility = isInTabSwitcherMode ? INVISIBLE : VISIBLE; | 1477 int browsingViewsVisibility = mIsInTabSwitcherMode ? INVISIBLE : VISIBLE
; |
1427 | 1478 |
1428 for (View view : mTabSwitcherModeViews) { | 1479 for (View view : mTabSwitcherModeViews) { |
1429 view.setVisibility(tabSwitcherViewsVisibility); | 1480 view.setVisibility(tabSwitcherViewsVisibility); |
1430 } | 1481 } |
1431 for (View view : mBrowsingModeViews) { | 1482 for (View view : mBrowsingModeViews) { |
1432 view.setVisibility(browsingViewsVisibility); | 1483 view.setVisibility(browsingViewsVisibility); |
1433 } | 1484 } |
1434 if (mShowMenuBadge) { | 1485 if (mShowMenuBadge) { |
1435 setMenuButtonContentDescription(!isInTabSwitcherMode); | 1486 setMenuButtonContentDescription(!mIsInTabSwitcherMode); |
1436 } | 1487 } |
1437 | 1488 |
1438 updateProgressBarVisibility(isInTabSwitcherMode); | 1489 updateProgressBarVisibility(); |
1439 updateVisualsForToolbarState(isInTabSwitcherMode); | 1490 updateVisualsForToolbarState(); |
1440 } | 1491 } |
1441 | 1492 |
1442 private void updateProgressBarVisibility(boolean isInTabSwitcherMode) { | 1493 private void updateProgressBarVisibility() { |
1443 getProgressBar().setVisibility( | 1494 getProgressBar().setVisibility( |
1444 isInTabSwitcherMode || isTabSwitcherAnimationRunning() ? INVISIB
LE : VISIBLE); | 1495 mIsInTabSwitcherMode || isTabSwitcherAnimationRunning() ? INVISI
BLE : VISIBLE); |
1445 } | 1496 } |
1446 | 1497 |
1447 @Override | 1498 @Override |
1448 protected void setContentAttached(boolean attached) { | 1499 protected void setContentAttached(boolean attached) { |
1449 updateVisualsForToolbarState(mIsInTabSwitcherMode); | 1500 updateVisualsForToolbarState(); |
1450 } | 1501 } |
1451 | 1502 |
1452 @Override | 1503 @Override |
1453 protected void setTabSwitcherMode( | 1504 protected void setTabSwitcherMode( |
1454 boolean inTabSwitcherMode, boolean showToolbar, boolean delayAnimati
on) { | 1505 boolean inTabSwitcherMode, boolean showToolbar, boolean delayAnimati
on) { |
1455 if (mIsInTabSwitcherMode == inTabSwitcherMode) return; | 1506 if (mIsInTabSwitcherMode == inTabSwitcherMode) return; |
| 1507 mIsInTabSwitcherMode = inTabSwitcherMode; |
1456 | 1508 |
1457 finishAnimations(); | 1509 finishAnimations(); |
1458 | 1510 |
1459 mDelayingTabSwitcherAnimation = delayAnimation; | 1511 mDelayingTabSwitcherAnimation = delayAnimation; |
1460 | 1512 |
1461 if (inTabSwitcherMode) { | 1513 if (inTabSwitcherMode) { |
1462 if (mUrlFocusLayoutAnimator != null && mUrlFocusLayoutAnimator.isRun
ning()) { | 1514 if (mUrlFocusLayoutAnimator != null && mUrlFocusLayoutAnimator.isRun
ning()) { |
1463 mUrlFocusLayoutAnimator.end(); | 1515 mUrlFocusLayoutAnimator.end(); |
1464 mUrlFocusLayoutAnimator = null; | 1516 mUrlFocusLayoutAnimator = null; |
1465 // After finishing the animation, force a re-layout of the locat
ion bar, | 1517 // After finishing the animation, force a re-layout of the locat
ion bar, |
1466 // so that the final translation position is correct (since onMe
asure updates | 1518 // so that the final translation position is correct (since onMe
asure updates |
1467 // won't happen in tab switcher mode). crbug.com/518795. | 1519 // won't happen in tab switcher mode). crbug.com/518795. |
1468 layoutLocationBar(getMeasuredWidth()); | 1520 layoutLocationBar(getMeasuredWidth()); |
1469 updateUrlExpansionAnimation(); | 1521 updateUrlExpansionAnimation(); |
1470 } | 1522 } |
1471 mNewTabButton.setEnabled(true); | 1523 mNewTabButton.setEnabled(true); |
1472 updateViewsForTabSwitcherMode(true); | 1524 updateViewsForTabSwitcherMode(); |
1473 mTabSwitcherModeAnimation = createEnterTabSwitcherModeAnimation(); | 1525 mTabSwitcherModeAnimation = createEnterTabSwitcherModeAnimation(); |
1474 } else { | 1526 } else { |
1475 if (!mDelayingTabSwitcherAnimation) { | 1527 if (!mDelayingTabSwitcherAnimation) { |
1476 mTabSwitcherModeAnimation = createExitTabSwitcherAnimation(showT
oolbar); | 1528 mTabSwitcherModeAnimation = createExitTabSwitcherAnimation(showT
oolbar); |
1477 } | 1529 } |
1478 mUIAnimatingTabSwitcherTransition = true; | 1530 mUIAnimatingTabSwitcherTransition = true; |
1479 } | 1531 } |
1480 | 1532 |
1481 mAnimateNormalToolbar = showToolbar; | 1533 mAnimateNormalToolbar = showToolbar; |
1482 mIsInTabSwitcherMode = inTabSwitcherMode; | |
1483 if (mTabSwitcherModeAnimation != null) mTabSwitcherModeAnimation.start()
; | 1534 if (mTabSwitcherModeAnimation != null) mTabSwitcherModeAnimation.start()
; |
1484 | 1535 |
1485 if (SysUtils.isLowEndDevice()) finishAnimations(); | 1536 if (SysUtils.isLowEndDevice()) finishAnimations(); |
1486 | 1537 |
1487 postInvalidateOnAnimation(); | 1538 postInvalidateOnAnimation(); |
1488 } | 1539 } |
1489 | 1540 |
1490 @Override | 1541 @Override |
1491 protected void onTabSwitcherTransitionFinished() { | 1542 protected void onTabSwitcherTransitionFinished() { |
1492 setAlpha(1.f); | 1543 setAlpha(1.f); |
1493 mClipRect = null; | 1544 mClipRect = null; |
1494 mUIAnimatingTabSwitcherTransition = false; | 1545 mUIAnimatingTabSwitcherTransition = false; |
1495 mTabSwitcherModePercent = mIsInTabSwitcherMode ? 1.0f : 0.0f; | 1546 mTabSwitcherModePercent = mIsInTabSwitcherMode ? 1.0f : 0.0f; |
1496 | 1547 |
1497 if (!mAnimateNormalToolbar) { | 1548 if (!mAnimateNormalToolbar) { |
1498 finishAnimations(); | 1549 finishAnimations(); |
1499 updateVisualsForToolbarState(mIsInTabSwitcherMode); | 1550 updateVisualsForToolbarState(); |
1500 } | 1551 } |
1501 | 1552 |
1502 if (mDelayingTabSwitcherAnimation) { | 1553 if (mDelayingTabSwitcherAnimation) { |
1503 mDelayingTabSwitcherAnimation = false; | 1554 mDelayingTabSwitcherAnimation = false; |
1504 mDelayedTabSwitcherModeAnimation = createPostExitTabSwitcherAnimatio
n(); | 1555 mDelayedTabSwitcherModeAnimation = createPostExitTabSwitcherAnimatio
n(); |
1505 mDelayedTabSwitcherModeAnimation.start(); | 1556 mDelayedTabSwitcherModeAnimation.start(); |
1506 } else { | 1557 } else { |
1507 updateViewsForTabSwitcherMode(mIsInTabSwitcherMode); | 1558 updateViewsForTabSwitcherMode(); |
1508 } | 1559 } |
1509 } | 1560 } |
1510 | 1561 |
1511 private void updateOverlayDrawables(boolean isInTabSwitcherMode) { | 1562 private void updateOverlayDrawables() { |
1512 if (!isNativeLibraryReady()) return; | 1563 if (!isNativeLibraryReady()) return; |
1513 | 1564 |
1514 VisualState overlayState = computeVisualState(false); | 1565 VisualState overlayState = computeVisualState(false); |
1515 boolean visualStateChanged = mOverlayDrawablesVisualState != overlayStat
e; | 1566 boolean visualStateChanged = mOverlayDrawablesVisualState != overlayStat
e; |
1516 | 1567 |
1517 if (!visualStateChanged && mVisualState == VisualState.BRAND_COLOR | 1568 if (!visualStateChanged && mVisualState == VisualState.BRAND_COLOR |
1518 && getToolbarDataProvider().getPrimaryColor() | 1569 && getToolbarDataProvider().getPrimaryColor() |
1519 != mTabSwitcherAnimationBgOverlay.getColor()) { | 1570 != mTabSwitcherAnimationBgOverlay.getColor()) { |
1520 visualStateChanged = true; | 1571 visualStateChanged = true; |
1521 } | 1572 } |
1522 if (!visualStateChanged) return; | 1573 if (!visualStateChanged) return; |
1523 | 1574 |
1524 mOverlayDrawablesVisualState = overlayState; | 1575 mOverlayDrawablesVisualState = overlayState; |
1525 mTabSwitcherAnimationBgOverlay.setColor(getToolbarColorForVisualState( | 1576 mTabSwitcherAnimationBgOverlay.setColor(getToolbarColorForVisualState( |
1526 mOverlayDrawablesVisualState)); | 1577 mOverlayDrawablesVisualState)); |
1527 | 1578 |
1528 setTabSwitcherAnimationMenuDrawable(); | 1579 setTabSwitcherAnimationMenuDrawable(); |
1529 setUseLightDrawablesForTextureCapture(); | 1580 setUseLightDrawablesForTextureCapture(); |
1530 | 1581 |
1531 if (!isInTabSwitcherMode && !mTextureCaptureMode && mLayoutUpdateHost !=
null) { | 1582 if (!mIsInTabSwitcherMode && !mTextureCaptureMode && mLayoutUpdateHost !
= null) { |
1532 // Request a layout update to trigger a texture capture if the tint
color is changing | 1583 // Request a layout update to trigger a texture capture if the tint
color is changing |
1533 // and we're not already in texture capture mode. This is necessary
if the tab switcher | 1584 // and we're not already in texture capture mode. This is necessary
if the tab switcher |
1534 // is entered immediately after a change to the tint color without a
ny user interactions | 1585 // is entered immediately after a change to the tint color without a
ny user interactions |
1535 // that would normally trigger a texture capture. | 1586 // that would normally trigger a texture capture. |
1536 mLayoutUpdateHost.requestUpdate(); | 1587 mLayoutUpdateHost.requestUpdate(); |
1537 } | 1588 } |
1538 } | 1589 } |
1539 | 1590 |
1540 @Override | 1591 @Override |
1541 public void destroy() { | 1592 public void destroy() { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1587 } | 1638 } |
1588 }; | 1639 }; |
1589 } | 1640 } |
1590 | 1641 |
1591 private void populateUrlFocusingAnimatorSet(List<Animator> animators) { | 1642 private void populateUrlFocusingAnimatorSet(List<Animator> animators) { |
1592 Animator animator = ObjectAnimator.ofFloat(this, mUrlFocusChangePercentP
roperty, 1f); | 1643 Animator animator = ObjectAnimator.ofFloat(this, mUrlFocusChangePercentP
roperty, 1f); |
1593 animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS); | 1644 animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS); |
1594 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); | 1645 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); |
1595 animators.add(animator); | 1646 animators.add(animator); |
1596 | 1647 |
1597 for (int i = 0; i < mPhoneLocationBar.getChildCount(); i++) { | 1648 for (int i = 0; i < mLocationBar.getChildCount(); i++) { |
1598 View childView = mPhoneLocationBar.getChildAt(i); | 1649 View childView = mLocationBar.getChildAt(i); |
1599 if (childView == mPhoneLocationBar.getFirstViewVisibleWhenFocused())
break; | 1650 if (childView == mLocationBar.getFirstViewVisibleWhenFocused()) brea
k; |
1600 animator = ObjectAnimator.ofFloat(childView, ALPHA, 0); | 1651 animator = ObjectAnimator.ofFloat(childView, ALPHA, 0); |
1601 animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS); | 1652 animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS); |
1602 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); | 1653 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); |
1603 animators.add(animator); | 1654 animators.add(animator); |
1604 } | 1655 } |
1605 | 1656 |
1606 float density = getContext().getResources().getDisplayMetrics().density; | 1657 float density = getContext().getResources().getDisplayMetrics().density; |
1607 boolean isRtl = ApiCompatibilityUtils.isLayoutRtl(this); | 1658 boolean isRtl = ApiCompatibilityUtils.isLayoutRtl(this); |
1608 float toolbarButtonTranslationX = MathUtils.flipSignIf( | 1659 float toolbarButtonTranslationX = MathUtils.flipSignIf( |
1609 URL_FOCUS_TOOLBAR_BUTTONS_TRANSLATION_X_DP, isRtl) * density; | 1660 URL_FOCUS_TOOLBAR_BUTTONS_TRANSLATION_X_DP, isRtl) * density; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); | 1709 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); |
1659 animators.add(animator); | 1710 animators.add(animator); |
1660 | 1711 |
1661 animator = ObjectAnimator.ofFloat(mToggleTabStackButton, ALPHA, 1); | 1712 animator = ObjectAnimator.ofFloat(mToggleTabStackButton, ALPHA, 1); |
1662 animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); | 1713 animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); |
1663 animator.setStartDelay(URL_CLEAR_FOCUS_TABSTACK_DELAY_MS); | 1714 animator.setStartDelay(URL_CLEAR_FOCUS_TABSTACK_DELAY_MS); |
1664 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); | 1715 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); |
1665 animators.add(animator); | 1716 animators.add(animator); |
1666 } | 1717 } |
1667 | 1718 |
1668 for (int i = 0; i < mPhoneLocationBar.getChildCount(); i++) { | 1719 for (int i = 0; i < mLocationBar.getChildCount(); i++) { |
1669 View childView = mPhoneLocationBar.getChildAt(i); | 1720 View childView = mLocationBar.getChildAt(i); |
1670 if (childView == mPhoneLocationBar.getFirstViewVisibleWhenFocused())
break; | 1721 if (childView == mLocationBar.getFirstViewVisibleWhenFocused()) brea
k; |
1671 animator = ObjectAnimator.ofFloat(childView, ALPHA, 1); | 1722 animator = ObjectAnimator.ofFloat(childView, ALPHA, 1); |
1672 animator.setStartDelay(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); | 1723 animator.setStartDelay(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); |
1673 animator.setDuration(URL_CLEAR_FOCUS_MENU_DELAY_MS); | 1724 animator.setDuration(URL_CLEAR_FOCUS_MENU_DELAY_MS); |
1674 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); | 1725 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); |
1675 animators.add(animator); | 1726 animators.add(animator); |
1676 } | 1727 } |
1677 | 1728 |
1678 if (isLocationBarShownInNTP() && mNtpSearchBoxScrollPercent == 0f) retur
n; | 1729 if (isLocationBarShownInNTP() && mNtpSearchBoxScrollPercent == 0f) retur
n; |
1679 | 1730 |
1680 // The call to getLayout() can return null briefly during text changes,
but as it | 1731 // The call to getLayout() can return null briefly during text changes,
but as it |
1681 // is only needed for RTL calculations, we proceed if the location bar i
s showing | 1732 // is only needed for RTL calculations, we proceed if the location bar i
s showing |
1682 // LTR content. | 1733 // LTR content. |
1683 boolean isLocationBarRtl = ApiCompatibilityUtils.isLayoutRtl(mPhoneLocat
ionBar); | 1734 boolean isLocationBarRtl = ApiCompatibilityUtils.isLayoutRtl(mLocationBa
r); |
1684 if (!isLocationBarRtl || mUrlBar.getLayout() != null) { | 1735 if (!isLocationBarRtl || mUrlBar.getLayout() != null) { |
1685 int urlBarStartScrollX = 0; | 1736 int urlBarStartScrollX = 0; |
1686 if (isLocationBarRtl) { | 1737 if (isLocationBarRtl) { |
1687 urlBarStartScrollX = (int) mUrlBar.getLayout().getPrimaryHorizon
tal(0); | 1738 urlBarStartScrollX = (int) mUrlBar.getLayout().getPrimaryHorizon
tal(0); |
1688 urlBarStartScrollX -= mUrlBar.getWidth(); | 1739 urlBarStartScrollX -= mUrlBar.getWidth(); |
1689 } | 1740 } |
1690 | 1741 |
1691 // If the scroll position matches the current scroll position, do no
t trigger | 1742 // If the scroll position matches the current scroll position, do no
t trigger |
1692 // this animation as it will cause visible jumps when going from cle
ared text | 1743 // this animation as it will cause visible jumps when going from cle
ared text |
1693 // back to page URLs (despite it continually calling setScrollX with
the same | 1744 // back to page URLs (despite it continually calling setScrollX with
the same |
1694 // number). | 1745 // number). |
1695 if (mUrlBar.getScrollX() != urlBarStartScrollX) { | 1746 if (mUrlBar.getScrollX() != urlBarStartScrollX) { |
1696 animator = ObjectAnimator.ofInt( | 1747 animator = ObjectAnimator.ofInt(mUrlBar, |
1697 mUrlBar, | 1748 buildUrlScrollProperty(mLocationBar, isLocationBarRtl),
urlBarStartScrollX); |
1698 buildUrlScrollProperty(mPhoneLocationBar, isLocationBarR
tl), | |
1699 urlBarStartScrollX); | |
1700 animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS); | 1749 animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS); |
1701 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE
); | 1750 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE
); |
1702 animators.add(animator); | 1751 animators.add(animator); |
1703 } | 1752 } |
1704 } | 1753 } |
1705 } | 1754 } |
1706 | 1755 |
1707 @Override | 1756 @Override |
1708 public void onUrlFocusChange(final boolean hasFocus) { | 1757 public void onUrlFocusChange(final boolean hasFocus) { |
1709 super.onUrlFocusChange(hasFocus); | 1758 super.onUrlFocusChange(hasFocus); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1765 | 1814 |
1766 @Override | 1815 @Override |
1767 public void onAnimationEnd(Animator animation) { | 1816 public void onAnimationEnd(Animator animation) { |
1768 if (mCanceled) return; | 1817 if (mCanceled) return; |
1769 | 1818 |
1770 if (!hasFocus) { | 1819 if (!hasFocus) { |
1771 mDisableLocationBarRelayout = false; | 1820 mDisableLocationBarRelayout = false; |
1772 mLayoutLocationBarInFocusedMode = false; | 1821 mLayoutLocationBarInFocusedMode = false; |
1773 requestLayout(); | 1822 requestLayout(); |
1774 } | 1823 } |
1775 mPhoneLocationBar.finishUrlFocusChange(hasFocus); | 1824 mLocationBar.finishUrlFocusChange(hasFocus); |
1776 mUrlFocusChangeInProgress = false; | 1825 mUrlFocusChangeInProgress = false; |
1777 } | 1826 } |
1778 }); | 1827 }); |
1779 mUrlFocusLayoutAnimator.start(); | 1828 mUrlFocusLayoutAnimator.start(); |
1780 } | 1829 } |
1781 | 1830 |
1782 @Override | 1831 @Override |
1783 protected boolean shouldShowMenuButton() { | 1832 protected boolean shouldShowMenuButton() { |
1784 // Even in Document mode, the toolbar menu button will be shown while on
the NTP. This | 1833 // Even in Document mode, the toolbar menu button will be shown while on
the NTP. This |
1785 // allows the menu to translate off the screen on scroll to match the ta
bbed behavior. | 1834 // allows the menu to translate off the screen on scroll to match the ta
bbed behavior. |
1786 if (mVisualState == VisualState.NEW_TAB_NORMAL) return true; | 1835 if (mVisualState == VisualState.NEW_TAB_NORMAL) return true; |
1787 | 1836 |
1788 return !mPhoneLocationBar.showMenuButtonInOmnibox() && super.shouldShowM
enuButton(); | 1837 return !mLocationBar.showMenuButtonInOmnibox() && super.shouldShowMenuBu
tton(); |
1789 } | 1838 } |
1790 | 1839 |
1791 @Override | 1840 @Override |
1792 protected void updateTabCountVisuals(int numberOfTabs) { | 1841 protected void updateTabCountVisuals(int numberOfTabs) { |
1793 if (mReturnButton != null) mReturnButton.setEnabled(true); | 1842 if (mReturnButton != null) mReturnButton.setEnabled(true); |
1794 if (mHomeButton != null) mHomeButton.setEnabled(true); | 1843 if (mHomeButton != null) mHomeButton.setEnabled(true); |
1795 | 1844 |
1796 if (mToggleTabStackButton == null) return; | 1845 if (mToggleTabStackButton == null) return; |
1797 | 1846 |
1798 mToggleTabStackButton.setEnabled(numberOfTabs >= 1); | 1847 mToggleTabStackButton.setEnabled(numberOfTabs >= 1); |
(...skipping 28 matching lines...) Expand all Loading... |
1827 if (mTabSwitcherAnimationTabStackDrawable != null) { | 1876 if (mTabSwitcherAnimationTabStackDrawable != null) { |
1828 mTabSwitcherAnimationTabStackDrawable.updateForTabCount( | 1877 mTabSwitcherAnimationTabStackDrawable.updateForTabCount( |
1829 numberOfTabs, isIncognito()); | 1878 numberOfTabs, isIncognito()); |
1830 } | 1879 } |
1831 } | 1880 } |
1832 | 1881 |
1833 @Override | 1882 @Override |
1834 protected void onTabContentViewChanged() { | 1883 protected void onTabContentViewChanged() { |
1835 super.onTabContentViewChanged(); | 1884 super.onTabContentViewChanged(); |
1836 updateNtpAnimationState(); | 1885 updateNtpAnimationState(); |
1837 updateVisualsForToolbarState(mIsInTabSwitcherMode); | 1886 updateVisualsForToolbarState(); |
1838 } | 1887 } |
1839 | 1888 |
1840 @Override | 1889 @Override |
1841 protected void onTabOrModelChanged() { | 1890 protected void onTabOrModelChanged() { |
1842 super.onTabOrModelChanged(); | 1891 super.onTabOrModelChanged(); |
1843 updateNtpAnimationState(); | 1892 updateNtpAnimationState(); |
1844 updateVisualsForToolbarState(mIsInTabSwitcherMode); | 1893 updateVisualsForToolbarState(); |
1845 | 1894 |
1846 if (mHasCheckedIfTabSwitcherCalloutIsNecessary) { | 1895 if (mHasCheckedIfTabSwitcherCalloutIsNecessary) { |
1847 dismissTabSwitcherCallout(); | 1896 dismissTabSwitcherCallout(); |
1848 } else { | 1897 } else { |
1849 mHasCheckedIfTabSwitcherCalloutIsNecessary = true; | 1898 mHasCheckedIfTabSwitcherCalloutIsNecessary = true; |
1850 showTabSwitcherCalloutIfNecessary(); | 1899 showTabSwitcherCalloutIfNecessary(); |
1851 } | 1900 } |
1852 } | 1901 } |
1853 | 1902 |
1854 private static boolean isVisualStateValidForBrandColorTransition(VisualState
state) { | 1903 private static boolean isVisualStateValidForBrandColorTransition(VisualState
state) { |
1855 return state == VisualState.NORMAL || state == VisualState.BRAND_COLOR; | 1904 return state == VisualState.NORMAL || state == VisualState.BRAND_COLOR; |
1856 } | 1905 } |
1857 | 1906 |
1858 @Override | 1907 @Override |
1859 protected void onPrimaryColorChanged(boolean shouldAnimate) { | 1908 protected void onPrimaryColorChanged(boolean shouldAnimate) { |
1860 super.onPrimaryColorChanged(shouldAnimate); | 1909 super.onPrimaryColorChanged(shouldAnimate); |
1861 if (mBrandColorTransitionActive) mBrandColorTransitionAnimation.cancel()
; | 1910 if (mBrandColorTransitionActive) mBrandColorTransitionAnimation.cancel()
; |
1862 if (!shouldAnimate || !isVisualStateValidForBrandColorTransition(mVisual
State)) { | 1911 if (!shouldAnimate || !isVisualStateValidForBrandColorTransition(mVisual
State)) { |
1863 return; | 1912 return; |
1864 } | 1913 } |
1865 final int initialColor = mToolbarBackground.getColor(); | 1914 final int initialColor = mToolbarBackground.getColor(); |
1866 final int finalColor = getToolbarDataProvider().getPrimaryColor(); | 1915 final int finalColor = getToolbarDataProvider().getPrimaryColor(); |
1867 if (initialColor == finalColor) return; | 1916 if (initialColor == finalColor) return; |
1868 | 1917 |
1869 boolean shouldUseOpaque = ColorUtils.shouldUseOpaqueTextboxBackground(fi
nalColor); | 1918 boolean shouldUseOpaque = ColorUtils.shouldUseOpaqueTextboxBackground(fi
nalColor); |
1870 final int initialAlpha = mUrlBackgroundAlpha; | 1919 final int initialAlpha = mLocationBarBackgroundAlpha; |
1871 final int finalAlpha = | 1920 final int finalAlpha = |
1872 shouldUseOpaque ? 255 : LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPH
A; | 1921 shouldUseOpaque ? 255 : LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPH
A; |
1873 final boolean shouldAnimateAlpha = initialAlpha != finalAlpha; | 1922 final boolean shouldAnimateAlpha = initialAlpha != finalAlpha; |
1874 mBrandColorTransitionAnimation = ValueAnimator.ofFloat(0, 1) | 1923 mBrandColorTransitionAnimation = ValueAnimator.ofFloat(0, 1) |
1875 .setDuration(THEME_COLOR_TRANSITION_DURATION); | 1924 .setDuration(THEME_COLOR_TRANSITION_DURATION); |
1876 mBrandColorTransitionAnimation.setInterpolator(BakedBezierInterpolator.T
RANSFORM_CURVE); | 1925 mBrandColorTransitionAnimation.setInterpolator(BakedBezierInterpolator.T
RANSFORM_CURVE); |
1877 mBrandColorTransitionAnimation.addUpdateListener(new AnimatorUpdateListe
ner() { | 1926 mBrandColorTransitionAnimation.addUpdateListener(new AnimatorUpdateListe
ner() { |
1878 @Override | 1927 @Override |
1879 public void onAnimationUpdate(ValueAnimator animation) { | 1928 public void onAnimationUpdate(ValueAnimator animation) { |
1880 float fraction = animation.getAnimatedFraction(); | 1929 float fraction = animation.getAnimatedFraction(); |
1881 if (shouldAnimateAlpha) { | 1930 if (shouldAnimateAlpha) { |
1882 mUrlBackgroundAlpha = | 1931 mLocationBarBackgroundAlpha = |
1883 (int) (MathUtils.interpolate(initialAlpha, finalAlph
a, fraction)); | 1932 (int) (MathUtils.interpolate(initialAlpha, finalAlph
a, fraction)); |
1884 } | 1933 } |
1885 updateToolbarBackground( | 1934 updateToolbarBackground( |
1886 ColorUtils.getColorWithOverlay(initialColor, finalColor,
fraction)); | 1935 ColorUtils.getColorWithOverlay(initialColor, finalColor,
fraction)); |
1887 } | 1936 } |
1888 }); | 1937 }); |
1889 mBrandColorTransitionAnimation.addListener(new AnimatorListenerAdapter()
{ | 1938 mBrandColorTransitionAnimation.addListener(new AnimatorListenerAdapter()
{ |
1890 @Override | 1939 @Override |
1891 public void onAnimationEnd(Animator animation) { | 1940 public void onAnimationEnd(Animator animation) { |
1892 mBrandColorTransitionActive = false; | 1941 mBrandColorTransitionActive = false; |
1893 updateVisualsForToolbarState(mIsInTabSwitcherMode); | 1942 updateVisualsForToolbarState(); |
1894 } | 1943 } |
1895 }); | 1944 }); |
1896 mBrandColorTransitionAnimation.start(); | 1945 mBrandColorTransitionAnimation.start(); |
1897 mBrandColorTransitionActive = true; | 1946 mBrandColorTransitionActive = true; |
1898 } | 1947 } |
1899 | 1948 |
1900 private void updateNtpAnimationState() { | 1949 private void updateNtpAnimationState() { |
1901 // Store previous NTP scroll before calling reset as that clears this va
lue. | 1950 // Store previous NTP scroll before calling reset as that clears this va
lue. |
1902 boolean wasShowingNtp = mVisibleNewTabPage != null; | 1951 boolean wasShowingNtp = mVisibleNewTabPage != null; |
1903 float previousNtpScrollPercent = mNtpSearchBoxScrollPercent; | 1952 float previousNtpScrollPercent = mNtpSearchBoxScrollPercent; |
(...skipping 25 matching lines...) Expand all Loading... |
1929 super.onDefaultSearchEngineChanged(); | 1978 super.onDefaultSearchEngineChanged(); |
1930 // Post an update for the toolbar state, which will allow all other list
eners | 1979 // Post an update for the toolbar state, which will allow all other list
eners |
1931 // for the search engine change to update before we check on the state o
f the | 1980 // for the search engine change to update before we check on the state o
f the |
1932 // world for a UI update. | 1981 // world for a UI update. |
1933 // TODO(tedchoc): Move away from updating based on the search engine cha
nge and instead | 1982 // TODO(tedchoc): Move away from updating based on the search engine cha
nge and instead |
1934 // add the toolbar as a listener to the NewTabPage and ud
pate only when | 1983 // add the toolbar as a listener to the NewTabPage and ud
pate only when |
1935 // it notifies the listeners that it has changed its stat
e. | 1984 // it notifies the listeners that it has changed its stat
e. |
1936 post(new Runnable() { | 1985 post(new Runnable() { |
1937 @Override | 1986 @Override |
1938 public void run() { | 1987 public void run() { |
1939 updateVisualsForToolbarState(mIsInTabSwitcherMode); | 1988 updateVisualsForToolbarState(); |
1940 updateNtpAnimationState(); | 1989 updateNtpAnimationState(); |
1941 } | 1990 } |
1942 }); | 1991 }); |
1943 } | 1992 } |
1944 | 1993 |
1945 @Override | 1994 @Override |
1946 protected void handleFindToolbarStateChange(boolean showing) { | 1995 protected void handleFindToolbarStateChange(boolean showing) { |
1947 setVisibility(showing ? View.GONE : View.VISIBLE); | 1996 setVisibility(showing ? View.GONE : View.VISIBLE); |
1948 TransitionDrawable shadowDrawable = (TransitionDrawable) mToolbarShadow.
getDrawable(); | 1997 TransitionDrawable shadowDrawable = (TransitionDrawable) mToolbarShadow.
getDrawable(); |
1949 if (showing) { | 1998 if (showing) { |
1950 shadowDrawable.startTransition(URL_FOCUS_CHANGE_ANIMATION_DURATION_M
S); | 1999 shadowDrawable.startTransition(URL_FOCUS_CHANGE_ANIMATION_DURATION_M
S); |
1951 } else { | 2000 } else { |
1952 shadowDrawable.reverseTransition(URL_FOCUS_CHANGE_ANIMATION_DURATION
_MS); | 2001 shadowDrawable.reverseTransition(URL_FOCUS_CHANGE_ANIMATION_DURATION
_MS); |
1953 } | 2002 } |
1954 } | 2003 } |
1955 | 2004 |
1956 private boolean isLocationBarShownInNTP() { | 2005 private boolean isLocationBarShownInNTP() { |
1957 NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab(); | 2006 NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab(); |
1958 return ntp != null && ntp.isLocationBarShownInNTP(); | 2007 return ntp != null && ntp.isLocationBarShownInNTP(); |
1959 } | 2008 } |
1960 | 2009 |
1961 private void updateShadowVisibility(boolean isInTabSwitcherMode) { | 2010 private void updateShadowVisibility() { |
1962 boolean shouldDrawShadow = !isInTabSwitcherMode && !isTabSwitcherAnimati
onRunning(); | 2011 boolean shouldDrawShadow = !mIsInTabSwitcherMode && !isTabSwitcherAnimat
ionRunning(); |
1963 int shadowVisibility = shouldDrawShadow ? View.VISIBLE : View.INVISIBLE; | 2012 int shadowVisibility = shouldDrawShadow ? View.VISIBLE : View.INVISIBLE; |
1964 | 2013 |
1965 if (mToolbarShadow.getVisibility() != shadowVisibility) { | 2014 if (mToolbarShadow.getVisibility() != shadowVisibility) { |
1966 mToolbarShadow.setVisibility(shadowVisibility); | 2015 mToolbarShadow.setVisibility(shadowVisibility); |
1967 } | 2016 } |
1968 } | 2017 } |
1969 | 2018 |
1970 private VisualState computeVisualState(boolean isInTabSwitcherMode) { | 2019 private VisualState computeVisualState(boolean isInTabSwitcherMode) { |
1971 if (isInTabSwitcherMode && isIncognito()) return VisualState.TAB_SWITCHE
R_INCOGNITO; | 2020 if (isInTabSwitcherMode && isIncognito()) return VisualState.TAB_SWITCHE
R_INCOGNITO; |
1972 if (isInTabSwitcherMode && !isIncognito()) return VisualState.TAB_SWITCH
ER_NORMAL; | 2021 if (isInTabSwitcherMode && !isIncognito()) return VisualState.TAB_SWITCH
ER_NORMAL; |
1973 if (isLocationBarShownInNTP()) return VisualState.NEW_TAB_NORMAL; | 2022 if (isLocationBarShownInNTP()) return VisualState.NEW_TAB_NORMAL; |
1974 if (isIncognito()) return VisualState.INCOGNITO; | 2023 if (isIncognito()) return VisualState.INCOGNITO; |
1975 if (getToolbarDataProvider().isUsingBrandColor()) return VisualState.BRA
ND_COLOR; | 2024 if (getToolbarDataProvider().isUsingBrandColor()) return VisualState.BRA
ND_COLOR; |
1976 return VisualState.NORMAL; | 2025 return VisualState.NORMAL; |
1977 } | 2026 } |
1978 | 2027 |
1979 private void updateVisualsForToolbarState(boolean isInTabSwitcherMode) { | 2028 private void updateVisualsForToolbarState() { |
1980 final boolean isIncognito = isIncognito(); | 2029 final boolean isIncognito = isIncognito(); |
1981 | 2030 |
1982 VisualState newVisualState = computeVisualState(isInTabSwitcherMode); | 2031 VisualState newVisualState = computeVisualState(mIsInTabSwitcherMode); |
1983 | 2032 |
1984 // If we are navigating to or from a brand color, allow the transition a
nimation | 2033 // If we are navigating to or from a brand color, allow the transition a
nimation |
1985 // to run to completion as it will handle the triggering this path again
and committing | 2034 // to run to completion as it will handle the triggering this path again
and committing |
1986 // the proper visual state when it finishes. Brand color transitions ar
e only valid | 2035 // the proper visual state when it finishes. Brand color transitions ar
e only valid |
1987 // between normal non-incognito pages and brand color pages, so if the v
isual states | 2036 // between normal non-incognito pages and brand color pages, so if the v
isual states |
1988 // do not match then cancel the animation below. | 2037 // do not match then cancel the animation below. |
1989 if (mBrandColorTransitionActive | 2038 if (mBrandColorTransitionActive |
1990 && isVisualStateValidForBrandColorTransition(mVisualState) | 2039 && isVisualStateValidForBrandColorTransition(mVisualState) |
1991 && isVisualStateValidForBrandColorTransition(newVisualState)) { | 2040 && isVisualStateValidForBrandColorTransition(newVisualState)) { |
1992 return; | 2041 return; |
(...skipping 24 matching lines...) Expand all Loading... |
2017 != mUnfocusedLocationBarUsesTransparentBg) { | 2066 != mUnfocusedLocationBarUsesTransparentBg) { |
2018 visualStateChanged = true; | 2067 visualStateChanged = true; |
2019 } else { | 2068 } else { |
2020 updateToolbarBackground(VisualState.BRAND_COLOR); | 2069 updateToolbarBackground(VisualState.BRAND_COLOR); |
2021 getProgressBar().setThemeColor(themeColorForProgressBar, isIncog
nito()); | 2070 getProgressBar().setThemeColor(themeColorForProgressBar, isIncog
nito()); |
2022 } | 2071 } |
2023 } | 2072 } |
2024 | 2073 |
2025 mVisualState = newVisualState; | 2074 mVisualState = newVisualState; |
2026 | 2075 |
2027 updateOverlayDrawables(isInTabSwitcherMode); | 2076 updateOverlayDrawables(); |
2028 updateShadowVisibility(isInTabSwitcherMode); | 2077 updateShadowVisibility(); |
| 2078 updateUrlExpansionAnimation(); |
2029 if (!visualStateChanged) { | 2079 if (!visualStateChanged) { |
2030 if (mVisualState == VisualState.NEW_TAB_NORMAL) { | 2080 if (mVisualState == VisualState.NEW_TAB_NORMAL) { |
2031 updateNtpTransitionAnimation(); | 2081 updateNtpTransitionAnimation(); |
2032 } | 2082 } |
2033 return; | 2083 return; |
2034 } | 2084 } |
2035 | 2085 |
2036 mUseLightToolbarDrawables = false; | 2086 mUseLightToolbarDrawables = false; |
2037 mUnfocusedLocationBarUsesTransparentBg = false; | 2087 mUnfocusedLocationBarUsesTransparentBg = false; |
2038 mUrlBackgroundAlpha = 255; | 2088 mLocationBarBackgroundAlpha = 255; |
2039 updateToolbarBackground(mVisualState); | 2089 updateToolbarBackground(mVisualState); |
2040 getProgressBar().setThemeColor(themeColorForProgressBar, isIncognito()); | 2090 getProgressBar().setThemeColor(themeColorForProgressBar, isIncognito()); |
2041 | 2091 |
2042 if (isInTabSwitcherMode) { | 2092 if (mIsInTabSwitcherMode) { |
2043 mUseLightToolbarDrawables = true; | 2093 mUseLightToolbarDrawables = true; |
2044 mUrlBackgroundAlpha = LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA; | 2094 mLocationBarBackgroundAlpha = LOCATION_BAR_TRANSPARENT_BACKGROUND_AL
PHA; |
2045 getProgressBar().setBackgroundColor(mProgressBackBackgroundColorWhit
e); | 2095 getProgressBar().setBackgroundColor(mProgressBackBackgroundColorWhit
e); |
2046 getProgressBar().setForegroundColor(ApiCompatibilityUtils.getColor(g
etResources(), | 2096 getProgressBar().setForegroundColor(ApiCompatibilityUtils.getColor(g
etResources(), |
2047 R.color.progress_bar_foreground_white)); | 2097 R.color.progress_bar_foreground_white)); |
2048 } else if (isIncognito()) { | 2098 } else if (isIncognito()) { |
2049 mUseLightToolbarDrawables = true; | 2099 mUseLightToolbarDrawables = true; |
2050 mUrlBackgroundAlpha = LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA; | 2100 mLocationBarBackgroundAlpha = LOCATION_BAR_TRANSPARENT_BACKGROUND_AL
PHA; |
2051 } else if (mVisualState == VisualState.BRAND_COLOR) { | 2101 } else if (mVisualState == VisualState.BRAND_COLOR) { |
2052 mUseLightToolbarDrawables = | 2102 mUseLightToolbarDrawables = |
2053 ColorUtils.shouldUseLightForegroundOnBackground(currentPrima
ryColor); | 2103 ColorUtils.shouldUseLightForegroundOnBackground(currentPrima
ryColor); |
2054 mUnfocusedLocationBarUsesTransparentBg = | 2104 mUnfocusedLocationBarUsesTransparentBg = |
2055 !ColorUtils.shouldUseOpaqueTextboxBackground(currentPrimaryC
olor); | 2105 !ColorUtils.shouldUseOpaqueTextboxBackground(currentPrimaryC
olor); |
2056 mUrlBackgroundAlpha = mUnfocusedLocationBarUsesTransparentBg | 2106 mLocationBarBackgroundAlpha = mUnfocusedLocationBarUsesTransparentBg |
2057 ? LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA : 255; | 2107 ? LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA |
| 2108 : 255; |
2058 } | 2109 } |
2059 | 2110 |
2060 if (mToggleTabStackButton != null) { | 2111 if (mToggleTabStackButton != null) { |
2061 mToggleTabStackButton.setImageDrawable(mUseLightToolbarDrawables | 2112 mToggleTabStackButton.setImageDrawable(mUseLightToolbarDrawables |
2062 ? mTabSwitcherButtonDrawableLight : mTabSwitcherButtonDrawab
le); | 2113 ? mTabSwitcherButtonDrawableLight : mTabSwitcherButtonDrawab
le); |
2063 if (mTabSwitcherAnimationTabStackDrawable != null) { | 2114 if (mTabSwitcherAnimationTabStackDrawable != null) { |
2064 mTabSwitcherAnimationTabStackDrawable.setTint( | 2115 mTabSwitcherAnimationTabStackDrawable.setTint( |
2065 mUseLightToolbarDrawables ? mLightModeTint : mDarkModeTi
nt); | 2116 mUseLightToolbarDrawables ? mLightModeTint : mDarkModeTi
nt); |
2066 } | 2117 } |
2067 } | 2118 } |
2068 | 2119 |
2069 if (shouldShowMenuButton()) { | 2120 if (shouldShowMenuButton()) { |
2070 mMenuButton.setTint(mUseLightToolbarDrawables ? mLightModeTint : mDa
rkModeTint); | 2121 mMenuButton.setTint(mUseLightToolbarDrawables ? mLightModeTint : mDa
rkModeTint); |
2071 | 2122 |
2072 if (mShowMenuBadge && !isInTabSwitcherMode) { | 2123 if (mShowMenuBadge && !mIsInTabSwitcherMode) { |
2073 setAppMenuUpdateBadgeDrawable(mUseLightToolbarDrawables); | 2124 setAppMenuUpdateBadgeDrawable(mUseLightToolbarDrawables); |
2074 } | 2125 } |
2075 } | 2126 } |
2076 ColorStateList tint = mUseLightToolbarDrawables ? mLightModeTint : mDark
ModeTint; | 2127 ColorStateList tint = mUseLightToolbarDrawables ? mLightModeTint : mDark
ModeTint; |
2077 if (isReturnButtonVisible()) mReturnButton.setTint(tint); | 2128 if (isReturnButtonVisible()) mReturnButton.setTint(tint); |
2078 if (mIsHomeButtonEnabled) mHomeButton.setTint(tint); | 2129 if (mIsHomeButtonEnabled) mHomeButton.setTint(tint); |
2079 | 2130 |
2080 mPhoneLocationBar.updateVisualsForState(); | 2131 mLocationBar.updateVisualsForState(); |
2081 // Remove the side padding for incognito to ensure the badge icon aligns
correctly with the | 2132 // Remove the side padding for incognito to ensure the badge icon aligns
correctly with the |
2082 // background of the location bar. | 2133 // background of the location bar. |
2083 if (isIncognito) { | 2134 if (isIncognito) { |
2084 mPhoneLocationBar.setPadding( | 2135 mLocationBar.setPadding( |
2085 0, mUrlBackgroundPadding.top, 0, mUrlBackgroundPadding.botto
m); | 2136 0, mLocationBarBackgroundPadding.top, 0, mLocationBarBackgro
undPadding.bottom); |
2086 } else { | 2137 } else { |
2087 mPhoneLocationBar.setPadding( | 2138 mLocationBar.setPadding( |
2088 mUrlBackgroundPadding.left, mUrlBackgroundPadding.top, | 2139 mLocationBarBackgroundPadding.left, mLocationBarBackgroundPa
dding.top, |
2089 mUrlBackgroundPadding.right, mUrlBackgroundPadding.bottom); | 2140 mLocationBarBackgroundPadding.right, mLocationBarBackgroundP
adding.bottom); |
2090 } | 2141 } |
2091 | 2142 |
2092 // We update the alpha before comparing the visual state as we need to c
hange | 2143 // We update the alpha before comparing the visual state as we need to c
hange |
2093 // its value when entering and exiting TabSwitcher mode. | 2144 // its value when entering and exiting TabSwitcher mode. |
2094 if (isLocationBarShownInNTP() && !isInTabSwitcherMode) { | 2145 if (isLocationBarShownInNTP() && !mIsInTabSwitcherMode) { |
2095 updateNtpTransitionAnimation(); | 2146 updateNtpTransitionAnimation(); |
2096 } | 2147 } |
2097 | 2148 |
2098 if (isInTabSwitcherMode) mNewTabButton.setIsIncognito(isIncognito); | 2149 if (mIsInTabSwitcherMode) mNewTabButton.setIsIncognito(isIncognito); |
2099 | 2150 |
2100 CharSequence newTabContentDescription = getResources().getText( | 2151 CharSequence newTabContentDescription = getResources().getText( |
2101 isIncognito ? R.string.accessibility_toolbar_btn_new_incognito_t
ab : | 2152 isIncognito ? R.string.accessibility_toolbar_btn_new_incognito_t
ab : |
2102 R.string.accessibility_toolbar_btn_new_tab); | 2153 R.string.accessibility_toolbar_btn_new_tab); |
2103 if (mNewTabButton != null | 2154 if (mNewTabButton != null |
2104 && !newTabContentDescription.equals(mNewTabButton.getContentDesc
ription())) { | 2155 && !newTabContentDescription.equals(mNewTabButton.getContentDesc
ription())) { |
2105 mNewTabButton.setContentDescription(newTabContentDescription); | 2156 mNewTabButton.setContentDescription(newTabContentDescription); |
2106 } | 2157 } |
2107 | 2158 |
2108 getMenuButtonWrapper().setVisibility(shouldShowMenuButton() ? View.VISIB
LE : View.GONE); | 2159 getMenuButtonWrapper().setVisibility(shouldShowMenuButton() ? View.VISIB
LE : View.GONE); |
2109 } | 2160 } |
2110 | 2161 |
2111 @Override | 2162 @Override |
2112 public LocationBar getLocationBar() { | 2163 public LocationBar getLocationBar() { |
2113 return mPhoneLocationBar; | 2164 return mLocationBar; |
2114 } | 2165 } |
2115 | 2166 |
2116 @Override | 2167 @Override |
2117 public void showAppMenuUpdateBadge() { | 2168 public void showAppMenuUpdateBadge() { |
2118 super.showAppMenuUpdateBadge(); | 2169 super.showAppMenuUpdateBadge(); |
2119 | 2170 |
2120 // Set up variables. | 2171 // Set up variables. |
2121 if (!mBrowsingModeViews.contains(mMenuBadge)) { | 2172 if (!mBrowsingModeViews.contains(mMenuBadge)) { |
2122 mBrowsingModeViews.add(mMenuBadge); | 2173 mBrowsingModeViews.add(mMenuBadge); |
2123 } | 2174 } |
2124 | 2175 |
2125 // Finish any in-progress animations and set the TabSwitcherAnimationMen
uBadgeDrawables. | 2176 // Finish any in-progress animations and set the TabSwitcherAnimationMen
uBadgeDrawables. |
2126 finishAnimations(); | 2177 finishAnimations(); |
2127 setTabSwitcherAnimationMenuBadgeDrawable(); | 2178 setTabSwitcherAnimationMenuBadgeDrawable(); |
2128 | 2179 |
2129 // Show the badge. | 2180 // Show the badge. |
2130 if (!mIsInTabSwitcherMode && shouldShowMenuButton()) { | 2181 if (!mIsInTabSwitcherMode && shouldShowMenuButton()) { |
2131 if (mUseLightToolbarDrawables) { | 2182 if (mUseLightToolbarDrawables) { |
2132 setAppMenuUpdateBadgeDrawable(mUseLightToolbarDrawables); | 2183 setAppMenuUpdateBadgeDrawable(mUseLightToolbarDrawables); |
2133 } | 2184 } |
2134 setAppMenuUpdateBadgeToVisible(true); | 2185 setAppMenuUpdateBadgeToVisible(true); |
2135 } | 2186 } |
2136 | 2187 |
2137 mPhoneLocationBar.showAppMenuUpdateBadge(true); | 2188 mLocationBar.showAppMenuUpdateBadge(true); |
2138 } | 2189 } |
2139 | 2190 |
2140 @Override | 2191 @Override |
2141 public void removeAppMenuUpdateBadge(boolean animate) { | 2192 public void removeAppMenuUpdateBadge(boolean animate) { |
2142 super.removeAppMenuUpdateBadge(animate); | 2193 super.removeAppMenuUpdateBadge(animate); |
2143 | 2194 |
2144 if (mBrowsingModeViews.contains(mMenuBadge)) { | 2195 if (mBrowsingModeViews.contains(mMenuBadge)) { |
2145 mBrowsingModeViews.remove(mMenuBadge); | 2196 mBrowsingModeViews.remove(mMenuBadge); |
2146 mTabSwitcherAnimationMenuBadgeDarkDrawable = null; | 2197 mTabSwitcherAnimationMenuBadgeDarkDrawable = null; |
2147 mTabSwitcherAnimationMenuBadgeLightDrawable = null; | 2198 mTabSwitcherAnimationMenuBadgeLightDrawable = null; |
2148 } | 2199 } |
2149 | 2200 |
2150 mPhoneLocationBar.removeAppMenuUpdateBadge(animate); | 2201 mLocationBar.removeAppMenuUpdateBadge(animate); |
2151 } | 2202 } |
2152 | 2203 |
2153 private void setTabSwitcherAnimationMenuDrawable() { | 2204 private void setTabSwitcherAnimationMenuDrawable() { |
2154 if (!shouldShowMenuButton()) return; | 2205 if (!shouldShowMenuButton()) return; |
2155 mTabSwitcherAnimationMenuDrawable = ApiCompatibilityUtils.getDrawable(ge
tResources(), | 2206 mTabSwitcherAnimationMenuDrawable = ApiCompatibilityUtils.getDrawable(ge
tResources(), |
2156 R.drawable.btn_menu); | 2207 R.drawable.btn_menu); |
2157 mTabSwitcherAnimationMenuDrawable.mutate(); | 2208 mTabSwitcherAnimationMenuDrawable.mutate(); |
2158 mTabSwitcherAnimationMenuDrawable.setColorFilter( | 2209 mTabSwitcherAnimationMenuDrawable.setColorFilter( |
2159 isIncognito() ? mLightModeDefaultColor : mDarkModeDefaultColor, | 2210 isIncognito() ? mLightModeDefaultColor : mDarkModeDefaultColor, |
2160 PorterDuff.Mode.SRC_IN); | 2211 PorterDuff.Mode.SRC_IN); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2227 }); | 2278 }); |
2228 | 2279 |
2229 if (mFullscreenManager != null) { | 2280 if (mFullscreenManager != null) { |
2230 mFullscreenCalloutToken = | 2281 mFullscreenCalloutToken = |
2231 mFullscreenManager.showControlsPersistentAndClearOldToken( | 2282 mFullscreenManager.showControlsPersistentAndClearOldToken( |
2232 mFullscreenCalloutToken); | 2283 mFullscreenCalloutToken); |
2233 } | 2284 } |
2234 } | 2285 } |
2235 } | 2286 } |
2236 | 2287 |
OLD | NEW |