Commit 0212bf00 authored by Cathy Li's avatar Cathy Li Committed by Commit Bot

Resize header views for feed v2

Bug: 1113427, b/161142289
Change-Id: I871b8012af71674d6e0e79a3a0b73dcbf03c686c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2365393
Commit-Queue: Cathy Li <chili@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarJustin DeWitt <dewittj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801184}
parent 294960b5
......@@ -4,6 +4,7 @@
package org.chromium.chrome.browser.feed.v2;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -13,6 +14,7 @@ import android.widget.FrameLayout;
import androidx.annotation.Nullable;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.xsurface.FeedActionsHandler;
import org.chromium.chrome.browser.xsurface.ListContentManager;
import org.chromium.chrome.browser.xsurface.ListContentManagerObserver;
......@@ -105,9 +107,9 @@ public class FeedListContentManager implements ListContentManager {
* Returns the native view if the content is supported by it. Null otherwise.
*/
public View getNativeView(ViewGroup parent) {
Context context = parent.getContext();
if (mNativeView == null) {
mNativeView =
LayoutInflater.from(parent.getContext()).inflate(mResId, parent, false);
mNativeView = LayoutInflater.from(context).inflate(mResId, parent, false);
}
// If there's already a parent, we have already enclosed this view previously.
......@@ -119,8 +121,13 @@ public class FeedListContentManager implements ListContentManager {
}
FrameLayout enclosingLayout = new FrameLayout(parent.getContext());
enclosingLayout.setLayoutParams(
// Set the left and right margins.
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
layoutParams.leftMargin = context.getResources().getDimensionPixelSize(
R.dimen.ntp_header_lateral_margins_v2);
layoutParams.rightMargin = layoutParams.leftMargin;
enclosingLayout.setLayoutParams(layoutParams);
enclosingLayout.addView(mNativeView);
return enclosingLayout;
}
......
......@@ -359,9 +359,10 @@
<dimen name="ntp_wide_card_lateral_margins">48dp</dimen>
<dimen name="ntp_wide_card_lateral_margins_v2">36dp</dimen>
<dimen name="snippets_article_header_height">40dp</dimen>
<dimen name="ntp_header_lateral_margins_v2">16dp</dimen>
<!-- This is in sp because we want the icon to scale with the TextView it sits alongside. -->
<dimen name="content_suggestions_card_modern_margin">12dp</dimen>
<dimen name="content_suggestions_card_modern_margin_v2">0dp</dimen>
<!-- This is in sp because we want the icon to scale with the TextView it sits alongside. -->
<dimen name="md_incognito_ntp_line_spacing">6sp</dimen>
<dimen name="md_incognito_ntp_padding_left">16dp</dimen>
<dimen name="cryptid_height_in_logo_wrapper">60dp</dimen>
......
......@@ -126,7 +126,7 @@ public class FeedStreamSurfaceTest {
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mActivity = Robolectric.buildActivity(Activity.class).get();
mActivity = Robolectric.buildActivity(Activity.class).setup().get();
mParent = new LinearLayout(mActivity);
mocker.mock(FeedStreamSurfaceJni.TEST_HOOKS, mFeedStreamSurfaceJniMock);
mocker.mock(FeedServiceBridgeJni.TEST_HOOKS, mFeedServiceBridgeJniMock);
......
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