| Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/CardViewHolder.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/CardViewHolder.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/CardViewHolder.java
|
| index c5a2ef4e8e4ba590433cc31f6878ceba029fb3b4..5f72f1c169ac87cf68d83fad3142d7d7e8479377 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/CardViewHolder.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/CardViewHolder.java
|
| @@ -13,6 +13,8 @@
|
| import android.view.animation.Interpolator;
|
|
|
| import org.chromium.chrome.R;
|
| +import org.chromium.chrome.browser.ntp.DisplayStyleObserver;
|
| +import org.chromium.chrome.browser.ntp.UiConfig;
|
| import org.chromium.chrome.browser.util.MathUtils;
|
|
|
| /**
|
| @@ -45,6 +47,9 @@
|
|
|
| private final NewTabPageRecyclerView mRecyclerView;
|
|
|
| + private final UiConfig mConfig;
|
| + private final int mWideMarginSizePixels;
|
| +
|
| /**
|
| * Current padding value. The padding and the margins are manipulated together to create the
|
| * shrunk/peeking appearance of the cards. When the padding is low, the margins are high and
|
| @@ -58,8 +63,11 @@
|
| * @param layoutId resource id of the layout to inflate and to use as card.
|
| * @param recyclerView ViewGroup that will contain the newly created view.
|
| */
|
| - public CardViewHolder(int layoutId, final NewTabPageRecyclerView recyclerView) {
|
| + public CardViewHolder(
|
| + int layoutId, final NewTabPageRecyclerView recyclerView, UiConfig config) {
|
| super(inflateView(layoutId, recyclerView));
|
| + mWideMarginSizePixels = itemView.getResources().getDimensionPixelSize(
|
| + R.dimen.ntp_wide_card_lateral_margins);
|
|
|
| mCards9PatchAdjustment = recyclerView.getResources().getDimensionPixelSize(
|
| R.dimen.snippets_card_9_patch_adjustment);
|
| @@ -81,6 +89,9 @@ public void onClick(View v) {
|
| }
|
| }
|
| });
|
| +
|
| + mConfig = config;
|
| + new DisplayStyleObserver.ViewAdapter(itemView, mConfig, new MarginResizer(itemView));
|
| }
|
|
|
| /**
|
| @@ -152,13 +163,23 @@ private void setPeekingStateForPadding(int padding) {
|
|
|
| // Modify the padding so as the margin increases, the padding decreases, keeping the card's
|
| // contents in the same position. The top and bottom remain the same.
|
| - itemView.setPadding(mPeekPadding, mMaxPeekPadding, mPeekPadding, mMaxPeekPadding);
|
| + int lateralPadding;
|
| + int lateralMargin;
|
| + if (mConfig.getDisplayStyle() != UiConfig.DISPLAY_STYLE_WIDE) {
|
| + lateralPadding = mPeekPadding;
|
| + lateralMargin = mMaxPeekPadding - (mPeekPadding + mCards9PatchAdjustment);
|
| + } else {
|
| + lateralPadding = mMaxPeekPadding;
|
| + lateralMargin = mWideMarginSizePixels;
|
| + }
|
| +
|
| + itemView.setPadding(lateralPadding, mMaxPeekPadding, lateralPadding, mMaxPeekPadding);
|
|
|
| // This mCards9PatchAdjustment value will be used to adjust the padding so the card width
|
| // is the actual width not including the elevation shadow so we can have full bleed.
|
| RecyclerView.LayoutParams params = getParams();
|
| - params.leftMargin = mMaxPeekPadding - (mPeekPadding + mCards9PatchAdjustment);
|
| - params.rightMargin = mMaxPeekPadding - (mPeekPadding + mCards9PatchAdjustment);
|
| + params.leftMargin = lateralMargin;
|
| + params.rightMargin = lateralMargin;
|
|
|
| // Set the opacity of the card content to be 0 when peeking and 1 when full width.
|
| int itemViewChildCount = ((ViewGroup) itemView).getChildCount();
|
|
|