Commit b18b9370 authored by Yue Zhang's avatar Yue Zhang Committed by Commit Bot

[StartSurface] Make trendy-terms adapt to scroll mode config

http://crrev.com/c/2199934 introduces two scroll modes for omnibox in
omnibox-only variation. This CL makes trendy term section also adapt to
above scroll modes by combining the omnibox and the trendy term section
into one scroll component.

Bug: 1099037
Change-Id: I54016d78d3f90b2ed723ab4d0b46b0e7651113f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2267844
Commit-Queue: Yue Zhang <yuezhanggg@chromium.org>
Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782744}
parent 208883aa
...@@ -857,20 +857,23 @@ public class StartSurfaceTest { ...@@ -857,20 +857,23 @@ public class StartSurfaceTest {
@DisableIf.Build(hardware_is = "bullhead", message = "crbug.com/1081657") @DisableIf.Build(hardware_is = "bullhead", message = "crbug.com/1081657")
@CommandLineFlags.Add({BASE_PARAMS + "/omniboxonly" + @CommandLineFlags.Add({BASE_PARAMS + "/omniboxonly" +
"/hide_switch_when_no_incognito_tabs/true/omnibox_scroll_mode/top"}) "/hide_switch_when_no_incognito_tabs/true/omnibox_scroll_mode/top"})
public void testScroll_OmniboxOnly_Top() { public void testScroll_Top() {
// clang-format on // clang-format on
// TODO(crbug.com/1082664): Make it work with NoReturn. // TODO(crbug.com/1082664): Make it work with NoReturn.
assumeTrue(mImmediateReturn); assumeTrue(mImmediateReturn);
onViewWaiting(allOf(withId(R.id.primary_tasks_surface_view), isDisplayed())); onViewWaiting(allOf(withId(R.id.primary_tasks_surface_view), isDisplayed()));
onView(withId(R.id.search_box)).check(matches(isDisplayed())); onView(withId(org.chromium.chrome.tab_ui.R.id.scroll_component_container))
.check(matches(isDisplayed()));
onView(withId(org.chromium.chrome.tab_ui.R.id.tasks_surface_body)) onView(withId(org.chromium.chrome.tab_ui.R.id.tasks_surface_body))
.perform(SWIPE_UP_FROM_CENTER, SWIPE_UP_FROM_CENTER, SWIPE_UP_FROM_CENTER); .perform(SWIPE_UP_FROM_CENTER, SWIPE_UP_FROM_CENTER, SWIPE_UP_FROM_CENTER);
onView(withId(R.id.search_box)).check(matches(not(isDisplayed()))); onView(withId(org.chromium.chrome.tab_ui.R.id.scroll_component_container))
.check(matches(not(isDisplayed())));
onView(withId(org.chromium.chrome.tab_ui.R.id.tasks_surface_body)) onView(withId(org.chromium.chrome.tab_ui.R.id.tasks_surface_body))
.perform(SWIPE_DOWN_FROM_CENTER); .perform(SWIPE_DOWN_FROM_CENTER);
onView(withId(R.id.search_box)).check(matches(not(isDisplayed()))); onView(withId(org.chromium.chrome.tab_ui.R.id.scroll_component_container))
.check(matches(not(isDisplayed())));
} }
@Test @Test
...@@ -880,20 +883,23 @@ public class StartSurfaceTest { ...@@ -880,20 +883,23 @@ public class StartSurfaceTest {
@DisableIf.Build(sdk_is_less_than = P, message = "crbug.com/1083174") @DisableIf.Build(sdk_is_less_than = P, message = "crbug.com/1083174")
@CommandLineFlags.Add({BASE_PARAMS + "/omniboxonly" + @CommandLineFlags.Add({BASE_PARAMS + "/omniboxonly" +
"/hide_switch_when_no_incognito_tabs/true/omnibox_scroll_mode/quick"}) "/hide_switch_when_no_incognito_tabs/true/omnibox_scroll_mode/quick"})
public void testScroll_OmniboxOnly_Quick() { public void testScroll_Quick() {
// clang-format on // clang-format on
// TODO(crbug.com/1082664): Make it work with NoReturn. // TODO(crbug.com/1082664): Make it work with NoReturn.
assumeTrue(mImmediateReturn); assumeTrue(mImmediateReturn);
onViewWaiting(allOf(withId(R.id.primary_tasks_surface_view), isDisplayed())); onViewWaiting(allOf(withId(R.id.primary_tasks_surface_view), isDisplayed()));
onView(withId(R.id.search_box)).check(matches(isDisplayed())); onView(withId(org.chromium.chrome.tab_ui.R.id.scroll_component_container))
.check(matches(isDisplayed()));
onView(withId(org.chromium.chrome.tab_ui.R.id.tasks_surface_body)) onView(withId(org.chromium.chrome.tab_ui.R.id.tasks_surface_body))
.perform(SWIPE_UP_FROM_CENTER, SWIPE_UP_FROM_CENTER, SWIPE_UP_FROM_CENTER); .perform(SWIPE_UP_FROM_CENTER, SWIPE_UP_FROM_CENTER, SWIPE_UP_FROM_CENTER);
onView(withId(R.id.search_box)).check(matches(not(isDisplayed()))); onView(withId(org.chromium.chrome.tab_ui.R.id.scroll_component_container))
.check(matches(not(isDisplayed())));
onView(withId(org.chromium.chrome.tab_ui.R.id.tasks_surface_body)) onView(withId(org.chromium.chrome.tab_ui.R.id.tasks_surface_body))
.perform(SWIPE_DOWN_FROM_CENTER); .perform(SWIPE_DOWN_FROM_CENTER);
onView(withId(R.id.search_box)).check(matches(isDisplayed())); onView(withId(org.chromium.chrome.tab_ui.R.id.scroll_component_container))
.check(matches(isDisplayed()));
} }
@Test @Test
...@@ -903,17 +909,19 @@ public class StartSurfaceTest { ...@@ -903,17 +909,19 @@ public class StartSurfaceTest {
@DisabledTest(message = "crbug.com/1083459") @DisabledTest(message = "crbug.com/1083459")
@CommandLineFlags.Add({BASE_PARAMS + "/omniboxonly" + @CommandLineFlags.Add({BASE_PARAMS + "/omniboxonly" +
"/hide_switch_when_no_incognito_tabs/true/omnibox_scroll_mode/pinned"}) "/hide_switch_when_no_incognito_tabs/true/omnibox_scroll_mode/pinned"})
public void testScroll_OmniboxOnly_Pinned() { public void testScroll_Pinned() {
// clang-format on // clang-format on
// TODO(crbug.com/1082664): Make it work with NoReturn. // TODO(crbug.com/1082664): Make it work with NoReturn.
assumeTrue(mImmediateReturn); assumeTrue(mImmediateReturn);
onViewWaiting(allOf(withId(R.id.primary_tasks_surface_view), isDisplayed())); onViewWaiting(allOf(withId(R.id.primary_tasks_surface_view), isDisplayed()));
onView(withId(R.id.search_box)).check(matches(isDisplayed())); onView(withId(org.chromium.chrome.tab_ui.R.id.scroll_component_container))
.check(matches(isDisplayed()));
onView(withId(org.chromium.chrome.tab_ui.R.id.tasks_surface_body)) onView(withId(org.chromium.chrome.tab_ui.R.id.tasks_surface_body))
.perform(SWIPE_UP_FROM_CENTER, SWIPE_UP_FROM_CENTER, SWIPE_UP_FROM_CENTER); .perform(SWIPE_UP_FROM_CENTER, SWIPE_UP_FROM_CENTER, SWIPE_UP_FROM_CENTER);
onView(withId(R.id.search_box)).check(matches(isDisplayed())); onView(withId(org.chromium.chrome.tab_ui.R.id.scroll_component_container))
.check(matches(isDisplayed()));
} }
private void waitForTabModel() { private void waitForTabModel() {
......
...@@ -15,7 +15,22 @@ ...@@ -15,7 +15,22 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:elevation="0dp"> app:elevation="0dp">
<LinearLayout
android:id="@+id/scroll_component_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/fake_search_box_layout"/> <include layout="@layout/fake_search_box_layout"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/trendy_terms_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="4dp"
android:visibility="gone">
</androidx.recyclerview.widget.RecyclerView>
</LinearLayout>
<HorizontalScrollView android:id="@+id/mv_tiles_container" <HorizontalScrollView android:id="@+id/mv_tiles_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -29,14 +44,6 @@ ...@@ -29,14 +44,6 @@
android:orientation="horizontal" android:orientation="horizontal"
android:paddingBottom="@dimen/tasks_view_items_vertical_spacing" /> android:paddingBottom="@dimen/tasks_view_items_vertical_spacing" />
</HorizontalScrollView> </HorizontalScrollView>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/trendy_terms_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:visibility="gone">
</androidx.recyclerview.widget.RecyclerView>
<LinearLayout <LinearLayout
android:id="@+id/tab_switcher_title" android:id="@+id/tab_switcher_title"
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -77,15 +77,18 @@ class TasksView extends CoordinatorLayoutForPointer { ...@@ -77,15 +77,18 @@ class TasksView extends CoordinatorLayoutForPointer {
mSearchBoxCoordinator = new SearchBoxCoordinator(getContext(), this); mSearchBoxCoordinator = new SearchBoxCoordinator(getContext(), this);
mHeaderView = (AppBarLayout) findViewById(R.id.task_surface_header); mHeaderView = (AppBarLayout) findViewById(R.id.task_surface_header);
AppBarLayout.LayoutParams layoutParams = AppBarLayout.LayoutParams layoutParams =
(AppBarLayout.LayoutParams) mSearchBoxCoordinator.getView().getLayoutParams(); (AppBarLayout.LayoutParams) (findViewById(R.id.scroll_component_container)
.getLayoutParams());
layoutParams.setScrollFlags(SCROLL_FLAG_SCROLL); layoutParams.setScrollFlags(SCROLL_FLAG_SCROLL);
adjustOmniboxScrollMode(layoutParams); adjustScrollMode(layoutParams);
setTabCarouselTitleStyle(); setTabCarouselTitleStyle();
} }
private void adjustOmniboxScrollMode(AppBarLayout.LayoutParams layoutParams) { private void adjustScrollMode(AppBarLayout.LayoutParams layoutParams) {
if (!StartSurfaceConfiguration.START_SURFACE_VARIATION.getValue().equals("omniboxonly")) { if (!StartSurfaceConfiguration.START_SURFACE_VARIATION.getValue().equals("omniboxonly")
// Omnibox scroll mode is only relevant in omnibox-only variation. && !StartSurfaceConfiguration.START_SURFACE_VARIATION.getValue().equals(
"trendyterms")) {
// Scroll mode is only relevant in omnibox-only variation and trendy-terms variation.
return; return;
} }
String scrollMode = StartSurfaceConfiguration.START_SURFACE_OMNIBOX_SCROLL_MODE.getValue(); String scrollMode = StartSurfaceConfiguration.START_SURFACE_OMNIBOX_SCROLL_MODE.getValue();
......
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