Commit ebe890d7 authored by gogerald's avatar gogerald Committed by Commit Bot

[StartSurface] Refactor and make MV tiles available on all start surfaces

This is the first patch of splitting the bigger one
https://chromium-review.googlesource.com/c/chromium/src/+/1797069

Screenshots:
https://drive.google.com/file/d/1bmR-hfo1XQsaB61MbGUSmRjAIOyypaEj/view?usp=sharing
https://drive.google.com/file/d/1opItnNVwGI-eRJxlN6M2hxurS88D4btX/view?usp=sharing
https://drive.google.com/file/d/1ElJLgbogCb-f-D5vO6hmjC5SznxxWZKc/view?usp=sharing
https://drive.google.com/file/d/1RU88SHUqFqSu_VhxrdyfVTSSWJcMdn3i/view?usp=sharing
https://drive.google.com/file/d/1JQZAiFVOcQSeU9N8XOK7Zyh7TL5xT6Vk/view?usp=sharing

Bug: 982018
Change-Id: Iec9086c6538d29208ba92b106985bb04f0148983
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1817106
Commit-Queue: Ganggui Tang <gogerald@chromium.org>
Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Auto-Submit: Ganggui Tang <gogerald@chromium.org>
Cr-Commit-Position: refs/heads/master@{#701715}
parent 02cb2dcd
...@@ -89,6 +89,8 @@ android_library("java") { ...@@ -89,6 +89,8 @@ android_library("java") {
"java/src/org/chromium/chrome/features/start_surface/StartSurfaceLayout.java", "java/src/org/chromium/chrome/features/start_surface/StartSurfaceLayout.java",
"java/src/org/chromium/chrome/features/start_surface/StartSurfaceMediator.java", "java/src/org/chromium/chrome/features/start_surface/StartSurfaceMediator.java",
"java/src/org/chromium/chrome/features/start_surface/StartSurfaceProperties.java", "java/src/org/chromium/chrome/features/start_surface/StartSurfaceProperties.java",
"java/src/org/chromium/chrome/features/start_surface/SecondaryTasksSurfaceViewBinder.java",
"java/src/org/chromium/chrome/features/start_surface/TasksSurfaceViewBinder.java",
] ]
deps = [ deps = [
......
// Copyright 2019 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.
package org.chromium.chrome.features.start_surface;
import static org.chromium.chrome.features.start_surface.StartSurfaceProperties.IS_SECONDARY_SURFACE_VISIBLE;
import static org.chromium.chrome.features.start_surface.StartSurfaceProperties.IS_SHOWING_OVERVIEW;
import static org.chromium.chrome.features.start_surface.StartSurfaceProperties.TOP_BAR_HEIGHT;
import android.view.View;
import android.view.ViewGroup.MarginLayoutParams;
import org.chromium.ui.modelutil.PropertyKey;
import org.chromium.ui.modelutil.PropertyModel;
/** The binder controls the display of the secondary {@link TasksView} in its parent. */
class SecondaryTasksSurfaceViewBinder {
public static void bind(PropertyModel model, TasksSurfaceViewBinder.ViewHolder viewHolder,
PropertyKey propertyKey) {
if (IS_SECONDARY_SURFACE_VISIBLE == propertyKey) {
setVisibility(viewHolder, model,
model.get(IS_SHOWING_OVERVIEW) && model.get(IS_SECONDARY_SURFACE_VISIBLE));
} else if (IS_SHOWING_OVERVIEW == propertyKey) {
setVisibility(viewHolder, model,
model.get(IS_SHOWING_OVERVIEW) && model.get(IS_SECONDARY_SURFACE_VISIBLE));
}
}
private static void setVisibility(
TasksSurfaceViewBinder.ViewHolder viewHolder, PropertyModel model, boolean isShowing) {
if (isShowing && viewHolder.tasksSurfaceView.getParent() == null) {
MarginLayoutParams layoutParams =
(MarginLayoutParams) viewHolder.scrollContainer.getLayoutParams();
layoutParams.topMargin = model.get(TOP_BAR_HEIGHT);
viewHolder.parentView.addView(viewHolder.scrollContainer);
viewHolder.scrollContainer.addView(viewHolder.tasksSurfaceView);
}
viewHolder.scrollContainer.setVisibility(isShowing ? View.VISIBLE : View.GONE);
}
}
...@@ -146,10 +146,6 @@ public class StartSurfaceLayout extends Layout implements StartSurface.OverviewM ...@@ -146,10 +146,6 @@ public class StartSurfaceLayout extends Layout implements StartSurface.OverviewM
if (mController != null) { if (mController != null) {
mController.removeOverviewModeObserver(this); mController.removeOverviewModeObserver(this);
} }
if (mStartSurface != null) {
mStartSurface.destroy();
}
} }
@Override @Override
......
...@@ -32,6 +32,8 @@ class StartSurfaceProperties { ...@@ -32,6 +32,8 @@ class StartSurfaceProperties {
new PropertyModel.WritableBooleanPropertyKey(); new PropertyModel.WritableBooleanPropertyKey();
public static final PropertyModel.WritableBooleanPropertyKey IS_EXPLORE_SURFACE_VISIBLE = public static final PropertyModel.WritableBooleanPropertyKey IS_EXPLORE_SURFACE_VISIBLE =
new PropertyModel.WritableBooleanPropertyKey(); new PropertyModel.WritableBooleanPropertyKey();
public static final PropertyModel.WritableBooleanPropertyKey IS_SECONDARY_SURFACE_VISIBLE =
new PropertyModel.WritableBooleanPropertyKey();
public static final PropertyModel.WritableBooleanPropertyKey IS_SHOWING_OVERVIEW = public static final PropertyModel.WritableBooleanPropertyKey IS_SHOWING_OVERVIEW =
new PropertyModel.WritableBooleanPropertyKey(); new PropertyModel.WritableBooleanPropertyKey();
public static final PropertyModel public static final PropertyModel
...@@ -41,6 +43,6 @@ class StartSurfaceProperties { ...@@ -41,6 +43,6 @@ class StartSurfaceProperties {
new PropertyModel.WritableIntPropertyKey(); new PropertyModel.WritableIntPropertyKey();
public static final PropertyKey[] ALL_KEYS = new PropertyKey[] {BOTTOM_BAR_CLICKLISTENER, public static final PropertyKey[] ALL_KEYS = new PropertyKey[] {BOTTOM_BAR_CLICKLISTENER,
BOTTOM_BAR_HEIGHT, BOTTOM_BAR_SELECTED_TAB_POSITION, IS_BOTTOM_BAR_VISIBLE, BOTTOM_BAR_HEIGHT, BOTTOM_BAR_SELECTED_TAB_POSITION, IS_BOTTOM_BAR_VISIBLE,
IS_EXPLORE_SURFACE_VISIBLE, IS_SHOWING_OVERVIEW, FEED_SURFACE_COORDINATOR, IS_EXPLORE_SURFACE_VISIBLE, IS_SECONDARY_SURFACE_VISIBLE, IS_SHOWING_OVERVIEW,
TOP_BAR_HEIGHT}; FEED_SURFACE_COORDINATOR, TOP_BAR_HEIGHT};
} }
// Copyright 2019 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.
package org.chromium.chrome.features.start_surface;
import static org.chromium.chrome.features.start_surface.StartSurfaceProperties.BOTTOM_BAR_HEIGHT;
import static org.chromium.chrome.features.start_surface.StartSurfaceProperties.IS_SHOWING_OVERVIEW;
import static org.chromium.chrome.features.start_surface.StartSurfaceProperties.TOP_BAR_HEIGHT;
import android.support.v4.widget.NestedScrollView;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.MarginLayoutParams;
import androidx.annotation.Nullable;
import org.chromium.ui.modelutil.PropertyKey;
import org.chromium.ui.modelutil.PropertyModel;
/** The binder controls the display of the {@link TasksView} in its parent. */
class TasksSurfaceViewBinder {
/**
* The view holder holds the parent view, the scroll container and the tasks surface view.
*/
public static class ViewHolder {
public final ViewGroup parentView;
@Nullable
public final NestedScrollView scrollContainer;
public final ViewGroup tasksSurfaceView;
ViewHolder(ViewGroup parentView, @Nullable NestedScrollView scrollContainer,
ViewGroup tasksSurfaceView) {
this.parentView = parentView;
this.scrollContainer = scrollContainer;
this.tasksSurfaceView = tasksSurfaceView;
}
}
public static void bind(PropertyModel model, ViewHolder viewHolder, PropertyKey propertyKey) {
if (IS_SHOWING_OVERVIEW == propertyKey) {
updateLayoutAndVisibility(viewHolder, model, model.get(IS_SHOWING_OVERVIEW));
} else if (BOTTOM_BAR_HEIGHT == propertyKey) {
setBottomBarHeight(viewHolder, model.get(BOTTOM_BAR_HEIGHT));
}
}
private static void updateLayoutAndVisibility(
ViewHolder viewHolder, PropertyModel model, boolean isShowing) {
ViewGroup targetView = viewHolder.scrollContainer == null ? viewHolder.tasksSurfaceView
: viewHolder.scrollContainer;
if (isShowing && viewHolder.tasksSurfaceView.getParent() == null) {
viewHolder.parentView.addView(targetView);
if (viewHolder.scrollContainer != null) targetView.addView(viewHolder.tasksSurfaceView);
MarginLayoutParams layoutParams = (MarginLayoutParams) targetView.getLayoutParams();
layoutParams.bottomMargin = model.get(BOTTOM_BAR_HEIGHT);
layoutParams.topMargin = model.get(TOP_BAR_HEIGHT);
}
targetView.setVisibility(isShowing ? View.VISIBLE : View.GONE);
}
private static void setBottomBarHeight(ViewHolder viewHolder, int height) {
ViewGroup targetView = viewHolder.scrollContainer == null ? viewHolder.tasksSurfaceView
: viewHolder.scrollContainer;
((MarginLayoutParams) targetView.getLayoutParams()).bottomMargin = height;
}
}
...@@ -92,9 +92,4 @@ public interface StartSurface { ...@@ -92,9 +92,4 @@ public interface StartSurface {
* @return TabListDelegate implementation that can be used to access the Tab List. * @return TabListDelegate implementation that can be used to access the Tab List.
*/ */
TabSwitcher.TabListDelegate getTabListDelegate(); TabSwitcher.TabListDelegate getTabListDelegate();
/**
* Perform any necessary cleanup.
*/
void destroy();
} }
\ No newline at end of file
...@@ -78,9 +78,7 @@ android_resources("java_resources") { ...@@ -78,9 +78,7 @@ android_resources("java_resources") {
android_library("java") { android_library("java") {
java_files = [ java_files = [
"java/src/org/chromium/chrome/browser/tasks/MostVisitedListCoordinator.java", "java/src/org/chromium/chrome/browser/tasks/MostVisitedListCoordinator.java",
"java/src/org/chromium/chrome/browser/tasks/MostVisitedListMediator.java",
"java/src/org/chromium/chrome/browser/tasks/MostVisitedListViewBinder.java", "java/src/org/chromium/chrome/browser/tasks/MostVisitedListViewBinder.java",
"java/src/org/chromium/chrome/browser/tasks/MostVisitedListProperties.java",
"java/src/org/chromium/chrome/browser/tasks/TasksSurfaceMediator.java", "java/src/org/chromium/chrome/browser/tasks/TasksSurfaceMediator.java",
"java/src/org/chromium/chrome/browser/tasks/TasksSurfaceCoordinator.java", "java/src/org/chromium/chrome/browser/tasks/TasksSurfaceCoordinator.java",
"java/src/org/chromium/chrome/browser/tasks/TasksView.java", "java/src/org/chromium/chrome/browser/tasks/TasksView.java",
......
...@@ -44,18 +44,15 @@ class MostVisitedListCoordinator implements TileGroup.Observer, TileGroup.TileSe ...@@ -44,18 +44,15 @@ class MostVisitedListCoordinator implements TileGroup.Observer, TileGroup.TileSe
// There's a limit of 12 in {@link MostVisitedSitesBridge#setObserver}. // There's a limit of 12 in {@link MostVisitedSitesBridge#setObserver}.
private static final int MAX_RESULTS = 12; private static final int MAX_RESULTS = 12;
private PropertyModelChangeProcessor mModelChangeProcessor; private PropertyModelChangeProcessor mModelChangeProcessor;
private MostVisitedListMediator mMediator;
private TileGroup mTileGroup; private TileGroup mTileGroup;
private TileRenderer mRenderer; private TileRenderer mRenderer;
private ViewGroup mParent; private ViewGroup mParent;
public MostVisitedListCoordinator(ChromeActivity activity, ViewGroup parent) { public MostVisitedListCoordinator(
PropertyModel propertyModel = new PropertyModel(MostVisitedListProperties.ALL_KEYS); ChromeActivity activity, ViewGroup parent, PropertyModel propertyModel) {
mModelChangeProcessor = PropertyModelChangeProcessor.create( mModelChangeProcessor = PropertyModelChangeProcessor.create(
propertyModel, parent, MostVisitedListViewBinder::bind); propertyModel, parent, MostVisitedListViewBinder::bind);
mMediator = new MostVisitedListMediator(propertyModel, activity.getTabModelSelector());
mParent = parent; mParent = parent;
Profile profile = Profile.getLastUsedProfile(); Profile profile = Profile.getLastUsedProfile();
SuggestionsSource suggestionsSource = SuggestionsSource suggestionsSource =
...@@ -82,10 +79,6 @@ class MostVisitedListCoordinator implements TileGroup.Observer, TileGroup.TileSe ...@@ -82,10 +79,6 @@ class MostVisitedListCoordinator implements TileGroup.Observer, TileGroup.TileSe
mTileGroup.startObserving(MAX_RESULTS); mTileGroup.startObserving(MAX_RESULTS);
} }
void destroy() {
mMediator.destroy();
}
private void updateTileIcon(Tile tile) { private void updateTileIcon(Tile tile) {
for (int i = 0; i < mParent.getChildCount(); i++) { for (int i = 0; i < mParent.getChildCount(); i++) {
View tileView = mParent.getChildAt(i); View tileView = mParent.getChildAt(i);
......
// Copyright 2019 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.
package org.chromium.chrome.browser.tasks;
import static org.chromium.chrome.browser.tasks.MostVisitedListProperties.IS_VISIBLE;
import org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver;
import org.chromium.chrome.browser.tabmodel.TabModel;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver;
import org.chromium.ui.modelutil.PropertyModel;
/** Mediator handling logic and model operations for most visited list. */
class MostVisitedListMediator {
private final PropertyModel mModel;
private final TabModelSelector mTabModelSelector;
private final TabModelSelectorObserver mTabModelSelectorObserver;
MostVisitedListMediator(PropertyModel model, TabModelSelector tabModelSelector) {
mModel = model;
mTabModelSelector = tabModelSelector;
mTabModelSelectorObserver = new EmptyTabModelSelectorObserver() {
@Override
public void onTabModelSelected(TabModel newModel, TabModel oldModel) {
mModel.set(IS_VISIBLE, !newModel.isIncognito());
}
};
mTabModelSelector.addObserver(mTabModelSelectorObserver);
}
void destroy() {
mTabModelSelector.removeObserver(mTabModelSelectorObserver);
}
}
...@@ -36,9 +36,4 @@ public interface TasksSurface { ...@@ -36,9 +36,4 @@ public interface TasksSurface {
* @return The surface's container {@link ViewGroup}. * @return The surface's container {@link ViewGroup}.
*/ */
ViewGroup getContainerView(); ViewGroup getContainerView();
/**
* Perform any necessary cleanup.
*/
void destroy();
} }
...@@ -39,11 +39,10 @@ public class TasksSurfaceCoordinator implements TasksSurface { ...@@ -39,11 +39,10 @@ public class TasksSurfaceCoordinator implements TasksSurface {
activity, mView.getTabSwitcherContainer()); activity, mView.getTabSwitcherContainer());
} }
mMediator = new TasksSurfaceMediator( mMediator = new TasksSurfaceMediator(activity, propertyModel, isTabCarousel);
activity, propertyModel, isTabCarousel, activity.getOverviewModeBehavior());
LinearLayout mvTilesLayout = mView.findViewById(R.id.mv_tiles_layout); LinearLayout mvTilesLayout = mView.findViewById(R.id.mv_tiles_layout);
mMostVisitedList = new MostVisitedListCoordinator(activity, mvTilesLayout); mMostVisitedList = new MostVisitedListCoordinator(activity, mvTilesLayout, propertyModel);
} }
/** TasksSurface implementation. */ /** TasksSurface implementation. */
...@@ -66,10 +65,4 @@ public class TasksSurfaceCoordinator implements TasksSurface { ...@@ -66,10 +65,4 @@ public class TasksSurfaceCoordinator implements TasksSurface {
public ViewGroup getContainerView() { public ViewGroup getContainerView() {
return mView; return mView;
} }
@Override
public void destroy() {
mMediator.destroy();
mMostVisitedList.destroy();
}
} }
...@@ -5,63 +5,19 @@ ...@@ -5,63 +5,19 @@
package org.chromium.chrome.browser.tasks; package org.chromium.chrome.browser.tasks;
import static org.chromium.chrome.browser.tasks.TasksSurfaceProperties.IS_TAB_CAROUSEL; import static org.chromium.chrome.browser.tasks.TasksSurfaceProperties.IS_TAB_CAROUSEL;
import static org.chromium.chrome.browser.tasks.TasksSurfaceProperties.MV_TILES_VISIBLE;
import static org.chromium.chrome.browser.tasks.TasksSurfaceProperties.TOP_PADDING;
import android.content.Context; import android.content.Context;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior;
import org.chromium.ui.modelutil.PropertyModel; import org.chromium.ui.modelutil.PropertyModel;
/** /**
* Mediator for handling {@link TasksSurface}-related logic. * Mediator for handling {@link TasksSurface}-related logic.
*/ */
class TasksSurfaceMediator implements OverviewModeBehavior.OverviewModeObserver { class TasksSurfaceMediator {
private final PropertyModel mModel; private final PropertyModel mModel;
private OverviewModeBehavior mOverviewModeBehavior; TasksSurfaceMediator(Context context, PropertyModel model, boolean isTabCarousel) {
TasksSurfaceMediator(Context context, PropertyModel model, boolean isTabCarousel,
OverviewModeBehavior overviewModeBehavior) {
mModel = model; mModel = model;
mModel.set(IS_TAB_CAROUSEL, isTabCarousel); mModel.set(IS_TAB_CAROUSEL, isTabCarousel);
if (!isTabCarousel) {
mModel.set(TOP_PADDING,
context.getResources().getDimensionPixelSize(R.dimen.toolbar_height_no_shadow)
* 2);
}
// TODO(mattsimmons): Move all of the tasks surface visibility changes here and handle it
// for all surface variations. This is not ideal as-is.
if (ReturnToChromeExperimentsUtil.shouldShowMostVisitedOnTabSwitcher()) {
mOverviewModeBehavior = overviewModeBehavior;
mOverviewModeBehavior.addOverviewModeObserver(this);
}
}
@Override
public void onOverviewModeStartedShowing(boolean showToolbar) {
mModel.set(MV_TILES_VISIBLE, true);
}
@Override
public void onOverviewModeFinishedShowing() {}
@Override
public void onOverviewModeStartedHiding(boolean showToolbar, boolean delayAnimation) {
mModel.set(MV_TILES_VISIBLE, false);
}
@Override
public void onOverviewModeFinishedHiding() {}
void destroy() {
if (mOverviewModeBehavior != null) {
mOverviewModeBehavior.removeOverviewModeObserver(this);
mOverviewModeBehavior = null;
}
} }
} }
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
package org.chromium.chrome.browser.tasks; package org.chromium.chrome.browser.tasks;
import static org.chromium.chrome.browser.tasks.MostVisitedListProperties.IS_VISIBLE;
import android.view.View; import android.view.View;
import org.chromium.ui.modelutil.PropertyKey; import org.chromium.ui.modelutil.PropertyKey;
...@@ -11,15 +13,14 @@ import org.chromium.ui.modelutil.PropertyModel; ...@@ -11,15 +13,14 @@ import org.chromium.ui.modelutil.PropertyModel;
/** List of the tasks surface properties. */ /** List of the tasks surface properties. */
public class TasksSurfaceProperties { public class TasksSurfaceProperties {
private TasksSurfaceProperties() {}
public static final PropertyModel.WritableBooleanPropertyKey IS_TAB_CAROUSEL = public static final PropertyModel.WritableBooleanPropertyKey IS_TAB_CAROUSEL =
new PropertyModel.WritableBooleanPropertyKey(); new PropertyModel.WritableBooleanPropertyKey();
public static final PropertyModel public static final PropertyModel
.WritableObjectPropertyKey<View.OnClickListener> MORE_TABS_CLICK_LISTENER = .WritableObjectPropertyKey<View.OnClickListener> MORE_TABS_CLICK_LISTENER =
new PropertyModel.WritableObjectPropertyKey<View.OnClickListener>(); new PropertyModel.WritableObjectPropertyKey<View.OnClickListener>();
public static final PropertyModel.WritableBooleanPropertyKey MV_TILES_VISIBLE = public static final PropertyModel.WritableBooleanPropertyKey MV_TILES_VISIBLE = IS_VISIBLE;
new PropertyModel.WritableBooleanPropertyKey(); public static final PropertyKey[] ALL_KEYS =
public static final PropertyModel.WritableIntPropertyKey TOP_PADDING = new PropertyKey[] {IS_TAB_CAROUSEL, MORE_TABS_CLICK_LISTENER, MV_TILES_VISIBLE};
new PropertyModel.WritableIntPropertyKey();
public static final PropertyKey[] ALL_KEYS = new PropertyKey[] {
IS_TAB_CAROUSEL, MORE_TABS_CLICK_LISTENER, MV_TILES_VISIBLE, TOP_PADDING};
} }
...@@ -7,7 +7,6 @@ package org.chromium.chrome.browser.tasks; ...@@ -7,7 +7,6 @@ package org.chromium.chrome.browser.tasks;
import static org.chromium.chrome.browser.tasks.TasksSurfaceProperties.IS_TAB_CAROUSEL; import static org.chromium.chrome.browser.tasks.TasksSurfaceProperties.IS_TAB_CAROUSEL;
import static org.chromium.chrome.browser.tasks.TasksSurfaceProperties.MORE_TABS_CLICK_LISTENER; import static org.chromium.chrome.browser.tasks.TasksSurfaceProperties.MORE_TABS_CLICK_LISTENER;
import static org.chromium.chrome.browser.tasks.TasksSurfaceProperties.MV_TILES_VISIBLE; import static org.chromium.chrome.browser.tasks.TasksSurfaceProperties.MV_TILES_VISIBLE;
import static org.chromium.chrome.browser.tasks.TasksSurfaceProperties.TOP_PADDING;
import android.view.View; import android.view.View;
...@@ -23,8 +22,6 @@ class TasksViewBinder { ...@@ -23,8 +22,6 @@ class TasksViewBinder {
view.setMoreTabsOnClickListener(model.get(MORE_TABS_CLICK_LISTENER)); view.setMoreTabsOnClickListener(model.get(MORE_TABS_CLICK_LISTENER));
} else if (propertyKey == MV_TILES_VISIBLE) { } else if (propertyKey == MV_TILES_VISIBLE) {
view.setMostVisitedVisibility(model.get(MV_TILES_VISIBLE) ? View.VISIBLE : View.GONE); view.setMostVisitedVisibility(model.get(MV_TILES_VISIBLE) ? View.VISIBLE : View.GONE);
} else if (propertyKey == TOP_PADDING) {
view.setPadding(0, model.get(TOP_PADDING), 0, 0);
} }
} }
} }
\ No newline at end of file
...@@ -100,12 +100,6 @@ public interface TabSwitcher { ...@@ -100,12 +100,6 @@ public interface TabSwitcher {
* @return Whether or not the TabSwitcher consumed the event. * @return Whether or not the TabSwitcher consumed the event.
*/ */
boolean onBackPressed(); boolean onBackPressed();
/**
* Set the bottom control height to margin the bottom of the TabListRecyclerView.
* @param bottomControlsHeight The bottom control height in pixel.
*/
void setBottomControlsHeight(int bottomControlsHeight);
} }
/** /**
......
...@@ -504,11 +504,6 @@ class TabSwitcherMediator implements TabSwitcher.Controller, TabListRecyclerView ...@@ -504,11 +504,6 @@ class TabSwitcherMediator implements TabSwitcher.Controller, TabListRecyclerView
return true; return true;
} }
@Override
public void setBottomControlsHeight(int bottomControlsHeight) {
mContainerViewModel.set(BOTTOM_CONTROLS_HEIGHT, bottomControlsHeight);
}
/** /**
* Do clean-up work after the overview hiding animation is finished. * Do clean-up work after the overview hiding animation is finished.
* @see TabSwitcher#postHiding * @see TabSwitcher#postHiding
......
// Copyright 2019 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.
package org.chromium.chrome.browser.tasks;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
import static org.chromium.chrome.browser.tasks.MostVisitedListProperties.IS_VISIBLE;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.chromium.chrome.browser.tabmodel.TabModel;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver;
import org.chromium.testing.local.LocalRobolectricTestRunner;
import org.chromium.ui.modelutil.PropertyModel;
/**
* Tests for {@link MostVisitedListMediator}.
*/
@RunWith(LocalRobolectricTestRunner.class)
public final class MostVisitedListMediatorUnitTest {
private final PropertyModel mModel = new PropertyModel(MostVisitedListProperties.ALL_KEYS);
@Mock
private TabModel mNewTabModel;
@Mock
private TabModelSelector mTabModelSelector;
@Captor
private ArgumentCaptor<TabModelSelectorObserver> mTabModelSelectorObserverCaptor;
private MostVisitedListMediator mMediator;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mMediator = new MostVisitedListMediator(mModel, mTabModelSelector);
verify(mTabModelSelector).addObserver(mTabModelSelectorObserverCaptor.capture());
}
@Test
public void incognitoTabModel_setsNotVisible() {
mModel.set(IS_VISIBLE, true);
doReturn(true).when(mNewTabModel).isIncognito();
mTabModelSelectorObserverCaptor.getValue().onTabModelSelected(mNewTabModel, null);
assertFalse(mModel.get(IS_VISIBLE));
}
@Test
public void regularTabModel_setsVisible() {
mModel.set(IS_VISIBLE, false);
doReturn(false).when(mNewTabModel).isIncognito();
mTabModelSelectorObserverCaptor.getValue().onTabModelSelected(mNewTabModel, null);
assertTrue(mModel.get(IS_VISIBLE));
}
}
...@@ -6,6 +6,7 @@ import( ...@@ -6,6 +6,7 @@ import(
"//chrome/android/features/start_surface/public/start_surface_public_java_sources.gni") "//chrome/android/features/start_surface/public/start_surface_public_java_sources.gni")
public_tab_management_java_sources = [ public_tab_management_java_sources = [
"//chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/MostVisitedListProperties.java",
"//chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/TasksSurface.java", "//chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/TasksSurface.java",
"//chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/TasksSurfaceProperties.java", "//chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/TasksSurfaceProperties.java",
"//chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupModelFilter.java", "//chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupModelFilter.java",
...@@ -31,7 +32,6 @@ tab_management_test_java_sources = [ ...@@ -31,7 +32,6 @@ tab_management_test_java_sources = [
] ]
tab_management_junit_java_sources = [ tab_management_junit_java_sources = [
"//chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/MostVisitedListMediatorUnitTest.java",
"//chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/MostVisitedListViewBinderUnitTest.java", "//chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/MostVisitedListViewBinderUnitTest.java",
"//chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupModelFilterUnitTest.java", "//chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupModelFilterUnitTest.java",
"//chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabSwitcherMediatorUnitTest.java", "//chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/TabSwitcherMediatorUnitTest.java",
......
...@@ -68,19 +68,6 @@ public final class ReturnToChromeExperimentsUtil { ...@@ -68,19 +68,6 @@ public final class ReturnToChromeExperimentsUtil {
&& ChromeFeatureList.isEnabled(ChromeFeatureList.START_SURFACE_ANDROID); && ChromeFeatureList.isEnabled(ChromeFeatureList.START_SURFACE_ANDROID);
} }
/**
* TODO(mattsimmons): Merge this with the one above once all the surface variations work
* correctly with mv tiles, omnibox, etc. (both should be true when != NO_START_SURFACE)
* @return Whether we show the most visited tiles on the tab switcher.
*/
public static boolean shouldShowMostVisitedOnTabSwitcher() {
return ChromeFeatureList.isInitialized()
&& ChromeFeatureList
.getFieldTrialParamByFeature(ChromeFeatureList.START_SURFACE_ANDROID,
"start_surface_variation")
.equals("tasksonly");
}
/** /**
* Check if we should handle the navigation. If so, create a new tab and load the URL. * Check if we should handle the navigation. If so, create a new tab and load the URL.
* *
......
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