Commit 156d069f authored by Theresa's avatar Theresa Committed by Commit Bot

[Modern] Polish modern top toolbar and omnibox suggestions styling

 - Update the toolbar shadow and use alpha animation instead of
   transition drawable for url focus
 - Fix composited url bar alpha to prevent C++ url bar background
   from being drawn
 - Remove top padding in suggestions list when modern is enabled

 BUG=803088,803618

Change-Id: I848c1168ef26955a2eeb9b81738941f5fa886dd4
Reviewed-on: https://chromium-review.googlesource.com/893530
Commit-Queue: Theresa <twellington@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533062}
parent dadd6c74
...@@ -81,11 +81,13 @@ public class TabListSceneLayer extends SceneLayer { ...@@ -81,11 +81,13 @@ public class TabListSceneLayer extends SceneLayer {
toolbarBackgroundColor = defaultThemeColor; toolbarBackgroundColor = defaultThemeColor;
textBoxBackgroundColor = ColorUtils.getTextBoxColorForToolbarBackground( textBoxBackgroundColor = ColorUtils.getTextBoxColorForToolbarBackground(
res, false, toolbarBackgroundColor, useModernDesign); res, false, toolbarBackgroundColor, useModernDesign);
// In the modern design, the text box is always drawn in the Java layer rather textBoxAlpha = t.isIncognito() ? textBoxAlpha : 1f;
// than the compositor layer.
textBoxAlpha = useModernDesign ? 0.f : t.isIncognito() ? textBoxAlpha : 1f;
} }
// In the modern design, the text box is always drawn in the Java layer rather
// than the compositor layer.
if (useModernDesign) textBoxAlpha = 0.f;
int closeButtonColor = int closeButtonColor =
ColorUtils.getThemedAssetColor(toolbarBackgroundColor, t.isIncognito()); ColorUtils.getThemedAssetColor(toolbarBackgroundColor, t.isIncognito());
......
...@@ -493,7 +493,7 @@ public class LocationBarLayout extends FrameLayout ...@@ -493,7 +493,7 @@ public class LocationBarLayout extends FrameLayout
mSuggestionDefinitionHeight = context.getResources().getDimensionPixelOffset( mSuggestionDefinitionHeight = context.getResources().getDimensionPixelOffset(
R.dimen.omnibox_suggestion_definition_height); R.dimen.omnibox_suggestion_definition_height);
int paddingTop = mBottomSheet != null int paddingTop = useModernDesign()
? 0 ? 0
: context.getResources().getDimensionPixelOffset( : context.getResources().getDimensionPixelOffset(
R.dimen.omnibox_suggestion_list_padding_top); R.dimen.omnibox_suggestion_list_padding_top);
......
...@@ -326,6 +326,11 @@ public class LocationBarTablet extends LocationBarLayout { ...@@ -326,6 +326,11 @@ public class LocationBarTablet extends LocationBarLayout {
} }
} }
@Override
public boolean useModernDesign() {
return false;
}
/** /**
* @param button The {@link View} of the button to show. * @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 * @return An animator to run for the given view when showing buttons in the unfocused location
......
...@@ -485,6 +485,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -485,6 +485,7 @@ public class ToolbarPhone extends ToolbarLayout
// native is loaded. // native is loaded.
if (mLocationBar.useModernDesign()) { if (mLocationBar.useModernDesign()) {
mNewTabButton.setIsModern(); mNewTabButton.setIsModern();
if (mToolbarShadow != null) mToolbarShadow.setImageDrawable(getToolbarShadowDrawable());
initLocationBarBackground(); initLocationBarBackground();
} }
...@@ -1114,7 +1115,10 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1114,7 +1115,10 @@ public class ToolbarPhone extends ToolbarLayout
mToolbarButtonsContainer.setTranslationY(0); mToolbarButtonsContainer.setTranslationY(0);
if (mHomeButton != null) mHomeButton.setTranslationY(0); if (mHomeButton != null) mHomeButton.setTranslationY(0);
} }
if (!mToolbarShadowPermanentlyHidden) mToolbarShadow.setAlpha(1f); if (!mToolbarShadowPermanentlyHidden) {
mToolbarShadow.setAlpha(
mLocationBar.useModernDesign() && mUrlBar.hasFocus() ? 0.f : 1.f);
}
mLocationBar.setAlpha(1); mLocationBar.setAlpha(1);
mForceDrawLocationBarBackground = false; mForceDrawLocationBarBackground = false;
mLocationBarBackgroundAlpha = 255; mLocationBarBackgroundAlpha = 255;
...@@ -1482,11 +1486,19 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1482,11 +1486,19 @@ public class ToolbarPhone extends ToolbarLayout
// This is a workaround for http://crbug.com/574928. Since Jelly Bean is the lowest version // This is a workaround for http://crbug.com/574928. Since Jelly Bean is the lowest version
// we support now and the next deprecation target, we decided to simply workaround. // we support now and the next deprecation target, we decided to simply workaround.
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN) { if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN) {
mToolbarShadow.setImageDrawable( mToolbarShadow.setImageDrawable(getToolbarShadowDrawable());
ApiCompatibilityUtils.getDrawable(getResources(), R.drawable.toolbar_shadow));
} }
} }
/**
* @return The {@link Drawable} to use for the toolbar shadow.
*/
private Drawable getToolbarShadowDrawable() {
return ApiCompatibilityUtils.getDrawable(getResources(),
mLocationBar.useModernDesign() ? R.drawable.modern_toolbar_shadow
: R.drawable.toolbar_shadow);
}
@Override @Override
public void draw(Canvas canvas) { public void draw(Canvas canvas) {
// If capturing a texture of the toolbar, ensure the alpha is set prior to draw(...) being // If capturing a texture of the toolbar, ensure the alpha is set prior to draw(...) being
...@@ -1941,6 +1953,13 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1941,6 +1953,13 @@ public class ToolbarPhone extends ToolbarLayout
animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE); animator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);
animators.add(animator); animators.add(animator);
} }
if (mLocationBar.useModernDesign()) {
animator = ObjectAnimator.ofFloat(mToolbarShadow, ALPHA, 0);
animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(animator);
}
} }
private void populateUrlClearFocusingAnimatorSet(List<Animator> animators) { private void populateUrlClearFocusingAnimatorSet(List<Animator> animators) {
...@@ -2012,6 +2031,13 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -2012,6 +2031,13 @@ public class ToolbarPhone extends ToolbarLayout
animators.add(animator); animators.add(animator);
} }
} }
if (mLocationBar.useModernDesign() && !isLocationBarShownInNTP()) {
animator = ObjectAnimator.ofFloat(mToolbarShadow, ALPHA, 1);
animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
animators.add(animator);
}
} }
@Override @Override
...@@ -2020,15 +2046,9 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -2020,15 +2046,9 @@ public class ToolbarPhone extends ToolbarLayout
triggerUrlFocusAnimation(hasFocus); triggerUrlFocusAnimation(hasFocus);
if (mToolbarShadowPermanentlyHidden) return; if (hasFocus) dismissTabSwitcherCallout();
TransitionDrawable shadowDrawable = (TransitionDrawable) mToolbarShadow.getDrawable(); transitionShadowDrawable(hasFocus);
if (hasFocus) {
dismissTabSwitcherCallout();
shadowDrawable.startTransition(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
} else {
shadowDrawable.reverseTransition(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
}
} }
protected void triggerUrlFocusAnimation(final boolean hasFocus) { protected void triggerUrlFocusAnimation(final boolean hasFocus) {
...@@ -2253,10 +2273,24 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -2253,10 +2273,24 @@ public class ToolbarPhone extends ToolbarLayout
protected void handleFindToolbarStateChange(boolean showing) { protected void handleFindToolbarStateChange(boolean showing) {
setVisibility(showing ? View.GONE : View.VISIBLE); setVisibility(showing ? View.GONE : View.VISIBLE);
transitionShadowDrawable(showing);
}
/**
* Transition the shadow drawable, if a transition drawable is being used.
* @param startTransition Whether the transition, showing the second layer on top of the first,
* should begin. See {@link TransitionDrawable#startTransition(int)}.
* If false, the transition will be reversed.
* See {@link TransitionDrawable#reverseTransition(int)}.
*/
private void transitionShadowDrawable(boolean startTransition) {
if (mToolbarShadowPermanentlyHidden) return; if (mToolbarShadowPermanentlyHidden) return;
// Modern does not use a transition drawable for the shadow.
if (mLocationBar.useModernDesign()) return;
TransitionDrawable shadowDrawable = (TransitionDrawable) mToolbarShadow.getDrawable(); TransitionDrawable shadowDrawable = (TransitionDrawable) mToolbarShadow.getDrawable();
if (showing) { if (startTransition) {
shadowDrawable.startTransition(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS); shadowDrawable.startTransition(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
} else { } else {
shadowDrawable.reverseTransition(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS); shadowDrawable.reverseTransition(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
......
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