Commit 9cdeda40 authored by Mehran Mahmoudi's avatar Mehran Mahmoudi Committed by Commit Bot

[TTS] Fix padding problem with BarBanner

The TextView in BarBanner for Contextual Search was not vertically aligned, but instead fixed at a vertical position. This CL vertically aligns the TextView.

Change-Id: I7ffaf487ab7c93b98f530b49ae72f077237445ca
Reviewed-on: https://chromium-review.googlesource.com/795172
Commit-Queue: Mehran Mahmoudi <mahmoudi@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Reviewed-by: default avatarDonn Denman <donnd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520731}
parent aeb6e407
......@@ -107,7 +107,6 @@
<dimen name="infobar_translate_menu_width">260dp</dimen>
<!-- Contextual search dimensions -->
<dimen name="contextual_search_bar_banner_height">48dp</dimen>
<dimen name="contextual_search_bar_banner_padding">12dp</dimen>
<dimen name="contextual_search_bar_image_size">36dp</dimen>
<!-- The following two dimensions were taking from the UI specs for contextual search, where
......
......@@ -56,9 +56,10 @@ public class ContextualSearchBarBannerControl extends OverlayPanelInflater {
private final float mPaddingPx;
/**
* The precomputed default height of the Bar Banner in pixels.
* The padded height of the Bar Banner in pixels. Set to zero initially, calculated on the first
* call.
*/
private final float mDefaultHeightPx;
private float mPaddedHeightPx = 0.f;
/**
* The precomputed minimum width of the Ripple resource in pixels.
......@@ -83,8 +84,6 @@ public class ContextualSearchBarBannerControl extends OverlayPanelInflater {
final float dpToPx = context.getResources().getDisplayMetrics().density;
mDefaultHeightPx = context.getResources().getDimensionPixelOffset(
R.dimen.contextual_search_bar_banner_height);
mPaddingPx = context.getResources().getDimensionPixelOffset(
R.dimen.contextual_search_bar_banner_padding);
......@@ -100,7 +99,7 @@ public class ContextualSearchBarBannerControl extends OverlayPanelInflater {
if (mIsVisible) return;
mIsVisible = true;
mHeightPx = Math.round(mDefaultHeightPx);
mHeightPx = Math.round(getPaddedHeightPx());
invalidate();
}
......@@ -120,7 +119,20 @@ public class ContextualSearchBarBannerControl extends OverlayPanelInflater {
* @return The height of the Bar Banner when the Panel is the peeked state.
*/
float getHeightPeekingPx() {
return mIsVisible ? mDefaultHeightPx : 0.f;
return mIsVisible ? getPaddedHeightPx() : 0.f;
}
/** Calculates the padded height of the bar banner if it has not been calculated before.
* @return The padded height of the Bar Banner.
*/
private float getPaddedHeightPx() {
if (mPaddedHeightPx == 0.f) {
// Calculate the padded height based on the measured height of the TextView.
inflate();
layout();
mPaddedHeightPx = getMeasuredHeight() + (2 * mPaddingPx);
}
return mPaddedHeightPx;
}
// ============================================================================================
......@@ -194,7 +206,7 @@ public class ContextualSearchBarBannerControl extends OverlayPanelInflater {
public void onUpdateFromCloseToPeek(float percentage) {
if (!isVisible()) return;
mHeightPx = Math.round(mDefaultHeightPx);
mHeightPx = Math.round(getPaddedHeightPx());
}
/**
......@@ -205,7 +217,7 @@ public class ContextualSearchBarBannerControl extends OverlayPanelInflater {
public void onUpdateFromPeekToExpand(float percentage) {
if (!isVisible()) return;
mHeightPx = Math.round(MathUtils.interpolate(mDefaultHeightPx, 0.f, percentage));
mHeightPx = Math.round(MathUtils.interpolate(getPaddedHeightPx(), 0.f, percentage));
mTextOpacity = MathUtils.interpolate(1.f, 0.f, percentage);
}
......
......@@ -65,7 +65,6 @@ public class MockResourcesForLayout extends MockResources {
mStrings.put(R.string.tab_loading_default_title, "Loading...");
mFloats.put(org.chromium.chrome.R.dimen.overlay_panel_bar_height, 56.f);
mFloats.put(org.chromium.chrome.R.dimen.control_container_height, 56.f);
mFloats.put(org.chromium.chrome.R.dimen.contextual_search_bar_banner_height, 48.f);
mFloats.put(org.chromium.chrome.R.dimen.contextual_search_bar_banner_padding, 12.f);
mFloats.put(org.chromium.chrome.R.dimen.contextual_search_end_button_width, 41.f);
mFloats.put(org.chromium.chrome.R.dimen.toolbar_height_no_shadow, 56.f);
......
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