Commit 4350a5e6 authored by gogerald's avatar gogerald Committed by Commit Bot

[StartSurface] Fix tab switcher button color on the start surface toolbar

Screenshots:
Incognito mode:
https://drive.google.com/file/d/1Dt28k02QOq2aB0a2Oc3VVK10ScaSfwmF/view?usp=sharing
Dark mode:
https://drive.google.com/file/d/1ke4Aa8DG2SQ4X77CIsxODvacEAJB2P7Y/view?usp=sharing
Normal mode:
https://drive.google.com/file/d/1-L4G1POaYiYSIweRxRBFrpD1QDEmRI1x/view?usp=sharing

Bug: 1083853
Change-Id: I6e00a511b72c384b217a10dcbdf0e0c3c83399e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2208609
Commit-Queue: Yusuf Ozuysal <yusufo@chromium.org>
Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Reviewed-by: default avatarPatrick Noland <pnoland@chromium.org>
Auto-Submit: Ganggui Tang <gogerald@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772380}
parent b63cffc3
...@@ -22,6 +22,7 @@ import org.chromium.chrome.browser.ntp.NewTabPage; ...@@ -22,6 +22,7 @@ import org.chromium.chrome.browser.ntp.NewTabPage;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabThemeColorHelper; import org.chromium.chrome.browser.tab.TabThemeColorHelper;
import org.chromium.chrome.browser.tasks.tab_management.TabUiFeatureUtilities; import org.chromium.chrome.browser.tasks.tab_management.TabUiFeatureUtilities;
import org.chromium.chrome.features.start_surface.StartSurfaceConfiguration;
import org.chromium.components.browser_ui.styles.ChromeColors; import org.chromium.components.browser_ui.styles.ChromeColors;
import org.chromium.ui.util.ColorUtils; import org.chromium.ui.util.ColorUtils;
...@@ -160,6 +161,8 @@ public class ToolbarColors { ...@@ -160,6 +161,8 @@ public class ToolbarColors {
final boolean isHorizontalTabSwitcherEnabled = ChromeFeatureList.isInitialized() final boolean isHorizontalTabSwitcherEnabled = ChromeFeatureList.isInitialized()
&& ChromeFeatureList.isEnabled(ChromeFeatureList.HORIZONTAL_TAB_SWITCHER_ANDROID); && ChromeFeatureList.isEnabled(ChromeFeatureList.HORIZONTAL_TAB_SWITCHER_ANDROID);
final boolean isTabGridEnabled = TabUiFeatureUtilities.isGridTabSwitcherEnabled(); final boolean isTabGridEnabled = TabUiFeatureUtilities.isGridTabSwitcherEnabled();
return (isAccessibilityEnabled || isHorizontalTabSwitcherEnabled || isTabGridEnabled); final boolean isStartSurfaceEnabled = StartSurfaceConfiguration.isStartSurfaceEnabled();
return (isAccessibilityEnabled || isHorizontalTabSwitcherEnabled || isTabGridEnabled
|| isStartSurfaceEnabled);
} }
} }
...@@ -326,7 +326,9 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve ...@@ -326,7 +326,9 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve
mToolbar = new TopToolbarCoordinator(controlContainer, mActivity.findViewById(R.id.toolbar), mToolbar = new TopToolbarCoordinator(controlContainer, mActivity.findViewById(R.id.toolbar),
identityDiscController, mLocationBarModel, mToolbarTabController, identityDiscController, mLocationBarModel, mToolbarTabController,
new UserEducationHelper(mActivity), buttonDataProviders, new UserEducationHelper(mActivity), buttonDataProviders,
mOverviewModeBehaviorSupplier); mOverviewModeBehaviorSupplier,
mActivity.isTablet() ? mAppThemeColorProvider : mTabThemeColorProvider,
mAppThemeColorProvider);
mActionModeController = mActionModeController =
new ActionModeController(mActivity, mActionBarDelegate, toolbarActionModeCallback); new ActionModeController(mActivity, mActionBarDelegate, toolbarActionModeCallback);
...@@ -664,8 +666,6 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve ...@@ -664,8 +666,6 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve
mToolbar.setTabCountProvider(mTabCountProvider); mToolbar.setTabCountProvider(mTabCountProvider);
mToolbar.setIncognitoStateProvider(mIncognitoStateProvider); mToolbar.setIncognitoStateProvider(mIncognitoStateProvider);
mToolbar.setThemeColorProvider(
mActivity.isTablet() ? mAppThemeColorProvider : mTabThemeColorProvider);
AccessibilityUtil.addObserver(this); AccessibilityUtil.addObserver(this);
......
...@@ -54,7 +54,8 @@ public class StartSurfaceToolbarCoordinator { ...@@ -54,7 +54,8 @@ public class StartSurfaceToolbarCoordinator {
StartSurfaceToolbarCoordinator(ViewStub startSurfaceToolbarStub, StartSurfaceToolbarCoordinator(ViewStub startSurfaceToolbarStub,
IdentityDiscController identityDiscController, UserEducationHelper userEducationHelper, IdentityDiscController identityDiscController, UserEducationHelper userEducationHelper,
ObservableSupplier<OverviewModeBehavior> overviewModeBehaviorSupplier) { ObservableSupplier<OverviewModeBehavior> overviewModeBehaviorSupplier,
ThemeColorProvider provider) {
mStub = startSurfaceToolbarStub; mStub = startSurfaceToolbarStub;
mOverviewModeBehaviorSupplier = overviewModeBehaviorSupplier; mOverviewModeBehaviorSupplier = overviewModeBehaviorSupplier;
...@@ -88,6 +89,8 @@ public class StartSurfaceToolbarCoordinator { ...@@ -88,6 +89,8 @@ public class StartSurfaceToolbarCoordinator {
}, },
StartSurfaceConfiguration.START_SURFACE_HIDE_INCOGNITO_SWITCH.getValue(), StartSurfaceConfiguration.START_SURFACE_HIDE_INCOGNITO_SWITCH.getValue(),
StartSurfaceConfiguration.START_SURFACE_SHOW_STACK_TAB_SWITCHER.getValue()); StartSurfaceConfiguration.START_SURFACE_SHOW_STACK_TAB_SWITCHER.getValue());
mThemeColorProvider = provider;
} }
/** /**
...@@ -194,17 +197,6 @@ public class StartSurfaceToolbarCoordinator { ...@@ -194,17 +197,6 @@ public class StartSurfaceToolbarCoordinator {
} }
} }
/**
* @param themeColorProvider The {@link ThemeColorProvider} to update the tab switcher button.
*/
void setThemeColorProvider(ThemeColorProvider themeColorProvider) {
if (mTabSwitcherButtonCoordinator != null) {
mTabSwitcherButtonCoordinator.setThemeColorProvider(themeColorProvider);
} else {
mThemeColorProvider = themeColorProvider;
}
}
/** /**
* @param onClickListener The {@link OnClickListener} for the tab switcher button. * @param onClickListener The {@link OnClickListener} for the tab switcher button.
*/ */
...@@ -253,15 +245,12 @@ public class StartSurfaceToolbarCoordinator { ...@@ -253,15 +245,12 @@ public class StartSurfaceToolbarCoordinator {
} }
mTabSwitcherButtonCoordinator = mTabSwitcherButtonCoordinator =
new TabSwitcherButtonCoordinator(mTabSwitcherButtonView); new TabSwitcherButtonCoordinator(mTabSwitcherButtonView);
mTabSwitcherButtonCoordinator.setThemeColorProvider(mThemeColorProvider);
mTabSwitcherButtonView.setVisibility(View.VISIBLE); mTabSwitcherButtonView.setVisibility(View.VISIBLE);
if (mTabCountProvider != null) { if (mTabCountProvider != null) {
mTabSwitcherButtonCoordinator.setTabCountProvider(mTabCountProvider); mTabSwitcherButtonCoordinator.setTabCountProvider(mTabCountProvider);
mTabCountProvider = null; mTabCountProvider = null;
} }
if (mThemeColorProvider != null) {
mTabSwitcherButtonCoordinator.setThemeColorProvider(mThemeColorProvider);
mThemeColorProvider = null;
}
if (mTabSwitcherClickListener != null) { if (mTabSwitcherClickListener != null) {
mTabSwitcherButtonCoordinator.setTabSwitcherListener(mTabSwitcherClickListener); mTabSwitcherButtonCoordinator.setTabSwitcherListener(mTabSwitcherClickListener);
mTabSwitcherClickListener = null; mTabSwitcherClickListener = null;
......
...@@ -97,12 +97,16 @@ public class TopToolbarCoordinator implements Toolbar { ...@@ -97,12 +97,16 @@ public class TopToolbarCoordinator implements Toolbar {
* browsing mode toolbar. * browsing mode toolbar.
* @param overviewModeBehaviorSupplier Supplier of the overview mode manager for the current * @param overviewModeBehaviorSupplier Supplier of the overview mode manager for the current
* profile. * profile.
* @param normalThemeColorProvider The {@link ThemeColorProvider} for normal mode.
* @param overviewThemeColorProvider The {@link ThemeColorProvider} for overview mode.
*/ */
public TopToolbarCoordinator(ToolbarControlContainer controlContainer, public TopToolbarCoordinator(ToolbarControlContainer controlContainer,
ToolbarLayout toolbarLayout, IdentityDiscController identityDiscController, ToolbarLayout toolbarLayout, IdentityDiscController identityDiscController,
ToolbarDataProvider toolbarDataProvider, ToolbarTabController tabController, ToolbarDataProvider toolbarDataProvider, ToolbarTabController tabController,
UserEducationHelper userEducationHelper, List<ButtonDataProvider> buttonDataProviders, UserEducationHelper userEducationHelper, List<ButtonDataProvider> buttonDataProviders,
ObservableSupplier<OverviewModeBehavior> overviewModeBehaviorSupplier) { ObservableSupplier<OverviewModeBehavior> overviewModeBehaviorSupplier,
ThemeColorProvider normalThemeColorProvider,
ThemeColorProvider overviewThemeColorProvider) {
mToolbarLayout = toolbarLayout; mToolbarLayout = toolbarLayout;
mIdentityDiscController = identityDiscController; mIdentityDiscController = identityDiscController;
mOptionalButtonController = new OptionalBrowsingModeButtonController(buttonDataProviders, mOptionalButtonController = new OptionalBrowsingModeButtonController(buttonDataProviders,
...@@ -116,8 +120,8 @@ public class TopToolbarCoordinator implements Toolbar { ...@@ -116,8 +120,8 @@ public class TopToolbarCoordinator implements Toolbar {
if (StartSurfaceConfiguration.isStartSurfaceEnabled()) { if (StartSurfaceConfiguration.isStartSurfaceEnabled()) {
mStartSurfaceToolbarCoordinator = new StartSurfaceToolbarCoordinator( mStartSurfaceToolbarCoordinator = new StartSurfaceToolbarCoordinator(
controlContainer.getRootView().findViewById(R.id.tab_switcher_toolbar_stub), controlContainer.getRootView().findViewById(R.id.tab_switcher_toolbar_stub),
mIdentityDiscController, userEducationHelper, mIdentityDiscController, userEducationHelper, mOverviewModeBehaviorSupplier,
mOverviewModeBehaviorSupplier); overviewThemeColorProvider);
} else { } else {
mTabSwitcherModeCoordinatorPhone = new TabSwitcherModeTTCoordinatorPhone( mTabSwitcherModeCoordinatorPhone = new TabSwitcherModeTTCoordinatorPhone(
controlContainer.getRootView().findViewById( controlContainer.getRootView().findViewById(
...@@ -127,6 +131,12 @@ public class TopToolbarCoordinator implements Toolbar { ...@@ -127,6 +131,12 @@ public class TopToolbarCoordinator implements Toolbar {
controlContainer.setToolbar(this); controlContainer.setToolbar(this);
HomepageManager.getInstance().addListener(mHomepageStateListener); HomepageManager.getInstance().addListener(mHomepageStateListener);
mToolbarLayout.initialize(toolbarDataProvider, tabController); mToolbarLayout.initialize(toolbarDataProvider, tabController);
final MenuButton menuButtonWrapper = getMenuButtonWrapper();
if (menuButtonWrapper != null) {
menuButtonWrapper.setThemeColorProvider(normalThemeColorProvider);
}
mToolbarLayout.setThemeColorProvider(normalThemeColorProvider);
} }
/** /**
...@@ -522,20 +532,6 @@ public class TopToolbarCoordinator implements Toolbar { ...@@ -522,20 +532,6 @@ public class TopToolbarCoordinator implements Toolbar {
} }
} }
/**
* @param provider The provider used to determine theme color.
*/
public void setThemeColorProvider(ThemeColorProvider provider) {
final MenuButton menuButtonWrapper = getMenuButtonWrapper();
if (menuButtonWrapper != null) {
menuButtonWrapper.setThemeColorProvider(provider);
}
mToolbarLayout.setThemeColorProvider(provider);
if (mStartSurfaceToolbarCoordinator != null) {
mStartSurfaceToolbarCoordinator.setThemeColorProvider(provider);
}
}
/** /**
* Gives inheriting classes the chance to update themselves based on default search engine * Gives inheriting classes the chance to update themselves based on default search engine
* changes. * changes.
......
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