Commit ffbe3d53 authored by bttk's avatar bttk Committed by Commit Bot

[ToolbarMVC] Rename identifiers with "percent" to "fraction"

Only changing files related to ToolbarLayout.

This correction came when moving
LocationBarPhone.setUrlFocusChangePercent to the LocationBar interface.
The move of the method will depend on this change.

Bug: 1133482
Change-Id: I222175e8c39b39a75d87a05a3993d6c3cdae1bfb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2439109
Auto-Submit: who/bttk <bttk@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarPatrick Noland <pnoland@chromium.org>
Commit-Queue: who/bttk <bttk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812906}
parent d55503d4
...@@ -140,14 +140,14 @@ public abstract class ToolbarLayout ...@@ -140,14 +140,14 @@ public abstract class ToolbarLayout
} }
/** /**
* @param urlExpansionObserver The observer that observes URL expansion percentage change. * @param urlExpansionObserver The observer that observes URL expansion progress change.
*/ */
void addUrlExpansionObserver(UrlExpansionObserver urlExpansionObserver) { void addUrlExpansionObserver(UrlExpansionObserver urlExpansionObserver) {
mUrlExpansionObservers.addObserver(urlExpansionObserver); mUrlExpansionObservers.addObserver(urlExpansionObserver);
} }
/** /**
* @param urlExpansionObserver The observer that observes URL expansion percentage change. * @param urlExpansionObserver The observer that observes URL expansion progress change.
*/ */
void removeUrlExpansionObserver(UrlExpansionObserver urlExpansionObserver) { void removeUrlExpansionObserver(UrlExpansionObserver urlExpansionObserver) {
mUrlExpansionObservers.removeObserver(urlExpansionObserver); mUrlExpansionObservers.removeObserver(urlExpansionObserver);
......
...@@ -108,7 +108,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -108,7 +108,7 @@ public class ToolbarPhone extends ToolbarLayout
private static final int EXPERIMENTAL_ICON_ANIMATION_DURATION_MS = 100; private static final int EXPERIMENTAL_ICON_ANIMATION_DURATION_MS = 100;
private static final int EXPERIMENTAL_ICON_ANIMATION_DELAY_MS = 125; private static final int EXPERIMENTAL_ICON_ANIMATION_DELAY_MS = 125;
private static final float UNINITIALIZED_PERCENT = -1f; private static final float UNINITIALIZED_FRACTION = -1f;
/** States that the toolbar can be in regarding the tab switcher. */ /** States that the toolbar can be in regarding the tab switcher. */
protected static final int STATIC_TAB = 0; protected static final int STATIC_TAB = 0;
...@@ -163,7 +163,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -163,7 +163,7 @@ public class ToolbarPhone extends ToolbarLayout
// mode. 0 = entirely in normal mode and 1.0 = entirely in TabSwitcher mode. In between values // mode. 0 = entirely in normal mode and 1.0 = entirely in TabSwitcher mode. In between values
// can be used for animating between the two view modes. // can be used for animating between the two view modes.
@ViewDebug.ExportedProperty(category = "chrome") @ViewDebug.ExportedProperty(category = "chrome")
protected float mTabSwitcherModePercent; protected float mTabSwitcherModeFraction;
// Used to clip the toolbar during the fade transition into and out of TabSwitcher mode. Only // Used to clip the toolbar during the fade transition into and out of TabSwitcher mode. Only
// used when |mAnimateNormalToolbar| is false. // used when |mAnimateNormalToolbar| is false.
...@@ -175,18 +175,18 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -175,18 +175,18 @@ public class ToolbarPhone extends ToolbarLayout
/** 1.0 is 100% focused, 0 is completely unfocused */ /** 1.0 is 100% focused, 0 is completely unfocused */
@ViewDebug.ExportedProperty(category = "chrome") @ViewDebug.ExportedProperty(category = "chrome")
private float mUrlFocusChangePercent; private float mUrlFocusChangeFraction;
/** /**
* The degree to which the omnibox has expanded to full width, either because it is getting * The degree to which the omnibox has expanded to full width, either because it is getting
* focused or the NTP search box is being scrolled up. Note that in the latter case, the actual * focused or the NTP search box is being scrolled up. Note that in the latter case, the actual
* width of the omnibox is not interpolated linearly from this value. The value will be the * width of the omnibox is not interpolated linearly from this value. The value will be the
* maximum of {@link #mUrlFocusChangePercent} and {@link #mNtpSearchBoxScrollPercent}. * maximum of {@link #mUrlFocusChangeFraction} and {@link #mNtpSearchBoxScrollFraction}.
* *
* 0.0 == no expansion, 1.0 == fully expanded. * 0.0 == no expansion, 1.0 == fully expanded.
*/ */
@ViewDebug.ExportedProperty(category = "chrome") @ViewDebug.ExportedProperty(category = "chrome")
protected float mUrlExpansionPercent; protected float mUrlExpansionFraction;
private AnimatorSet mUrlFocusLayoutAnimator; private AnimatorSet mUrlFocusLayoutAnimator;
protected boolean mDisableLocationBarRelayout; protected boolean mDisableLocationBarRelayout;
...@@ -198,7 +198,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -198,7 +198,7 @@ public class ToolbarPhone extends ToolbarLayout
private boolean mUnfocusedLocationBarUsesTransparentBg; private boolean mUnfocusedLocationBarUsesTransparentBg;
private int mLocationBarBackgroundAlpha = 255; private int mLocationBarBackgroundAlpha = 255;
private float mNtpSearchBoxScrollPercent = UNINITIALIZED_PERCENT; private float mNtpSearchBoxScrollFraction = UNINITIALIZED_FRACTION;
protected ColorDrawable mToolbarBackground; protected ColorDrawable mToolbarBackground;
/** The omnibox background (white with a shadow). */ /** The omnibox background (white with a shadow). */
...@@ -207,9 +207,6 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -207,9 +207,6 @@ public class ToolbarPhone extends ToolbarLayout
protected boolean mForceDrawLocationBarBackground; protected boolean mForceDrawLocationBarBackground;
private final int mLightModeDefaultColor;
private final int mDarkModeDefaultColor;
/** The boundaries of the omnibox, without the NTP-specific offset applied. */ /** The boundaries of the omnibox, without the NTP-specific offset applied. */
protected final Rect mLocationBarBackgroundBounds = new Rect(); protected final Rect mLocationBarBackgroundBounds = new Rect();
...@@ -268,13 +265,14 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -268,13 +265,14 @@ public class ToolbarPhone extends ToolbarLayout
private AnimatorSet mOptionalButtonAnimator; private AnimatorSet mOptionalButtonAnimator;
private boolean mOptionalButtonAnimationRunning; private boolean mOptionalButtonAnimationRunning;
private int mOptionalButtonTranslation; private int mOptionalButtonTranslation;
/** /**
* The percent completion for the location bar width change animation that is run when the * The progress fraction for the location bar width change animation that is run when the
* optional button is shown/hidden. Animates from 1.f to 0.f when showing the button and * optional button is shown/hidden. Animates from 1.f to 0.f when showing the button and
* 0.f to 1.f when hiding the button, where 0.f indicates the location bar width is not offset * 0.f to 1.f when hiding the button, where 0.f indicates the location bar width is not offset
* at all for the animation. * at all for the animation.
*/ */
private float mLocBarWidthChangePercent; private float mLocBarWidthChangeFraction;
/** /**
* A global layout listener used to capture a new texture when the experimental toolbar button * A global layout listener used to capture a new texture when the experimental toolbar button
...@@ -285,59 +283,56 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -285,59 +283,56 @@ public class ToolbarPhone extends ToolbarLayout
// The following are some properties used during animation. We use explicit property classes // The following are some properties used during animation. We use explicit property classes
// to avoid the cost of reflection for each animation setup. // to avoid the cost of reflection for each animation setup.
private final Property<ToolbarPhone, Float> mUrlFocusChangePercentProperty = private final Property<ToolbarPhone, Float> mUrlFocusChangeFractionProperty =
new Property<ToolbarPhone, Float>(Float.class, "") { new Property<ToolbarPhone, Float>(Float.class, "") {
@Override @Override
public Float get(ToolbarPhone object) { public Float get(ToolbarPhone object) {
return object.mUrlFocusChangePercent; return object.mUrlFocusChangeFraction;
} }
@Override @Override
public void set(ToolbarPhone object, Float value) { public void set(ToolbarPhone object, Float value) {
setUrlFocusChangePercent(value); setUrlFocusChangeFraction(value);
} }
}; };
private final Property<ToolbarPhone, Float> mTabSwitcherModePercentProperty = private final Property<ToolbarPhone, Float> mTabSwitcherModeFractionProperty =
new Property<ToolbarPhone, Float>(Float.class, "") { new Property<ToolbarPhone, Float>(Float.class, "") {
@Override @Override
public Float get(ToolbarPhone object) { public Float get(ToolbarPhone object) {
return object.mTabSwitcherModePercent; return object.mTabSwitcherModeFraction;
} }
@Override @Override
public void set(ToolbarPhone object, Float value) { public void set(ToolbarPhone object, Float value) {
object.mTabSwitcherModePercent = value; object.mTabSwitcherModeFraction = value;
triggerPaintInvalidate(ToolbarPhone.this::postInvalidateOnAnimation); triggerPaintInvalidate(ToolbarPhone.this::postInvalidateOnAnimation);
} }
}; };
private final Property<ToolbarPhone, Float> mLocBarWidthChangePercentProperty = private final Property<ToolbarPhone, Float> mLocBarWidthChangeFractionProperty =
new Property<ToolbarPhone, Float>(Float.class, "") { new Property<ToolbarPhone, Float>(Float.class, "") {
@Override @Override
public Float get(ToolbarPhone object) { public Float get(ToolbarPhone object) {
return object.mLocBarWidthChangePercent; return object.mLocBarWidthChangeFraction;
} }
@Override @Override
public void set(ToolbarPhone object, Float value) { public void set(ToolbarPhone object, Float value) {
mLocBarWidthChangePercent = value; mLocBarWidthChangeFraction = value;
updateLocationBarLayoutForExpansionAnimation(); updateLocationBarLayoutForExpansionAnimation();
} }
}; };
/** /**
* Constructs a ToolbarPhone object. * Constructs a ToolbarPhone object.
*
* @param context The Context in which this View object is created. * @param context The Context in which this View object is created.
* @param attrs The AttributeSet that was specified with this View. * @param attrs The AttributeSet that was specified with this View.
*/ */
public ToolbarPhone(Context context, AttributeSet attrs) { public ToolbarPhone(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
mToolbarSidePadding = getResources().getDimensionPixelOffset(R.dimen.toolbar_edge_padding); mToolbarSidePadding = getResources().getDimensionPixelOffset(R.dimen.toolbar_edge_padding);
mLightModeDefaultColor =
ToolbarColors.getThemedToolbarIconTint(getContext(), true).getDefaultColor();
mDarkModeDefaultColor =
ToolbarColors.getThemedToolbarIconTint(getContext(), false).getDefaultColor();
} }
@Override @Override
...@@ -490,8 +485,8 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -490,8 +485,8 @@ public class ToolbarPhone extends ToolbarLayout
// If the NTP is partially scrolled, prevent all touch events to the child views. This // If the NTP is partially scrolled, prevent all touch events to the child views. This
// is to not allow a secondary touch event to trigger entering the tab switcher, which // is to not allow a secondary touch event to trigger entering the tab switcher, which
// can lead to really odd snapshots and transitions to the switcher. // can lead to really odd snapshots and transitions to the switcher.
if (mNtpSearchBoxScrollPercent != 0f && mNtpSearchBoxScrollPercent != 1f if (mNtpSearchBoxScrollFraction != 0f && mNtpSearchBoxScrollFraction != 1f
&& mNtpSearchBoxScrollPercent != UNINITIALIZED_PERCENT) { && mNtpSearchBoxScrollFraction != UNINITIALIZED_FRACTION) {
return true; return true;
} }
...@@ -720,10 +715,10 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -720,10 +715,10 @@ public class ToolbarPhone extends ToolbarLayout
// bar is fully expanded), the background needs to change back to the default // bar is fully expanded), the background needs to change back to the default
// toolbar color so that the NTP content is not visible beneath the toolbar. In // toolbar color so that the NTP content is not visible beneath the toolbar. In
// between the transition, we set a translucent default toolbar color based on // between the transition, we set a translucent default toolbar color based on
// the expansion percentage of the toolbar. // the expansion progress of the toolbar.
return androidx.core.graphics.ColorUtils.setAlphaComponent( return androidx.core.graphics.ColorUtils.setAlphaComponent(
ChromeColors.getDefaultThemeColor(getResources(), false), ChromeColors.getDefaultThemeColor(getResources(), false),
Math.round(mUrlExpansionPercent * 255)); Math.round(mUrlExpansionFraction * 255));
case VisualState.NORMAL: case VisualState.NORMAL:
return ChromeColors.getDefaultThemeColor(getResources(), false); return ChromeColors.getDefaultThemeColor(getResources(), false);
case VisualState.INCOGNITO: case VisualState.INCOGNITO:
...@@ -760,7 +755,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -760,7 +755,7 @@ public class ToolbarPhone extends ToolbarLayout
// set the values before the draw happens. // set the values before the draw happens.
if (!mAnimateNormalToolbar) { if (!mAnimateNormalToolbar) {
drawTabSwitcherFadeAnimation( drawTabSwitcherFadeAnimation(
tabSwitcherAnimationFinished, mTabSwitcherModePercent); tabSwitcherAnimationFinished, mTabSwitcherModeFraction);
} }
} }
...@@ -770,7 +765,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -770,7 +765,7 @@ public class ToolbarPhone extends ToolbarLayout
// Perform the overlay logic after super.dispatchDraw(canvas) as we need to draw on // Perform the overlay logic after super.dispatchDraw(canvas) as we need to draw on
// top of the current views. // top of the current views.
if (mAnimateNormalToolbar) { if (mAnimateNormalToolbar) {
drawTabSwitcherAnimationOverlay(canvas, mTabSwitcherModePercent); drawTabSwitcherAnimationOverlay(canvas, mTabSwitcherModeFraction);
} }
// Clear the animation. // Clear the animation.
...@@ -786,9 +781,9 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -786,9 +781,9 @@ public class ToolbarPhone extends ToolbarLayout
// NewTabPage.OnSearchBoxScrollListener // NewTabPage.OnSearchBoxScrollListener
@Override @Override
public void onNtpScrollChanged(float scrollPercentage) { public void onNtpScrollChanged(float scrollFraction) {
mNtpSearchBoxScrollPercent = scrollPercentage; mNtpSearchBoxScrollFraction = scrollFraction;
updateUrlExpansionPercent(); updateUrlExpansionFraction();
updateUrlExpansionAnimation(); updateUrlExpansionAnimation();
} }
...@@ -805,7 +800,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -805,7 +800,7 @@ public class ToolbarPhone extends ToolbarLayout
private void updateLocationBarBackgroundBounds(Rect out, @VisualState int visualState) { private void updateLocationBarBackgroundBounds(Rect out, @VisualState int visualState) {
// Calculate the visible boundaries of the left and right most child views of the // Calculate the visible boundaries of the left and right most child views of the
// location bar. // location bar.
float expansion = getExpansionPercentForVisualState(visualState); float expansion = getExpansionFractionForVisualState(visualState);
int leftViewPosition = getLeftPositionOfLocationBarBackground(visualState); int leftViewPosition = getLeftPositionOfLocationBarBackground(visualState);
int rightViewPosition = getRightPositionOfLocationBarBackground(visualState); int rightViewPosition = getRightPositionOfLocationBarBackground(visualState);
...@@ -824,7 +819,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -824,7 +819,7 @@ public class ToolbarPhone extends ToolbarLayout
* @return The left drawing position for the location bar background. * @return The left drawing position for the location bar background.
*/ */
private int getLeftPositionOfLocationBarBackground(@VisualState int visualState) { private int getLeftPositionOfLocationBarBackground(@VisualState int visualState) {
float expansion = getExpansionPercentForVisualState(visualState); float expansion = getExpansionFractionForVisualState(visualState);
int leftViewPosition = int leftViewPosition =
(int) MathUtils.interpolate(getViewBoundsLeftOfLocationBar(visualState), (int) MathUtils.interpolate(getViewBoundsLeftOfLocationBar(visualState),
getFocusedLeftPositionOfLocationBarBackground(), expansion); getFocusedLeftPositionOfLocationBarBackground(), expansion);
...@@ -849,7 +844,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -849,7 +844,7 @@ public class ToolbarPhone extends ToolbarLayout
* @return The right drawing position for the location bar background. * @return The right drawing position for the location bar background.
*/ */
private int getRightPositionOfLocationBarBackground(@VisualState int visualState) { private int getRightPositionOfLocationBarBackground(@VisualState int visualState) {
float expansion = getExpansionPercentForVisualState(visualState); float expansion = getExpansionFractionForVisualState(visualState);
int rightViewPosition = int rightViewPosition =
(int) MathUtils.interpolate(getViewBoundsRightOfLocationBar(visualState), (int) MathUtils.interpolate(getViewBoundsRightOfLocationBar(visualState),
getFocusedRightPositionOfLocationBarBackground(), expansion); getFocusedRightPositionOfLocationBarBackground(), expansion);
...@@ -866,7 +861,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -866,7 +861,7 @@ public class ToolbarPhone extends ToolbarLayout
* show/hide animation is running. * show/hide animation is running.
*/ */
private int getLocationBarBackgroundOffsetForOptionalButton() { private int getLocationBarBackgroundOffsetForOptionalButton() {
return (int) (getLocationBarWidthOffsetForOptionalButton() * mLocBarWidthChangePercent); return (int) (getLocationBarWidthOffsetForOptionalButton() * mLocBarWidthChangeFraction);
} }
/** /**
...@@ -894,30 +889,31 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -894,30 +889,31 @@ public class ToolbarPhone extends ToolbarLayout
return getWidth() - mToolbarSidePadding; return getWidth() - mToolbarSidePadding;
} }
private float getExpansionPercentForVisualState(@VisualState int visualState) { private float getExpansionFractionForVisualState(@VisualState int visualState) {
return visualState == VisualState.NEW_TAB_NORMAL && mTabSwitcherState == STATIC_TAB return visualState == VisualState.NEW_TAB_NORMAL && mTabSwitcherState == STATIC_TAB
|| getToolbarDataProvider().isInOverviewAndShowingOmnibox() || getToolbarDataProvider().isInOverviewAndShowingOmnibox()
? 1 ? 1
: mUrlExpansionPercent; : mUrlExpansionFraction;
} }
/** /**
* Updates percentage of current the URL focus change animation. * Updates progress of current the URL focus change animation.
* @param percent 1.0 is 100% focused, 0 is completely unfocused. *
* @param fraction 1.0 is 100% focused, 0 is completely unfocused.
*/ */
private void setUrlFocusChangePercent(float percent) { private void setUrlFocusChangeFraction(float fraction) {
mUrlFocusChangePercent = percent; mUrlFocusChangeFraction = fraction;
updateUrlExpansionPercent(); updateUrlExpansionFraction();
updateUrlExpansionAnimation(); updateUrlExpansionAnimation();
} }
private void updateUrlExpansionPercent() { private void updateUrlExpansionFraction() {
mUrlExpansionPercent = Math.max(mNtpSearchBoxScrollPercent, mUrlFocusChangePercent); mUrlExpansionFraction = Math.max(mNtpSearchBoxScrollFraction, mUrlFocusChangeFraction);
for (UrlExpansionObserver observer : mUrlExpansionObservers) { for (UrlExpansionObserver observer : mUrlExpansionObservers) {
observer.onUrlExpansionPercentageChanged(mUrlExpansionPercent); observer.onUrlExpansionProgressChanged(mUrlExpansionFraction);
} }
assert mUrlExpansionPercent >= 0; assert mUrlExpansionFraction >= 0;
assert mUrlExpansionPercent <= 1; assert mUrlExpansionFraction <= 1;
} }
/** /**
...@@ -944,7 +940,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -944,7 +940,7 @@ public class ToolbarPhone extends ToolbarLayout
* @return The visibility for {@link #mToolbarButtonsContainer}. * @return The visibility for {@link #mToolbarButtonsContainer}.
*/ */
private int getToolbarButtonVisibility() { private int getToolbarButtonVisibility() {
return mUrlExpansionPercent == 1f ? INVISIBLE : VISIBLE; return mUrlExpansionFraction == 1f ? INVISIBLE : VISIBLE;
} }
/** /**
...@@ -992,8 +988,8 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -992,8 +988,8 @@ public class ToolbarPhone extends ToolbarLayout
} }
locationBarBaseTranslationX *= 1f locationBarBaseTranslationX *= 1f
- (mOptionalButtonAnimationRunning ? mLocBarWidthChangePercent - (mOptionalButtonAnimationRunning ? mLocBarWidthChangeFraction
: mUrlExpansionPercent); : mUrlExpansionFraction);
mLocationBarBackgroundNtpOffset.setEmpty(); mLocationBarBackgroundNtpOffset.setEmpty();
mLocationBarNtpOffsetLeft = 0; mLocationBarNtpOffsetLeft = 0;
...@@ -1003,7 +999,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1003,7 +999,7 @@ public class ToolbarPhone extends ToolbarLayout
if (currentTab != null) { if (currentTab != null) {
NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab(); NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab();
if (ntp != null) { if (ntp != null) {
ntp.setUrlFocusChangeAnimationPercent(mUrlFocusChangePercent); ntp.setUrlFocusChangeAnimationPercent(mUrlFocusChangeFraction);
} }
if (isLocationBarShownInNTP() if (isLocationBarShownInNTP()
...@@ -1030,7 +1026,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1030,7 +1026,7 @@ public class ToolbarPhone extends ToolbarLayout
// LocationBar#getUrlBarTranslationXForToolbarAnimation() for implementation details. // LocationBar#getUrlBarTranslationXForToolbarAnimation() for implementation details.
if (SearchEngineLogoUtils.shouldShowSearchEngineLogo(isIncognito)) { if (SearchEngineLogoUtils.shouldShowSearchEngineLogo(isIncognito)) {
mUrlBar.setTranslationX(mLocationBar.getUrlBarTranslationXForToolbarAnimation( mUrlBar.setTranslationX(mLocationBar.getUrlBarTranslationXForToolbarAnimation(
mUrlExpansionPercent, hasFocus())); mUrlExpansionFraction, hasFocus()));
} else if (SearchEngineLogoUtils.isSearchEngineLogoEnabled()) { } else if (SearchEngineLogoUtils.isSearchEngineLogoEnabled()) {
mUrlBar.setTranslationX(0); mUrlBar.setTranslationX(0);
} }
...@@ -1038,7 +1034,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1038,7 +1034,7 @@ public class ToolbarPhone extends ToolbarLayout
if (!mOptionalButtonAnimationRunning) { if (!mOptionalButtonAnimationRunning) {
mUrlActionContainer.setTranslationX(getUrlActionsTranslationXForExpansionAnimation( mUrlActionContainer.setTranslationX(getUrlActionsTranslationXForExpansionAnimation(
isLocationBarRtl, locationBarBaseTranslationX)); isLocationBarRtl, locationBarBaseTranslationX));
mLocationBar.setUrlFocusChangePercent(mUrlExpansionPercent); mLocationBar.setUrlFocusChangePercent(mUrlExpansionFraction);
// Only transition theme colors if in static tab mode that is not the NTP. In practice // Only transition theme colors if in static tab mode that is not the NTP. In practice
// this only runs when you focus the omnibox on a web page. // this only runs when you focus the omnibox on a web page.
...@@ -1049,10 +1045,10 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1049,10 +1045,10 @@ public class ToolbarPhone extends ToolbarLayout
int themedLocationBarColor = getLocationBarColorForToolbarColor(primaryColor); int themedLocationBarColor = getLocationBarColorForToolbarColor(primaryColor);
updateToolbarBackground(ColorUtils.getColorWithOverlay( updateToolbarBackground(ColorUtils.getColorWithOverlay(
primaryColor, defaultColor, mUrlFocusChangePercent)); primaryColor, defaultColor, mUrlFocusChangeFraction));
updateModernLocationBarColor(ColorUtils.getColorWithOverlay( updateModernLocationBarColor(ColorUtils.getColorWithOverlay(
themedLocationBarColor, defaultLocationBarColor, mUrlFocusChangePercent)); themedLocationBarColor, defaultLocationBarColor, mUrlFocusChangeFraction));
} }
} }
...@@ -1119,8 +1115,8 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1119,8 +1115,8 @@ public class ToolbarPhone extends ToolbarLayout
} }
setAncestorsShouldClipChildren(true); setAncestorsShouldClipChildren(true);
mNtpSearchBoxScrollPercent = UNINITIALIZED_PERCENT; mNtpSearchBoxScrollFraction = UNINITIALIZED_FRACTION;
updateUrlExpansionPercent(); updateUrlExpansionFraction();
} }
/** /**
...@@ -1131,11 +1127,11 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1131,11 +1127,11 @@ public class ToolbarPhone extends ToolbarLayout
// Skip if in or entering tab switcher mode. // Skip if in or entering tab switcher mode.
if (mTabSwitcherState == TAB_SWITCHER || mTabSwitcherState == ENTERING_TAB_SWITCHER) return; if (mTabSwitcherState == TAB_SWITCHER || mTabSwitcherState == ENTERING_TAB_SWITCHER) return;
boolean isExpanded = mUrlExpansionPercent > 0f; boolean isExpanded = mUrlExpansionFraction > 0f;
setAncestorsShouldClipChildren(!isExpanded); setAncestorsShouldClipChildren(!isExpanded);
if (!mUrlFocusChangeInProgress) { if (!mUrlFocusChangeInProgress) {
float alpha = 0.f; float alpha = 0.f;
if (!mUrlBar.hasFocus() && mNtpSearchBoxScrollPercent == 1.f) { if (!mUrlBar.hasFocus() && mNtpSearchBoxScrollFraction == 1.f) {
alpha = 1.f; alpha = 1.f;
} }
mToolbarShadow.setAlpha(alpha); mToolbarShadow.setAlpha(alpha);
...@@ -1154,13 +1150,13 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1154,13 +1150,13 @@ public class ToolbarPhone extends ToolbarLayout
// shrinking the omnibox down to the size of the search box. // shrinking the omnibox down to the size of the search box.
float shrinkage = 1f float shrinkage = 1f
- Interpolators.FAST_OUT_SLOW_IN_INTERPOLATOR.getInterpolation( - Interpolators.FAST_OUT_SLOW_IN_INTERPOLATOR.getInterpolation(
mUrlExpansionPercent); mUrlExpansionFraction);
int leftBoundDifference = mNtpSearchBoxBounds.left - mLocationBarBackgroundBounds.left; int leftBoundDifference = mNtpSearchBoxBounds.left - mLocationBarBackgroundBounds.left;
int rightBoundDifference = mNtpSearchBoxBounds.right - mLocationBarBackgroundBounds.right; int rightBoundDifference = mNtpSearchBoxBounds.right - mLocationBarBackgroundBounds.right;
int verticalInset = (int) (getResources().getDimensionPixelSize( int verticalInset = (int) (getResources().getDimensionPixelSize(
R.dimen.ntp_search_box_bounds_vertical_inset_modern) R.dimen.ntp_search_box_bounds_vertical_inset_modern)
* (1.f - mUrlExpansionPercent)); * (1.f - mUrlExpansionFraction));
mLocationBarBackgroundNtpOffset.set(Math.round(leftBoundDifference * shrinkage), mLocationBarBackgroundNtpOffset.set(Math.round(leftBoundDifference * shrinkage),
locationBarTranslationY, Math.round(rightBoundDifference * shrinkage), locationBarTranslationY, Math.round(rightBoundDifference * shrinkage),
locationBarTranslationY); locationBarTranslationY);
...@@ -1275,7 +1271,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1275,7 +1271,7 @@ public class ToolbarPhone extends ToolbarLayout
// Draw the tab stack button and associated text if necessary. // Draw the tab stack button and associated text if necessary.
if (mTabSwitcherAnimationTabStackDrawable != null && mToggleTabStackButton != null if (mTabSwitcherAnimationTabStackDrawable != null && mToggleTabStackButton != null
&& mUrlExpansionPercent != 1f) { && mUrlExpansionFraction != 1f) {
// Draw the tab stack button image. // Draw the tab stack button image.
canvas.save(); canvas.save();
translateCanvasToView(mToolbarButtonsContainer, mToggleTabStackButton, canvas); translateCanvasToView(mToolbarButtonsContainer, mToggleTabStackButton, canvas);
...@@ -1351,7 +1347,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1351,7 +1347,7 @@ public class ToolbarPhone extends ToolbarLayout
int translationY = (int) mLocationBar.getTranslationY(); int translationY = (int) mLocationBar.getTranslationY();
int clipTop = mLocationBarBackgroundBounds.top + translationY; int clipTop = mLocationBarBackgroundBounds.top + translationY;
if (mUrlExpansionPercent != 0f && clipTop < child.getBottom()) { if (mUrlExpansionFraction != 0f && clipTop < child.getBottom()) {
// For other child views, use the inverse clipping of the URL viewport. // For other child views, use the inverse clipping of the URL viewport.
// Only necessary during animations. // Only necessary during animations.
// Hardware mode does not support unioned clip regions, so clip using the // Hardware mode does not support unioned clip regions, so clip using the
...@@ -1429,24 +1425,25 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1429,24 +1425,25 @@ public class ToolbarPhone extends ToolbarLayout
// viewport used to draw the background. During expansion transitions, compensation // viewport used to draw the background. During expansion transitions, compensation
// is applied to increase the clip regions such that when the location bar converts // is applied to increase the clip regions such that when the location bar converts
// to the narrower collapsed layout the visible content is the same. // to the narrower collapsed layout the visible content is the same.
if (mUrlExpansionPercent != 1f && !mOptionalButtonAnimationRunning) { if (mUrlExpansionFraction != 1f && !mOptionalButtonAnimationRunning) {
int leftDelta = mUnfocusedLocationBarLayoutLeft int leftDelta = mUnfocusedLocationBarLayoutLeft
- getViewBoundsLeftOfLocationBar(mVisualState); - getViewBoundsLeftOfLocationBar(mVisualState);
int rightDelta = getViewBoundsRightOfLocationBar(mVisualState) int rightDelta = getViewBoundsRightOfLocationBar(mVisualState)
- mUnfocusedLocationBarLayoutLeft - mUnfocusedLocationBarLayoutWidth; - mUnfocusedLocationBarLayoutLeft - mUnfocusedLocationBarLayoutWidth;
float inversePercent = 1f - mUrlExpansionPercent; float remainingFraction = 1f - mUrlExpansionFraction;
locationBarClipLeft += leftDelta * inversePercent; locationBarClipLeft += leftDelta * remainingFraction;
locationBarClipRight -= rightDelta * inversePercent; locationBarClipRight -= rightDelta * remainingFraction;
// When the defocus animation is running, the location bar padding needs to be // When the defocus animation is running, the location bar padding needs to be
// subtracted from the clip bounds so that the location bar text width in the last // subtracted from the clip bounds so that the location bar text width in the last
// frame of the animation matches the text width of the unfocused location bar. // frame of the animation matches the text width of the unfocused location bar.
if (mLocationBar.getLayoutDirection() == LAYOUT_DIRECTION_RTL) { if (mLocationBar.getLayoutDirection() == LAYOUT_DIRECTION_RTL) {
locationBarClipLeft += locationBarClipLeft +=
ViewCompat.getPaddingStart(mLocationBar) * inversePercent; ViewCompat.getPaddingStart(mLocationBar) * remainingFraction;
} else { } else {
locationBarClipRight -= ViewCompat.getPaddingEnd(mLocationBar) * inversePercent; locationBarClipRight -=
ViewCompat.getPaddingEnd(mLocationBar) * remainingFraction;
} }
} }
if (mOptionalButtonAnimationRunning) { if (mOptionalButtonAnimationRunning) {
...@@ -1665,7 +1662,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1665,7 +1662,7 @@ public class ToolbarPhone extends ToolbarLayout
private ObjectAnimator createEnterTabSwitcherModeAnimation() { private ObjectAnimator createEnterTabSwitcherModeAnimation() {
ObjectAnimator enterAnimation = ObjectAnimator enterAnimation =
ObjectAnimator.ofFloat(this, mTabSwitcherModePercentProperty, 1.f); ObjectAnimator.ofFloat(this, mTabSwitcherModeFractionProperty, 1.f);
enterAnimation.setDuration( enterAnimation.setDuration(
TopToolbarCoordinator.TAB_SWITCHER_MODE_NORMAL_ANIMATION_DURATION_MS); TopToolbarCoordinator.TAB_SWITCHER_MODE_NORMAL_ANIMATION_DURATION_MS);
enterAnimation.setInterpolator(Interpolators.LINEAR_INTERPOLATOR); enterAnimation.setInterpolator(Interpolators.LINEAR_INTERPOLATOR);
...@@ -1675,7 +1672,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1675,7 +1672,7 @@ public class ToolbarPhone extends ToolbarLayout
private ObjectAnimator createExitTabSwitcherAnimation(final boolean animateNormalToolbar) { private ObjectAnimator createExitTabSwitcherAnimation(final boolean animateNormalToolbar) {
ObjectAnimator exitAnimation = ObjectAnimator exitAnimation =
ObjectAnimator.ofFloat(this, mTabSwitcherModePercentProperty, 0.f); ObjectAnimator.ofFloat(this, mTabSwitcherModeFractionProperty, 0.f);
exitAnimation.setDuration(animateNormalToolbar exitAnimation.setDuration(animateNormalToolbar
? TopToolbarCoordinator.TAB_SWITCHER_MODE_NORMAL_ANIMATION_DURATION_MS ? TopToolbarCoordinator.TAB_SWITCHER_MODE_NORMAL_ANIMATION_DURATION_MS
: TAB_SWITCHER_MODE_EXIT_FADE_ANIMATION_DURATION_MS); : TAB_SWITCHER_MODE_EXIT_FADE_ANIMATION_DURATION_MS);
...@@ -1748,7 +1745,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1748,7 +1745,7 @@ public class ToolbarPhone extends ToolbarLayout
private boolean hideShadowForRegularNtpTextureCapture() { private boolean hideShadowForRegularNtpTextureCapture() {
return !isIncognito() && NewTabPage.isNTPUrl(getToolbarDataProvider().getCurrentUrl()) return !isIncognito() && NewTabPage.isNTPUrl(getToolbarDataProvider().getCurrentUrl())
&& mNtpSearchBoxScrollPercent < 1.f; && mNtpSearchBoxScrollFraction < 1.f;
} }
// TODO(dtrainor): This is always true when in the tab switcher (crbug.com/710750). // TODO(dtrainor): This is always true when in the tab switcher (crbug.com/710750).
...@@ -1899,7 +1896,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1899,7 +1896,7 @@ public class ToolbarPhone extends ToolbarLayout
// crbug.com/974745. // crbug.com/974745.
requestLayout(); requestLayout();
mTabSwitcherModePercent = mTabSwitcherState != STATIC_TAB ? 1.0f : 0.0f; mTabSwitcherModeFraction = mTabSwitcherState != STATIC_TAB ? 1.0f : 0.0f;
if (!mAnimateNormalToolbar) { if (!mAnimateNormalToolbar) {
finishAnimations(); finishAnimations();
...@@ -1939,7 +1936,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1939,7 +1936,7 @@ public class ToolbarPhone extends ToolbarLayout
@Override @Override
public boolean shouldIgnoreSwipeGesture() { public boolean shouldIgnoreSwipeGesture() {
return super.shouldIgnoreSwipeGesture() || mUrlExpansionPercent > 0f return super.shouldIgnoreSwipeGesture() || mUrlExpansionFraction > 0f
|| mNtpSearchBoxTranslation.y < 0f; || mNtpSearchBoxTranslation.y < 0f;
} }
...@@ -1976,7 +1973,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1976,7 +1973,7 @@ public class ToolbarPhone extends ToolbarLayout
private void populateUrlFocusingAnimatorSet(List<Animator> animators) { private void populateUrlFocusingAnimatorSet(List<Animator> animators) {
TraceEvent.begin("ToolbarPhone.populateUrlFocusingAnimatorSet"); TraceEvent.begin("ToolbarPhone.populateUrlFocusingAnimatorSet");
Animator animator = ObjectAnimator.ofFloat(this, mUrlFocusChangePercentProperty, 1f); Animator animator = ObjectAnimator.ofFloat(this, mUrlFocusChangeFractionProperty, 1f);
animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS); animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(animator); animators.add(animator);
...@@ -2039,7 +2036,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -2039,7 +2036,7 @@ public class ToolbarPhone extends ToolbarLayout
} }
private void populateUrlClearFocusingAnimatorSet(List<Animator> animators) { private void populateUrlClearFocusingAnimatorSet(List<Animator> animators) {
Animator animator = ObjectAnimator.ofFloat(this, mUrlFocusChangePercentProperty, 0f); Animator animator = ObjectAnimator.ofFloat(this, mUrlFocusChangeFractionProperty, 0f);
animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS); animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(animator); animators.add(animator);
...@@ -2093,7 +2090,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -2093,7 +2090,7 @@ public class ToolbarPhone extends ToolbarLayout
mLocationBar.populateFadeAnimations( mLocationBar.populateFadeAnimations(
animators, URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS, URL_CLEAR_FOCUS_MENU_DELAY_MS, 1); animators, URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS, URL_CLEAR_FOCUS_MENU_DELAY_MS, 1);
if (isLocationBarShownInNTP() && mNtpSearchBoxScrollPercent == 0f) return; if (isLocationBarShownInNTP() && mNtpSearchBoxScrollFraction == 0f) return;
if (mToolbarShadow != null) { if (mToolbarShadow != null) {
animator = ObjectAnimator.ofFloat(mToolbarShadow, ALPHA, 1); animator = ObjectAnimator.ofFloat(mToolbarShadow, ALPHA, 1);
...@@ -2292,7 +2289,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -2292,7 +2289,7 @@ public class ToolbarPhone extends ToolbarLayout
private void updateNtpAnimationState() { private void updateNtpAnimationState() {
// Store previous NTP scroll before calling reset as that clears this value. // Store previous NTP scroll before calling reset as that clears this value.
boolean wasShowingNtp = mVisibleNewTabPage != null; boolean wasShowingNtp = mVisibleNewTabPage != null;
float previousNtpScrollPercent = mNtpSearchBoxScrollPercent; float previousNtpScrollFraction = mNtpSearchBoxScrollFraction;
resetNtpAnimationValues(); resetNtpAnimationValues();
if (mVisibleNewTabPage != null) { if (mVisibleNewTabPage != null) {
...@@ -2311,11 +2308,12 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -2311,11 +2308,12 @@ public class ToolbarPhone extends ToolbarLayout
requestLayout(); requestLayout();
} else if (wasShowingNtp) { } else if (wasShowingNtp) {
// Convert the previous NTP scroll percentage to URL focus percentage because that // Convert the previous NTP scroll progress to URL focus progress because that
// will give a nicer transition animation from the expanded NTP omnibox to the // will give a nicer transition animation from the expanded NTP omnibox to the
// collapsed normal omnibox on other non-NTP pages. // collapsed normal omnibox on other non-NTP pages.
if (mTabSwitcherState == STATIC_TAB && previousNtpScrollPercent > 0f) { if (mTabSwitcherState == STATIC_TAB && previousNtpScrollFraction > 0f) {
mUrlFocusChangePercent = Math.max(previousNtpScrollPercent, mUrlFocusChangePercent); mUrlFocusChangeFraction =
Math.max(previousNtpScrollFraction, mUrlFocusChangeFraction);
triggerUrlFocusAnimation(false); triggerUrlFocusAnimation(false);
} }
requestLayout(); requestLayout();
...@@ -2353,7 +2351,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -2353,7 +2351,7 @@ public class ToolbarPhone extends ToolbarLayout
private boolean isLocationBarCurrentlyShown() { private boolean isLocationBarCurrentlyShown() {
NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab(); NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab();
return ntp == null || !isLocationBarShownInNTP() || mUrlExpansionPercent > 0; return ntp == null || !isLocationBarShownInNTP() || mUrlExpansionFraction > 0;
} }
/** /**
...@@ -2607,9 +2605,9 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -2607,9 +2605,9 @@ public class ToolbarPhone extends ToolbarLayout
List<Animator> animators = new ArrayList<>(); List<Animator> animators = new ArrayList<>();
mLocBarWidthChangePercent = 1.f; mLocBarWidthChangeFraction = 1.f;
Animator widthChangeAnimator = Animator widthChangeAnimator =
ObjectAnimator.ofFloat(this, mLocBarWidthChangePercentProperty, 0.f); ObjectAnimator.ofFloat(this, mLocBarWidthChangeFractionProperty, 0.f);
widthChangeAnimator.setDuration(LOC_BAR_WIDTH_CHANGE_ANIMATION_DURATION_MS); widthChangeAnimator.setDuration(LOC_BAR_WIDTH_CHANGE_ANIMATION_DURATION_MS);
widthChangeAnimator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); widthChangeAnimator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(widthChangeAnimator); animators.add(widthChangeAnimator);
...@@ -2659,9 +2657,9 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -2659,9 +2657,9 @@ public class ToolbarPhone extends ToolbarLayout
if (mOptionalButtonAnimationRunning) mOptionalButtonAnimator.end(); if (mOptionalButtonAnimationRunning) mOptionalButtonAnimator.end();
List<Animator> animators = new ArrayList<>(); List<Animator> animators = new ArrayList<>();
mLocBarWidthChangePercent = 0.f; mLocBarWidthChangeFraction = 0.f;
Animator widthChangeAnimator = Animator widthChangeAnimator =
ObjectAnimator.ofFloat(this, mLocBarWidthChangePercentProperty, 1.f); ObjectAnimator.ofFloat(this, mLocBarWidthChangeFractionProperty, 1.f);
widthChangeAnimator.setDuration(LOC_BAR_WIDTH_CHANGE_ANIMATION_DURATION_MS); widthChangeAnimator.setDuration(LOC_BAR_WIDTH_CHANGE_ANIMATION_DURATION_MS);
widthChangeAnimator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); widthChangeAnimator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(widthChangeAnimator); animators.add(widthChangeAnimator);
......
...@@ -410,9 +410,9 @@ public class ToolbarTablet extends ToolbarLayout ...@@ -410,9 +410,9 @@ public class ToolbarTablet extends ToolbarLayout
if (mVisibleNtp != null) { if (mVisibleNtp != null) {
mVisibleNtp.setSearchBoxScrollListener(new NewTabPage.OnSearchBoxScrollListener() { mVisibleNtp.setSearchBoxScrollListener(new NewTabPage.OnSearchBoxScrollListener() {
@Override @Override
public void onNtpScrollChanged(float scrollPercentage) { public void onNtpScrollChanged(float scrollFraction) {
// Fade the search box out in the first 40% of the scrolling transition. // Fade the search box out in the first 40% of the scrolling transition.
float alpha = Math.max(1f - scrollPercentage * 2.5f, 0f); float alpha = Math.max(1f - scrollFraction * 2.5f, 0f);
mVisibleNtp.setSearchBoxAlpha(alpha); mVisibleNtp.setSearchBoxAlpha(alpha);
mVisibleNtp.setSearchProviderLogoAlpha(alpha); mVisibleNtp.setSearchProviderLogoAlpha(alpha);
} }
......
...@@ -44,16 +44,17 @@ import java.util.List; ...@@ -44,16 +44,17 @@ import java.util.List;
*/ */
public class TopToolbarCoordinator implements Toolbar { public class TopToolbarCoordinator implements Toolbar {
/** /**
* Observes toolbar URL expansion percentage change. * Observes toolbar URL expansion progress change.
*/ */
public interface UrlExpansionObserver { public interface UrlExpansionObserver {
/** /**
* Notified when toolbar URL expansion percentage changes. * Notified when toolbar URL expansion progress fraction changes.
* @param percentage The toolbar expansion percentage. 0 indicates that the URL bar is not *
* @param fraction The toolbar expansion progress. 0 indicates that the URL bar is not
* expanded. 1 indicates that the URL bar is expanded to the maximum * expanded. 1 indicates that the URL bar is expanded to the maximum
* width. * width.
*/ */
void onUrlExpansionPercentageChanged(float percentage); void onUrlExpansionProgressChanged(float fraction);
} }
public static final int TAB_SWITCHER_MODE_NORMAL_ANIMATION_DURATION_MS = 200; public static final int TAB_SWITCHER_MODE_NORMAL_ANIMATION_DURATION_MS = 200;
...@@ -201,14 +202,14 @@ public class TopToolbarCoordinator implements Toolbar { ...@@ -201,14 +202,14 @@ public class TopToolbarCoordinator implements Toolbar {
} }
/** /**
* @param urlExpansionObserver The observer that observes URL expansion percentage change. * @param urlExpansionObserver The observer that observes URL expansion progress change.
*/ */
public void addUrlExpansionObserver(UrlExpansionObserver urlExpansionObserver) { public void addUrlExpansionObserver(UrlExpansionObserver urlExpansionObserver) {
mToolbarLayout.addUrlExpansionObserver(urlExpansionObserver); mToolbarLayout.addUrlExpansionObserver(urlExpansionObserver);
} }
/** /**
* @param urlExpansionObserver The observer that observes URL expansion percentage change. * @param urlExpansionObserver The observer that observes URL expansion progress change.
*/ */
public void removeUrlExpansionObserver(UrlExpansionObserver urlExpansionObserver) { public void removeUrlExpansionObserver(UrlExpansionObserver urlExpansionObserver) {
mToolbarLayout.removeUrlExpansionObserver(urlExpansionObserver); mToolbarLayout.removeUrlExpansionObserver(urlExpansionObserver);
......
...@@ -227,8 +227,8 @@ public class StatusBarColorController ...@@ -227,8 +227,8 @@ public class StatusBarColorController
// TopToolbarCoordinator.UrlExpansionObserver implementation. // TopToolbarCoordinator.UrlExpansionObserver implementation.
@Override @Override
public void onUrlExpansionPercentageChanged(float percentage) { public void onUrlExpansionProgressChanged(float fraction) {
mToolbarUrlExpansionPercentage = percentage; mToolbarUrlExpansionPercentage = fraction;
if (mShouldUpdateStatusBarColorForNTP) updateStatusBarColor(); if (mShouldUpdateStatusBarColorForNTP) updateStatusBarColor();
} }
......
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