Skip to content

Commit

Permalink
[Android] Toolbar code was reorganized
Browse files Browse the repository at this point in the history
Chromium change:
https://chromium.googlesource.com/chromium/src.git/+/bfdfa6488a2a0babca504fd614b43eb54fc0d864

Toolbar: Remove deps on feature flags

Removes the dependencies on the following flags. They are now passed
from ToolbarManager through ctors/setters:

- TabUiFeatureUtilities.isGridTabSwitcherEnabled()
- TabUiFeatureUtilities.isTabToGtsAnimationEnabled()
- StartSurfaceConfiguration.isStartSurfaceEnabled()
- VrModuleProvider.getDelegate().isInVr()

This change allows following toolbar classes to be in the modularized
target:

- NewTabButton
- ProgressAnimationSmooth
- ToolbarProgressBar/Test
- LoadProgressCoordinator MVC/Test
- TabSwitcherButtonCoordinator MVC
- TopToolbarOverlayCoordinator MVC
- TopToolbarSceneLayer

Bug: 1127732
  • Loading branch information
samartnik authored and mkarolin committed Mar 10, 2021
1 parent 2fdb501 commit 8dde273
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.chromium.chrome.browser.fullscreen.FullscreenManager;
import org.chromium.chrome.browser.homepage.HomepageManager;
import org.chromium.chrome.browser.identity_disc.IdentityDiscController;
import org.chromium.chrome.browser.intent.IntentMetadata;
import org.chromium.chrome.browser.layouts.LayoutStateProvider;
import org.chromium.chrome.browser.lifecycle.ActivityLifecycleDispatcher;
import org.chromium.chrome.browser.night_mode.NightModeStateProvider;
Expand Down Expand Up @@ -124,7 +123,7 @@ public BraveToolbarManager(AppCompatActivity activity, BrowserControlsSizer cont
ObservableSupplier<TabModelSelector> tabModelSelectorSupplier,
OneshotSupplier<StartSurface> startSurfaceSupplier,
ObservableSupplier<Boolean> omniboxFocusStateSupplier,
OneshotSupplier<IntentMetadata> intentMetadataOneshotSupplier,
OneshotSupplier<ToolbarIntentMetadata> intentMetadataOneshotSupplier,
OneshotSupplier<Boolean> promoShownOneshotSupplier, WindowAndroid windowAndroid,
Supplier<Boolean> isInOverviewModeSupplier, boolean isCustomTab,
Supplier<ModalDialogManager> modalDialogManagerSupplier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.chromium.chrome.browser.theme.ThemeColorProvider;
import org.chromium.chrome.browser.theme.ThemeColorProvider.ThemeColorObserver;
import org.chromium.chrome.browser.theme.ThemeColorProvider.TintObserver;
import org.chromium.chrome.browser.theme.ThemeUtils;
import org.chromium.chrome.browser.toolbar.ToolbarColors;
import org.chromium.ui.widget.ChromeImageButton;

Expand Down Expand Up @@ -104,7 +105,7 @@ private void updateBackground() {
return;
}
mBackground.setColorFilter(
ToolbarColors.getTextBoxColorForToolbarBackgroundInNonNativePage(mResources,
ThemeUtils.getTextBoxColorForToolbarBackgroundInNonNativePage(mResources,
mThemeColorProvider.getThemeColor(),
mThemeColorProvider.useLight()
&& mIncognitoStateProvider.isIncognitoSelected()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.chromium.chrome.browser.theme.ThemeColorProvider;
import org.chromium.chrome.browser.theme.ThemeColorProvider.ThemeColorObserver;
import org.chromium.chrome.browser.theme.ThemeColorProvider.TintObserver;
import org.chromium.chrome.browser.theme.ThemeUtils;
import org.chromium.chrome.browser.toolbar.ToolbarColors;
import org.chromium.ui.widget.ChromeImageButton;

Expand Down Expand Up @@ -95,7 +96,7 @@ public void onIncognitoStateChanged(boolean isIncognito) {
private void updateBackground() {
if (mThemeColorProvider == null || mIncognitoStateProvider == null) return;

mBackground.setColorFilter(ToolbarColors.getTextBoxColorForToolbarBackgroundInNonNativePage(
mBackground.setColorFilter(ThemeUtils.getTextBoxColorForToolbarBackgroundInNonNativePage(
mResources, mThemeColorProvider.getThemeColor(),
mIncognitoStateProvider.isIncognitoSelected()
&& mThemeColorProvider.useLight()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ class BraveTabSwitcherModeTTCoordinatorPhone extends TabSwitcherModeTTCoordinato
private boolean mIsBottomToolbarVisible;
private MenuButtonCoordinator mBraveMenuButtonCoordinator;

BraveTabSwitcherModeTTCoordinatorPhone(
ViewStub tabSwitcherToolbarStub, MenuButtonCoordinator menuButtonCoordinator) {
super(tabSwitcherToolbarStub, menuButtonCoordinator);
BraveTabSwitcherModeTTCoordinatorPhone(ViewStub tabSwitcherToolbarStub,
MenuButtonCoordinator menuButtonCoordinator, boolean isGridTabSwitcherEnabled,
boolean isTabToGtsAnimationEnabled) {
super(tabSwitcherToolbarStub, menuButtonCoordinator, isGridTabSwitcherEnabled,
isTabToGtsAnimationEnabled);
mBraveMenuButtonCoordinator = menuButtonCoordinator;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.chromium.base.Log;
import org.chromium.base.MathUtils;
import org.chromium.base.ThreadUtils;
import org.chromium.base.supplier.BooleanSupplier;
import org.chromium.base.task.AsyncTask;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.BraveAdsNativeHelper;
Expand Down Expand Up @@ -93,6 +94,7 @@
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.tabmodel.TabModelSelectorTabModelObserver;
import org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver;
import org.chromium.chrome.browser.theme.ThemeUtils;
import org.chromium.chrome.browser.toolbar.HomeButton;
import org.chromium.chrome.browser.toolbar.ToolbarColors;
import org.chromium.chrome.browser.toolbar.ToolbarDataProvider;
Expand Down Expand Up @@ -1101,7 +1103,7 @@ private void updateNotificationBadgeForNewInstall() {

@Override
public void onThemeColorChanged(int color, boolean shouldAnimate) {
final int textBoxColor = ToolbarColors.getTextBoxColorForToolbarBackgroundInNonNativePage(
final int textBoxColor = ThemeUtils.getTextBoxColorForToolbarBackgroundInNonNativePage(
getResources(), color, isIncognito());
updateModernLocationBarColor(textBoxColor);
}
Expand Down Expand Up @@ -1174,8 +1176,9 @@ private boolean isMenuButtonOnBottom() {

@Override
protected void initialize(ToolbarDataProvider toolbarDataProvider,
ToolbarTabController tabController, MenuButtonCoordinator menuButtonCoordinator) {
super.initialize(toolbarDataProvider, tabController, menuButtonCoordinator);
ToolbarTabController tabController, MenuButtonCoordinator menuButtonCoordinator,
BooleanSupplier isInVrSupplier) {
super.initialize(toolbarDataProvider, tabController, menuButtonCoordinator, isInVrSupplier);
BraveMenuButtonCoordinator.setMenuFromBottom(isMenuButtonOnBottom());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.content.Context;

import org.chromium.base.Callback;
import org.chromium.base.supplier.BooleanSupplier;
import org.chromium.base.supplier.ObservableSupplier;
import org.chromium.base.supplier.OneshotSupplier;
import org.chromium.base.supplier.Supplier;
Expand Down Expand Up @@ -49,22 +50,26 @@ public BraveTopToolbarCoordinator(ToolbarControlContainer controlContainer,
ObservableSupplier<Boolean> identityDiscStateSupplier,
Callback<Runnable> invalidatorCallback, Supplier<ButtonData> identityDiscButtonSupplier,
OneshotSupplier<StartSurface> startSurfaceSupplier,
Supplier<ResourceManager> resourceManagerSupplier) {
Supplier<ResourceManager> resourceManagerSupplier, BooleanSupplier isInVrSupplier,
boolean isGridTabSwitcherEnabled, boolean isTabToGtsAnimationEnabled,
boolean isStartSurfaceEnabled) {
super(controlContainer, toolbarLayout, toolbarDataProvider, tabController,
userEducationHelper, buttonDataProviders, layoutStateProviderSupplier,
normalThemeColorProvider, overviewThemeColorProvider,
browsingModeMenuButtonCoordinator, overviewModeMenuButtonCoordinator,
appMenuButtonHelperSupplier, tabModelSelectorSupplier, homeButtonVisibilitySupplier,
identityDiscStateSupplier, invalidatorCallback, identityDiscButtonSupplier,
startSurfaceSupplier, resourceManagerSupplier);
startSurfaceSupplier, resourceManagerSupplier, isInVrSupplier,
isGridTabSwitcherEnabled, isTabToGtsAnimationEnabled, isStartSurfaceEnabled);

mBraveToolbarLayout = toolbarLayout;

if (isToolbarPhone()) {
if (!StartSurfaceConfiguration.isStartSurfaceEnabled()) {
mTabSwitcherModeCoordinatorPhone = new BraveTabSwitcherModeTTCoordinatorPhone(
controlContainer.getRootView().findViewById(R.id.tab_switcher_toolbar_stub),
overviewModeMenuButtonCoordinator);
overviewModeMenuButtonCoordinator, isGridTabSwitcherEnabled,
isTabToGtsAnimationEnabled);
}
}
}
Expand Down

0 comments on commit 8dde273

Please sign in to comment.