Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageLayout.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageLayout.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageLayout.java |
| index ed07b24b808799a63c7534d99b78318c5b591569..4b27926501402d0674753e2714ffad1fa51ab028 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageLayout.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageLayout.java |
| @@ -5,6 +5,7 @@ |
| package org.chromium.chrome.browser.ntp; |
| import android.content.Context; |
| +import android.content.res.Resources; |
| import android.util.AttributeSet; |
| import android.view.View; |
| @@ -29,6 +30,7 @@ |
| private final int mMiddleSpacerHeight; |
| private final int mBottomSpacerHeight; |
| private final int mTotalSpacerHeight; |
| + private final int mMostVisitedLayoutBleed; |
| private int mParentScrollViewportHeight; |
| @@ -37,16 +39,22 @@ |
| private View mBottomSpacer; |
| private View mScrollCompensationSpacer; |
| + private LogoView mSearchProviderLogoView; |
| + private View mSearchBoxView; |
| + private MostVisitedLayout mMostVisitedLayout; |
| + |
| /** |
| * Constructor for inflating from XML. |
| */ |
| public NewTabPageLayout(Context context, AttributeSet attrs) { |
| super(context, attrs); |
| - float density = getResources().getDisplayMetrics().density; |
| + Resources res = getResources(); |
| + float density = res.getDisplayMetrics().density; |
| mTopSpacerHeight = Math.round(density * TOP_SPACER_HEIGHT_DP); |
| mMiddleSpacerHeight = Math.round(density * MIDDLE_SPACER_HEIGHT_DP); |
| mBottomSpacerHeight = Math.round(density * BOTTOM_SPACER_HEIGHT_DP); |
| mTotalSpacerHeight = Math.round(density * TOTAL_SPACER_HEIGHT_DP); |
| + mMostVisitedLayoutBleed = res.getDimensionPixelSize(R.dimen.most_visited_layout_bleed); |
| } |
| @Override |
| @@ -56,6 +64,9 @@ protected void onFinishInflate() { |
| mMiddleSpacer = findViewById(R.id.ntp_middle_spacer); |
| mBottomSpacer = findViewById(R.id.ntp_bottom_spacer); |
| mScrollCompensationSpacer = findViewById(R.id.ntp_scroll_spacer); |
| + mSearchProviderLogoView = (LogoView) findViewById(R.id.search_provider_logo); |
| + mSearchBoxView = findViewById(R.id.search_box); |
| + mMostVisitedLayout = (MostVisitedLayout) findViewById(R.id.most_visited_layout); |
| } |
| /** |
| @@ -106,6 +117,23 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
| } else { |
| mScrollCompensationSpacer.setVisibility(View.GONE); |
| } |
| + |
| + // Make the search box and logo as wide as the most visited items |
|
newt (away)
2016/03/30 19:03:50
Why not use the old simpler logic?
if (mMostV
dgn
2016/03/31 00:46:44
That's to address May's comment here: https://code
|
| + int mostVisitedWidth = 0; |
| + if (mMostVisitedLayout.getVisibility() != GONE) { |
| + mostVisitedWidth = mMostVisitedLayout.getMeasuredWidth() - mMostVisitedLayoutBleed; |
| + } |
| + |
| + if (mostVisitedWidth > 0) { |
| + int mostVisitedWidthSpec = |
| + MeasureSpec.makeMeasureSpec(mostVisitedWidth, MeasureSpec.EXACTLY); |
| + int searchBoxHeight = MeasureSpec.makeMeasureSpec( |
| + mSearchBoxView.getMeasuredHeight(), MeasureSpec.EXACTLY); |
| + mSearchBoxView.measure(mostVisitedWidthSpec, searchBoxHeight); |
| + int logoHeight = MeasureSpec.makeMeasureSpec( |
| + mSearchProviderLogoView.getMeasuredHeight(), MeasureSpec.EXACTLY); |
| + mSearchProviderLogoView.measure(mostVisitedWidthSpec, logoHeight); |
| + } |
| } |
| /** |