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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageLayout.java

Issue 1812293002: Add new NTP layout with snippet cards and hide it behind a flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase + CR comments + added background color to new NTP Created 4 years, 9 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/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 da2234d7509b8cdf7b6a09670c3321e4f43edfe6..c248150978bfbaf7c3c58f258acb3061b0e22ca0 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
@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.ntp;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
+import android.view.View.MeasureSpec;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.widget.BoundedLinearLayout;
@@ -37,6 +38,10 @@ public class NewTabPageLayout extends BoundedLinearLayout {
private View mBottomSpacer;
private View mScrollCompensationSpacer;
+ private LogoView mSearchProviderLogoView;
+ private View mSearchBoxView;
+ private int mMostVisitedWidth;
+
/**
* Constructor for inflating from XML.
*/
@@ -56,6 +61,8 @@ public class NewTabPageLayout extends BoundedLinearLayout {
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);
}
/**
@@ -71,6 +78,16 @@ public class NewTabPageLayout extends BoundedLinearLayout {
mParentScrollViewportHeight = height;
}
+ /**
+ * Set the width of the most visited sites view. This is needed so the logo can be resized to
+ * exactly the same size as the most visited sites view.
+ *
+ * @param width of the most visited sites view as extracted using MeasureSpec.getSize()
+ */
+ public void setMostVisitedWidth(int width) {
newt (away) 2016/03/24 19:47:39 As mentioned in NewTabPageView, this method should
dgn 2016/03/28 21:33:02 Done.
+ mMostVisitedWidth = width;
+ }
+
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
mScrollCompensationSpacer.getLayoutParams().height = 0;
@@ -107,6 +124,16 @@ public class NewTabPageLayout extends BoundedLinearLayout {
} else {
mScrollCompensationSpacer.setVisibility(View.GONE);
}
+
+ // Make the search box and logo as wide as the most visited items
+ int mostVisitedWidthSpec =
May 2016/03/24 07:21:20 To whoever takes over this CL: This (line 129 - 13
dgn 2016/03/28 21:33:02 Done.
+ MeasureSpec.makeMeasureSpec(mMostVisitedWidth, 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);
}
/**

Powered by Google App Engine
This is Rietveld 408576698