Commit 8f6dce28 authored by Theresa's avatar Theresa Committed by Commit Bot

Revert "Modern] Update toolbar button animation for NTP"

This reverts commit 36fc4d87.

Reason for revert: caused crbug.com/859423 and crbug.com/859421

BUG=859421,859423,835412

Original change's description:
> Modern] Update toolbar button animation for NTP
> 
> Fade out the toolbar buttons rather than scrolling them off when the NTP
> is scrolled.
> 
> BUG=835412
> 
> Change-Id: I9c273aaa83f3546c9e04f9a7140c39796f09af9c
> Reviewed-on: https://chromium-review.googlesource.com/1120442
> Reviewed-by: Matthew Jones <mdjones@chromium.org>
> Commit-Queue: Theresa <twellington@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#571530}

TBR=twellington@chromium.org,mdjones@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 835412
Change-Id: I98b3f2d9b561eff9f80b798abb3965065ecf6002
Reviewed-on: https://chromium-review.googlesource.com/1122877Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Theresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571918}
parent 03a0f53b
...@@ -1221,8 +1221,8 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1221,8 +1221,8 @@ public class ToolbarPhone extends ToolbarLayout
mNtpSearchBoxTranslation.set(0, 0); mNtpSearchBoxTranslation.set(0, 0);
mLocationBar.setTranslationY(0); mLocationBar.setTranslationY(0);
if (!mUrlFocusChangeInProgress) { if (!mUrlFocusChangeInProgress) {
mToolbarButtonsContainer.setAlpha(1.f); mToolbarButtonsContainer.setTranslationY(0);
if (mHomeButton != null) mHomeButton.setAlpha(1.f); if (mHomeButton != null) mHomeButton.setTranslationY(0);
} }
if (!(mLocationBar.useModernDesign() && mUrlFocusChangeInProgress)) { if (!(mLocationBar.useModernDesign() && mUrlFocusChangeInProgress)) {
...@@ -1269,7 +1269,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1269,7 +1269,7 @@ public class ToolbarPhone extends ToolbarLayout
Math.max(0, (mNtpSearchBoxBounds.top - mLocationBar.getTop())); Math.max(0, (mNtpSearchBoxBounds.top - mLocationBar.getTop()));
mLocationBar.setTranslationY(locationBarTranslationY); mLocationBar.setTranslationY(locationBarTranslationY);
updateButtonsAlphaForNtp(); updateButtonsTranslationY();
// Linearly interpolate between the bounds of the search box on the NTP and the omnibox // Linearly interpolate between the bounds of the search box on the NTP and the omnibox
// background bounds. |shrinkage| is the scaling factor for the offset -- if it's 1, we are // background bounds. |shrinkage| is the scaling factor for the offset -- if it's 1, we are
...@@ -1317,17 +1317,14 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1317,17 +1317,14 @@ public class ToolbarPhone extends ToolbarLayout
} }
/** /**
* Update the alpha of the toolbar buttons to make them disappear as the new tab page is * Update the y translation of the buttons to make it appear as if they were scrolling with
* scrolled. * the new tab page.
*/ */
private void updateButtonsAlphaForNtp() { private void updateButtonsTranslationY() {
float transitionPercent = ((float) mNtpSearchBoxTranslation.y / (float) getHeight()); int transY = mTabSwitcherState == STATIC_TAB ? Math.min(mNtpSearchBoxTranslation.y, 0) : 0;
float alpha = mTabSwitcherState == STATIC_TAB
? MathUtils.clamp(1.f + transitionPercent, 0.f, 1.f)
: 1.f;
mToolbarButtonsContainer.setAlpha(alpha); mToolbarButtonsContainer.setTranslationY(transY);
if (mHomeButton != null) mHomeButton.setAlpha(alpha); if (mHomeButton != null) mHomeButton.setTranslationY(transY);
} }
private void setAncestorsShouldClipChildren(boolean clip) { private void setAncestorsShouldClipChildren(boolean clip) {
...@@ -1979,7 +1976,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1979,7 +1976,7 @@ public class ToolbarPhone extends ToolbarLayout
} }
} }
updateButtonsAlphaForNtp(); updateButtonsTranslationY();
mAnimateNormalToolbar = showToolbar; mAnimateNormalToolbar = showToolbar;
if (mTabSwitcherModeAnimation != null) mTabSwitcherModeAnimation.start(); if (mTabSwitcherModeAnimation != null) mTabSwitcherModeAnimation.start();
...@@ -2120,35 +2117,31 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -2120,35 +2117,31 @@ public class ToolbarPhone extends ToolbarLayout
float toolbarButtonTranslationX = MathUtils.flipSignIf( float toolbarButtonTranslationX = MathUtils.flipSignIf(
URL_FOCUS_TOOLBAR_BUTTONS_TRANSLATION_X_DP, isRtl) * density; URL_FOCUS_TOOLBAR_BUTTONS_TRANSLATION_X_DP, isRtl) * density;
// When the location bar is shown in the NTP, toolbar button animation is handled in final View menuButtonWrapper = getMenuButtonWrapper();
// #updateButtonsAlphaForNtp(). if (menuButtonWrapper != null) {
if (!isLocationBarShownInNTP()) { animator = ObjectAnimator.ofFloat(
final View menuButtonWrapper = getMenuButtonWrapper(); menuButtonWrapper, TRANSLATION_X, toolbarButtonTranslationX);
if (menuButtonWrapper != null) { animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
animator = ObjectAnimator.ofFloat( animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);
menuButtonWrapper, TRANSLATION_X, toolbarButtonTranslationX); animators.add(animator);
animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);
animators.add(animator);
animator = ObjectAnimator.ofFloat(menuButtonWrapper, ALPHA, 0); animator = ObjectAnimator.ofFloat(menuButtonWrapper, ALPHA, 0);
animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE); animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);
animators.add(animator); animators.add(animator);
} }
if (mToggleTabStackButton != null) { if (mToggleTabStackButton != null) {
animator = ObjectAnimator.ofFloat( animator = ObjectAnimator.ofFloat(
mToggleTabStackButton, TRANSLATION_X, toolbarButtonTranslationX); mToggleTabStackButton, TRANSLATION_X, toolbarButtonTranslationX);
animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE); animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);
animators.add(animator); animators.add(animator);
animator = ObjectAnimator.ofFloat(mToggleTabStackButton, ALPHA, 0); animator = ObjectAnimator.ofFloat(mToggleTabStackButton, ALPHA, 0);
animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE); animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);
animators.add(animator); animators.add(animator);
}
} }
if (mLocationBar.useModernDesign()) { if (mLocationBar.useModernDesign()) {
...@@ -2165,37 +2158,33 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -2165,37 +2158,33 @@ public class ToolbarPhone extends ToolbarLayout
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(animator); animators.add(animator);
// When the location bar is shown in the NTP, toolbar button animation is handled in
// #updateButtonsAlphaForNtp().
final View menuButtonWrapper = getMenuButtonWrapper(); final View menuButtonWrapper = getMenuButtonWrapper();
if (!isLocationBarShownInNTP()) { if (menuButtonWrapper != null) {
if (menuButtonWrapper != null) { animator = ObjectAnimator.ofFloat(menuButtonWrapper, TRANSLATION_X, 0);
animator = ObjectAnimator.ofFloat(menuButtonWrapper, TRANSLATION_X, 0); animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); animator.setStartDelay(URL_CLEAR_FOCUS_MENU_DELAY_MS);
animator.setStartDelay(URL_CLEAR_FOCUS_MENU_DELAY_MS); animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); animators.add(animator);
animators.add(animator);
animator = ObjectAnimator.ofFloat(menuButtonWrapper, ALPHA, 1); animator = ObjectAnimator.ofFloat(menuButtonWrapper, ALPHA, 1);
animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
animator.setStartDelay(URL_CLEAR_FOCUS_MENU_DELAY_MS); animator.setStartDelay(URL_CLEAR_FOCUS_MENU_DELAY_MS);
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(animator); animators.add(animator);
} }
if (mToggleTabStackButton != null) { if (mToggleTabStackButton != null) {
animator = ObjectAnimator.ofFloat(mToggleTabStackButton, TRANSLATION_X, 0); animator = ObjectAnimator.ofFloat(mToggleTabStackButton, TRANSLATION_X, 0);
animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
animator.setStartDelay(URL_CLEAR_FOCUS_TABSTACK_DELAY_MS); animator.setStartDelay(URL_CLEAR_FOCUS_TABSTACK_DELAY_MS);
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(animator); animators.add(animator);
animator = ObjectAnimator.ofFloat(mToggleTabStackButton, ALPHA, 1); animator = ObjectAnimator.ofFloat(mToggleTabStackButton, ALPHA, 1);
animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS); animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
animator.setStartDelay(URL_CLEAR_FOCUS_TABSTACK_DELAY_MS); animator.setStartDelay(URL_CLEAR_FOCUS_TABSTACK_DELAY_MS);
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(animator); animators.add(animator);
}
} }
for (int i = 0; i < mLocationBar.getChildCount(); i++) { for (int i = 0; i < mLocationBar.getChildCount(); i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment