Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(819)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarPhone.java

Issue 2198993002: Revert of Use only toolbar to transition from fakebox to real omnibox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarPhone.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarPhone.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarPhone.java
index 3580d89175257cf9d85e861c5224de07e43a97eb..c4ce6e7f8201c7be0af11bf5b790e7430eaa2c03 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarPhone.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarPhone.java
@@ -25,7 +25,6 @@
import android.graphics.drawable.TransitionDrawable;
import android.os.Build;
import android.os.SystemClock;
-import android.support.v4.view.animation.FastOutSlowInInterpolator;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Property;
@@ -37,7 +36,6 @@
import android.view.ViewDebug;
import android.view.ViewGroup;
import android.view.WindowManager;
-import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
@@ -94,12 +92,11 @@
private static final float UNINITIALIZED_PERCENT = -1f;
+ private static final String TAG = "ToolbarPhone";
+
static final int LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA = 51;
- private static final Interpolator NTP_SEARCH_BOX_EXPANSION_INTERPOLATOR =
- new FastOutSlowInInterpolator();
-
- private LocationBarPhone mLocationBar;
+ private LocationBarPhone mPhoneLocationBar;
private ViewGroup mToolbarButtonsContainer;
private ImageView mToggleTabStackButton;
@@ -107,7 +104,7 @@
private TintedImageButton mReturnButton;
private TintedImageButton mHomeButton;
private TextView mUrlBar;
- private View mUrlActionContainer;
+ private View mUrlActionsContainer;
private ImageView mToolbarShadow;
private final int mProgressBackBackgroundColorWhite;
@@ -177,13 +174,12 @@
private int mUnfocusedLocationBarLayoutLeft;
private boolean mUnfocusedLocationBarUsesTransparentBg;
- private int mLocationBarBackgroundAlpha = 255;
+ private int mUrlBackgroundAlpha = 255;
private float mNtpSearchBoxScrollPercent = UNINITIALIZED_PERCENT;
private ColorDrawable mToolbarBackground;
- /** The omnibox background (white with a shadow). */
+ // The omnibox background (white with a shadow).
private Drawable mLocationBarBackground;
-
private boolean mForceDrawLocationBarBackground;
private TabSwitcherDrawable mTabSwitcherButtonDrawable;
private TabSwitcherDrawable mTabSwitcherButtonDrawableLight;
@@ -191,30 +187,16 @@
private final int mLightModeDefaultColor;
private final int mDarkModeDefaultColor;
- /** The boundaries of the omnibox, without the NTP-specific offset applied. */
- private final Rect mLocationBarBackgroundBounds = new Rect();
-
- private final Rect mLocationBarBackgroundPadding = new Rect();
+ private final Rect mUrlViewportBounds = new Rect();
+ private final Rect mUrlBackgroundPadding = new Rect();
private final Rect mBackgroundOverlayBounds = new Rect();
-
- /** Offset applied to the bounds of the omnibox if we are showing a New Tab Page. */
- private final Rect mLocationBarBackgroundNtpOffset = new Rect();
-
- /**
- * Offsets applied to the <i>contents</i> of the omnibox if we are showing a New Tab Page.
- * This can be different from {@link #mLocationBarBackgroundNtpOffset} due to the fact that we
- * extend the omnibox horizontally beyond the screen boundaries when focused, to hide its
- * rounded corners.
- */
- private float mLocationBarNtpOffsetLeft;
- private float mLocationBarNtpOffsetRight;
-
- private final Rect mNtpSearchBoxBounds = new Rect();
- private final Point mNtpSearchBoxTranslation = new Point();
-
+ private final Rect mLocationBarBackgroundOffset = new Rect();
+
+ private final Rect mNtpSearchBoxOriginalBounds = new Rect();
+ private final Rect mNtpSearchBoxTransformedBounds = new Rect();
+
+ private final int mLocationBarInsets;
private final int mToolbarSidePadding;
- private final int mLocationBarVerticalMargin;
- private final int mLocationBarBackgroundCornerRadius;
private ValueAnimator mBrandColorTransitionAnimation;
private boolean mBrandColorTransitionActive;
@@ -295,10 +277,9 @@
super(context, attrs);
mToolbarSidePadding = getResources().getDimensionPixelOffset(
R.dimen.toolbar_edge_padding);
- mLocationBarVerticalMargin =
- getResources().getDimensionPixelOffset(R.dimen.location_bar_vertical_margin);
- mLocationBarBackgroundCornerRadius =
- getResources().getDimensionPixelOffset(R.dimen.location_bar_corner_radius);
+ // Insets used for the PhoneLocatioBar background drawable.
+ mLocationBarInsets = getResources().getDimensionPixelSize(R.dimen.location_bar_margin_top)
+ + getResources().getDimensionPixelSize(R.dimen.location_bar_margin_bottom);
mProgressBackBackgroundColorWhite = ApiCompatibilityUtils.getColor(getResources(),
R.color.progress_bar_background_white);
mLightModeDefaultColor =
@@ -310,7 +291,7 @@
@Override
public void onFinishInflate() {
super.onFinishInflate();
- mLocationBar = (LocationBarPhone) findViewById(R.id.location_bar);
+ mPhoneLocationBar = (LocationBarPhone) findViewById(R.id.location_bar);
mToolbarButtonsContainer = (ViewGroup) findViewById(R.id.toolbar_buttons);
@@ -319,20 +300,20 @@
mUrlBar = (TextView) findViewById(R.id.url_bar);
- mUrlActionContainer = findViewById(R.id.url_action_container);
-
- mBrowsingModeViews.add(mLocationBar);
+ mUrlActionsContainer = findViewById(R.id.url_action_container);
+
+ mBrowsingModeViews.add(mPhoneLocationBar);
mToolbarBackground = new ColorDrawable(getToolbarColorForVisualState(VisualState.NORMAL));
mTabSwitcherAnimationBgOverlay =
new ColorDrawable(getToolbarColorForVisualState(VisualState.NORMAL));
mLocationBarBackground =
- ApiCompatibilityUtils.getDrawable(getResources(), R.drawable.textbox);
- mLocationBarBackground.getPadding(mLocationBarBackgroundPadding);
- mLocationBar.setPadding(
- mLocationBarBackgroundPadding.left, mLocationBarBackgroundPadding.top,
- mLocationBarBackgroundPadding.right, mLocationBarBackgroundPadding.bottom);
+ ApiCompatibilityUtils.getDrawable(getResources(), R.drawable.inset_textbox);
+ mLocationBarBackground.getPadding(mUrlBackgroundPadding);
+ mPhoneLocationBar.setPadding(
+ mUrlBackgroundPadding.left, mUrlBackgroundPadding.top,
+ mUrlBackgroundPadding.right, mUrlBackgroundPadding.bottom);
setLayoutTransition(null);
@@ -459,7 +440,7 @@
});
onHomeButtonUpdate(HomepageManager.isHomepageEnabled(getContext()));
- updateVisualsForToolbarState();
+ updateVisualsForToolbarState(mIsInTabSwitcherMode);
}
@Override
@@ -529,8 +510,8 @@
private void updateUnfocusedLocationBarLayoutParams() {
boolean hasVisibleViewPriorToUrlBar = false;
- for (int i = 0; i < mLocationBar.getChildCount(); i++) {
- View child = mLocationBar.getChildAt(i);
+ for (int i = 0; i < mPhoneLocationBar.getChildCount(); i++) {
+ View child = mPhoneLocationBar.getChildAt(i);
if (child == mUrlBar) break;
if (child.getVisibility() != GONE) {
hasVisibleViewPriorToUrlBar = true;
@@ -539,21 +520,14 @@
}
int leftViewBounds = getViewBoundsLeftOfLocationBar(mVisualState);
+ if (!hasVisibleViewPriorToUrlBar) leftViewBounds += mToolbarSidePadding;
int rightViewBounds = getViewBoundsRightOfLocationBar(mVisualState);
- if (!hasVisibleViewPriorToUrlBar) {
- if (ApiCompatibilityUtils.isLayoutRtl(mLocationBar)) {
- rightViewBounds -= mToolbarSidePadding;
- } else {
- leftViewBounds += mToolbarSidePadding;
- }
- }
-
- if (!mLocationBar.hasVisibleViewsAfterUrlBarWhenUnfocused()) {
+ if (!mPhoneLocationBar.hasVisibleViewsAfterUrlBarWhenUnfocused()) {
// Add spacing between the end of the URL and the edge of the omnibox drawable.
// This only applies if there is no end aligned view that should be visible
// while the omnibox is unfocused.
- if (ApiCompatibilityUtils.isLayoutRtl(mLocationBar)) {
+ if (ApiCompatibilityUtils.isLayoutRtl(mPhoneLocationBar)) {
leftViewBounds += mToolbarSidePadding;
} else {
rightViewBounds -= mToolbarSidePadding;
@@ -600,15 +574,15 @@
if (mLayoutLocationBarInFocusedMode || mVisualState == VisualState.NEW_TAB_NORMAL) {
int priorVisibleWidth = 0;
- for (int i = 0; i < mLocationBar.getChildCount(); i++) {
- View child = mLocationBar.getChildAt(i);
- if (child == mLocationBar.getFirstViewVisibleWhenFocused()) break;
+ for (int i = 0; i < mPhoneLocationBar.getChildCount(); i++) {
+ View child = mPhoneLocationBar.getChildAt(i);
+ if (child == mPhoneLocationBar.getFirstViewVisibleWhenFocused()) break;
if (child.getVisibility() == GONE) continue;
priorVisibleWidth += child.getMeasuredWidth();
}
width = containerWidth - (2 * mToolbarSidePadding) + priorVisibleWidth;
- if (ApiCompatibilityUtils.isLayoutRtl(mLocationBar)) {
+ if (ApiCompatibilityUtils.isLayoutRtl(mPhoneLocationBar)) {
leftMargin = mToolbarSidePadding;
} else {
leftMargin = -priorVisibleWidth + mToolbarSidePadding;
@@ -703,8 +677,8 @@
}
if (mLocationBarBackground != null
- && (mLocationBar.getVisibility() == VISIBLE || mTextureCaptureMode)) {
- updateLocationBarBackgroundBounds(mLocationBarBackgroundBounds, mVisualState);
+ && (mPhoneLocationBar.getVisibility() == VISIBLE || mTextureCaptureMode)) {
+ updateUrlViewportBounds(mUrlViewportBounds, mVisualState, false);
}
if (mTextureCaptureMode) {
@@ -758,20 +732,18 @@
}
/**
- * Calculate the bounds for the location bar background and set them to {@code out}.
+ * Calculate the bounds for UrlViewport and set them to out rect.
*/
- private void updateLocationBarBackgroundBounds(Rect out, VisualState visualState) {
- // Calculate the visible boundaries of the left and right most child views of the
- // location bar.
- float expansion = visualState == VisualState.NEW_TAB_NORMAL ? 1 : mUrlExpansionPercent;
+ private void updateUrlViewportBounds(Rect out, VisualState visualState,
+ boolean ignoreTranslationY) {
+ // Calculate the visible boundaries of the left and right most child views
+ // of the location bar.
int leftViewPosition = (int) MathUtils.interpolate(
- getViewBoundsLeftOfLocationBar(visualState),
- -mLocationBarBackgroundCornerRadius,
- expansion);
+ getViewBoundsLeftOfLocationBar(visualState), 0f, mUrlExpansionPercent)
+ - mUrlBackgroundPadding.left;
int rightViewPosition = (int) MathUtils.interpolate(
- getViewBoundsRightOfLocationBar(visualState),
- getWidth() + mLocationBarBackgroundCornerRadius,
- expansion);
+ getViewBoundsRightOfLocationBar(visualState), getWidth(), mUrlExpansionPercent)
+ + mUrlBackgroundPadding.right;
// The bounds are set by the following:
// - The left most visible location bar child view.
@@ -779,11 +751,13 @@
// - The right most visible location bar child view.
// - The bottom of the viewport is aligned with the bottom of the location bar.
// Additional padding can be applied for use during animations.
- int verticalMargin = (int) MathUtils.interpolate(mLocationBarVerticalMargin, 0, expansion);
+ float yOffset = ignoreTranslationY ? mPhoneLocationBar.getTop() : mPhoneLocationBar.getY();
+
out.set(leftViewPosition,
- mLocationBar.getTop() + verticalMargin,
+ (int) (yOffset - (mUrlBackgroundPadding.top * mUrlExpansionPercent)),
rightViewPosition,
- mLocationBar.getBottom() - verticalMargin);
+ (int) (yOffset + MathUtils.interpolate(mPhoneLocationBar.getMeasuredHeight(),
+ getHeight() + mUrlBackgroundPadding.bottom, mUrlExpansionPercent)));
}
/**
@@ -802,78 +776,36 @@
assert mUrlExpansionPercent <= 1;
}
- /**
- * Updates the parameters relating to expanding the location bar, as the result of either a
- * focus change or scrolling the New Tab Page.
- */
private void updateUrlExpansionAnimation() {
if (mIsInTabSwitcherMode || isTabSwitcherAnimationRunning()) {
mToolbarButtonsContainer.setVisibility(VISIBLE);
return;
}
- FrameLayout.LayoutParams locationBarLayoutParams = getFrameLayoutParams(mLocationBar);
+ mLocationBarBackgroundOffset.setEmpty();
+
+ FrameLayout.LayoutParams locationBarLayoutParams =
+ getFrameLayoutParams(mPhoneLocationBar);
int currentLeftMargin = locationBarLayoutParams.leftMargin;
int currentWidth = locationBarLayoutParams.width;
- float locationBarBaseTranslationX = mUnfocusedLocationBarLayoutLeft - currentLeftMargin;
- boolean isLocationBarRtl = ApiCompatibilityUtils.isLayoutRtl(mLocationBar);
+ float inversePercent = 1f - mUrlExpansionPercent;
+ float locationBarTranslationX = mUnfocusedLocationBarLayoutLeft - currentLeftMargin;
+ boolean isLocationBarRtl = ApiCompatibilityUtils.isLayoutRtl(mPhoneLocationBar);
if (isLocationBarRtl) {
- locationBarBaseTranslationX += mUnfocusedLocationBarLayoutWidth - currentWidth;
- }
- locationBarBaseTranslationX *= 1f - mUrlExpansionPercent;
-
- mLocationBarBackgroundNtpOffset.setEmpty();
- mLocationBarNtpOffsetLeft = 0;
- mLocationBarNtpOffsetRight = 0;
-
- Tab currentTab = getToolbarDataProvider().getTab();
- if (currentTab != null) {
- NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab();
- // Explicitly use the focus change percentage here because it applies scroll
- // compensation that only applies during focus animations.
- if (ntp != null && mUrlFocusChangeInProgress) {
- ntp.setUrlFocusChangeAnimationPercent(mUrlFocusChangePercent);
- }
-
- if (isLocationBarShownInNTP()) {
- updateNtpTransitionAnimation();
- } else {
- // Reset these values in case we transitioned to a different page during the
- // transition.
- resetNtpAnimationValues();
- }
- }
-
- boolean isRtl = ApiCompatibilityUtils.isLayoutRtl(this);
-
- float locationBarTranslationX;
- // Get the padding straight from the location bar instead of
- // |mLocationBarBackgroundPadding|, because it might be different in incognito mode.
- if (isRtl) {
- locationBarTranslationX = locationBarBaseTranslationX
- + mLocationBarNtpOffsetRight - mLocationBar.getPaddingRight();
- } else {
- locationBarTranslationX = locationBarBaseTranslationX
- + mLocationBarNtpOffsetLeft + mLocationBar.getPaddingLeft();
- }
- mLocationBar.setTranslationX(locationBarTranslationX);
+ locationBarTranslationX += mUnfocusedLocationBarLayoutWidth - currentWidth;
+ }
+ locationBarTranslationX *= inversePercent;
+
+ mPhoneLocationBar.setTranslationX(locationBarTranslationX);
// Negate the location bar translation to keep the URL action container in the same
// place during the focus expansion.
- float urlActionsTranslationX = 0;
- if (!isLocationBarRtl || isRtl) {
- urlActionsTranslationX = -locationBarBaseTranslationX;
- }
-
- if (isRtl) {
- urlActionsTranslationX += mLocationBarNtpOffsetLeft - mLocationBarNtpOffsetRight;
- } else {
- urlActionsTranslationX += mLocationBarNtpOffsetRight - mLocationBarNtpOffsetLeft;
- }
- mUrlActionContainer.setTranslationX(urlActionsTranslationX);
-
- mLocationBar.setUrlFocusChangePercent(mUrlExpansionPercent);
+ if (!isLocationBarRtl || ApiCompatibilityUtils.isLayoutRtl(this)) {
+ mUrlActionsContainer.setTranslationX(-locationBarTranslationX);
+ }
+
+ mPhoneLocationBar.setUrlFocusChangePercent(mUrlExpansionPercent);
// Ensure the buttons are invisible after focusing the omnibox to prevent them from
// accepting click events.
@@ -888,99 +820,113 @@
// Force an invalidation of the location bar to properly handle the clipping of the URL
// bar text as a result of the url action container translations.
- mLocationBar.invalidate();
+ mPhoneLocationBar.invalidate();
invalidate();
- }
-
- /**
- * Reset the parameters for the New Tab Page transition animation (expanding the location bar as
- * a result of scrolling the New Tab Page) to their default values.
- */
+
+ Tab currentTab = getToolbarDataProvider().getTab();
+ if (currentTab == null) return;
+
+ NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab();
+ // Explicitly use the focus change percentage here because it applies scroll compensation
+ // that only applies during focus animations.
+ if (ntp != null && mUrlFocusChangeInProgress) {
+ ntp.setUrlFocusChangeAnimationPercent(mUrlFocusChangePercent);
+ }
+
+ if (!isLocationBarShownInNTP()) {
+ // Reset these values in case we transitioned to a different page during the
+ // transition.
+ resetNtpAnimationValues();
+ return;
+ }
+
+ updateNtpTransitionAnimation();
+ }
+
private void resetNtpAnimationValues() {
- mLocationBarBackgroundNtpOffset.setEmpty();
- mLocationBar.setTranslationY(0);
+ mLocationBarBackgroundOffset.setEmpty();
+ mPhoneLocationBar.setTranslationY(0);
if (!mUrlFocusChangeInProgress) {
mToolbarButtonsContainer.setTranslationY(0);
mReturnButton.setTranslationY(0);
mHomeButton.setTranslationY(0);
}
mToolbarShadow.setAlpha(1f);
- mLocationBar.setAlpha(1);
+ mPhoneLocationBar.setAlpha(1);
mForceDrawLocationBarBackground = false;
- mLocationBarBackgroundAlpha = 255;
- if (isIncognito()
- || (mUnfocusedLocationBarUsesTransparentBg && !mUrlFocusChangeInProgress
- && !mLocationBar.hasFocus())) {
- mLocationBarBackgroundAlpha = LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA;
- }
+ mUrlBackgroundAlpha = isIncognito()
+ || (mUnfocusedLocationBarUsesTransparentBg
+ && !mUrlFocusChangeInProgress
+ && !mPhoneLocationBar.hasFocus())
+ ? LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA : 255;
setAncestorsShouldClipChildren(true);
mNtpSearchBoxScrollPercent = UNINITIALIZED_PERCENT;
updateUrlExpansionPercent();
}
- /**
- * Updates the parameters of the New Tab Page transition animation (expanding the location bar
- * as a result of scrolling the New Tab Page).
- */
private void updateNtpTransitionAnimation() {
if (mIsInTabSwitcherMode) return;
+ NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab();
+
setAncestorsShouldClipChildren(mUrlExpansionPercent == 0f);
mToolbarShadow.setAlpha(0f);
- NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab();
- ntp.getSearchBoxBounds(mNtpSearchBoxBounds, mNtpSearchBoxTranslation);
- int locationBarTranslationY =
- Math.max(0, (mNtpSearchBoxBounds.top - mLocationBar.getTop()));
- mLocationBar.setTranslationY(locationBarTranslationY);
+ float growthPercent = 0f;
+ if (ntp.isCardsUiEnabled() || mUrlExpansionPercent == 0f || mUrlExpansionPercent == 1f) {
+ growthPercent = 1f - mUrlExpansionPercent;
+ } else {
+ // During the transition from search box to omnibox, keep the omnibox drawing
+ // at the same size of the search box for first 40% of the scroll transition.
+ growthPercent = mUrlExpansionPercent <= 0.4f
+ ? 1f : Math.min(1f, (1f - mUrlExpansionPercent) * 1.66667f);
+ }
+
+ int paddingTop = mPhoneLocationBar.getPaddingTop();
+ int paddingBottom = mPhoneLocationBar.getPaddingBottom();
+
+ ntp.getSearchBoxBounds(mNtpSearchBoxOriginalBounds, mNtpSearchBoxTransformedBounds);
+ float halfHeightDifference = (mNtpSearchBoxTransformedBounds.height()
+ - (mPhoneLocationBar.getMeasuredHeight() - paddingTop - paddingBottom
+ + mLocationBarInsets)) / 2f;
+ mPhoneLocationBar.setTranslationY(growthPercent == 0f ? 0 : Math.max(0,
+ (mNtpSearchBoxTransformedBounds.top - mPhoneLocationBar.getTop()
+ + halfHeightDifference)));
if (!mUrlFocusChangeInProgress) {
setButtonsTranslationY();
}
- // 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
- // shrinking the omnibox down to the size of the search box.
- float shrinkage;
- if (ntp.isCardsUiEnabled()) {
- shrinkage = 1f
- - NTP_SEARCH_BOX_EXPANSION_INTERPOLATOR.getInterpolation(mUrlExpansionPercent);
+ mLocationBarBackgroundOffset.set(
+ (int) ((mNtpSearchBoxTransformedBounds.left - mUrlViewportBounds.left
+ - mPhoneLocationBar.getPaddingLeft()) * growthPercent),
+ (int) ((-halfHeightDifference - paddingTop) * growthPercent),
+ (int) ((mNtpSearchBoxTransformedBounds.right - mUrlViewportBounds.right
+ + mPhoneLocationBar.getPaddingRight()) * growthPercent),
+ (int) ((halfHeightDifference - paddingBottom + mLocationBarInsets)
+ * growthPercent));
+
+ // The transparency of the location bar is dependent on how different its size is
+ // from the final value. This is based on how much growth is applied between the
+ // desired size of the location bar to its drawn size. The location bar then only
+ // starts becoming opaque once the growth is at least half done.
+ if (growthPercent >= 0.5f) {
+ mPhoneLocationBar.setAlpha(0);
} else {
- // During the transition from middle of the NTP to the top, keep the omnibox drawing
- // at the same size of the search box for first 40% of the scroll transition.
- shrinkage = Math.min(1f, (1f - mUrlExpansionPercent) * 1.66667f);
- }
-
- int leftBoundDifference = mNtpSearchBoxBounds.left - mLocationBarBackgroundBounds.left;
- int rightBoundDifference = mNtpSearchBoxBounds.right - mLocationBarBackgroundBounds.right;
- mLocationBarBackgroundNtpOffset.set(
- (int) Math.round(leftBoundDifference * shrinkage),
- locationBarTranslationY,
- (int) Math.round(rightBoundDifference * shrinkage),
- locationBarTranslationY);
-
- // The omnibox background bounds are outset by |mLocationBarBackgroundCornerRadius| in the
- // fully expanded state (and only there!) to hide the rounded corners, so undo that before
- // applying the shrinkage factor.
- mLocationBarNtpOffsetLeft =
- (leftBoundDifference - mLocationBarBackgroundCornerRadius) * shrinkage;
- mLocationBarNtpOffsetRight =
- (rightBoundDifference + mLocationBarBackgroundCornerRadius) * shrinkage;
-
- mLocationBarBackgroundAlpha = mUrlExpansionPercent > 0f ? 255 : 0;
- mForceDrawLocationBarBackground = mLocationBarBackgroundAlpha > 0;
- float relativeAlpha = mLocationBarBackgroundAlpha / 255f;
- mLocationBar.setAlpha(relativeAlpha);
-
- // The search box on the NTP is visible if our omnibox is invisible, and vice-versa.
- ntp.setSearchBoxAlpha(1f - relativeAlpha);
-
- if (!ntp.isCardsUiEnabled()) {
- ntp.setSearchProviderLogoAlpha(Math.max(1f - mUrlExpansionPercent * 2.5f, 0f));
- }
+ mPhoneLocationBar.setAlpha(1f - growthPercent * 2);
+ }
+
+ // Go from a transparent url background to a fully opaque one in the first 40% of the
+ // scroll transition.
+ mUrlBackgroundAlpha =
+ mUrlExpansionPercent >= 0.4f ? 255 : (int) ((mUrlExpansionPercent * 2.5f) * 255);
+ if (mUrlExpansionPercent == 1f) mUrlBackgroundAlpha = 255;
+ mForceDrawLocationBarBackground = mUrlExpansionPercent != 0f;
}
private void setButtonsTranslationY() {
- int searchBoxTranslationY = Math.min(mNtpSearchBoxTranslation.y, 0);
+ float searchBoxTranslationY =
+ mNtpSearchBoxTransformedBounds.top - mNtpSearchBoxOriginalBounds.top;
+ searchBoxTranslationY = Math.min(searchBoxTranslationY, 0);
mToolbarButtonsContainer.setTranslationY(searchBoxTranslationY);
mReturnButton.setTranslationY(searchBoxTranslationY);
mHomeButton.setTranslationY(searchBoxTranslationY);
@@ -1037,13 +983,13 @@
}
// Draw the location/URL bar.
- previousAlpha = mLocationBar.getAlpha();
- mLocationBar.setAlpha(previousAlpha * floatAlpha);
+ previousAlpha = mPhoneLocationBar.getAlpha();
+ mPhoneLocationBar.setAlpha(previousAlpha * floatAlpha);
// If the location bar is now fully transparent, do not bother drawing it.
- if (mLocationBar.getAlpha() != 0) {
- drawChild(canvas, mLocationBar, SystemClock.uptimeMillis());
- }
- mLocationBar.setAlpha(previousAlpha);
+ if (mPhoneLocationBar.getAlpha() != 0) {
+ drawChild(canvas, mPhoneLocationBar, SystemClock.uptimeMillis());
+ }
+ mPhoneLocationBar.setAlpha(previousAlpha);
// Draw the tab stack button and associated text.
translateCanvasToView(this, mToolbarButtonsContainer, canvas);
@@ -1135,18 +1081,14 @@
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
- if (child == mLocationBar) return drawLocationBar(canvas, drawingTime);
+ if (child == mPhoneLocationBar) return drawLocationBar(canvas, drawingTime);
boolean clipped = false;
if (mLocationBarBackground != null
&& ((!mIsInTabSwitcherMode && !mTabSwitcherModeViews.contains(child))
|| (mIsInTabSwitcherMode && mBrowsingModeViews.contains(child)))) {
canvas.save();
-
- int translationY = (int) mLocationBar.getTranslationY();
- int clipTop = mLocationBarBackgroundBounds.top - mLocationBarBackgroundPadding.top
- + translationY;
- if (mUrlExpansionPercent != 0f && clipTop < child.getBottom()) {
+ if (mUrlExpansionPercent != 0f && mUrlViewportBounds.top < child.getBottom()) {
// For other child views, use the inverse clipping of the URL viewport.
// Only necessary during animations.
// Hardware mode does not support unioned clip regions, so clip using the
@@ -1155,24 +1097,24 @@
boolean isLeft = (child == mNewTabButton || child == mReturnButton
|| child == mHomeButton) ^ LocalizationUtils.isLayoutRtl();
- int clipBottom = mLocationBarBackgroundBounds.bottom
- + mLocationBarBackgroundPadding.bottom + translationY;
+ int clipTop = mUrlViewportBounds.top;
+ int clipBottom = mUrlViewportBounds.bottom;
boolean verticalClip = false;
- if (translationY > 0f) {
+ if (mPhoneLocationBar.getTranslationY() > 0f) {
clipTop = child.getTop();
- clipBottom = clipTop;
+ clipBottom = mUrlViewportBounds.top;
verticalClip = true;
}
if (isLeft) {
- int clipRight = verticalClip ? child.getMeasuredWidth()
- : mLocationBarBackgroundBounds.left
- - mLocationBarBackgroundPadding.left;
- canvas.clipRect(0, clipTop, clipRight, clipBottom);
+ canvas.clipRect(
+ 0, clipTop,
+ verticalClip ? child.getMeasuredWidth() : mUrlViewportBounds.left,
+ clipBottom);
} else {
- int clipLeft = verticalClip ? 0 : mLocationBarBackgroundBounds.right
- + mLocationBarBackgroundPadding.right;
- canvas.clipRect(clipLeft, clipTop, getMeasuredWidth(), clipBottom);
+ canvas.clipRect(
+ verticalClip ? 0 : mUrlViewportBounds.right,
+ clipTop, getMeasuredWidth(), clipBottom);
}
}
clipped = true;
@@ -1192,7 +1134,7 @@
// Fade out/in the location bar towards the beginning of the animations to avoid
// large jumps of stark white.
backgroundAlpha =
- (int) (Math.pow(mLocationBar.getAlpha(), 3) * mLocationBarBackgroundAlpha);
+ (int) (Math.pow(mPhoneLocationBar.getAlpha(), 3) * mUrlBackgroundAlpha);
} else if (getToolbarDataProvider().isUsingBrandColor()
&& !mBrandColorTransitionActive) {
backgroundAlpha = mUnfocusedLocationBarUsesTransparentBg
@@ -1200,32 +1142,28 @@
255, mUrlExpansionPercent))
: 255;
} else {
- backgroundAlpha = mLocationBarBackgroundAlpha;
+ backgroundAlpha = mUrlBackgroundAlpha;
}
mLocationBarBackground.setAlpha(backgroundAlpha);
- if ((mLocationBar.getAlpha() > 0 || mForceDrawLocationBarBackground)
+ if ((mPhoneLocationBar.getAlpha() > 0 || mForceDrawLocationBarBackground)
&& !mTextureCaptureMode) {
mLocationBarBackground.setBounds(
- mLocationBarBackgroundBounds.left + mLocationBarBackgroundNtpOffset.left
- - mLocationBarBackgroundPadding.left,
- mLocationBarBackgroundBounds.top + mLocationBarBackgroundNtpOffset.top
- - mLocationBarBackgroundPadding.top,
- mLocationBarBackgroundBounds.right + mLocationBarBackgroundNtpOffset.right
- + mLocationBarBackgroundPadding.right,
- mLocationBarBackgroundBounds.bottom + mLocationBarBackgroundNtpOffset.bottom
- + mLocationBarBackgroundPadding.bottom);
+ mUrlViewportBounds.left + mLocationBarBackgroundOffset.left,
+ mUrlViewportBounds.top + mLocationBarBackgroundOffset.top,
+ mUrlViewportBounds.right + mLocationBarBackgroundOffset.right,
+ mUrlViewportBounds.bottom + mLocationBarBackgroundOffset.bottom);
mLocationBarBackground.draw(canvas);
}
- float locationBarClipLeft =
- mLocationBarBackgroundBounds.left + mLocationBarBackgroundNtpOffset.left;
- float locationBarClipRight =
- mLocationBarBackgroundBounds.right + mLocationBarBackgroundNtpOffset.right;
- float locationBarClipTop =
- mLocationBarBackgroundBounds.top + mLocationBarBackgroundNtpOffset.top;
- float locationBarClipBottom =
- mLocationBarBackgroundBounds.bottom + mLocationBarBackgroundNtpOffset.bottom;
+ float locationBarClipLeft = mUrlViewportBounds.left
+ + mPhoneLocationBar.getPaddingLeft() + mLocationBarBackgroundOffset.left;
+ float locationBarClipRight = mUrlViewportBounds.right
+ - mPhoneLocationBar.getPaddingRight() + mLocationBarBackgroundOffset.right;
+ float locationBarClipTop = mUrlViewportBounds.top + mPhoneLocationBar.getPaddingTop()
+ + mLocationBarBackgroundOffset.top;
+ float locationBarClipBottom = mUrlViewportBounds.bottom
+ - mPhoneLocationBar.getPaddingBottom() + mLocationBarBackgroundOffset.bottom;
// When unexpanded, the location bar's visible content boundaries are inset from the
// viewport used to draw the background. During expansion transitions, compensation
@@ -1249,7 +1187,7 @@
clipped = true;
}
- boolean retVal = super.drawChild(canvas, mLocationBar, drawingTime);
+ boolean retVal = super.drawChild(canvas, mPhoneLocationBar, drawingTime);
if (clipped) canvas.restore();
return retVal;
@@ -1346,12 +1284,23 @@
// The Android framework calls onAnimationEnd() on listeners before Animator#isRunning()
// returns false. Sometimes this causes the progress bar visibility to be set incorrectly.
// Update the visibility now that animations are set to null. (see crbug.com/606419)
- updateProgressBarVisibility();
+ updateProgressBarVisibility(mIsInTabSwitcherMode);
}
@Override
public void getLocationBarContentRect(Rect outRect) {
- updateLocationBarBackgroundBounds(outRect, VisualState.NORMAL);
+ mLocationBarBackground.getPadding(outRect);
+ int paddingLeft = outRect.left;
+ int paddingTop = outRect.top;
+ int paddingRight = outRect.right;
+ int paddingBottom = outRect.bottom;
+
+ updateUrlViewportBounds(outRect, VisualState.NORMAL, true);
+
+ outRect.set(outRect.left + paddingLeft,
+ outRect.top + paddingTop,
+ outRect.right - paddingRight,
+ outRect.bottom - paddingBottom);
}
@Override
@@ -1416,7 +1365,7 @@
exitAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
- updateViewsForTabSwitcherMode();
+ updateViewsForTabSwitcherMode(mIsInTabSwitcherMode);
}
});
@@ -1431,7 +1380,7 @@
exitAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
- updateViewsForTabSwitcherMode();
+ updateViewsForTabSwitcherMode(mIsInTabSwitcherMode);
// On older builds, force an update to ensure the new visuals are used
// when bringing in the toolbar. crbug.com/404571
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN) {
@@ -1442,8 +1391,8 @@
@Override
public void onAnimationEnd(Animator animation) {
mDelayedTabSwitcherModeAnimation = null;
- updateShadowVisibility();
- updateViewsForTabSwitcherMode();
+ updateShadowVisibility(mIsInTabSwitcherMode);
+ updateViewsForTabSwitcherMode(mIsInTabSwitcherMode);
}
});
@@ -1460,7 +1409,7 @@
setAlpha(1);
} else {
setAlpha(mPreTextureCaptureAlpha);
- updateShadowVisibility();
+ updateShadowVisibility(mIsInTabSwitcherMode);
mPreTextureCaptureAlpha = 1f;
}
}
@@ -1472,9 +1421,9 @@
&& mDelayedTabSwitcherModeAnimation.isRunning());
}
- private void updateViewsForTabSwitcherMode() {
- int tabSwitcherViewsVisibility = mIsInTabSwitcherMode ? VISIBLE : INVISIBLE;
- int browsingViewsVisibility = mIsInTabSwitcherMode ? INVISIBLE : VISIBLE;
+ private void updateViewsForTabSwitcherMode(boolean isInTabSwitcherMode) {
+ int tabSwitcherViewsVisibility = isInTabSwitcherMode ? VISIBLE : INVISIBLE;
+ int browsingViewsVisibility = isInTabSwitcherMode ? INVISIBLE : VISIBLE;
for (View view : mTabSwitcherModeViews) {
view.setVisibility(tabSwitcherViewsVisibility);
@@ -1483,28 +1432,27 @@
view.setVisibility(browsingViewsVisibility);
}
if (mShowMenuBadge) {
- setMenuButtonContentDescription(!mIsInTabSwitcherMode);
- }
-
- updateProgressBarVisibility();
- updateVisualsForToolbarState();
- }
-
- private void updateProgressBarVisibility() {
+ setMenuButtonContentDescription(!isInTabSwitcherMode);
+ }
+
+ updateProgressBarVisibility(isInTabSwitcherMode);
+ updateVisualsForToolbarState(isInTabSwitcherMode);
+ }
+
+ private void updateProgressBarVisibility(boolean isInTabSwitcherMode) {
getProgressBar().setVisibility(
- mIsInTabSwitcherMode || isTabSwitcherAnimationRunning() ? INVISIBLE : VISIBLE);
+ isInTabSwitcherMode || isTabSwitcherAnimationRunning() ? INVISIBLE : VISIBLE);
}
@Override
protected void setContentAttached(boolean attached) {
- updateVisualsForToolbarState();
+ updateVisualsForToolbarState(mIsInTabSwitcherMode);
}
@Override
protected void setTabSwitcherMode(
boolean inTabSwitcherMode, boolean showToolbar, boolean delayAnimation) {
if (mIsInTabSwitcherMode == inTabSwitcherMode) return;
- mIsInTabSwitcherMode = inTabSwitcherMode;
finishAnimations();
@@ -1521,7 +1469,7 @@
updateUrlExpansionAnimation();
}
mNewTabButton.setEnabled(true);
- updateViewsForTabSwitcherMode();
+ updateViewsForTabSwitcherMode(true);
mTabSwitcherModeAnimation = createEnterTabSwitcherModeAnimation();
} else {
if (!mDelayingTabSwitcherAnimation) {
@@ -1531,6 +1479,7 @@
}
mAnimateNormalToolbar = showToolbar;
+ mIsInTabSwitcherMode = inTabSwitcherMode;
if (mTabSwitcherModeAnimation != null) mTabSwitcherModeAnimation.start();
if (SysUtils.isLowEndDevice()) finishAnimations();
@@ -1547,7 +1496,7 @@
if (!mAnimateNormalToolbar) {
finishAnimations();
- updateVisualsForToolbarState();
+ updateVisualsForToolbarState(mIsInTabSwitcherMode);
}
if (mDelayingTabSwitcherAnimation) {
@@ -1555,11 +1504,11 @@
mDelayedTabSwitcherModeAnimation = createPostExitTabSwitcherAnimation();
mDelayedTabSwitcherModeAnimation.start();
} else {
- updateViewsForTabSwitcherMode();
- }
- }
-
- private void updateOverlayDrawables() {
+ updateViewsForTabSwitcherMode(mIsInTabSwitcherMode);
+ }
+ }
+
+ private void updateOverlayDrawables(boolean isInTabSwitcherMode) {
if (!isNativeLibraryReady()) return;
VisualState overlayState = computeVisualState(false);
@@ -1579,7 +1528,7 @@
setTabSwitcherAnimationMenuDrawable();
setUseLightDrawablesForTextureCapture();
- if (!mIsInTabSwitcherMode && !mTextureCaptureMode && mLayoutUpdateHost != null) {
+ if (!isInTabSwitcherMode && !mTextureCaptureMode && mLayoutUpdateHost != null) {
// Request a layout update to trigger a texture capture if the tint color is changing
// and we're not already in texture capture mode. This is necessary if the tab switcher
// is entered immediately after a change to the tint color without any user interactions
@@ -1645,9 +1594,9 @@
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(animator);
- for (int i = 0; i < mLocationBar.getChildCount(); i++) {
- View childView = mLocationBar.getChildAt(i);
- if (childView == mLocationBar.getFirstViewVisibleWhenFocused()) break;
+ for (int i = 0; i < mPhoneLocationBar.getChildCount(); i++) {
+ View childView = mPhoneLocationBar.getChildAt(i);
+ if (childView == mPhoneLocationBar.getFirstViewVisibleWhenFocused()) break;
animator = ObjectAnimator.ofFloat(childView, ALPHA, 0);
animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
@@ -1716,9 +1665,9 @@
animators.add(animator);
}
- for (int i = 0; i < mLocationBar.getChildCount(); i++) {
- View childView = mLocationBar.getChildAt(i);
- if (childView == mLocationBar.getFirstViewVisibleWhenFocused()) break;
+ for (int i = 0; i < mPhoneLocationBar.getChildCount(); i++) {
+ View childView = mPhoneLocationBar.getChildAt(i);
+ if (childView == mPhoneLocationBar.getFirstViewVisibleWhenFocused()) break;
animator = ObjectAnimator.ofFloat(childView, ALPHA, 1);
animator.setStartDelay(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
animator.setDuration(URL_CLEAR_FOCUS_MENU_DELAY_MS);
@@ -1731,7 +1680,7 @@
// The call to getLayout() can return null briefly during text changes, but as it
// is only needed for RTL calculations, we proceed if the location bar is showing
// LTR content.
- boolean isLocationBarRtl = ApiCompatibilityUtils.isLayoutRtl(mLocationBar);
+ boolean isLocationBarRtl = ApiCompatibilityUtils.isLayoutRtl(mPhoneLocationBar);
if (!isLocationBarRtl || mUrlBar.getLayout() != null) {
int urlBarStartScrollX = 0;
if (isLocationBarRtl) {
@@ -1744,8 +1693,10 @@
// back to page URLs (despite it continually calling setScrollX with the same
// number).
if (mUrlBar.getScrollX() != urlBarStartScrollX) {
- animator = ObjectAnimator.ofInt(mUrlBar,
- buildUrlScrollProperty(mLocationBar, isLocationBarRtl), urlBarStartScrollX);
+ animator = ObjectAnimator.ofInt(
+ mUrlBar,
+ buildUrlScrollProperty(mPhoneLocationBar, isLocationBarRtl),
+ urlBarStartScrollX);
animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(animator);
@@ -1821,7 +1772,7 @@
mLayoutLocationBarInFocusedMode = false;
requestLayout();
}
- mLocationBar.finishUrlFocusChange(hasFocus);
+ mPhoneLocationBar.finishUrlFocusChange(hasFocus);
mUrlFocusChangeInProgress = false;
}
});
@@ -1834,7 +1785,7 @@
// allows the menu to translate off the screen on scroll to match the tabbed behavior.
if (mVisualState == VisualState.NEW_TAB_NORMAL) return true;
- return !mLocationBar.showMenuButtonInOmnibox() && super.shouldShowMenuButton();
+ return !mPhoneLocationBar.showMenuButtonInOmnibox() && super.shouldShowMenuButton();
}
@Override
@@ -1883,14 +1834,14 @@
protected void onTabContentViewChanged() {
super.onTabContentViewChanged();
updateNtpAnimationState();
- updateVisualsForToolbarState();
+ updateVisualsForToolbarState(mIsInTabSwitcherMode);
}
@Override
protected void onTabOrModelChanged() {
super.onTabOrModelChanged();
updateNtpAnimationState();
- updateVisualsForToolbarState();
+ updateVisualsForToolbarState(mIsInTabSwitcherMode);
if (mHasCheckedIfTabSwitcherCalloutIsNecessary) {
dismissTabSwitcherCallout();
@@ -1916,7 +1867,7 @@
if (initialColor == finalColor) return;
boolean shouldUseOpaque = ColorUtils.shouldUseOpaqueTextboxBackground(finalColor);
- final int initialAlpha = mLocationBarBackgroundAlpha;
+ final int initialAlpha = mUrlBackgroundAlpha;
final int finalAlpha =
shouldUseOpaque ? 255 : LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA;
final boolean shouldAnimateAlpha = initialAlpha != finalAlpha;
@@ -1928,7 +1879,7 @@
public void onAnimationUpdate(ValueAnimator animation) {
float fraction = animation.getAnimatedFraction();
if (shouldAnimateAlpha) {
- mLocationBarBackgroundAlpha =
+ mUrlBackgroundAlpha =
(int) (MathUtils.interpolate(initialAlpha, finalAlpha, fraction));
}
updateToolbarBackground(
@@ -1939,7 +1890,7 @@
@Override
public void onAnimationEnd(Animator animation) {
mBrandColorTransitionActive = false;
- updateVisualsForToolbarState();
+ updateVisualsForToolbarState(mIsInTabSwitcherMode);
}
});
mBrandColorTransitionAnimation.start();
@@ -1985,7 +1936,7 @@
post(new Runnable() {
@Override
public void run() {
- updateVisualsForToolbarState();
+ updateVisualsForToolbarState(mIsInTabSwitcherMode);
updateNtpAnimationState();
}
});
@@ -2007,8 +1958,8 @@
return ntp != null && ntp.isLocationBarShownInNTP();
}
- private void updateShadowVisibility() {
- boolean shouldDrawShadow = !mIsInTabSwitcherMode && !isTabSwitcherAnimationRunning();
+ private void updateShadowVisibility(boolean isInTabSwitcherMode) {
+ boolean shouldDrawShadow = !isInTabSwitcherMode && !isTabSwitcherAnimationRunning();
int shadowVisibility = shouldDrawShadow ? View.VISIBLE : View.INVISIBLE;
if (mToolbarShadow.getVisibility() != shadowVisibility) {
@@ -2025,10 +1976,10 @@
return VisualState.NORMAL;
}
- private void updateVisualsForToolbarState() {
+ private void updateVisualsForToolbarState(boolean isInTabSwitcherMode) {
final boolean isIncognito = isIncognito();
- VisualState newVisualState = computeVisualState(mIsInTabSwitcherMode);
+ VisualState newVisualState = computeVisualState(isInTabSwitcherMode);
// If we are navigating to or from a brand color, allow the transition animation
// to run to completion as it will handle the triggering this path again and committing
@@ -2073,9 +2024,8 @@
mVisualState = newVisualState;
- updateOverlayDrawables();
- updateShadowVisibility();
- updateUrlExpansionAnimation();
+ updateOverlayDrawables(isInTabSwitcherMode);
+ updateShadowVisibility(isInTabSwitcherMode);
if (!visualStateChanged) {
if (mVisualState == VisualState.NEW_TAB_NORMAL) {
updateNtpTransitionAnimation();
@@ -2085,27 +2035,26 @@
mUseLightToolbarDrawables = false;
mUnfocusedLocationBarUsesTransparentBg = false;
- mLocationBarBackgroundAlpha = 255;
+ mUrlBackgroundAlpha = 255;
updateToolbarBackground(mVisualState);
getProgressBar().setThemeColor(themeColorForProgressBar, isIncognito());
- if (mIsInTabSwitcherMode) {
+ if (isInTabSwitcherMode) {
mUseLightToolbarDrawables = true;
- mLocationBarBackgroundAlpha = LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA;
+ mUrlBackgroundAlpha = LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA;
getProgressBar().setBackgroundColor(mProgressBackBackgroundColorWhite);
getProgressBar().setForegroundColor(ApiCompatibilityUtils.getColor(getResources(),
R.color.progress_bar_foreground_white));
} else if (isIncognito()) {
mUseLightToolbarDrawables = true;
- mLocationBarBackgroundAlpha = LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA;
+ mUrlBackgroundAlpha = LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA;
} else if (mVisualState == VisualState.BRAND_COLOR) {
mUseLightToolbarDrawables =
ColorUtils.shouldUseLightForegroundOnBackground(currentPrimaryColor);
mUnfocusedLocationBarUsesTransparentBg =
!ColorUtils.shouldUseOpaqueTextboxBackground(currentPrimaryColor);
- mLocationBarBackgroundAlpha = mUnfocusedLocationBarUsesTransparentBg
- ? LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA
- : 255;
+ mUrlBackgroundAlpha = mUnfocusedLocationBarUsesTransparentBg
+ ? LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA : 255;
}
if (mToggleTabStackButton != null) {
@@ -2120,7 +2069,7 @@
if (shouldShowMenuButton()) {
mMenuButton.setTint(mUseLightToolbarDrawables ? mLightModeTint : mDarkModeTint);
- if (mShowMenuBadge && !mIsInTabSwitcherMode) {
+ if (mShowMenuBadge && !isInTabSwitcherMode) {
setAppMenuUpdateBadgeDrawable(mUseLightToolbarDrawables);
}
}
@@ -2128,25 +2077,25 @@
if (isReturnButtonVisible()) mReturnButton.setTint(tint);
if (mIsHomeButtonEnabled) mHomeButton.setTint(tint);
- mLocationBar.updateVisualsForState();
+ mPhoneLocationBar.updateVisualsForState();
// Remove the side padding for incognito to ensure the badge icon aligns correctly with the
// background of the location bar.
if (isIncognito) {
- mLocationBar.setPadding(
- 0, mLocationBarBackgroundPadding.top, 0, mLocationBarBackgroundPadding.bottom);
+ mPhoneLocationBar.setPadding(
+ 0, mUrlBackgroundPadding.top, 0, mUrlBackgroundPadding.bottom);
} else {
- mLocationBar.setPadding(
- mLocationBarBackgroundPadding.left, mLocationBarBackgroundPadding.top,
- mLocationBarBackgroundPadding.right, mLocationBarBackgroundPadding.bottom);
+ mPhoneLocationBar.setPadding(
+ mUrlBackgroundPadding.left, mUrlBackgroundPadding.top,
+ mUrlBackgroundPadding.right, mUrlBackgroundPadding.bottom);
}
// We update the alpha before comparing the visual state as we need to change
// its value when entering and exiting TabSwitcher mode.
- if (isLocationBarShownInNTP() && !mIsInTabSwitcherMode) {
+ if (isLocationBarShownInNTP() && !isInTabSwitcherMode) {
updateNtpTransitionAnimation();
}
- if (mIsInTabSwitcherMode) mNewTabButton.setIsIncognito(isIncognito);
+ if (isInTabSwitcherMode) mNewTabButton.setIsIncognito(isIncognito);
CharSequence newTabContentDescription = getResources().getText(
isIncognito ? R.string.accessibility_toolbar_btn_new_incognito_tab :
@@ -2161,7 +2110,7 @@
@Override
public LocationBar getLocationBar() {
- return mLocationBar;
+ return mPhoneLocationBar;
}
@Override
@@ -2185,7 +2134,7 @@
setAppMenuUpdateBadgeToVisible(true);
}
- mLocationBar.showAppMenuUpdateBadge(true);
+ mPhoneLocationBar.showAppMenuUpdateBadge(true);
}
@Override
@@ -2198,7 +2147,7 @@
mTabSwitcherAnimationMenuBadgeLightDrawable = null;
}
- mLocationBar.removeAppMenuUpdateBadge(animate);
+ mPhoneLocationBar.removeAppMenuUpdateBadge(animate);
}
private void setTabSwitcherAnimationMenuDrawable() {

Powered by Google App Engine
This is Rietveld 408576698