Commit 00ba3be9 authored by Justin DeWitt's avatar Justin DeWitt Committed by Commit Bot

[Feed V2] Update the menu header visual style to match spec

This changes:
* Removes the hairline around the menu
* Widens the menu view so that the gear and the cog are aligned with the
  edges of card content

New Screenshots:
Feed V2 Enabled: https://screenshot.googleplex.com/7X8V4WTYgTx9EUW
Feed V2 Turned Off: https://screenshot.googleplex.com/9UJLL9uDcjNGjyQ

Bug: 1123996
Change-Id: I8db77160cbae5e0121dfc3397d732b81532ff56a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2388261
Commit-Queue: Justin DeWitt <dewittj@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Reviewed-by: default avatarVincent Boisselle <vincb@google.com>
Reviewed-by: default avatarCathy Li <chili@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804311}
parent 62be58d1
...@@ -914,6 +914,7 @@ chrome_java_resources = [ ...@@ -914,6 +914,7 @@ chrome_java_resources = [
"java/res/layout/navigation_sheet.xml", "java/res/layout/navigation_sheet.xml",
"java/res/layout/navigation_sheet_toolbar.xml", "java/res/layout/navigation_sheet_toolbar.xml",
"java/res/layout/new_tab_page_cryptid_holder.xml", "java/res/layout/new_tab_page_cryptid_holder.xml",
"java/res/layout/new_tab_page_feed_v2_expandable_header.xml",
"java/res/layout/new_tab_page_incognito.xml", "java/res/layout/new_tab_page_incognito.xml",
"java/res/layout/new_tab_page_layout.xml", "java/res/layout/new_tab_page_layout.xml",
"java/res/layout/new_tab_page_offline_card.xml", "java/res/layout/new_tab_page_offline_card.xml",
......
...@@ -32,4 +32,8 @@ public final class FeedFeatures { ...@@ -32,4 +32,8 @@ public final class FeedFeatures {
&& CachedFeatureFlags.isEnabled( && CachedFeatureFlags.isEnabled(
ChromeFeatureList.REPORT_FEED_USER_ACTIONS)); ChromeFeatureList.REPORT_FEED_USER_ACTIONS));
} }
public static boolean isV2Enabled() {
return ChromeFeatureList.isEnabled(ChromeFeatureList.INTEREST_FEED_V2);
}
} }
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2020 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<org.chromium.chrome.browser.ntp.snippets.SectionHeaderView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/snippets_article_header_height"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layoutDirection="locale"
app:showHairlineWhenDisabled="false">
<!-- Note: Setting textDirection to "locale" makes sure that a non-translated English word in
the title text view is aligned based on the device locale and not the text content.
-->
<TextView
android:id="@+id/header_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="@style/TextAppearance.TextAccentMediumThick.Secondary"
android:textDirection="locale" />
<org.chromium.components.browser_ui.widget.listmenu.ListMenuButton
android:id="@+id/header_menu"
android:layout_width="@dimen/snippets_article_header_menu_size"
android:layout_height="@dimen/snippets_article_header_menu_size"
android:scaleType="fitXY"
android:padding="15dp"
android:layout_marginTop="@dimen/feed_v2_header_menu_vertical_inset"
android:layout_marginBottom="@dimen/feed_v2_header_menu_vertical_inset"
android:layout_marginEnd="@dimen/feed_v2_header_menu_end_inset"
android:background="@null"
android:src="@drawable/ic_settings_gear_24dp"
android:contentDescription="@string/accessibility_ntp_feed_menu_button"
app:menuMaxWidth="@dimen/feed_header_menu_max_width"
app:tint="@color/default_icon_color_tint_list" />
</org.chromium.chrome.browser.ntp.snippets.SectionHeaderView>
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
<org.chromium.components.browser_ui.widget.listmenu.ListMenuButton <org.chromium.components.browser_ui.widget.listmenu.ListMenuButton
android:id="@+id/header_menu" android:id="@+id/header_menu"
android:layout_width="48dp" android:layout_width="@dimen/snippets_article_header_menu_size"
android:layout_height="48dp" android:layout_height="@dimen/snippets_article_header_menu_size"
android:scaleType="fitXY" android:scaleType="fitXY"
android:padding="15dp" android:padding="15dp"
android:background="@null" android:background="@null"
......
...@@ -20,4 +20,8 @@ ...@@ -20,4 +20,8 @@
<declare-styleable name="ExploreSitesTileView"> <declare-styleable name="ExploreSitesTileView">
<attr name="iconCornerRadius" format="dimension"/> <attr name="iconCornerRadius" format="dimension"/>
</declare-styleable> </declare-styleable>
<declare-styleable name="SectionHeaderView">
<attr name="showHairlineWhenDisabled" format="boolean"/>
</declare-styleable>
</resources> </resources>
...@@ -359,6 +359,10 @@ ...@@ -359,6 +359,10 @@
<dimen name="ntp_wide_card_lateral_margins">48dp</dimen> <dimen name="ntp_wide_card_lateral_margins">48dp</dimen>
<dimen name="ntp_wide_card_lateral_margins_v2">36dp</dimen> <dimen name="ntp_wide_card_lateral_margins_v2">36dp</dimen>
<dimen name="snippets_article_header_height">40dp</dimen> <dimen name="snippets_article_header_height">40dp</dimen>
<dimen name="snippets_article_header_menu_size">48dp</dimen>
<dimen name="feed_v2_header_menu_vertical_inset">-4dp</dimen>
<!-- This should match |ntp_header_lateral_margins_v2|. -->
<dimen name="feed_v2_header_menu_end_inset">-16dp</dimen>
<dimen name="ntp_header_lateral_margins_v2">16dp</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. --> <!-- 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">12dp</dimen>
......
...@@ -420,7 +420,11 @@ public class NewTabPage implements NativePage, InvalidationAwareThumbnailProvide ...@@ -420,7 +420,11 @@ public class NewTabPage implements NativePage, InvalidationAwareThumbnailProvide
// Determine the feed header to use. // Determine the feed header to use.
final SectionHeaderView sectionHeaderView; final SectionHeaderView sectionHeaderView;
if (FeedFeatures.isReportingUserActions()) { if (FeedFeatures.isV2Enabled()) {
sectionHeaderView = (SectionHeaderView) inflater.inflate(
R.layout.new_tab_page_feed_v2_expandable_header, null, false);
} else if (FeedFeatures.isReportingUserActions()) {
sectionHeaderView = (SectionHeaderView) inflater.inflate( sectionHeaderView = (SectionHeaderView) inflater.inflate(
R.layout.new_tab_page_snippets_expandable_header_with_menu, null, false); R.layout.new_tab_page_snippets_expandable_header_with_menu, null, false);
} else { } else {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.ntp.snippets; package org.chromium.chrome.browser.ntp.snippets;
import android.content.Context; import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect; import android.graphics.Rect;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
...@@ -44,9 +45,19 @@ public class SectionHeaderView extends LinearLayout implements View.OnClickListe ...@@ -44,9 +45,19 @@ public class SectionHeaderView extends LinearLayout implements View.OnClickListe
private SectionHeader mHeader; private SectionHeader mHeader;
private boolean mHasMenu; private boolean mHasMenu;
private boolean mHairlineWhenDisabled = true;
public SectionHeaderView(Context context, @Nullable AttributeSet attrs) { public SectionHeaderView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs); super(context, attrs);
TypedArray attrArray = context.getTheme().obtainStyledAttributes(
attrs, R.styleable.SectionHeaderView, 0, 0);
try {
mHairlineWhenDisabled = attrArray.getBoolean(
R.styleable.SectionHeaderView_showHairlineWhenDisabled, true);
} finally {
attrArray.recycle();
}
} }
@Override @Override
...@@ -103,8 +114,9 @@ public class SectionHeaderView extends LinearLayout implements View.OnClickListe ...@@ -103,8 +114,9 @@ public class SectionHeaderView extends LinearLayout implements View.OnClickListe
mStatusView.setText( mStatusView.setText(
mHeader.isExpanded() ? R.string.hide_content : R.string.show_content); mHeader.isExpanded() ? R.string.hide_content : R.string.show_content);
} }
setBackgroundResource( setBackgroundResource(mHeader.isExpanded() || !mHairlineWhenDisabled
mHeader.isExpanded() ? 0 : R.drawable.hairline_border_card_background); ? 0
: R.drawable.hairline_border_card_background);
} }
} }
......
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