| 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; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 import android.widget.ImageView; | 39 import android.widget.ImageView; |
| 40 import android.widget.TextView; | 40 import android.widget.TextView; |
| 41 | 41 |
| 42 import org.chromium.base.ApiCompatibilityUtils; | 42 import org.chromium.base.ApiCompatibilityUtils; |
| 43 import org.chromium.base.SysUtils; | 43 import org.chromium.base.SysUtils; |
| 44 import org.chromium.base.VisibleForTesting; | 44 import org.chromium.base.VisibleForTesting; |
| 45 import org.chromium.base.metrics.RecordUserAction; | 45 import org.chromium.base.metrics.RecordUserAction; |
| 46 import org.chromium.chrome.R; | 46 import org.chromium.chrome.R; |
| 47 import org.chromium.chrome.browser.compositor.Invalidator; | 47 import org.chromium.chrome.browser.compositor.Invalidator; |
| 48 import org.chromium.chrome.browser.ntp.NewTabPage; | 48 import org.chromium.chrome.browser.ntp.NewTabPage; |
| 49 import org.chromium.chrome.browser.omaha.UpdateMenuItemHelper; |
| 49 import org.chromium.chrome.browser.omnibox.LocationBar; | 50 import org.chromium.chrome.browser.omnibox.LocationBar; |
| 50 import org.chromium.chrome.browser.omnibox.LocationBarPhone; | 51 import org.chromium.chrome.browser.omnibox.LocationBarPhone; |
| 51 import org.chromium.chrome.browser.omnibox.UrlContainer; | 52 import org.chromium.chrome.browser.omnibox.UrlContainer; |
| 52 import org.chromium.chrome.browser.partnercustomizations.HomepageManager; | 53 import org.chromium.chrome.browser.partnercustomizations.HomepageManager; |
| 53 import org.chromium.chrome.browser.tab.Tab; | 54 import org.chromium.chrome.browser.tab.Tab; |
| 54 import org.chromium.chrome.browser.util.ColorUtils; | 55 import org.chromium.chrome.browser.util.ColorUtils; |
| 55 import org.chromium.chrome.browser.util.FeatureUtilities; | 56 import org.chromium.chrome.browser.util.FeatureUtilities; |
| 56 import org.chromium.chrome.browser.util.MathUtils; | 57 import org.chromium.chrome.browser.util.MathUtils; |
| 57 import org.chromium.chrome.browser.widget.TintedImageButton; | 58 import org.chromium.chrome.browser.widget.TintedImageButton; |
| 58 import org.chromium.chrome.browser.widget.newtab.NewTabButton; | 59 import org.chromium.chrome.browser.widget.newtab.NewTabButton; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 102 |
| 102 private final int mProgressBackBackgroundColor; | 103 private final int mProgressBackBackgroundColor; |
| 103 private final int mProgressBackBackgroundColorWhite; | 104 private final int mProgressBackBackgroundColorWhite; |
| 104 | 105 |
| 105 private ObjectAnimator mTabSwitcherModeAnimation; | 106 private ObjectAnimator mTabSwitcherModeAnimation; |
| 106 private ObjectAnimator mDelayedTabSwitcherModeAnimation; | 107 private ObjectAnimator mDelayedTabSwitcherModeAnimation; |
| 107 | 108 |
| 108 private final List<View> mTabSwitcherModeViews = new ArrayList<View>(); | 109 private final List<View> mTabSwitcherModeViews = new ArrayList<View>(); |
| 109 private final Set<View> mBrowsingModeViews = new HashSet<View>(); | 110 private final Set<View> mBrowsingModeViews = new HashSet<View>(); |
| 110 @ViewDebug.ExportedProperty(category = "chrome") | 111 @ViewDebug.ExportedProperty(category = "chrome") |
| 111 private boolean mInTabSwitcherMode; | 112 private boolean mIsInTabSwitcherMode; |
| 112 | 113 |
| 113 // This determines whether or not the toolbar draws as expected (false) or w
hether it always | 114 // This determines whether or not the toolbar draws as expected (false) or w
hether it always |
| 114 // draws as if it's showing the non-tabswitcher, non-animating toolbar. This
is used in grabbing | 115 // draws as if it's showing the non-tabswitcher, non-animating toolbar. This
is used in grabbing |
| 115 // a bitmap to use as a texture representation of this view. | 116 // a bitmap to use as a texture representation of this view. |
| 116 @ViewDebug.ExportedProperty(category = "chrome") | 117 @ViewDebug.ExportedProperty(category = "chrome") |
| 117 private boolean mTextureCaptureMode; | 118 private boolean mTextureCaptureMode; |
| 118 | 119 |
| 119 @ViewDebug.ExportedProperty(category = "chrome") | 120 @ViewDebug.ExportedProperty(category = "chrome") |
| 120 private boolean mAnimateNormalToolbar; | 121 private boolean mAnimateNormalToolbar; |
| 121 @ViewDebug.ExportedProperty(category = "chrome") | 122 @ViewDebug.ExportedProperty(category = "chrome") |
| 122 private boolean mDelayingTabSwitcherAnimation; | 123 private boolean mDelayingTabSwitcherAnimation; |
| 123 | 124 |
| 124 private ColorDrawable mTabSwitcherAnimationBgOverlay; | 125 private ColorDrawable mTabSwitcherAnimationBgOverlay; |
| 125 private TabSwitcherDrawable mTabSwitcherAnimationTabStackDrawable; | 126 private TabSwitcherDrawable mTabSwitcherAnimationTabStackDrawable; |
| 126 private Drawable mTabSwitcherAnimationMenuDrawable; | 127 private Drawable mTabSwitcherAnimationMenuDrawable; |
| 128 private Drawable mTabSwitcherAnimationMenuBadgeDrawable; |
| 127 // Value that determines the amount of transition from the normal toolbar mo
de to TabSwitcher | 129 // Value that determines the amount of transition from the normal toolbar mo
de to TabSwitcher |
| 128 // mode. 0 = entirely in normal mode and 1.0 = entirely in TabSwitcher mode
. In between values | 130 // mode. 0 = entirely in normal mode and 1.0 = entirely in TabSwitcher mode
. In between values |
| 129 // can be used for animating between the two view modes. | 131 // can be used for animating between the two view modes. |
| 130 @ViewDebug.ExportedProperty(category = "chrome") | 132 @ViewDebug.ExportedProperty(category = "chrome") |
| 131 private float mTabSwitcherModePercent = 0; | 133 private float mTabSwitcherModePercent = 0; |
| 132 @ViewDebug.ExportedProperty(category = "chrome") | 134 @ViewDebug.ExportedProperty(category = "chrome") |
| 133 private boolean mUIAnimatingTabSwitcherTransition; | 135 private boolean mUIAnimatingTabSwitcherTransition; |
| 134 | 136 |
| 135 // Used to clip the toolbar during the fade transition into and out of TabSw
itcher mode. Only | 137 // Used to clip the toolbar during the fade transition into and out of TabSw
itcher mode. Only |
| 136 // used when |mAnimateNormalToolbar| is false. | 138 // used when |mAnimateNormalToolbar| is false. |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 | 278 |
| 277 mLocationBarBackground = | 279 mLocationBarBackground = |
| 278 ApiCompatibilityUtils.getDrawable(getResources(), R.drawable.ins
et_textbox); | 280 ApiCompatibilityUtils.getDrawable(getResources(), R.drawable.ins
et_textbox); |
| 279 mLocationBarBackground.getPadding(mUrlBackgroundPadding); | 281 mLocationBarBackground.getPadding(mUrlBackgroundPadding); |
| 280 mPhoneLocationBar.setPadding( | 282 mPhoneLocationBar.setPadding( |
| 281 mUrlBackgroundPadding.left, mUrlBackgroundPadding.top, | 283 mUrlBackgroundPadding.left, mUrlBackgroundPadding.top, |
| 282 mUrlBackgroundPadding.right, mUrlBackgroundPadding.bottom); | 284 mUrlBackgroundPadding.right, mUrlBackgroundPadding.bottom); |
| 283 | 285 |
| 284 setLayoutTransition(null); | 286 setLayoutTransition(null); |
| 285 | 287 |
| 286 mMenuButton.setVisibility(shouldShowMenuButton() ? View.VISIBLE : View.G
ONE); | 288 mMenuButtonWrapper.setVisibility(shouldShowMenuButton() ? View.VISIBLE :
View.GONE); |
| 287 if (FeatureUtilities.isDocumentMode(getContext())) { | 289 if (FeatureUtilities.isDocumentMode(getContext())) { |
| 288 ApiCompatibilityUtils.setMarginEnd( | 290 ApiCompatibilityUtils.setMarginEnd( |
| 289 (MarginLayoutParams) mMenuButton.getLayoutParams(), | 291 (MarginLayoutParams) mMenuButtonWrapper.getLayoutParams(), |
| 290 getResources().getDimensionPixelSize(R.dimen.document_toolba
r_menu_offset)); | 292 getResources().getDimensionPixelSize(R.dimen.document_toolba
r_menu_offset)); |
| 291 } | 293 } |
| 292 | 294 |
| 293 if (FeatureUtilities.isTabSwitchingEnabled(getContext())) { | 295 if (FeatureUtilities.isTabSwitchingEnabled(getContext())) { |
| 294 inflateTabSwitchingResources(); | 296 inflateTabSwitchingResources(); |
| 295 } else { | 297 } else { |
| 296 hideTabSwitchingResources(); | 298 hideTabSwitchingResources(); |
| 297 } | 299 } |
| 298 | 300 |
| 299 setWillNotDraw(false); | 301 setWillNotDraw(false); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 return mToggleTabStackButton; | 406 return mToggleTabStackButton; |
| 405 } | 407 } |
| 406 | 408 |
| 407 @Override | 409 @Override |
| 408 protected boolean handleEnterKeyPress() { | 410 protected boolean handleEnterKeyPress() { |
| 409 return getMenuButtonHelper().onEnterKeyPress(mMenuButton); | 411 return getMenuButtonHelper().onEnterKeyPress(mMenuButton); |
| 410 } | 412 } |
| 411 }); | 413 }); |
| 412 onHomeButtonUpdate(HomepageManager.isHomepageEnabled(getContext())); | 414 onHomeButtonUpdate(HomepageManager.isHomepageEnabled(getContext())); |
| 413 | 415 |
| 414 updateVisualsForToolbarState(mInTabSwitcherMode); | 416 updateVisualsForToolbarState(mIsInTabSwitcherMode); |
| 415 } | 417 } |
| 416 | 418 |
| 417 @Override | 419 @Override |
| 418 public boolean onInterceptTouchEvent(MotionEvent ev) { | 420 public boolean onInterceptTouchEvent(MotionEvent ev) { |
| 419 // If the NTP is partially scrolled, prevent all touch events to the chi
ld views. This | 421 // If the NTP is partially scrolled, prevent all touch events to the chi
ld views. This |
| 420 // is to not allow a secondary touch event to trigger entering the tab s
witcher, which | 422 // is to not allow a secondary touch event to trigger entering the tab s
witcher, which |
| 421 // can lead to really odd snapshots and transitions to the switcher. | 423 // can lead to really odd snapshots and transitions to the switcher. |
| 422 if (mNtpSearchBoxScrollPercent != 0f | 424 if (mNtpSearchBoxScrollPercent != 0f |
| 423 && mNtpSearchBoxScrollPercent != 1f | 425 && mNtpSearchBoxScrollPercent != 1f |
| 424 && mNtpSearchBoxScrollPercent != UNINITIALIZED_PERCENT) { | 426 && mNtpSearchBoxScrollPercent != UNINITIALIZED_PERCENT) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 } | 463 } |
| 462 return showAccessibilityToast(v, description); | 464 return showAccessibilityToast(v, description); |
| 463 } | 465 } |
| 464 | 466 |
| 465 @Override | 467 @Override |
| 466 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | 468 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
| 467 if (!mDisableLocationBarRelayout) { | 469 if (!mDisableLocationBarRelayout) { |
| 468 super.onMeasure(widthMeasureSpec, heightMeasureSpec); | 470 super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
| 469 | 471 |
| 470 boolean changed = layoutLocationBar(MeasureSpec.getSize(widthMeasure
Spec)); | 472 boolean changed = layoutLocationBar(MeasureSpec.getSize(widthMeasure
Spec)); |
| 471 if (!mInTabSwitcherMode) setUrlFocusChangePercent(mUrlFocusChangePer
cent); | 473 if (!mIsInTabSwitcherMode) setUrlFocusChangePercent(mUrlFocusChangeP
ercent); |
| 472 if (!changed) return; | 474 if (!changed) return; |
| 473 } else { | 475 } else { |
| 474 updateUnfocusedLocationBarLayoutParams(); | 476 updateUnfocusedLocationBarLayoutParams(); |
| 475 } | 477 } |
| 476 | 478 |
| 477 super.onMeasure(widthMeasureSpec, heightMeasureSpec); | 479 super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
| 478 } | 480 } |
| 479 | 481 |
| 480 private void updateUnfocusedLocationBarLayoutParams() { | 482 private void updateUnfocusedLocationBarLayoutParams() { |
| 481 boolean hasVisibleViewPriorToUrlBar = false; | 483 boolean hasVisibleViewPriorToUrlBar = false; |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 updateUrlExpansionAnimation(); | 734 updateUrlExpansionAnimation(); |
| 733 } | 735 } |
| 734 | 736 |
| 735 private void updateUrlExpansionPercent() { | 737 private void updateUrlExpansionPercent() { |
| 736 mUrlExpansionPercent = Math.max(mNtpSearchBoxScrollPercent, mUrlFocusCha
ngePercent); | 738 mUrlExpansionPercent = Math.max(mNtpSearchBoxScrollPercent, mUrlFocusCha
ngePercent); |
| 737 assert mUrlExpansionPercent >= 0; | 739 assert mUrlExpansionPercent >= 0; |
| 738 assert mUrlExpansionPercent <= 1; | 740 assert mUrlExpansionPercent <= 1; |
| 739 } | 741 } |
| 740 | 742 |
| 741 private void updateUrlExpansionAnimation() { | 743 private void updateUrlExpansionAnimation() { |
| 742 if (mInTabSwitcherMode || isTabSwitcherAnimationRunning()) return; | 744 if (mIsInTabSwitcherMode || isTabSwitcherAnimationRunning()) return; |
| 743 | 745 |
| 744 mLocationBarBackgroundOffset.setEmpty(); | 746 mLocationBarBackgroundOffset.setEmpty(); |
| 745 | 747 |
| 746 FrameLayout.LayoutParams locationBarLayoutParams = | 748 FrameLayout.LayoutParams locationBarLayoutParams = |
| 747 getFrameLayoutParams(mPhoneLocationBar); | 749 getFrameLayoutParams(mPhoneLocationBar); |
| 748 int currentLeftMargin = locationBarLayoutParams.leftMargin; | 750 int currentLeftMargin = locationBarLayoutParams.leftMargin; |
| 749 int currentWidth = locationBarLayoutParams.width; | 751 int currentWidth = locationBarLayoutParams.width; |
| 750 | 752 |
| 751 float inversePercent = 1f - mUrlExpansionPercent; | 753 float inversePercent = 1f - mUrlExpansionPercent; |
| 752 boolean isLocationBarRtl = ApiCompatibilityUtils.isLayoutRtl(mPhoneLocat
ionBar); | 754 boolean isLocationBarRtl = ApiCompatibilityUtils.isLayoutRtl(mPhoneLocat
ionBar); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 || (mUnfocusedLocationBarUsesTransparentBg | 819 || (mUnfocusedLocationBarUsesTransparentBg |
| 818 && !mUrlFocusChangeInProgress | 820 && !mUrlFocusChangeInProgress |
| 819 && !mPhoneLocationBar.hasFocus()) | 821 && !mPhoneLocationBar.hasFocus()) |
| 820 ? LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA : 255; | 822 ? LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA : 255; |
| 821 setAncestorsShouldClipChildren(true); | 823 setAncestorsShouldClipChildren(true); |
| 822 mNtpSearchBoxScrollPercent = UNINITIALIZED_PERCENT; | 824 mNtpSearchBoxScrollPercent = UNINITIALIZED_PERCENT; |
| 823 updateUrlExpansionPercent(); | 825 updateUrlExpansionPercent(); |
| 824 } | 826 } |
| 825 | 827 |
| 826 private void updateNtpTransitionAnimation(NewTabPage ntp) { | 828 private void updateNtpTransitionAnimation(NewTabPage ntp) { |
| 827 if (mInTabSwitcherMode) return; | 829 if (mIsInTabSwitcherMode) return; |
| 828 | 830 |
| 829 setAncestorsShouldClipChildren(mUrlExpansionPercent == 0f); | 831 setAncestorsShouldClipChildren(mUrlExpansionPercent == 0f); |
| 830 mToolbarShadow.setAlpha(0f); | 832 mToolbarShadow.setAlpha(0f); |
| 831 | 833 |
| 832 float growthPercent = 0f; | 834 float growthPercent = 0f; |
| 833 if (mUrlExpansionPercent == 0f || mUrlExpansionPercent == 1f) { | 835 if (mUrlExpansionPercent == 0f || mUrlExpansionPercent == 1f) { |
| 834 growthPercent = 1f - mUrlExpansionPercent; | 836 growthPercent = 1f - mUrlExpansionPercent; |
| 835 } else { | 837 } else { |
| 836 // During the transition from search box to omnibox, keep the omnibo
x drawing | 838 // During the transition from search box to omnibox, keep the omnibo
x drawing |
| 837 // at the same size of the search box for first 40% of the scroll tr
ansition. | 839 // at the same size of the search box for first 40% of the scroll tr
ansition. |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 canvas.translate(backgroundLeft, backgroundTop); | 961 canvas.translate(backgroundLeft, backgroundTop); |
| 960 | 962 |
| 961 mTabSwitcherAnimationTabStackDrawable.setAlpha(rgbAlpha); | 963 mTabSwitcherAnimationTabStackDrawable.setAlpha(rgbAlpha); |
| 962 mTabSwitcherAnimationTabStackDrawable.draw(canvas); | 964 mTabSwitcherAnimationTabStackDrawable.draw(canvas); |
| 963 canvas.restore(); | 965 canvas.restore(); |
| 964 } | 966 } |
| 965 | 967 |
| 966 // Draw the menu button if necessary. | 968 // Draw the menu button if necessary. |
| 967 if (mTabSwitcherAnimationMenuDrawable != null | 969 if (mTabSwitcherAnimationMenuDrawable != null |
| 968 && mUrlExpansionPercent != 1f) { | 970 && mUrlExpansionPercent != 1f) { |
| 971 canvas.save(); |
| 969 mTabSwitcherAnimationMenuDrawable.setBounds( | 972 mTabSwitcherAnimationMenuDrawable.setBounds( |
| 970 mMenuButton.getPaddingLeft(), mMenuButton.getPaddingTop(), | 973 mMenuButton.getPaddingLeft(), mMenuButton.getPaddingTop(), |
| 971 mMenuButton.getWidth() - mMenuButton.getPaddingRight(), | 974 mMenuButton.getWidth() - mMenuButton.getPaddingRight(), |
| 972 mMenuButton.getHeight() - mMenuButton.getPaddingBottom()); | 975 mMenuButton.getHeight() - mMenuButton.getPaddingBottom()); |
| 973 translateCanvasToView(mToolbarButtonsContainer, mMenuButton, canvas)
; | 976 translateCanvasToView(mToolbarButtonsContainer, mMenuButton, canvas)
; |
| 974 mTabSwitcherAnimationMenuDrawable.setAlpha(rgbAlpha); | 977 mTabSwitcherAnimationMenuDrawable.setAlpha(rgbAlpha); |
| 975 int color = mUseLightToolbarDrawables | 978 int color = mUseLightToolbarDrawables |
| 976 ? mLightModeDefaultColor | 979 ? mLightModeDefaultColor |
| 977 : mDarkModeDefaultColor; | 980 : mDarkModeDefaultColor; |
| 978 mTabSwitcherAnimationMenuDrawable.setColorFilter(color, PorterDuff.M
ode.SRC_IN); | 981 mTabSwitcherAnimationMenuDrawable.setColorFilter(color, PorterDuff.M
ode.SRC_IN); |
| 979 mTabSwitcherAnimationMenuDrawable.draw(canvas); | 982 mTabSwitcherAnimationMenuDrawable.draw(canvas); |
| 983 canvas.restore(); |
| 984 } |
| 985 |
| 986 // Draw the menu badge if necessary. |
| 987 if (mShowMenuBadge && mTabSwitcherAnimationMenuBadgeDrawable != null |
| 988 && mUrlExpansionPercent != 1f) { |
| 989 translateCanvasToView(mToolbarButtonsContainer, mMenuBadge, canvas); |
| 990 mTabSwitcherAnimationMenuBadgeDrawable.setAlpha(rgbAlpha); |
| 991 mTabSwitcherAnimationMenuBadgeDrawable.draw(canvas); |
| 980 } | 992 } |
| 981 | 993 |
| 982 canvas.restore(); | 994 canvas.restore(); |
| 983 } | 995 } |
| 984 | 996 |
| 985 @Override | 997 @Override |
| 986 public void doInvalidate() { | 998 public void doInvalidate() { |
| 987 postInvalidateOnAnimation(); | 999 postInvalidateOnAnimation(); |
| 988 } | 1000 } |
| 989 | 1001 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1008 to = (View) to.getParent(); | 1020 to = (View) to.getParent(); |
| 1009 } | 1021 } |
| 1010 } | 1022 } |
| 1011 | 1023 |
| 1012 @Override | 1024 @Override |
| 1013 protected boolean drawChild(Canvas canvas, View child, long drawingTime) { | 1025 protected boolean drawChild(Canvas canvas, View child, long drawingTime) { |
| 1014 if (child == mPhoneLocationBar) return drawLocationBar(canvas, drawingTi
me); | 1026 if (child == mPhoneLocationBar) return drawLocationBar(canvas, drawingTi
me); |
| 1015 boolean clipped = false; | 1027 boolean clipped = false; |
| 1016 | 1028 |
| 1017 if (mLocationBarBackground != null | 1029 if (mLocationBarBackground != null |
| 1018 && ((!mInTabSwitcherMode && !mTabSwitcherModeViews.contains(chil
d)) | 1030 && ((!mIsInTabSwitcherMode && !mTabSwitcherModeViews.contains(ch
ild)) |
| 1019 || (mInTabSwitcherMode && mBrowsingModeViews.contains(ch
ild)))) { | 1031 || (mIsInTabSwitcherMode && mBrowsingModeViews.contains(
child)))) { |
| 1020 canvas.save(); | 1032 canvas.save(); |
| 1021 if (mUrlExpansionPercent != 0f && mUrlViewportBounds.top < child.get
Bottom()) { | 1033 if (mUrlExpansionPercent != 0f && mUrlViewportBounds.top < child.get
Bottom()) { |
| 1022 // For other child views, use the inverse clipping of the URL vi
ewport. | 1034 // For other child views, use the inverse clipping of the URL vi
ewport. |
| 1023 // Only necessary during animations. | 1035 // Only necessary during animations. |
| 1024 // Hardware mode does not support unioned clip regions, so clip
using the | 1036 // Hardware mode does not support unioned clip regions, so clip
using the |
| 1025 // appropriate bounds based on whether the child is to the left
or right of the | 1037 // appropriate bounds based on whether the child is to the left
or right of the |
| 1026 // location bar. | 1038 // location bar. |
| 1027 boolean isLeft = (child == mNewTabButton || child == mHomeButton
) | 1039 boolean isLeft = (child == mNewTabButton || child == mHomeButton
) |
| 1028 ^ LocalizationUtils.isLayoutRtl(); | 1040 ^ LocalizationUtils.isLayoutRtl(); |
| 1029 | 1041 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1054 return retVal; | 1066 return retVal; |
| 1055 } | 1067 } |
| 1056 | 1068 |
| 1057 private boolean drawLocationBar(Canvas canvas, long drawingTime) { | 1069 private boolean drawLocationBar(Canvas canvas, long drawingTime) { |
| 1058 boolean clipped = false; | 1070 boolean clipped = false; |
| 1059 float locationBarClipLeft = 0; | 1071 float locationBarClipLeft = 0; |
| 1060 float locationBarClipRight = 0; | 1072 float locationBarClipRight = 0; |
| 1061 float locationBarClipTop = 0; | 1073 float locationBarClipTop = 0; |
| 1062 float locationBarClipBottom = 0; | 1074 float locationBarClipBottom = 0; |
| 1063 | 1075 |
| 1064 if (mLocationBarBackground != null && (!mInTabSwitcherMode || mTextureCa
ptureMode)) { | 1076 if (mLocationBarBackground != null && (!mIsInTabSwitcherMode || mTexture
CaptureMode)) { |
| 1065 canvas.save(); | 1077 canvas.save(); |
| 1066 int backgroundAlpha = mUrlBackgroundAlpha; | 1078 int backgroundAlpha = mUrlBackgroundAlpha; |
| 1067 if (mTabSwitcherModeAnimation != null) { | 1079 if (mTabSwitcherModeAnimation != null) { |
| 1068 // Fade out/in the location bar towards the beginning of the ani
mations to avoid | 1080 // Fade out/in the location bar towards the beginning of the ani
mations to avoid |
| 1069 // large jumps of stark white. | 1081 // large jumps of stark white. |
| 1070 backgroundAlpha = | 1082 backgroundAlpha = |
| 1071 (int) (Math.pow(mPhoneLocationBar.getAlpha(), 3) * backg
roundAlpha); | 1083 (int) (Math.pow(mPhoneLocationBar.getAlpha(), 3) * backg
roundAlpha); |
| 1072 } else if (getToolbarDataProvider().isUsingBrandColor() | 1084 } else if (getToolbarDataProvider().isUsingBrandColor() |
| 1073 && !mBrandColorTransitionActive) { | 1085 && !mBrandColorTransitionActive) { |
| 1074 int unfocusedAlpha = mUnfocusedLocationBarUsesTransparentBg | 1086 int unfocusedAlpha = mUnfocusedLocationBarUsesTransparentBg |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 } | 1173 } |
| 1162 } | 1174 } |
| 1163 | 1175 |
| 1164 @Override | 1176 @Override |
| 1165 public void onStateRestored() { | 1177 public void onStateRestored() { |
| 1166 if (mToggleTabStackButton != null) mToggleTabStackButton.setClickable(tr
ue); | 1178 if (mToggleTabStackButton != null) mToggleTabStackButton.setClickable(tr
ue); |
| 1167 } | 1179 } |
| 1168 | 1180 |
| 1169 @Override | 1181 @Override |
| 1170 public boolean isReadyForTextureCapture() { | 1182 public boolean isReadyForTextureCapture() { |
| 1171 return !(mInTabSwitcherMode || mTabSwitcherModeAnimation != null | 1183 return !(mIsInTabSwitcherMode || mTabSwitcherModeAnimation != null |
| 1172 || urlHasFocus() || mUrlFocusChangeInProgress); | 1184 || urlHasFocus() || mUrlFocusChangeInProgress); |
| 1173 } | 1185 } |
| 1174 | 1186 |
| 1175 @Override | 1187 @Override |
| 1176 protected void onNavigatedToDifferentPage() { | 1188 protected void onNavigatedToDifferentPage() { |
| 1177 super.onNavigatedToDifferentPage(); | 1189 super.onNavigatedToDifferentPage(); |
| 1178 if (FeatureUtilities.isDocumentMode(getContext())) { | 1190 if (FeatureUtilities.isDocumentMode(getContext())) { |
| 1179 mUrlContainer.setTrailingTextVisible(true); | 1191 mUrlContainer.setTrailingTextVisible(true); |
| 1180 } | 1192 } |
| 1181 } | 1193 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 | 1225 |
| 1214 outRect.set(outRect.left + paddingLeft, | 1226 outRect.set(outRect.left + paddingLeft, |
| 1215 outRect.top + paddingTop, | 1227 outRect.top + paddingTop, |
| 1216 outRect.right - paddingRight, | 1228 outRect.right - paddingRight, |
| 1217 outRect.bottom - paddingBottom); | 1229 outRect.bottom - paddingBottom); |
| 1218 } | 1230 } |
| 1219 | 1231 |
| 1220 @Override | 1232 @Override |
| 1221 protected void onHomeButtonUpdate(boolean homeButtonEnabled) { | 1233 protected void onHomeButtonUpdate(boolean homeButtonEnabled) { |
| 1222 if (homeButtonEnabled) { | 1234 if (homeButtonEnabled) { |
| 1223 mHomeButton.setVisibility(urlHasFocus() || mInTabSwitcherMode ? INVI
SIBLE : VISIBLE); | 1235 mHomeButton.setVisibility(urlHasFocus() || mIsInTabSwitcherMode ? IN
VISIBLE : VISIBLE); |
| 1224 if (!mBrowsingModeViews.contains(mHomeButton)) { | 1236 if (!mBrowsingModeViews.contains(mHomeButton)) { |
| 1225 mBrowsingModeViews.add(mHomeButton); | 1237 mBrowsingModeViews.add(mHomeButton); |
| 1226 } | 1238 } |
| 1227 } else { | 1239 } else { |
| 1228 mHomeButton.setVisibility(GONE); | 1240 mHomeButton.setVisibility(GONE); |
| 1229 mBrowsingModeViews.remove(mHomeButton); | 1241 mBrowsingModeViews.remove(mHomeButton); |
| 1230 } | 1242 } |
| 1231 } | 1243 } |
| 1232 | 1244 |
| 1233 private ObjectAnimator createEnterTabSwitcherModeAnimation() { | 1245 private ObjectAnimator createEnterTabSwitcherModeAnimation() { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1252 final boolean animateNormalToolbar) { | 1264 final boolean animateNormalToolbar) { |
| 1253 ObjectAnimator exitAnimation = | 1265 ObjectAnimator exitAnimation = |
| 1254 ObjectAnimator.ofFloat(this, mTabSwitcherModePercentProperty, 0.
f); | 1266 ObjectAnimator.ofFloat(this, mTabSwitcherModePercentProperty, 0.
f); |
| 1255 exitAnimation.setDuration(animateNormalToolbar | 1267 exitAnimation.setDuration(animateNormalToolbar |
| 1256 ? TAB_SWITCHER_MODE_EXIT_NORMAL_ANIMATION_DURATION_MS | 1268 ? TAB_SWITCHER_MODE_EXIT_NORMAL_ANIMATION_DURATION_MS |
| 1257 : TAB_SWITCHER_MODE_EXIT_FADE_ANIMATION_DURATION_MS); | 1269 : TAB_SWITCHER_MODE_EXIT_FADE_ANIMATION_DURATION_MS); |
| 1258 exitAnimation.setInterpolator(new LinearInterpolator()); | 1270 exitAnimation.setInterpolator(new LinearInterpolator()); |
| 1259 exitAnimation.addListener(new AnimatorListenerAdapter() { | 1271 exitAnimation.addListener(new AnimatorListenerAdapter() { |
| 1260 @Override | 1272 @Override |
| 1261 public void onAnimationEnd(Animator animation) { | 1273 public void onAnimationEnd(Animator animation) { |
| 1262 updateViewsForTabSwitcherMode(mInTabSwitcherMode); | 1274 updateViewsForTabSwitcherMode(mIsInTabSwitcherMode); |
| 1263 } | 1275 } |
| 1264 }); | 1276 }); |
| 1265 | 1277 |
| 1266 return exitAnimation; | 1278 return exitAnimation; |
| 1267 } | 1279 } |
| 1268 | 1280 |
| 1269 private ObjectAnimator createPostExitTabSwitcherAnimation() { | 1281 private ObjectAnimator createPostExitTabSwitcherAnimation() { |
| 1270 ObjectAnimator exitAnimation = ObjectAnimator.ofFloat( | 1282 ObjectAnimator exitAnimation = ObjectAnimator.ofFloat( |
| 1271 this, View.TRANSLATION_Y, -getHeight(), 0.f); | 1283 this, View.TRANSLATION_Y, -getHeight(), 0.f); |
| 1272 exitAnimation.setDuration(TAB_SWITCHER_MODE_POST_EXIT_ANIMATION_DURATION
_MS); | 1284 exitAnimation.setDuration(TAB_SWITCHER_MODE_POST_EXIT_ANIMATION_DURATION
_MS); |
| 1273 exitAnimation.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); | 1285 exitAnimation.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); |
| 1274 exitAnimation.addListener(new AnimatorListenerAdapter() { | 1286 exitAnimation.addListener(new AnimatorListenerAdapter() { |
| 1275 @Override | 1287 @Override |
| 1276 public void onAnimationStart(Animator animation) { | 1288 public void onAnimationStart(Animator animation) { |
| 1277 updateViewsForTabSwitcherMode(mInTabSwitcherMode); | 1289 updateViewsForTabSwitcherMode(mIsInTabSwitcherMode); |
| 1278 // On older builds, force an update to ensure the new visuals ar
e used | 1290 // On older builds, force an update to ensure the new visuals ar
e used |
| 1279 // when bringing in the toolbar. crbug.com/404571 | 1291 // when bringing in the toolbar. crbug.com/404571 |
| 1280 if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN) { | 1292 if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN) { |
| 1281 requestLayout(); | 1293 requestLayout(); |
| 1282 } | 1294 } |
| 1283 } | 1295 } |
| 1284 | 1296 |
| 1285 @Override | 1297 @Override |
| 1286 public void onAnimationEnd(Animator animation) { | 1298 public void onAnimationEnd(Animator animation) { |
| 1287 mDelayedTabSwitcherModeAnimation = null; | 1299 mDelayedTabSwitcherModeAnimation = null; |
| 1288 updateShadowVisibility(mInTabSwitcherMode); | 1300 updateShadowVisibility(mIsInTabSwitcherMode); |
| 1289 updateViewsForTabSwitcherMode(mInTabSwitcherMode); | 1301 updateViewsForTabSwitcherMode(mIsInTabSwitcherMode); |
| 1290 } | 1302 } |
| 1291 }); | 1303 }); |
| 1292 | 1304 |
| 1293 return exitAnimation; | 1305 return exitAnimation; |
| 1294 } | 1306 } |
| 1295 | 1307 |
| 1296 @Override | 1308 @Override |
| 1297 public void setTextureCaptureMode(boolean textureMode) { | 1309 public void setTextureCaptureMode(boolean textureMode) { |
| 1298 assert mTextureCaptureMode != textureMode; | 1310 assert mTextureCaptureMode != textureMode; |
| 1299 mTextureCaptureMode = textureMode; | 1311 mTextureCaptureMode = textureMode; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1324 view.setVisibility(browsingViewsVisibility); | 1336 view.setVisibility(browsingViewsVisibility); |
| 1325 } | 1337 } |
| 1326 getProgressBar().setVisibility( | 1338 getProgressBar().setVisibility( |
| 1327 isInTabSwitcherMode || isTabSwitcherAnimationRunning() ? INVISIB
LE : VISIBLE); | 1339 isInTabSwitcherMode || isTabSwitcherAnimationRunning() ? INVISIB
LE : VISIBLE); |
| 1328 updateVisualsForToolbarState(isInTabSwitcherMode); | 1340 updateVisualsForToolbarState(isInTabSwitcherMode); |
| 1329 | 1341 |
| 1330 } | 1342 } |
| 1331 | 1343 |
| 1332 @Override | 1344 @Override |
| 1333 protected void setContentAttached(boolean attached) { | 1345 protected void setContentAttached(boolean attached) { |
| 1334 updateVisualsForToolbarState(mInTabSwitcherMode); | 1346 updateVisualsForToolbarState(mIsInTabSwitcherMode); |
| 1335 } | 1347 } |
| 1336 | 1348 |
| 1337 @Override | 1349 @Override |
| 1338 protected void setTabSwitcherMode( | 1350 protected void setTabSwitcherMode( |
| 1339 boolean inTabSwitcherMode, boolean showToolbar, boolean delayAnimati
on) { | 1351 boolean inTabSwitcherMode, boolean showToolbar, boolean delayAnimati
on) { |
| 1340 if (mInTabSwitcherMode == inTabSwitcherMode) return; | 1352 if (mIsInTabSwitcherMode == inTabSwitcherMode) return; |
| 1341 | 1353 |
| 1342 finishAnimations(); | 1354 finishAnimations(); |
| 1343 | 1355 |
| 1344 mDelayingTabSwitcherAnimation = delayAnimation; | 1356 mDelayingTabSwitcherAnimation = delayAnimation; |
| 1345 | 1357 |
| 1346 if (inTabSwitcherMode) { | 1358 if (inTabSwitcherMode) { |
| 1347 if (mUrlFocusLayoutAnimator != null && mUrlFocusLayoutAnimator.isRun
ning()) { | 1359 if (mUrlFocusLayoutAnimator != null && mUrlFocusLayoutAnimator.isRun
ning()) { |
| 1348 mUrlFocusLayoutAnimator.end(); | 1360 mUrlFocusLayoutAnimator.end(); |
| 1349 mUrlFocusLayoutAnimator = null; | 1361 mUrlFocusLayoutAnimator = null; |
| 1350 // After finishing the animation, force a re-layout of the locat
ion bar, | 1362 // After finishing the animation, force a re-layout of the locat
ion bar, |
| 1351 // so that the final translation position is correct (since onMe
asure updates | 1363 // so that the final translation position is correct (since onMe
asure updates |
| 1352 // won't happen in tab switcher mode). crbug.com/518795. | 1364 // won't happen in tab switcher mode). crbug.com/518795. |
| 1353 layoutLocationBar(getMeasuredWidth()); | 1365 layoutLocationBar(getMeasuredWidth()); |
| 1354 updateUrlExpansionAnimation(); | 1366 updateUrlExpansionAnimation(); |
| 1355 } | 1367 } |
| 1356 mNewTabButton.setEnabled(true); | 1368 mNewTabButton.setEnabled(true); |
| 1357 updateViewsForTabSwitcherMode(true); | 1369 updateViewsForTabSwitcherMode(true); |
| 1358 mTabSwitcherModeAnimation = createEnterTabSwitcherModeAnimation(); | 1370 mTabSwitcherModeAnimation = createEnterTabSwitcherModeAnimation(); |
| 1359 } else { | 1371 } else { |
| 1360 if (!mDelayingTabSwitcherAnimation) { | 1372 if (!mDelayingTabSwitcherAnimation) { |
| 1361 mTabSwitcherModeAnimation = createExitTabSwitcherAnimation(showT
oolbar); | 1373 mTabSwitcherModeAnimation = createExitTabSwitcherAnimation(showT
oolbar); |
| 1362 } | 1374 } |
| 1363 mUIAnimatingTabSwitcherTransition = true; | 1375 mUIAnimatingTabSwitcherTransition = true; |
| 1364 } | 1376 } |
| 1365 | 1377 |
| 1366 mAnimateNormalToolbar = showToolbar; | 1378 mAnimateNormalToolbar = showToolbar; |
| 1367 mInTabSwitcherMode = inTabSwitcherMode; | 1379 mIsInTabSwitcherMode = inTabSwitcherMode; |
| 1368 if (mTabSwitcherModeAnimation != null) mTabSwitcherModeAnimation.start()
; | 1380 if (mTabSwitcherModeAnimation != null) mTabSwitcherModeAnimation.start()
; |
| 1369 | 1381 |
| 1370 if (SysUtils.isLowEndDevice()) finishAnimations(); | 1382 if (SysUtils.isLowEndDevice()) finishAnimations(); |
| 1371 | 1383 |
| 1372 postInvalidateOnAnimation(); | 1384 postInvalidateOnAnimation(); |
| 1373 } | 1385 } |
| 1374 | 1386 |
| 1375 @Override | 1387 @Override |
| 1376 protected void onTabSwitcherTransitionFinished() { | 1388 protected void onTabSwitcherTransitionFinished() { |
| 1377 setAlpha(1.f); | 1389 setAlpha(1.f); |
| 1378 mClipRect = null; | 1390 mClipRect = null; |
| 1379 mUIAnimatingTabSwitcherTransition = false; | 1391 mUIAnimatingTabSwitcherTransition = false; |
| 1392 |
| 1393 if (mShowMenuBadge && !mIsInTabSwitcherMode) { |
| 1394 // If mInTabSwitcherMode is true, the menu button drawable will be u
pdated in |
| 1395 // #updateVisualsForToolbarState(). |
| 1396 mMenuButton.setImageBitmap( |
| 1397 UpdateMenuItemHelper.getInstance().getBadgedMenuButtonBitmap
(getContext())); |
| 1398 } |
| 1380 if (!mAnimateNormalToolbar) { | 1399 if (!mAnimateNormalToolbar) { |
| 1381 finishAnimations(); | 1400 finishAnimations(); |
| 1382 updateVisualsForToolbarState(mInTabSwitcherMode); | 1401 updateVisualsForToolbarState(mIsInTabSwitcherMode); |
| 1383 } | 1402 } |
| 1384 | 1403 |
| 1385 if (mDelayingTabSwitcherAnimation) { | 1404 if (mDelayingTabSwitcherAnimation) { |
| 1386 mDelayingTabSwitcherAnimation = false; | 1405 mDelayingTabSwitcherAnimation = false; |
| 1387 mDelayedTabSwitcherModeAnimation = createPostExitTabSwitcherAnimatio
n(); | 1406 mDelayedTabSwitcherModeAnimation = createPostExitTabSwitcherAnimatio
n(); |
| 1388 mDelayedTabSwitcherModeAnimation.start(); | 1407 mDelayedTabSwitcherModeAnimation.start(); |
| 1389 } else { | 1408 } else { |
| 1390 updateViewsForTabSwitcherMode(mInTabSwitcherMode); | 1409 updateViewsForTabSwitcherMode(mIsInTabSwitcherMode); |
| 1391 } | 1410 } |
| 1392 } | 1411 } |
| 1393 | 1412 |
| 1394 private void updateOverlayDrawables() { | 1413 private void updateOverlayDrawables() { |
| 1395 if (!isNativeLibraryReady()) return; | 1414 if (!isNativeLibraryReady()) return; |
| 1396 | 1415 |
| 1397 VisualState overlayState = computeVisualState(false); | 1416 VisualState overlayState = computeVisualState(false); |
| 1398 boolean visualStateChanged = mOverlayDrawablesVisualState != overlayStat
e; | 1417 boolean visualStateChanged = mOverlayDrawablesVisualState != overlayStat
e; |
| 1399 | 1418 |
| 1400 if (!visualStateChanged && mVisualState == VisualState.BRAND_COLOR | 1419 if (!visualStateChanged && mVisualState == VisualState.BRAND_COLOR |
| 1401 && getToolbarDataProvider().getPrimaryColor() | 1420 && getToolbarDataProvider().getPrimaryColor() |
| 1402 != mTabSwitcherAnimationBgOverlay.getColor()) { | 1421 != mTabSwitcherAnimationBgOverlay.getColor()) { |
| 1403 visualStateChanged = true; | 1422 visualStateChanged = true; |
| 1404 } | 1423 } |
| 1405 if (!visualStateChanged) return; | 1424 if (!visualStateChanged) return; |
| 1406 | 1425 |
| 1407 mOverlayDrawablesVisualState = overlayState; | 1426 mOverlayDrawablesVisualState = overlayState; |
| 1408 mTabSwitcherAnimationBgOverlay.setColor(getToolbarColorForVisualState( | 1427 mTabSwitcherAnimationBgOverlay.setColor(getToolbarColorForVisualState( |
| 1409 mOverlayDrawablesVisualState)); | 1428 mOverlayDrawablesVisualState)); |
| 1410 | 1429 |
| 1411 if (shouldShowMenuButton()) { | 1430 setTabSwitcherAnimationMenuDrawable(); |
| 1412 Resources res = getResources(); | |
| 1413 mTabSwitcherAnimationMenuDrawable = ApiCompatibilityUtils.getDrawabl
e( | |
| 1414 res, R.drawable.btn_menu).mutate(); | |
| 1415 mTabSwitcherAnimationMenuDrawable.setColorFilter( | |
| 1416 isIncognito() ? mLightModeDefaultColor : mDarkModeDefaultCol
or, | |
| 1417 PorterDuff.Mode.SRC_IN); | |
| 1418 ((BitmapDrawable) mTabSwitcherAnimationMenuDrawable).setGravity(Grav
ity.CENTER); | |
| 1419 } | |
| 1420 } | 1431 } |
| 1421 | 1432 |
| 1422 @Override | 1433 @Override |
| 1423 public void setOnTabSwitcherClickHandler(OnClickListener listener) { | 1434 public void setOnTabSwitcherClickHandler(OnClickListener listener) { |
| 1424 mTabSwitcherListener = listener; | 1435 mTabSwitcherListener = listener; |
| 1425 } | 1436 } |
| 1426 | 1437 |
| 1427 @Override | 1438 @Override |
| 1428 public void setOnNewTabClickHandler(OnClickListener listener) { | 1439 public void setOnNewTabClickHandler(OnClickListener listener) { |
| 1429 mNewTabListener = listener; | 1440 mNewTabListener = listener; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1479 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); | 1490 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); |
| 1480 animators.add(animator); | 1491 animators.add(animator); |
| 1481 } | 1492 } |
| 1482 | 1493 |
| 1483 float density = getContext().getResources().getDisplayMetrics().density; | 1494 float density = getContext().getResources().getDisplayMetrics().density; |
| 1484 boolean isRtl = ApiCompatibilityUtils.isLayoutRtl(this); | 1495 boolean isRtl = ApiCompatibilityUtils.isLayoutRtl(this); |
| 1485 float toolbarButtonTranslationX = MathUtils.flipSignIf( | 1496 float toolbarButtonTranslationX = MathUtils.flipSignIf( |
| 1486 URL_FOCUS_TOOLBAR_BUTTONS_TRANSLATION_X_DP, isRtl) * density; | 1497 URL_FOCUS_TOOLBAR_BUTTONS_TRANSLATION_X_DP, isRtl) * density; |
| 1487 | 1498 |
| 1488 animator = ObjectAnimator.ofFloat( | 1499 animator = ObjectAnimator.ofFloat( |
| 1489 mMenuButton, TRANSLATION_X, toolbarButtonTranslationX); | 1500 mMenuButtonWrapper, TRANSLATION_X, toolbarButtonTranslationX); |
| 1490 animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); | 1501 animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); |
| 1491 animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE); | 1502 animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE); |
| 1492 animators.add(animator); | 1503 animators.add(animator); |
| 1493 | 1504 |
| 1494 animator = ObjectAnimator.ofFloat(mMenuButton, ALPHA, 0); | 1505 animator = ObjectAnimator.ofFloat(mMenuButtonWrapper, ALPHA, 0); |
| 1495 animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); | 1506 animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); |
| 1496 animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE); | 1507 animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE); |
| 1497 animators.add(animator); | 1508 animators.add(animator); |
| 1498 | 1509 |
| 1499 if (mToggleTabStackButton != null) { | 1510 if (mToggleTabStackButton != null) { |
| 1500 animator = ObjectAnimator.ofFloat( | 1511 animator = ObjectAnimator.ofFloat( |
| 1501 mToggleTabStackButton, TRANSLATION_X, toolbarButtonTranslati
onX); | 1512 mToggleTabStackButton, TRANSLATION_X, toolbarButtonTranslati
onX); |
| 1502 animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); | 1513 animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); |
| 1503 animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE); | 1514 animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE); |
| 1504 animators.add(animator); | 1515 animators.add(animator); |
| 1505 | 1516 |
| 1506 animator = ObjectAnimator.ofFloat(mToggleTabStackButton, ALPHA, 0); | 1517 animator = ObjectAnimator.ofFloat(mToggleTabStackButton, ALPHA, 0); |
| 1507 animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); | 1518 animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); |
| 1508 animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE); | 1519 animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE); |
| 1509 animators.add(animator); | 1520 animators.add(animator); |
| 1510 } | 1521 } |
| 1511 } | 1522 } |
| 1512 | 1523 |
| 1513 private void populateUrlClearFocusingAnimatorSet(List<Animator> animators) { | 1524 private void populateUrlClearFocusingAnimatorSet(List<Animator> animators) { |
| 1514 Animator animator = ObjectAnimator.ofFloat(this, mUrlFocusChangePercentP
roperty, 0f); | 1525 Animator animator = ObjectAnimator.ofFloat(this, mUrlFocusChangePercentP
roperty, 0f); |
| 1515 animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS); | 1526 animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS); |
| 1516 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); | 1527 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); |
| 1517 animators.add(animator); | 1528 animators.add(animator); |
| 1518 | 1529 |
| 1519 animator = ObjectAnimator.ofFloat(mMenuButton, TRANSLATION_X, 0); | 1530 animator = ObjectAnimator.ofFloat(mMenuButtonWrapper, TRANSLATION_X, 0); |
| 1520 animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); | 1531 animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); |
| 1521 animator.setStartDelay(URL_CLEAR_FOCUS_MENU_DELAY_MS); | 1532 animator.setStartDelay(URL_CLEAR_FOCUS_MENU_DELAY_MS); |
| 1522 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); | 1533 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); |
| 1523 animators.add(animator); | 1534 animators.add(animator); |
| 1524 | 1535 |
| 1525 animator = ObjectAnimator.ofFloat(mMenuButton, ALPHA, 1); | 1536 animator = ObjectAnimator.ofFloat(mMenuButtonWrapper, ALPHA, 1); |
| 1526 animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); | 1537 animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); |
| 1527 animator.setStartDelay(URL_CLEAR_FOCUS_MENU_DELAY_MS); | 1538 animator.setStartDelay(URL_CLEAR_FOCUS_MENU_DELAY_MS); |
| 1528 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); | 1539 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); |
| 1529 animators.add(animator); | 1540 animators.add(animator); |
| 1530 | 1541 |
| 1531 if (mToggleTabStackButton != null) { | 1542 if (mToggleTabStackButton != null) { |
| 1532 animator = ObjectAnimator.ofFloat(mToggleTabStackButton, TRANSLATION
_X, 0); | 1543 animator = ObjectAnimator.ofFloat(mToggleTabStackButton, TRANSLATION
_X, 0); |
| 1533 animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); | 1544 animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); |
| 1534 animator.setStartDelay(URL_CLEAR_FOCUS_TABSTACK_DELAY_MS); | 1545 animator.setStartDelay(URL_CLEAR_FOCUS_TABSTACK_DELAY_MS); |
| 1535 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); | 1546 animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1686 if (mTabSwitcherAnimationTabStackDrawable != null) { | 1697 if (mTabSwitcherAnimationTabStackDrawable != null) { |
| 1687 mTabSwitcherAnimationTabStackDrawable.updateForTabCount( | 1698 mTabSwitcherAnimationTabStackDrawable.updateForTabCount( |
| 1688 numberOfTabs, isIncognito()); | 1699 numberOfTabs, isIncognito()); |
| 1689 } | 1700 } |
| 1690 } | 1701 } |
| 1691 | 1702 |
| 1692 @Override | 1703 @Override |
| 1693 protected void onTabContentViewChanged() { | 1704 protected void onTabContentViewChanged() { |
| 1694 super.onTabContentViewChanged(); | 1705 super.onTabContentViewChanged(); |
| 1695 updateNtpAnimationState(); | 1706 updateNtpAnimationState(); |
| 1696 updateVisualsForToolbarState(mInTabSwitcherMode); | 1707 updateVisualsForToolbarState(mIsInTabSwitcherMode); |
| 1697 } | 1708 } |
| 1698 | 1709 |
| 1699 @Override | 1710 @Override |
| 1700 protected void onTabOrModelChanged() { | 1711 protected void onTabOrModelChanged() { |
| 1701 super.onTabOrModelChanged(); | 1712 super.onTabOrModelChanged(); |
| 1702 updateNtpAnimationState(); | 1713 updateNtpAnimationState(); |
| 1703 updateVisualsForToolbarState(mInTabSwitcherMode); | 1714 updateVisualsForToolbarState(mIsInTabSwitcherMode); |
| 1704 } | 1715 } |
| 1705 | 1716 |
| 1706 private static boolean isVisualStateValidForBrandColorTransition(VisualState
state) { | 1717 private static boolean isVisualStateValidForBrandColorTransition(VisualState
state) { |
| 1707 return state == VisualState.NORMAL || state == VisualState.BRAND_COLOR; | 1718 return state == VisualState.NORMAL || state == VisualState.BRAND_COLOR; |
| 1708 } | 1719 } |
| 1709 | 1720 |
| 1710 @Override | 1721 @Override |
| 1711 protected void onPrimaryColorChanged(boolean shouldAnimate) { | 1722 protected void onPrimaryColorChanged(boolean shouldAnimate) { |
| 1712 super.onPrimaryColorChanged(shouldAnimate); | 1723 super.onPrimaryColorChanged(shouldAnimate); |
| 1713 if (mBrandColorTransitionActive) mBrandColorTransitionAnimation.cancel()
; | 1724 if (mBrandColorTransitionActive) mBrandColorTransitionAnimation.cancel()
; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1739 mUrlBackgroundAlpha = | 1750 mUrlBackgroundAlpha = |
| 1740 (int) (initialAlpha + fraction * (finalAlpha - initi
alAlpha)); | 1751 (int) (initialAlpha + fraction * (finalAlpha - initi
alAlpha)); |
| 1741 } | 1752 } |
| 1742 updateToolbarBackground(Color.rgb(red, green, blue)); | 1753 updateToolbarBackground(Color.rgb(red, green, blue)); |
| 1743 } | 1754 } |
| 1744 }); | 1755 }); |
| 1745 mBrandColorTransitionAnimation.addListener(new AnimatorListenerAdapter()
{ | 1756 mBrandColorTransitionAnimation.addListener(new AnimatorListenerAdapter()
{ |
| 1746 @Override | 1757 @Override |
| 1747 public void onAnimationEnd(Animator animation) { | 1758 public void onAnimationEnd(Animator animation) { |
| 1748 mBrandColorTransitionActive = false; | 1759 mBrandColorTransitionActive = false; |
| 1749 updateVisualsForToolbarState(mInTabSwitcherMode); | 1760 updateVisualsForToolbarState(mIsInTabSwitcherMode); |
| 1750 } | 1761 } |
| 1751 }); | 1762 }); |
| 1752 mBrandColorTransitionAnimation.start(); | 1763 mBrandColorTransitionAnimation.start(); |
| 1753 mBrandColorTransitionActive = true; | 1764 mBrandColorTransitionActive = true; |
| 1754 } | 1765 } |
| 1755 | 1766 |
| 1756 private void updateNtpAnimationState() { | 1767 private void updateNtpAnimationState() { |
| 1757 // Store previous NTP scroll before calling reset as that clears this va
lue. | 1768 // Store previous NTP scroll before calling reset as that clears this va
lue. |
| 1758 boolean wasShowingNtp = mVisibleNewTabPage != null; | 1769 boolean wasShowingNtp = mVisibleNewTabPage != null; |
| 1759 float previousNtpScrollPercent = mNtpSearchBoxScrollPercent; | 1770 float previousNtpScrollPercent = mNtpSearchBoxScrollPercent; |
| 1760 | 1771 |
| 1761 resetNtpAnimationValues(); | 1772 resetNtpAnimationValues(); |
| 1762 if (mVisibleNewTabPage != null) { | 1773 if (mVisibleNewTabPage != null) { |
| 1763 mVisibleNewTabPage.setSearchBoxScrollListener(null); | 1774 mVisibleNewTabPage.setSearchBoxScrollListener(null); |
| 1764 mVisibleNewTabPage = null; | 1775 mVisibleNewTabPage = null; |
| 1765 } | 1776 } |
| 1766 mVisibleNewTabPage = getToolbarDataProvider().getNewTabPageForCurrentTab
(); | 1777 mVisibleNewTabPage = getToolbarDataProvider().getNewTabPageForCurrentTab
(); |
| 1767 if (mVisibleNewTabPage != null && mVisibleNewTabPage.isLocationBarShownI
nNTP()) { | 1778 if (mVisibleNewTabPage != null && mVisibleNewTabPage.isLocationBarShownI
nNTP()) { |
| 1768 mVisibleNewTabPage.setSearchBoxScrollListener(this); | 1779 mVisibleNewTabPage.setSearchBoxScrollListener(this); |
| 1769 requestLayout(); | 1780 requestLayout(); |
| 1770 } else if (wasShowingNtp) { | 1781 } else if (wasShowingNtp) { |
| 1771 // Convert the previous NTP scroll percentage to URL focus percentag
e because that | 1782 // Convert the previous NTP scroll percentage to URL focus percentag
e because that |
| 1772 // will give a nicer transition animation from the expanded NTP omni
box to the | 1783 // will give a nicer transition animation from the expanded NTP omni
box to the |
| 1773 // collapsed normal omnibox on other non-NTP pages. | 1784 // collapsed normal omnibox on other non-NTP pages. |
| 1774 if (!mInTabSwitcherMode && previousNtpScrollPercent > 0f) { | 1785 if (!mIsInTabSwitcherMode && previousNtpScrollPercent > 0f) { |
| 1775 mUrlFocusChangePercent = | 1786 mUrlFocusChangePercent = |
| 1776 Math.max(previousNtpScrollPercent, mUrlFocusChangePercen
t); | 1787 Math.max(previousNtpScrollPercent, mUrlFocusChangePercen
t); |
| 1777 triggerUrlFocusAnimation(false); | 1788 triggerUrlFocusAnimation(false); |
| 1778 } | 1789 } |
| 1779 requestLayout(); | 1790 requestLayout(); |
| 1780 } | 1791 } |
| 1781 } | 1792 } |
| 1782 | 1793 |
| 1783 @Override | 1794 @Override |
| 1784 protected void onDefaultSearchEngineChanged() { | 1795 protected void onDefaultSearchEngineChanged() { |
| 1785 super.onDefaultSearchEngineChanged(); | 1796 super.onDefaultSearchEngineChanged(); |
| 1786 // Post an update for the toolbar state, which will allow all other list
eners | 1797 // Post an update for the toolbar state, which will allow all other list
eners |
| 1787 // for the search engine change to update before we check on the state o
f the | 1798 // for the search engine change to update before we check on the state o
f the |
| 1788 // world for a UI update. | 1799 // world for a UI update. |
| 1789 // TODO(tedchoc): Move away from updating based on the search engine cha
nge and instead | 1800 // TODO(tedchoc): Move away from updating based on the search engine cha
nge and instead |
| 1790 // add the toolbar as a listener to the NewTabPage and ud
pate only when | 1801 // add the toolbar as a listener to the NewTabPage and ud
pate only when |
| 1791 // it notifies the listeners that it has changed its stat
e. | 1802 // it notifies the listeners that it has changed its stat
e. |
| 1792 post(new Runnable() { | 1803 post(new Runnable() { |
| 1793 @Override | 1804 @Override |
| 1794 public void run() { | 1805 public void run() { |
| 1795 updateVisualsForToolbarState(mInTabSwitcherMode); | 1806 updateVisualsForToolbarState(mIsInTabSwitcherMode); |
| 1796 updateNtpAnimationState(); | 1807 updateNtpAnimationState(); |
| 1797 } | 1808 } |
| 1798 }); | 1809 }); |
| 1799 } | 1810 } |
| 1800 | 1811 |
| 1801 @Override | 1812 @Override |
| 1802 protected void handleFindToolbarStateChange(boolean showing) { | 1813 protected void handleFindToolbarStateChange(boolean showing) { |
| 1803 setVisibility(showing ? View.GONE : View.VISIBLE); | 1814 setVisibility(showing ? View.GONE : View.VISIBLE); |
| 1804 TransitionDrawable shadowDrawable = (TransitionDrawable) mToolbarShadow.
getDrawable(); | 1815 TransitionDrawable shadowDrawable = (TransitionDrawable) mToolbarShadow.
getDrawable(); |
| 1805 if (showing) { | 1816 if (showing) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1906 ColorUtils.getLightProgressbarBackground(currentPrimaryColor
); | 1917 ColorUtils.getLightProgressbarBackground(currentPrimaryColor
); |
| 1907 } | 1918 } |
| 1908 | 1919 |
| 1909 getProgressBar().setBackgroundColor(progressBarBackgroundColor); | 1920 getProgressBar().setBackgroundColor(progressBarBackgroundColor); |
| 1910 int progressBarForegroundColor = ApiCompatibilityUtils.getColor(getResou
rces(), | 1921 int progressBarForegroundColor = ApiCompatibilityUtils.getColor(getResou
rces(), |
| 1911 mUseLightToolbarDrawables | 1922 mUseLightToolbarDrawables |
| 1912 ? R.color.progress_bar_foreground_white | 1923 ? R.color.progress_bar_foreground_white |
| 1913 : R.color.progress_bar_foreground); | 1924 : R.color.progress_bar_foreground); |
| 1914 getProgressBar().setForegroundColor(progressBarForegroundColor); | 1925 getProgressBar().setForegroundColor(progressBarForegroundColor); |
| 1915 | 1926 |
| 1916 | |
| 1917 if (mToggleTabStackButton != null) { | 1927 if (mToggleTabStackButton != null) { |
| 1918 mToggleTabStackButton.setImageDrawable(mUseLightToolbarDrawables | 1928 mToggleTabStackButton.setImageDrawable(mUseLightToolbarDrawables |
| 1919 ? mTabSwitcherButtonDrawableLight : mTabSwitcherButtonDrawab
le); | 1929 ? mTabSwitcherButtonDrawableLight : mTabSwitcherButtonDrawab
le); |
| 1920 if (mTabSwitcherAnimationTabStackDrawable != null) { | 1930 if (mTabSwitcherAnimationTabStackDrawable != null) { |
| 1921 mTabSwitcherAnimationTabStackDrawable.setTint( | 1931 mTabSwitcherAnimationTabStackDrawable.setTint( |
| 1922 mUseLightToolbarDrawables ? mLightModeTint : mDarkModeTi
nt); | 1932 mUseLightToolbarDrawables ? mLightModeTint : mDarkModeTi
nt); |
| 1923 } | 1933 } |
| 1924 } | 1934 } |
| 1925 | 1935 |
| 1926 if (shouldShowMenuButton()) { | 1936 if (shouldShowMenuButton()) { |
| 1937 // Only change the menu button drawable if isInTabSwitcherMode to av
oid changing |
| 1938 // it too soon if we're in the process of existing tab switcher mode
. The drawable |
| 1939 // will be changed in #onTabSwitcherTransitionFinished if we are exi
ting tab switcher |
| 1940 // mode. |
| 1941 if (mShowMenuBadge && isInTabSwitcherMode) { |
| 1942 mMenuButton.setImageDrawable(mUnbadgedMenuButtonDrawable); |
| 1943 } |
| 1927 mMenuButton.setTint(mUseLightToolbarDrawables ? mLightModeTint : mDa
rkModeTint); | 1944 mMenuButton.setTint(mUseLightToolbarDrawables ? mLightModeTint : mDa
rkModeTint); |
| 1928 } | 1945 } |
| 1929 if (mHomeButton.getVisibility() != GONE) { | 1946 if (mHomeButton.getVisibility() != GONE) { |
| 1930 mHomeButton.setTint(mUseLightToolbarDrawables ? mLightModeTint : mDa
rkModeTint); | 1947 mHomeButton.setTint(mUseLightToolbarDrawables ? mLightModeTint : mDa
rkModeTint); |
| 1931 } | 1948 } |
| 1932 | 1949 |
| 1933 mPhoneLocationBar.updateVisualsForState(); | 1950 mPhoneLocationBar.updateVisualsForState(); |
| 1934 // Remove the side padding for incognito to ensure the badge icon aligns
correctly with the | 1951 // Remove the side padding for incognito to ensure the badge icon aligns
correctly with the |
| 1935 // background of the location bar. | 1952 // background of the location bar. |
| 1936 if (isIncognito) { | 1953 if (isIncognito) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1952 if (isInTabSwitcherMode) mNewTabButton.setIsIncognito(isIncognito); | 1969 if (isInTabSwitcherMode) mNewTabButton.setIsIncognito(isIncognito); |
| 1953 | 1970 |
| 1954 CharSequence newTabContentDescription = getResources().getText( | 1971 CharSequence newTabContentDescription = getResources().getText( |
| 1955 isIncognito ? R.string.accessibility_toolbar_btn_new_incognito_t
ab : | 1972 isIncognito ? R.string.accessibility_toolbar_btn_new_incognito_t
ab : |
| 1956 R.string.accessibility_toolbar_btn_new_tab); | 1973 R.string.accessibility_toolbar_btn_new_tab); |
| 1957 if (mNewTabButton != null | 1974 if (mNewTabButton != null |
| 1958 && !newTabContentDescription.equals(mNewTabButton.getContentDesc
ription())) { | 1975 && !newTabContentDescription.equals(mNewTabButton.getContentDesc
ription())) { |
| 1959 mNewTabButton.setContentDescription(newTabContentDescription); | 1976 mNewTabButton.setContentDescription(newTabContentDescription); |
| 1960 } | 1977 } |
| 1961 | 1978 |
| 1962 getMenuButton().setVisibility(shouldShowMenuButton() ? View.VISIBLE : Vi
ew.GONE); | 1979 getMenuButtonWrapper().setVisibility(shouldShowMenuButton() ? View.VISIB
LE : View.GONE); |
| 1963 } | 1980 } |
| 1964 | 1981 |
| 1965 @Override | 1982 @Override |
| 1966 public LocationBar getLocationBar() { | 1983 public LocationBar getLocationBar() { |
| 1967 return mPhoneLocationBar; | 1984 return mPhoneLocationBar; |
| 1968 } | 1985 } |
| 1986 |
| 1987 @Override |
| 1988 public void showAppMenuUpdateBadge() { |
| 1989 super.showAppMenuUpdateBadge(); |
| 1990 // Set up variables. |
| 1991 if (!mBrowsingModeViews.contains(mMenuBadge)) { |
| 1992 mBrowsingModeViews.add(mMenuBadge); |
| 1993 } |
| 1994 |
| 1995 // Finish any in-progress animations and set the TabSwitcherAnimationMen
uDrawable. |
| 1996 finishAnimations(); |
| 1997 setTabSwitcherAnimationMenuDrawable(); |
| 1998 |
| 1999 // Show the badge and update the menu button drawable. |
| 2000 if (!mIsInTabSwitcherMode) { |
| 2001 setAppMenuUpdateBadgeToVisible(); |
| 2002 } |
| 2003 |
| 2004 mPhoneLocationBar.showAppMenuUpdateBadge(); |
| 2005 } |
| 2006 |
| 2007 @Override |
| 2008 public void removeAppMenuUpdateBadge() { |
| 2009 super.removeAppMenuUpdateBadge(); |
| 2010 mPhoneLocationBar.removeAppMenuUpdateBadge(); |
| 2011 } |
| 2012 |
| 2013 private void setTabSwitcherAnimationMenuDrawable() { |
| 2014 if (!shouldShowMenuButton()) return; |
| 2015 Resources res = getResources(); |
| 2016 if (mShowMenuBadge) { |
| 2017 mTabSwitcherAnimationMenuDrawable = new BitmapDrawable(res, |
| 2018 UpdateMenuItemHelper.getInstance().getBadgedMenuButtonBitmap
(getContext())); |
| 2019 mTabSwitcherAnimationMenuBadgeDrawable = mMenuBadge.getDrawable().mu
tate(); |
| 2020 } else { |
| 2021 mTabSwitcherAnimationMenuDrawable = ApiCompatibilityUtils.getDrawabl
e(getResources(), |
| 2022 R.drawable.btn_menu); |
| 2023 } |
| 2024 mTabSwitcherAnimationMenuDrawable.mutate(); |
| 2025 mTabSwitcherAnimationMenuDrawable.setColorFilter( |
| 2026 isIncognito() ? mLightModeDefaultColor : mDarkModeDefaultColor, |
| 2027 PorterDuff.Mode.SRC_IN); |
| 2028 ((BitmapDrawable) mTabSwitcherAnimationMenuDrawable).setGravity(Gravity.
CENTER); |
| 2029 } |
| 1969 } | 2030 } |
| 1970 | 2031 |
| OLD | NEW |