Commit eebaca54 authored by peconn's avatar peconn Committed by Commit bot

Translate ToolbarPhone buttons correctly in tab switcher.

The buttons in ToolbarPhone have their y translation modified to make it appear
like they are scrolling with the new tab page. This change fixes the calculation
to cancel this translation while in tab switcher mode.

In addition, this fixes a regression where the buttons would pop in after
defocusing the omnibox instead of sliding in from the side.

BUG=628597

Review-Url: https://codereview.chromium.org/2275073002
Cr-Commit-Position: refs/heads/master@{#414498}
parent 0f77323c
...@@ -926,9 +926,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -926,9 +926,7 @@ public class ToolbarPhone extends ToolbarLayout
int locationBarTranslationY = int locationBarTranslationY =
Math.max(0, (mNtpSearchBoxBounds.top - mLocationBar.getTop())); Math.max(0, (mNtpSearchBoxBounds.top - mLocationBar.getTop()));
mLocationBar.setTranslationY(locationBarTranslationY); mLocationBar.setTranslationY(locationBarTranslationY);
if (!mUrlFocusChangeInProgress) { updateButtonsTranslationY();
setButtonsTranslationY();
}
// 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
...@@ -972,11 +970,16 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -972,11 +970,16 @@ public class ToolbarPhone extends ToolbarLayout
} }
} }
private void setButtonsTranslationY() { /**
int searchBoxTranslationY = Math.min(mNtpSearchBoxTranslation.y, 0); * Update the y translation of the buttons to make it appear as if they were scrolling with
mToolbarButtonsContainer.setTranslationY(searchBoxTranslationY); * the new tab page.
mReturnButton.setTranslationY(searchBoxTranslationY); */
mHomeButton.setTranslationY(searchBoxTranslationY); private void updateButtonsTranslationY() {
int transY = mTabSwitcherState == STATIC_TAB ? Math.min(mNtpSearchBoxTranslation.y, 0) : 0;
mToolbarButtonsContainer.setTranslationY(transY);
mReturnButton.setTranslationY(transY);
mHomeButton.setTranslationY(transY);
} }
private void setAncestorsShouldClipChildren(boolean clip) { private void setAncestorsShouldClipChildren(boolean clip) {
...@@ -1533,6 +1536,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1533,6 +1536,7 @@ public class ToolbarPhone extends ToolbarLayout
} }
} }
updateButtonsTranslationY();
mAnimateNormalToolbar = showToolbar; mAnimateNormalToolbar = showToolbar;
if (mTabSwitcherModeAnimation != null) mTabSwitcherModeAnimation.start(); if (mTabSwitcherModeAnimation != null) mTabSwitcherModeAnimation.start();
...@@ -1770,16 +1774,6 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1770,16 +1774,6 @@ public class ToolbarPhone extends ToolbarLayout
return; return;
} }
// https://crbug.com/623885: The mToolbarButtonsContainer has its translationY modified
// during scroll so when the user scrolls on the NTP, it appears to scroll too. However
// during the URL focus and defocus animations it should not be touched. Unfortunately
// updateNtpTransitionAnimation() is called a few times after the URL focus animation has
// been completed while mUrlFocusChangeInProgress is set to false, causing translationY to
// incorrect at the end.
// We reset the translationY here so the mToolbarButtonsContainer is on screen for the
// defocusing animation.
setButtonsTranslationY();
triggerUrlFocusAnimation(hasFocus); triggerUrlFocusAnimation(hasFocus);
TransitionDrawable shadowDrawable = (TransitionDrawable) mToolbarShadow.getDrawable(); TransitionDrawable shadowDrawable = (TransitionDrawable) mToolbarShadow.getDrawable();
......
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