Commit 52fe73d0 authored by bttk's avatar bttk Committed by Commit Bot

[ToolbarMVC] Add nested LocationBar interfaces for phone and tablet

Making Toolbar interact with LocationBar only through those interfaces
uncovered which LocationBar* and View methods are used.
Next these interfaces can be replaced by Coordinator objects.

Bug: 1133482
Change-Id: Iececeed429fee66f7adbeb515a328403ef1b1aab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2444470Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarBrandon Wylie <wylieb@chromium.org>
Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Reviewed-by: default avatarPatrick Noland <pnoland@chromium.org>
Commit-Queue: who/bttk <bttk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814529}
parent b7edca7e
...@@ -4,10 +4,15 @@ ...@@ -4,10 +4,15 @@
package org.chromium.chrome.browser.omnibox; package org.chromium.chrome.browser.omnibox;
import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.app.Activity; import android.app.Activity;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window; import android.view.Window;
import android.widget.FrameLayout;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
...@@ -31,6 +36,7 @@ import org.chromium.ui.modaldialog.ModalDialogManager; ...@@ -31,6 +36,7 @@ import org.chromium.ui.modaldialog.ModalDialogManager;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.util.List;
/** /**
* Container that holds the {@link UrlBar} and SSL state related with the current {@link Tab}. * Container that holds the {@link UrlBar} and SSL state related with the current {@link Tab}.
...@@ -170,7 +176,7 @@ public interface LocationBar extends UrlBarDelegate, FakeboxDelegate { ...@@ -170,7 +176,7 @@ public interface LocationBar extends UrlBarDelegate, FakeboxDelegate {
void selectAll(); void selectAll();
/** /**
* Reverts any pending edits of the location bar and reset to the page state. This does not * Reverts any pending edits of the location bar and reset to the page state. This does not
* change the focus state of the location bar. * change the focus state of the location bar.
*/ */
void revertChanges(); void revertChanges();
...@@ -224,4 +230,276 @@ public interface LocationBar extends UrlBarDelegate, FakeboxDelegate { ...@@ -224,4 +230,276 @@ public interface LocationBar extends UrlBarDelegate, FakeboxDelegate {
* @param profileSupplier The supplier of the active profile. * @param profileSupplier The supplier of the active profile.
*/ */
void setProfileSupplier(ObservableSupplier<Profile> profileSupplier); void setProfileSupplier(ObservableSupplier<Profile> profileSupplier);
/**
* Public methods of LocationBar exclusive to smaller devices.
*/
interface Phone {
/**
* Returns width of child views before the first view that would be visible when location
* bar is focused. The first visible, focused view should be either url bar or status icon.
*/
int getOffsetOfFirstVisibleFocusedView();
/**
* Populates fade animators of status icon for location bar focus change animation.
*
* @param animators The target list to add animators to.
* @param startDelayMs Start delay of fade animation in milliseconds.
* @param durationMs Duration of fade animation in milliseconds.
* @param targetAlpha Target alpha value.
*/
void populateFadeAnimations(
List<Animator> animators, long startDelayMs, long durationMs, float targetAlpha);
/**
* Calculates the offset required for the focused LocationBar to appear as it's still
* unfocused so it can animate to a focused state.
*
* @param hasFocus True if the LocationBar has focus, this will be true between the focus
* animation starting and the unfocus animation starting.
* @return The offset for the location bar when showing the DSE/loupe icon.
*/
int getLocationBarOffsetForFocusAnimation(boolean hasFocus);
/**
* Function used to position the URL bar inside the location bar during omnibox animation.
*
* @param urlExpansionFraction The current expansion progress, 1 is fully focused and 0 is
* completely unfocused.
* @param hasFocus True if the LocationBar has focus, this will be true between the focus
* animation starting and the unfocus animation starting.
* @return The number of pixels of horizontal translation for the URL bar, used in the
* toolbar animation.
*/
float getUrlBarTranslationXForToolbarAnimation(
float urlExpansionFraction, boolean hasFocus);
/**
* Handles any actions to be performed after all other actions triggered by the URL focus
* change. This will be called after any animations are performed to transition from one
* focus state to the other.
*
* @param hasFocus Whether the URL field has gained focus.
*/
void finishUrlFocusChange(boolean hasFocus);
/**
* Sets whether the url bar should be focusable.
*/
void setUrlBarFocusable(boolean focusable);
/**
* Returns {@link FrameLayout.LayoutParams} of the LocationBar view.
*
* <p>TODO(1133482): Hide this View interaction if possible.
*
* @see View#getLayoutParams()
*/
FrameLayout.LayoutParams getFrameLayoutParams();
/**
* The opacity of the view.
*
* <p>TODO(1133482): Hide this View interaction if possible.
*
* @see View#getAlpha()
*/
float getAlpha();
/**
* Bottom position of this view relative to its parent.
*
* <p>TODO(1133482): Hide this View interaction if possible.
*
* @see View#getBottom()
* @return The bottom of this view, in pixels.
*/
int getBottom();
/**
* Returns the resolved layout direction for this view.
*
* <p>TODO(1133482): Hide this View interaction if possible.
*
* @see View#getLayoutDirection()
* @return {@link View#LAYOUT_DIRECTION_LTR}, or {@link View#LAYOUT_DIRECTION_RTL}.
*/
int getLayoutDirection();
/**
* Returns the end padding of this view.
*
* <p>TODO(1133482): Hide this View interaction if possible.
*
* @see View#getPaddingEnd()
* @return The end padding in pixels.
*/
int getPaddingEnd();
/**
* Returns the start padding of this view.
*
* <p>TODO(1133482): Hide this View interaction if possible.
*
* @see View#getPaddingStart()
* @return The start padding in pixels.
*/
int getPaddingStart();
/**
* Top position of this view relative to its parent.
*
* <p>TODO(1133482): Hide this View interaction if possible.
*
* @see View#getTop()
* @return The top of this view, in pixels.
*/
int getTop();
/**
* The vertical location of this view relative to its top position, in pixels.
*
* <p>TODO(1133482): Hide this View interaction if possible.
*
* @see View#getTranslationY()
*/
float getTranslationY();
/**
* Returns the visibility status for this view.
*
* <p>TODO(1133482): Hide this View interaction if possible.
*
* @see View#getVisibility()
*/
int getVisibility();
/**
* Returns true if this view has focus itself, or is the ancestor of the view that has
* focus.
*
* <p>TODO(1133482): Hide this View interaction if possible.
*
* @see View#hasFocus()
*/
boolean hasFocus();
/**
* Invalidate the whole view.
*
* <p>TODO(1133482): Hide this View interaction if possible.
*
* @see View#invalidate()
*/
void invalidate();
/**
* Sets the opacity of the view.
*
* <p>TODO(1133482): Hide this View interaction if possible.
*
* @see View#setAlpha(float)
*/
void setAlpha(float alpha);
/**
* Sets the padding.
*
* <p>TODO(1133482): Hide this View interaction if possible.
*
* @see View#setPadding(int, int, int, int)
*/
void setPadding(int left, int top, int right, int bottom);
/**
* Sets the horizontal location of this view relative to its left position.
*
* <p>TODO(1133482): Hide this View interaction if possible.
*
* @see View#setTranslationX(float)
*/
void setTranslationX(float translationX);
/**
* Sets the vertical location of this view relative to its top position.
*
* <p>TODO(1133482): Hide this View interaction if possible.
*
* @see View#setTranslationY(float)
*/
void setTranslationY(float translationY);
/**
* Returns the LocationBar view for use in drawing.
*
* <p>TODO(1133482): Hide this View interaction if possible.
*
* @see ViewGroup#drawChild(Canvas, View, long)
*/
View getViewForDrawing();
}
/**
* Public methods of LocationBar exclusive to larger devices.
*/
interface Tablet {
/**
* @param button The {@link View} of the button to hide.
* @return An animator to run for the given view when hiding buttons in the unfocused
* location bar. This should also be used to create animators for hiding toolbar
* buttons.
*/
ObjectAnimator createHideButtonAnimator(View button);
/**
* @param button The {@link View} of the button to show.
* @return An animator to run for the given view when showing buttons in the unfocused
* location bar. This should also be used to create animators for showing toolbar
* buttons.
*/
ObjectAnimator createShowButtonAnimator(View button);
/**
* Creates animators for hiding buttons in the unfocused location bar. The buttons fade out
* while width of the location bar gets larger. There are toolbar buttons that also hide at
* the same time, causing the width of the location bar to change.
*
* @param toolbarStartPaddingDifference The difference in the toolbar's start padding
* between the beginning and end of the animation.
* @return A list of animators to run.
*/
List<Animator> getHideButtonsWhenUnfocusedAnimators(int toolbarStartPaddingDifference);
/**
* Creates animators for showing buttons in the unfocused location bar. The buttons fade in
* while width of the location bar gets smaller. There are toolbar buttons that also show at
* the same time, causing the width of the location bar to change.
*
* @param toolbarStartPaddingDifference The difference in the toolbar's start padding
* between the beginning and end of the animation.
* @return A list of animators to run.
*/
List<Animator> getShowButtonsWhenUnfocusedAnimators(int toolbarStartPaddingDifference);
/**
* @param shouldShowButtons Whether buttons should be displayed in the URL bar when it's not
* focused.
*/
void setShouldShowButtonsWhenUnfocused(boolean shouldShowButtons);
/**
* Updates the visibility of the buttons inside the location bar.
*/
void updateButtonVisibility();
/**
* Gets the background drawable.
*
* <p>TODO(1133482): Hide this View interaction if possible.
*
* @see View#getBackground()
*/
Drawable getBackground();
}
} }
...@@ -12,6 +12,7 @@ import android.graphics.Rect; ...@@ -12,6 +12,7 @@ import android.graphics.Rect;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.TouchDelegate; import android.view.TouchDelegate;
import android.view.View; import android.view.View;
import android.widget.FrameLayout;
import org.chromium.base.TraceEvent; import org.chromium.base.TraceEvent;
import org.chromium.chrome.R; import org.chromium.chrome.R;
...@@ -23,7 +24,7 @@ import java.util.List; ...@@ -23,7 +24,7 @@ import java.util.List;
/** /**
* A location bar implementation specific for smaller/phone screens. * A location bar implementation specific for smaller/phone screens.
*/ */
public class LocationBarPhone extends LocationBarLayout { public class LocationBarPhone extends LocationBarLayout implements LocationBar.Phone {
private static final int ACTION_BUTTON_TOUCH_OVERFLOW_LEFT = 15; private static final int ACTION_BUTTON_TOUCH_OVERFLOW_LEFT = 15;
private View mFirstVisibleFocusedView; private View mFirstVisibleFocusedView;
...@@ -94,6 +95,7 @@ public class LocationBarPhone extends LocationBarLayout { ...@@ -94,6 +95,7 @@ public class LocationBarPhone extends LocationBarLayout {
* @return Width of child views before the first view that would be visible when location bar is * @return Width of child views before the first view that would be visible when location bar is
* focused. The first visible, focused view should be either url bar or status icon. * focused. The first visible, focused view should be either url bar or status icon.
*/ */
@Override
public int getOffsetOfFirstVisibleFocusedView() { public int getOffsetOfFirstVisibleFocusedView() {
int visibleWidth = 0; int visibleWidth = 0;
for (int i = 0; i < getChildCount(); i++) { for (int i = 0; i < getChildCount(); i++) {
...@@ -112,6 +114,7 @@ public class LocationBarPhone extends LocationBarLayout { ...@@ -112,6 +114,7 @@ public class LocationBarPhone extends LocationBarLayout {
* @param durationMs Duration of fade animation in milliseconds. * @param durationMs Duration of fade animation in milliseconds.
* @param targetAlpha Target alpha value. * @param targetAlpha Target alpha value.
*/ */
@Override
public void populateFadeAnimations( public void populateFadeAnimations(
List<Animator> animators, long startDelayMs, long durationMs, float targetAlpha) { List<Animator> animators, long startDelayMs, long durationMs, float targetAlpha) {
for (int i = 0; i < getChildCount(); i++) { for (int i = 0; i < getChildCount(); i++) {
...@@ -133,6 +136,7 @@ public class LocationBarPhone extends LocationBarLayout { ...@@ -133,6 +136,7 @@ public class LocationBarPhone extends LocationBarLayout {
* animation starting and the unfocus animation starting. * animation starting and the unfocus animation starting.
* @return The offset for the location bar when showing the dse icon. * @return The offset for the location bar when showing the dse icon.
*/ */
@Override
public int getLocationBarOffsetForFocusAnimation(boolean hasFocus) { public int getLocationBarOffsetForFocusAnimation(boolean hasFocus) {
if (mStatusCoordinator == null) return 0; if (mStatusCoordinator == null) return 0;
...@@ -166,6 +170,7 @@ public class LocationBarPhone extends LocationBarLayout { ...@@ -166,6 +170,7 @@ public class LocationBarPhone extends LocationBarLayout {
* animation starting and the unfocus animation starting. * animation starting and the unfocus animation starting.
* @return The X translation for the URL bar, used in the toolbar animation. * @return The X translation for the URL bar, used in the toolbar animation.
*/ */
@Override
public float getUrlBarTranslationXForToolbarAnimation( public float getUrlBarTranslationXForToolbarAnimation(
float urlExpansionPercent, boolean hasFocus) { float urlExpansionPercent, boolean hasFocus) {
// This will be called before status view is ready. // This will be called before status view is ready.
...@@ -277,6 +282,11 @@ public class LocationBarPhone extends LocationBarLayout { ...@@ -277,6 +282,11 @@ public class LocationBarPhone extends LocationBarLayout {
mStatusCoordinator.onUrlAnimationFinished(hasFocus); mStatusCoordinator.onUrlAnimationFinished(hasFocus);
} }
@Override
public FrameLayout.LayoutParams getFrameLayoutParams() {
return (FrameLayout.LayoutParams) getLayoutParams();
}
@Override @Override
protected void updateButtonVisibility() { protected void updateButtonVisibility() {
super.updateButtonVisibility(); super.updateButtonVisibility();
...@@ -328,6 +338,11 @@ public class LocationBarPhone extends LocationBarLayout { ...@@ -328,6 +338,11 @@ public class LocationBarPhone extends LocationBarLayout {
} }
} }
@Override
public View getViewForDrawing() {
return this;
}
/** Update the status visibility according to the current state held in LocationBar. */ /** Update the status visibility according to the current state held in LocationBar. */
private void updateStatusVisibility() { private void updateStatusVisibility() {
boolean incognito = getToolbarDataProvider().isIncognito(); boolean incognito = getToolbarDataProvider().isIncognito();
......
...@@ -29,7 +29,7 @@ import java.util.List; ...@@ -29,7 +29,7 @@ import java.util.List;
/** /**
* Location bar for tablet form factors. * Location bar for tablet form factors.
*/ */
public class LocationBarTablet extends LocationBarLayout { public class LocationBarTablet extends LocationBarLayout implements LocationBar.Tablet {
private static final long MAX_NTP_KEYBOARD_FOCUS_DURATION_MS = 200; private static final long MAX_NTP_KEYBOARD_FOCUS_DURATION_MS = 200;
private static final int ICON_FADE_ANIMATION_DURATION_MS = 150; private static final int ICON_FADE_ANIMATION_DURATION_MS = 150;
...@@ -187,6 +187,7 @@ public class LocationBarTablet extends LocationBarLayout { ...@@ -187,6 +187,7 @@ public class LocationBarTablet extends LocationBarLayout {
* @param shouldShowButtons Whether buttons should be displayed in the URL bar when it's not * @param shouldShowButtons Whether buttons should be displayed in the URL bar when it's not
* focused. * focused.
*/ */
@Override
public void setShouldShowButtonsWhenUnfocused(boolean shouldShowButtons) { public void setShouldShowButtonsWhenUnfocused(boolean shouldShowButtons) {
mShouldShowButtonsWhenUnfocused = shouldShowButtons; mShouldShowButtonsWhenUnfocused = shouldShowButtons;
updateButtonVisibility(); updateButtonVisibility();
...@@ -267,6 +268,7 @@ public class LocationBarTablet extends LocationBarLayout { ...@@ -267,6 +268,7 @@ public class LocationBarTablet extends LocationBarLayout {
* @return An animator to run for the given view when showing buttons in the unfocused location * @return An animator to run for the given view when showing buttons in the unfocused location
* bar. This should also be used to create animators for showing toolbar buttons. * bar. This should also be used to create animators for showing toolbar buttons.
*/ */
@Override
public ObjectAnimator createShowButtonAnimator(View button) { public ObjectAnimator createShowButtonAnimator(View button) {
if (button.getVisibility() != View.VISIBLE) { if (button.getVisibility() != View.VISIBLE) {
button.setAlpha(0.f); button.setAlpha(0.f);
...@@ -283,6 +285,7 @@ public class LocationBarTablet extends LocationBarLayout { ...@@ -283,6 +285,7 @@ public class LocationBarTablet extends LocationBarLayout {
* @return An animator to run for the given view when hiding buttons in the unfocused location * @return An animator to run for the given view when hiding buttons in the unfocused location
* bar. This should also be used to create animators for hiding toolbar buttons. * bar. This should also be used to create animators for hiding toolbar buttons.
*/ */
@Override
public ObjectAnimator createHideButtonAnimator(View button) { public ObjectAnimator createHideButtonAnimator(View button) {
ObjectAnimator buttonAnimator = ObjectAnimator.ofFloat(button, View.ALPHA, 0.f); ObjectAnimator buttonAnimator = ObjectAnimator.ofFloat(button, View.ALPHA, 0.f);
buttonAnimator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE); buttonAnimator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);
...@@ -299,6 +302,7 @@ public class LocationBarTablet extends LocationBarLayout { ...@@ -299,6 +302,7 @@ public class LocationBarTablet extends LocationBarLayout {
* the beginning and end of the animation. * the beginning and end of the animation.
* @return An ArrayList of animators to run. * @return An ArrayList of animators to run.
*/ */
@Override
public List<Animator> getShowButtonsWhenUnfocusedAnimators(int toolbarStartPaddingDifference) { public List<Animator> getShowButtonsWhenUnfocusedAnimators(int toolbarStartPaddingDifference) {
mToolbarStartPaddingDifference = toolbarStartPaddingDifference; mToolbarStartPaddingDifference = toolbarStartPaddingDifference;
...@@ -353,6 +357,7 @@ public class LocationBarTablet extends LocationBarLayout { ...@@ -353,6 +357,7 @@ public class LocationBarTablet extends LocationBarLayout {
* the beginning and end of the animation. * the beginning and end of the animation.
* @return An ArrayList of animators to run. * @return An ArrayList of animators to run.
*/ */
@Override
public List<Animator> getHideButtonsWhenUnfocusedAnimators(int toolbarStartPaddingDifference) { public List<Animator> getHideButtonsWhenUnfocusedAnimators(int toolbarStartPaddingDifference) {
mToolbarStartPaddingDifference = toolbarStartPaddingDifference; mToolbarStartPaddingDifference = toolbarStartPaddingDifference;
......
...@@ -43,7 +43,6 @@ import androidx.annotation.Nullable; ...@@ -43,7 +43,6 @@ import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import androidx.appcompat.graphics.drawable.DrawableWrapper; import androidx.appcompat.graphics.drawable.DrawableWrapper;
import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.graphics.drawable.DrawableCompat;
import androidx.core.view.ViewCompat;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.MathUtils; import org.chromium.base.MathUtils;
...@@ -55,7 +54,6 @@ import org.chromium.chrome.browser.feature_engagement.TrackerFactory; ...@@ -55,7 +54,6 @@ import org.chromium.chrome.browser.feature_engagement.TrackerFactory;
import org.chromium.chrome.browser.homepage.HomepageManager; import org.chromium.chrome.browser.homepage.HomepageManager;
import org.chromium.chrome.browser.ntp.NewTabPage; import org.chromium.chrome.browser.ntp.NewTabPage;
import org.chromium.chrome.browser.omnibox.LocationBar; import org.chromium.chrome.browser.omnibox.LocationBar;
import org.chromium.chrome.browser.omnibox.LocationBarPhone;
import org.chromium.chrome.browser.omnibox.SearchEngineLogoUtils; import org.chromium.chrome.browser.omnibox.SearchEngineLogoUtils;
import org.chromium.chrome.browser.partnercustomizations.PartnerBrowserCustomizations; import org.chromium.chrome.browser.partnercustomizations.PartnerBrowserCustomizations;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
...@@ -125,7 +123,8 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -125,7 +123,8 @@ public class ToolbarPhone extends ToolbarLayout
private TabCountProvider mTabCountProvider; private TabCountProvider mTabCountProvider;
protected LocationBarPhone mLocationBar; protected LocationBar mLocationBar;
protected LocationBar.Phone mLocationBarPhone;
private ViewGroup mToolbarButtonsContainer; private ViewGroup mToolbarButtonsContainer;
protected @Nullable ToggleTabStackButton mToggleTabStackButton; protected @Nullable ToggleTabStackButton mToggleTabStackButton;
...@@ -338,7 +337,8 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -338,7 +337,8 @@ public class ToolbarPhone extends ToolbarLayout
public void onFinishInflate() { public void onFinishInflate() {
try (TraceEvent te = TraceEvent.scoped("ToolbarPhone.onFinishInflate")) { try (TraceEvent te = TraceEvent.scoped("ToolbarPhone.onFinishInflate")) {
super.onFinishInflate(); super.onFinishInflate();
mLocationBar = (LocationBarPhone) findViewById(R.id.location_bar); mLocationBar = (LocationBar) findViewById(R.id.location_bar);
mLocationBarPhone = (LocationBar.Phone) mLocationBar;
mToolbarButtonsContainer = (ViewGroup) findViewById(R.id.toolbar_buttons); mToolbarButtonsContainer = (ViewGroup) findViewById(R.id.toolbar_buttons);
...@@ -384,7 +384,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -384,7 +384,7 @@ public class ToolbarPhone extends ToolbarLayout
mLocationBarBackground = createModernLocationBarBackground(getResources()); mLocationBarBackground = createModernLocationBarBackground(getResources());
int lateralPadding = res.getDimensionPixelOffset(R.dimen.location_bar_lateral_padding); int lateralPadding = res.getDimensionPixelOffset(R.dimen.location_bar_lateral_padding);
mLocationBar.setPadding(lateralPadding, 0, lateralPadding, 0); mLocationBarPhone.setPadding(lateralPadding, 0, lateralPadding, 0);
mActiveLocationBarBackground = mLocationBarBackground; mActiveLocationBarBackground = mLocationBarBackground;
} }
...@@ -498,7 +498,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -498,7 +498,7 @@ public class ToolbarPhone extends ToolbarLayout
public boolean onTouchEvent(MotionEvent ev) { public boolean onTouchEvent(MotionEvent ev) {
// Forward touch events to the NTP if the toolbar is moved away but the search box hasn't // Forward touch events to the NTP if the toolbar is moved away but the search box hasn't
// reached the top of the page yet. // reached the top of the page yet.
if (mNtpSearchBoxTranslation.y < 0 && mLocationBar.getTranslationY() > 0) { if (mNtpSearchBoxTranslation.y < 0 && mLocationBarPhone.getTranslationY() > 0) {
NewTabPage newTabPage = getToolbarDataProvider().getNewTabPageForCurrentTab(); NewTabPage newTabPage = getToolbarDataProvider().getNewTabPageForCurrentTab();
// No null check -- the toolbar should not be moved if we are not on an NTP. // No null check -- the toolbar should not be moved if we are not on an NTP.
...@@ -511,7 +511,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -511,7 +511,7 @@ public class ToolbarPhone extends ToolbarLayout
@Override @Override
public void onClick(View v) { public void onClick(View v) {
// Don't allow clicks while the omnibox is being focused. // Don't allow clicks while the omnibox is being focused.
if (mLocationBar != null && mLocationBar.hasFocus()) return; if (mLocationBarPhone != null && mLocationBarPhone.hasFocus()) return;
if (mHomeButton != null && mHomeButton == v) { if (mHomeButton != null && mHomeButton == v) {
openHomepage(); openHomepage();
...@@ -594,7 +594,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -594,7 +594,7 @@ public class ToolbarPhone extends ToolbarLayout
if (mLayoutLocationBarInFocusedMode if (mLayoutLocationBarInFocusedMode
|| (mVisualState == VisualState.NEW_TAB_NORMAL || (mVisualState == VisualState.NEW_TAB_NORMAL
&& mTabSwitcherState == STATIC_TAB)) { && mTabSwitcherState == STATIC_TAB)) {
int priorVisibleWidth = mLocationBar.getOffsetOfFirstVisibleFocusedView(); int priorVisibleWidth = mLocationBarPhone.getOffsetOfFirstVisibleFocusedView();
width = getFocusedLocationBarWidth(containerWidth, priorVisibleWidth); width = getFocusedLocationBarWidth(containerWidth, priorVisibleWidth);
leftMargin = getFocusedLocationBarLeftMargin(priorVisibleWidth); leftMargin = getFocusedLocationBarLeftMargin(priorVisibleWidth);
} else { } else {
...@@ -637,7 +637,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -637,7 +637,7 @@ public class ToolbarPhone extends ToolbarLayout
*/ */
private int getFocusedLocationBarLeftMargin(int priorVisibleWidth) { private int getFocusedLocationBarLeftMargin(int priorVisibleWidth) {
int baseMargin = mToolbarSidePadding; int baseMargin = mToolbarSidePadding;
if (mLocationBar.getLayoutDirection() == LAYOUT_DIRECTION_RTL) { if (mLocationBarPhone.getLayoutDirection() == LAYOUT_DIRECTION_RTL) {
return baseMargin; return baseMargin;
} else { } else {
return baseMargin - priorVisibleWidth; return baseMargin - priorVisibleWidth;
...@@ -741,7 +741,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -741,7 +741,7 @@ public class ToolbarPhone extends ToolbarLayout
} }
if (mLocationBarBackground != null if (mLocationBarBackground != null
&& (mLocationBar.getVisibility() == VISIBLE || mTextureCaptureMode)) { && (mLocationBarPhone.getVisibility() == VISIBLE || mTextureCaptureMode)) {
updateLocationBarBackgroundBounds(mLocationBarBackgroundBounds, mVisualState); updateLocationBarBackgroundBounds(mLocationBarBackgroundBounds, mVisualState);
} }
...@@ -811,8 +811,9 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -811,8 +811,9 @@ public class ToolbarPhone extends ToolbarLayout
// - The right most visible location bar child view. // - The right most visible location bar child view.
// - The bottom of the viewport is aligned with the bottom of the location bar. // - The bottom of the viewport is aligned with the bottom of the location bar.
// Additional padding can be applied for use during animations. // Additional padding can be applied for use during animations.
out.set(leftViewPosition, mLocationBar.getTop() + mLocationBarBackgroundVerticalInset, out.set(leftViewPosition, mLocationBarPhone.getTop() + mLocationBarBackgroundVerticalInset,
rightViewPosition, mLocationBar.getBottom() - mLocationBarBackgroundVerticalInset); rightViewPosition,
mLocationBarPhone.getBottom() - mLocationBarBackgroundVerticalInset);
} }
/** /**
...@@ -950,7 +951,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -950,7 +951,7 @@ public class ToolbarPhone extends ToolbarLayout
*/ */
private void updateLocationBarLayoutForExpansionAnimation() { private void updateLocationBarLayoutForExpansionAnimation() {
TraceEvent.begin("ToolbarPhone.updateLocationBarLayoutForExpansionAnimation"); TraceEvent.begin("ToolbarPhone.updateLocationBarLayoutForExpansionAnimation");
FrameLayout.LayoutParams locationBarLayoutParams = getFrameLayoutParams(mLocationBar); FrameLayout.LayoutParams locationBarLayoutParams = mLocationBarPhone.getFrameLayoutParams();
int currentLeftMargin = locationBarLayoutParams.leftMargin; int currentLeftMargin = locationBarLayoutParams.leftMargin;
int currentWidth = locationBarLayoutParams.width; int currentWidth = locationBarLayoutParams.width;
...@@ -980,10 +981,10 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -980,10 +981,10 @@ public class ToolbarPhone extends ToolbarLayout
boolean isIncognito = getToolbarDataProvider().isIncognito(); boolean isIncognito = getToolbarDataProvider().isIncognito();
if (SearchEngineLogoUtils.shouldShowSearchEngineLogo(isIncognito)) { if (SearchEngineLogoUtils.shouldShowSearchEngineLogo(isIncognito)) {
locationBarBaseTranslationX += locationBarBaseTranslationX +=
mLocationBar.getLocationBarOffsetForFocusAnimation(hasFocus()); mLocationBarPhone.getLocationBarOffsetForFocusAnimation(hasFocus());
} }
boolean isLocationBarRtl = mLocationBar.getLayoutDirection() == LAYOUT_DIRECTION_RTL; boolean isLocationBarRtl = mLocationBarPhone.getLayoutDirection() == LAYOUT_DIRECTION_RTL;
if (isLocationBarRtl) { if (isLocationBarRtl) {
locationBarBaseTranslationX += mUnfocusedLocationBarLayoutWidth - currentWidth; locationBarBaseTranslationX += mUnfocusedLocationBarLayoutWidth - currentWidth;
} }
...@@ -1020,13 +1021,13 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1020,13 +1021,13 @@ public class ToolbarPhone extends ToolbarLayout
locationBarTranslationX = locationBarBaseTranslationX + mLocationBarNtpOffsetLeft; locationBarTranslationX = locationBarBaseTranslationX + mLocationBarNtpOffsetLeft;
} }
mLocationBar.setTranslationX(locationBarTranslationX); mLocationBarPhone.setTranslationX(locationBarTranslationX);
// When the dse icon is enabled, the UrlBar needs additional translation to compensate for // When the dse icon is enabled, the UrlBar needs additional translation to compensate for
// the additional translation applied to the LocationBar. See comments in // the additional translation applied to the LocationBar. See comments in
// LocationBar#getUrlBarTranslationXForToolbarAnimation() for implementation details. // LocationBar#getUrlBarTranslationXForToolbarAnimation() for implementation details.
if (SearchEngineLogoUtils.shouldShowSearchEngineLogo(isIncognito)) { if (SearchEngineLogoUtils.shouldShowSearchEngineLogo(isIncognito)) {
mUrlBar.setTranslationX(mLocationBar.getUrlBarTranslationXForToolbarAnimation( mUrlBar.setTranslationX(mLocationBarPhone.getUrlBarTranslationXForToolbarAnimation(
mUrlExpansionFraction, hasFocus())); mUrlExpansionFraction, hasFocus()));
} else if (SearchEngineLogoUtils.isSearchEngineLogoEnabled()) { } else if (SearchEngineLogoUtils.isSearchEngineLogoEnabled()) {
mUrlBar.setTranslationX(0); mUrlBar.setTranslationX(0);
...@@ -1055,7 +1056,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1055,7 +1056,7 @@ public class ToolbarPhone extends ToolbarLayout
// Force an invalidation of the location bar to properly handle the clipping of the URL // 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. // bar text as a result of the URL action container translations.
mLocationBar.invalidate(); mLocationBarPhone.invalidate();
invalidate(); invalidate();
TraceEvent.end("ToolbarPhone.updateLocationBarLayoutForExpansionAnimation"); TraceEvent.end("ToolbarPhone.updateLocationBarLayoutForExpansionAnimation");
} }
...@@ -1096,7 +1097,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1096,7 +1097,7 @@ public class ToolbarPhone extends ToolbarLayout
mLocationBarBackgroundNtpOffset.setEmpty(); mLocationBarBackgroundNtpOffset.setEmpty();
mActiveLocationBarBackground = mLocationBarBackground; mActiveLocationBarBackground = mLocationBarBackground;
mNtpSearchBoxTranslation.set(0, 0); mNtpSearchBoxTranslation.set(0, 0);
mLocationBar.setTranslationY(0); mLocationBarPhone.setTranslationY(0);
if (!mUrlFocusChangeInProgress) { if (!mUrlFocusChangeInProgress) {
mToolbarButtonsContainer.setTranslationY(0); mToolbarButtonsContainer.setTranslationY(0);
if (mHomeButton != null) mHomeButton.setTranslationY(0); if (mHomeButton != null) mHomeButton.setTranslationY(0);
...@@ -1106,12 +1107,12 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1106,12 +1107,12 @@ public class ToolbarPhone extends ToolbarLayout
mToolbarShadow.setAlpha(mUrlBar.hasFocus() ? 0.f : 1.f); mToolbarShadow.setAlpha(mUrlBar.hasFocus() ? 0.f : 1.f);
} }
mLocationBar.setAlpha(1); mLocationBarPhone.setAlpha(1);
mForceDrawLocationBarBackground = false; mForceDrawLocationBarBackground = false;
mLocationBarBackgroundAlpha = 255; mLocationBarBackgroundAlpha = 255;
if (isIncognito() if (isIncognito()
|| (mUnfocusedLocationBarUsesTransparentBg && !mUrlFocusChangeInProgress || (mUnfocusedLocationBarUsesTransparentBg && !mUrlFocusChangeInProgress
&& !mLocationBar.hasFocus())) { && !mLocationBarPhone.hasFocus())) {
mLocationBarBackgroundAlpha = LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA; mLocationBarBackgroundAlpha = LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA;
} }
...@@ -1141,8 +1142,8 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1141,8 +1142,8 @@ public class ToolbarPhone extends ToolbarLayout
NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab(); NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab();
ntp.getSearchBoxBounds(mNtpSearchBoxBounds, mNtpSearchBoxTranslation); ntp.getSearchBoxBounds(mNtpSearchBoxBounds, mNtpSearchBoxTranslation);
int locationBarTranslationY = int locationBarTranslationY =
Math.max(0, (mNtpSearchBoxBounds.top - mLocationBar.getTop())); Math.max(0, (mNtpSearchBoxBounds.top - mLocationBarPhone.getTop()));
mLocationBar.setTranslationY(locationBarTranslationY); mLocationBarPhone.setTranslationY(locationBarTranslationY);
updateButtonsTranslationY(); updateButtonsTranslationY();
...@@ -1169,7 +1170,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1169,7 +1170,7 @@ public class ToolbarPhone extends ToolbarLayout
mLocationBarBackgroundAlpha = isExpanded ? 255 : 0; mLocationBarBackgroundAlpha = isExpanded ? 255 : 0;
mForceDrawLocationBarBackground = mLocationBarBackgroundAlpha > 0; mForceDrawLocationBarBackground = mLocationBarBackgroundAlpha > 0;
float relativeAlpha = mLocationBarBackgroundAlpha / 255f; float relativeAlpha = mLocationBarBackgroundAlpha / 255f;
mLocationBar.setAlpha(relativeAlpha); mLocationBarPhone.setAlpha(relativeAlpha);
// The search box on the NTP is visible if our omnibox is invisible, and vice-versa. // The search box on the NTP is visible if our omnibox is invisible, and vice-versa.
ntp.setSearchBoxAlpha(1f - relativeAlpha); ntp.setSearchBoxAlpha(1f - relativeAlpha);
...@@ -1234,13 +1235,13 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1234,13 +1235,13 @@ public class ToolbarPhone extends ToolbarLayout
} }
// Draw the location/URL bar. // Draw the location/URL bar.
previousAlpha = mLocationBar.getAlpha(); previousAlpha = mLocationBarPhone.getAlpha();
mLocationBar.setAlpha(previousAlpha * floatAlpha); mLocationBarPhone.setAlpha(previousAlpha * floatAlpha);
// If the location bar is now fully transparent, do not bother drawing it. // If the location bar is now fully transparent, do not bother drawing it.
if (mLocationBar.getAlpha() != 0 && isLocationBarCurrentlyShown()) { if (mLocationBarPhone.getAlpha() != 0 && isLocationBarCurrentlyShown()) {
drawChild(canvas, mLocationBar, SystemClock.uptimeMillis()); drawLocationBar(canvas, SystemClock.uptimeMillis());
} }
mLocationBar.setAlpha(previousAlpha); mLocationBarPhone.setAlpha(previousAlpha);
// Translate to draw end toolbar buttons. // Translate to draw end toolbar buttons.
ViewUtils.translateCanvasToView(this, mToolbarButtonsContainer, canvas); ViewUtils.translateCanvasToView(this, mToolbarButtonsContainer, canvas);
...@@ -1323,7 +1324,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1323,7 +1324,7 @@ public class ToolbarPhone extends ToolbarLayout
if (mLocationBarBackground != null) { if (mLocationBarBackground != null) {
canvas.save(); canvas.save();
int translationY = (int) mLocationBar.getTranslationY(); int translationY = (int) mLocationBarPhone.getTranslationY();
int clipTop = mLocationBarBackgroundBounds.top + translationY; int clipTop = mLocationBarBackgroundBounds.top + translationY;
if (mUrlExpansionFraction != 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.
...@@ -1416,19 +1417,17 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1416,19 +1417,17 @@ public class ToolbarPhone extends ToolbarLayout
// 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 (mLocationBarPhone.getLayoutDirection() == LAYOUT_DIRECTION_RTL) {
locationBarClipLeft += locationBarClipLeft += mLocationBarPhone.getPaddingStart() * remainingFraction;
ViewCompat.getPaddingStart(mLocationBar) * remainingFraction;
} else { } else {
locationBarClipRight -= locationBarClipRight -= mLocationBarPhone.getPaddingEnd() * remainingFraction;
ViewCompat.getPaddingEnd(mLocationBar) * remainingFraction;
} }
} }
if (mOptionalButtonAnimationRunning) { if (mOptionalButtonAnimationRunning) {
if (mLocationBar.getLayoutDirection() == LAYOUT_DIRECTION_RTL) { if (mLocationBarPhone.getLayoutDirection() == LAYOUT_DIRECTION_RTL) {
locationBarClipLeft += mLocationBar.getPaddingStart(); locationBarClipLeft += mLocationBarPhone.getPaddingStart();
} else { } else {
locationBarClipRight -= mLocationBar.getPaddingEnd(); locationBarClipRight -= mLocationBarPhone.getPaddingEnd();
} }
} }
...@@ -1436,10 +1435,10 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1436,10 +1435,10 @@ public class ToolbarPhone extends ToolbarLayout
// omnibox background when animating in. // omnibox background when animating in.
if (SearchEngineLogoUtils.shouldShowSearchEngineLogo(isIncognito()) if (SearchEngineLogoUtils.shouldShowSearchEngineLogo(isIncognito())
&& isLocationBarShownInNTP() && urlHasFocus() && mUrlFocusChangeInProgress) { && isLocationBarShownInNTP() && urlHasFocus() && mUrlFocusChangeInProgress) {
if (mLocationBar.getLayoutDirection() == LAYOUT_DIRECTION_RTL) { if (mLocationBarPhone.getLayoutDirection() == LAYOUT_DIRECTION_RTL) {
locationBarClipRight -= mLocationBar.getPaddingStart(); locationBarClipRight -= mLocationBarPhone.getPaddingStart();
} else { } else {
locationBarClipLeft += mLocationBar.getPaddingStart(); locationBarClipLeft += mLocationBarPhone.getPaddingStart();
} }
} }
...@@ -1449,7 +1448,9 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1449,7 +1448,9 @@ public class ToolbarPhone extends ToolbarLayout
clipped = true; clipped = true;
} }
boolean retVal = super.drawChild(canvas, mLocationBar, drawingTime); // TODO(1133482): Hide this View interaction if possible.
boolean retVal =
super.drawChild(canvas, mLocationBarPhone.getViewForDrawing(), drawingTime);
if (clipped) canvas.restore(); if (clipped) canvas.restore();
TraceEvent.end("ToolbarPhone.drawLocationBar"); TraceEvent.end("ToolbarPhone.drawLocationBar");
...@@ -1461,7 +1462,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1461,7 +1462,7 @@ public class ToolbarPhone extends ToolbarLayout
* {@link #drawLocationBar(Canvas, long)}. * {@link #drawLocationBar(Canvas, long)}.
*/ */
private boolean shouldDrawLocationBarBackground() { private boolean shouldDrawLocationBarBackground() {
return (mLocationBar.getAlpha() > 0 || mForceDrawLocationBarBackground) return (mLocationBarPhone.getAlpha() > 0 || mForceDrawLocationBarBackground)
&& !mTextureCaptureMode; && !mTextureCaptureMode;
} }
...@@ -1781,7 +1782,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1781,7 +1782,7 @@ public class ToolbarPhone extends ToolbarLayout
// crbug.com/974745. // crbug.com/974745.
requestLayout(); requestLayout();
mLocationBar.setUrlBarFocusable(false); mLocationBarPhone.setUrlBarFocusable(false);
finishAnimations(); finishAnimations();
...@@ -1864,7 +1865,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1864,7 +1865,7 @@ public class ToolbarPhone extends ToolbarLayout
// Detect what was being transitioned from and set the new state appropriately. // Detect what was being transitioned from and set the new state appropriately.
if (mTabSwitcherState == EXITING_TAB_SWITCHER) { if (mTabSwitcherState == EXITING_TAB_SWITCHER) {
mLocationBar.setUrlBarFocusable(true); mLocationBarPhone.setUrlBarFocusable(true);
mTabSwitcherState = STATIC_TAB; mTabSwitcherState = STATIC_TAB;
updateVisualsForLocationBarState(); updateVisualsForLocationBarState();
} }
...@@ -1956,7 +1957,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1956,7 +1957,7 @@ public class ToolbarPhone extends ToolbarLayout
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(animator); animators.add(animator);
mLocationBar.populateFadeAnimations( mLocationBarPhone.populateFadeAnimations(
animators, 0, URL_FOCUS_CHANGE_ANIMATION_DURATION_MS, 0); animators, 0, URL_FOCUS_CHANGE_ANIMATION_DURATION_MS, 0);
float density = getContext().getResources().getDisplayMetrics().density; float density = getContext().getResources().getDisplayMetrics().density;
...@@ -2046,7 +2047,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -2046,7 +2047,7 @@ public class ToolbarPhone extends ToolbarLayout
animators.add(animator); animators.add(animator);
} }
mLocationBar.populateFadeAnimations( mLocationBarPhone.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() && mNtpSearchBoxScrollFraction == 0f) return; if (isLocationBarShownInNTP() && mNtpSearchBoxScrollFraction == 0f) return;
...@@ -2116,7 +2117,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -2116,7 +2117,7 @@ public class ToolbarPhone extends ToolbarLayout
mLayoutLocationBarInFocusedMode = false; mLayoutLocationBarInFocusedMode = false;
requestLayout(); requestLayout();
} }
mLocationBar.finishUrlFocusChange(hasFocus); mLocationBarPhone.finishUrlFocusChange(hasFocus);
mUrlFocusChangeInProgress = false; mUrlFocusChangeInProgress = false;
if (getToolbarDataProvider().shouldShowLocationBarInOverviewMode()) { if (getToolbarDataProvider().shouldShowLocationBarInOverviewMode()) {
......
...@@ -32,7 +32,6 @@ import org.chromium.chrome.browser.download.DownloadUtils; ...@@ -32,7 +32,6 @@ import org.chromium.chrome.browser.download.DownloadUtils;
import org.chromium.chrome.browser.homepage.HomepageManager; import org.chromium.chrome.browser.homepage.HomepageManager;
import org.chromium.chrome.browser.ntp.NewTabPage; import org.chromium.chrome.browser.ntp.NewTabPage;
import org.chromium.chrome.browser.omnibox.LocationBar; import org.chromium.chrome.browser.omnibox.LocationBar;
import org.chromium.chrome.browser.omnibox.LocationBarTablet;
import org.chromium.chrome.browser.preferences.ChromePreferenceKeys; import org.chromium.chrome.browser.preferences.ChromePreferenceKeys;
import org.chromium.chrome.browser.preferences.SharedPreferencesManager; import org.chromium.chrome.browser.preferences.SharedPreferencesManager;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
...@@ -85,7 +84,8 @@ public class ToolbarTablet extends ToolbarLayout ...@@ -85,7 +84,8 @@ public class ToolbarTablet extends ToolbarLayout
private NavigationPopup mNavigationPopup; private NavigationPopup mNavigationPopup;
private Boolean mIsIncognito; private Boolean mIsIncognito;
private LocationBarTablet mLocationBar; private LocationBar mLocationBar;
private LocationBar.Tablet mLocationBarTablet;
private final int mStartPaddingWithButtons; private final int mStartPaddingWithButtons;
private final int mStartPaddingWithoutButtons; private final int mStartPaddingWithoutButtons;
...@@ -110,7 +110,8 @@ public class ToolbarTablet extends ToolbarLayout ...@@ -110,7 +110,8 @@ public class ToolbarTablet extends ToolbarLayout
@Override @Override
public void onFinishInflate() { public void onFinishInflate() {
super.onFinishInflate(); super.onFinishInflate();
mLocationBar = (LocationBarTablet) findViewById(R.id.location_bar); mLocationBar = (LocationBar) findViewById(R.id.location_bar);
mLocationBarTablet = (LocationBar.Tablet) mLocationBar;
mHomeButton = findViewById(R.id.home_button); mHomeButton = findViewById(R.id.home_button);
mBackButton = findViewById(R.id.back_button); mBackButton = findViewById(R.id.back_button);
...@@ -391,7 +392,7 @@ public class ToolbarTablet extends ToolbarLayout ...@@ -391,7 +392,7 @@ public class ToolbarTablet extends ToolbarLayout
setBackgroundColor(color); setBackgroundColor(color);
final int textBoxColor = ToolbarColors.getTextBoxColorForToolbarBackgroundInNonNativePage( final int textBoxColor = ToolbarColors.getTextBoxColorForToolbarBackgroundInNonNativePage(
getResources(), color, isIncognito()); getResources(), color, isIncognito());
mLocationBar.getBackground().setColorFilter(textBoxColor, PorterDuff.Mode.SRC_IN); mLocationBarTablet.getBackground().setColorFilter(textBoxColor, PorterDuff.Mode.SRC_IN);
mLocationBar.updateVisualsForState(); mLocationBar.updateVisualsForState();
} }
...@@ -428,7 +429,7 @@ public class ToolbarTablet extends ToolbarLayout ...@@ -428,7 +429,7 @@ public class ToolbarTablet extends ToolbarLayout
@Override @Override
void updateButtonVisibility() { void updateButtonVisibility() {
mLocationBar.updateButtonVisibility(); mLocationBarTablet.updateButtonVisibility();
} }
@Override @Override
...@@ -616,7 +617,7 @@ public class ToolbarTablet extends ToolbarLayout ...@@ -616,7 +617,7 @@ public class ToolbarTablet extends ToolbarLayout
for (ImageButton button : mToolbarButtons) { for (ImageButton button : mToolbarButtons) {
button.setVisibility(visible ? View.VISIBLE : View.GONE); button.setVisibility(visible ? View.VISIBLE : View.GONE);
} }
mLocationBar.setShouldShowButtonsWhenUnfocused(visible); mLocationBarTablet.setShouldShowButtonsWhenUnfocused(visible);
setStartPaddingBasedOnButtonVisibility(visible); setStartPaddingBasedOnButtonVisibility(visible);
} }
} }
...@@ -657,11 +658,11 @@ public class ToolbarTablet extends ToolbarLayout ...@@ -657,11 +658,11 @@ public class ToolbarTablet extends ToolbarLayout
// Create animators for all of the toolbar buttons. // Create animators for all of the toolbar buttons.
for (ImageButton button : mToolbarButtons) { for (ImageButton button : mToolbarButtons) {
animators.add(mLocationBar.createShowButtonAnimator(button)); animators.add(mLocationBarTablet.createShowButtonAnimator(button));
} }
// Add animators for location bar. // Add animators for location bar.
animators.addAll(mLocationBar.getShowButtonsWhenUnfocusedAnimators( animators.addAll(mLocationBarTablet.getShowButtonsWhenUnfocusedAnimators(
getStartPaddingDifferenceForButtonVisibilityAnimation())); getStartPaddingDifferenceForButtonVisibilityAnimation()));
AnimatorSet set = new AnimatorSet(); AnimatorSet set = new AnimatorSet();
...@@ -692,11 +693,11 @@ public class ToolbarTablet extends ToolbarLayout ...@@ -692,11 +693,11 @@ public class ToolbarTablet extends ToolbarLayout
// Create animators for all of the toolbar buttons. // Create animators for all of the toolbar buttons.
for (ImageButton button : mToolbarButtons) { for (ImageButton button : mToolbarButtons) {
animators.add(mLocationBar.createHideButtonAnimator(button)); animators.add(mLocationBarTablet.createHideButtonAnimator(button));
} }
// Add animators for location bar. // Add animators for location bar.
animators.addAll(mLocationBar.getHideButtonsWhenUnfocusedAnimators( animators.addAll(mLocationBarTablet.getHideButtonsWhenUnfocusedAnimators(
getStartPaddingDifferenceForButtonVisibilityAnimation())); getStartPaddingDifferenceForButtonVisibilityAnimation()));
AnimatorSet set = new AnimatorSet(); AnimatorSet set = new AnimatorSet();
......
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