Commit b61bcf7b authored by spdonghao's avatar spdonghao Committed by Commit Bot

[Instant Start] Add Feed placeholder header with menu.

Bug: 1076139
Change-Id: Iceed665287c5bf438b240a53e6379704e15edc59
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2293217
Commit-Queue: Hao Dong <spdonghao@chromium.org>
Reviewed-by: default avatarHenrique Nakashima <hnakashima@chromium.org>
Reviewed-by: default avatarXi Han <hanxi@chromium.org>
Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790870}
parent f888178b
......@@ -8,29 +8,10 @@
android:orientation="vertical">
<LinearLayout
android:id="@+id/feed_placeholder_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="@dimen/snippets_article_header_height"
android:orientation="horizontal"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<TextView
android:id="@+id/header_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingStart="6dp"
android:textAlignment="viewStart"
android:textAppearance="@style/TextAppearance.TextMediumThick.Primary" />
<TextView
android:id="@+id/header_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.TextMedium.Blue" />
</LinearLayout>
android:orientation="vertical"/>
<LinearLayout
android:id="@+id/placeholders_layout"
......
......@@ -4,6 +4,7 @@
package org.chromium.chrome.features.start_surface;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
......@@ -12,10 +13,14 @@ import android.graphics.drawable.LayerDrawable;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import org.chromium.chrome.browser.flags.CachedFeatureFlags;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.start_surface.R;
import org.chromium.components.browser_ui.widget.displaystyle.HorizontalDisplayStyle;
import org.chromium.components.browser_ui.widget.displaystyle.UiConfig;
......@@ -50,7 +55,7 @@ public class FeedLoadingLayout extends LinearLayout {
@Override
protected void onFinishInflate() {
super.onFinishInflate();
// TODO (crbug.com/1079443): Inflate article suggestions section header here.
setHeader();
setPlaceholders();
mLayoutInflationCompleteMs = SystemClock.elapsedRealtime();
}
......@@ -61,6 +66,29 @@ public class FeedLoadingLayout extends LinearLayout {
setPlaceholders();
}
/**
* Set the header blank for the placeholder.The header blank should be consistent with the
* sectionHeaderView of {@link ExploreSurfaceCoordinator.FeedSurfaceCreator#}
*/
@SuppressLint("InflateParams")
private void setHeader() {
LayoutInflater inflater = LayoutInflater.from(mContext);
View header;
// This flag is checked directly with ChromeFeatureList#isEnabled() in other places. Using
// CachedFeatureFlags#isEnabled here is deliberate for a pre-native check. This
// inconsistency is fine because the check here is for the Feed header blank size, the
// mismatch is bearable and only once for every change.
if (CachedFeatureFlags.isEnabled(ChromeFeatureList.REPORT_FEED_USER_ACTIONS)) {
header = inflater.inflate(
R.layout.new_tab_page_snippets_expandable_header_with_menu, null, false);
header.findViewById(R.id.header_menu).setVisibility(INVISIBLE);
} else {
header = inflater.inflate(R.layout.ss_feed_header, null, false);
}
LinearLayout headerView = findViewById(R.id.feed_placeholder_header);
headerView.addView(header);
}
private void setPlaceholders() {
setPadding();
boolean isLandscape = getResources().getConfiguration().orientation
......
......@@ -65,6 +65,7 @@ public class ChromeCachedFlags {
ChromeFeatureList.PAINT_PREVIEW_DEMO,
ChromeFeatureList.PAINT_PREVIEW_SHOW_ON_STARTUP,
ChromeFeatureList.PRIORITIZE_BOOTSTRAP_TASKS,
ChromeFeatureList.REPORT_FEED_USER_ACTIONS,
ChromeFeatureList.START_SURFACE_ANDROID,
ChromeFeatureList.SWAP_PIXEL_FORMAT_TO_FIX_CONVERT_FROM_TRANSLUCENT,
ChromeFeatureList.TAB_GRID_LAYOUT_ANDROID,
......
......@@ -76,6 +76,7 @@ public class CachedFeatureFlags {
put(ChromeFeatureList.OMNIBOX_SUGGESTIONS_RECYCLER_VIEW, false);
put(ChromeFeatureList.TEST_DEFAULT_DISABLED, false);
put(ChromeFeatureList.TEST_DEFAULT_ENABLED, true);
put(ChromeFeatureList.REPORT_FEED_USER_ACTIONS, false);
}
};
......
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