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

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

Issue 2144413003: NTP, peeking card and heading hiding constraints (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changes Created 4 years, 5 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
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/CardViewHolder.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a4e1f4fa6697b98e31fda6a70947f4b0ef97f340..6a2c4ebdc18daa6518527439f0077c2916dae568 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
@@ -93,7 +93,6 @@ public class NewTabPageLayout extends LinearLayout {
/**
* Sets whether the cards UI is enabled.
- * This view assumes that a peeking card will always be present when the cards UI is used.
*/
public void setUseCardsUiEnabled(boolean useCardsUi) {
mCardsUiEnabled = useCardsUi;
@@ -107,31 +106,29 @@ public class NewTabPageLayout extends LinearLayout {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (getMeasuredHeight() > mParentViewportHeight) {
- // This layout is bigger than its parent's viewport, so the user will need to scroll
- // to see all of it. Extra spacing should be added at the bottom so the user can scroll
- // until Most Visited is at the top.
-
- // The top, middle, and bottom spacers should have a measured height of 0 at this point
- // since they use weights to set height, and there was no extra space.
- assert mTopSpacer.getMeasuredHeight() == 0;
- assert mMiddleSpacer.getMeasuredHeight() == 0;
- assert mBottomSpacer.getMeasuredHeight() == 0;
-
- final int topOfMostVisited = calculateTopOfMostVisited();
- final int belowTheFoldHeight = getMeasuredHeight() - mParentViewportHeight;
- if (belowTheFoldHeight < topOfMostVisited) {
- mScrollCompensationSpacer.getLayoutParams().height =
- topOfMostVisited - belowTheFoldHeight;
-
- if (mCardsUiEnabled) {
- // If we have a peeking card, allow that to show at the bottom of the screen.
- mScrollCompensationSpacer.getLayoutParams().height -= mPeekingCardHeight;
+ // No scroll spacing needed when using the cards ui.
+ if (!mCardsUiEnabled) {
+ // This layout is bigger than its parent's viewport, so the user will need to scroll
+ // to see all of it. Extra spacing should be added at the bottom so the user can
+ // scroll until Most Visited is at the top.
+
+ // The top, middle, and bottom spacers should have a measured height of 0 at this
+ // point since they use weights to set height, and there was no extra space.
+ assert mTopSpacer.getMeasuredHeight() == 0;
+ assert mMiddleSpacer.getMeasuredHeight() == 0;
+ assert mBottomSpacer.getMeasuredHeight() == 0;
+
+ final int topOfMostVisited = calculateTopOfMostVisited();
+ final int belowTheFoldHeight = getMeasuredHeight() - mParentViewportHeight;
+ if (belowTheFoldHeight < topOfMostVisited) {
+ // Include the scroll spacer in the layout and call super.onMeasure again so it
+ // is measured.
+ mScrollCompensationSpacer.getLayoutParams().height =
+ topOfMostVisited - belowTheFoldHeight;
+
+ mScrollCompensationSpacer.setVisibility(View.INVISIBLE);
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
-
- // Include the scroll spacer in the layout and call super.onMeasure again so it is
- // measured.
- mScrollCompensationSpacer.setVisibility(View.INVISIBLE);
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
} else {
// This layout is smaller than or equal to its parent viewport. Redistribute any
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/CardViewHolder.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698