Commit be3c1659 authored by Pedro Amaral's avatar Pedro Amaral Committed by Commit Bot

Introducing Bottom Controls Component

Introduces a new root MVC component for bottom controls UI. This
component has a composited component to allow the bottom controls
to be scrolled offscreen. Currently only the split toolbar lives in
the bottom controls component but soon tab groups bottom toobar will
also live there.

Change-Id: I2070301da2faf6a2182dacf0a75b66b2bd97e61a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1496599
Commit-Queue: Pedro Amaral <amaralp@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638372}
parent d191cd94
<?xml version="1.0" encoding="utf-8"?>
<!-- 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. -->
<org.chromium.chrome.browser.toolbar.bottom.ScrollingBottomViewResourceFrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_toolbar_height_with_shadow" >
<ImageView
android:id="@+id/bottom_container_top_shadow"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_shadow_height"
android:src="@drawable/modern_toolbar_shadow"
android:scaleType="fitXY"
android:scaleY="-1"
tools:ignore="ContentDescription" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/bottom_container_slot">
<ViewStub
android:id="@+id/bottom_toolbar_stub"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start|bottom"
android:inflatedId="@+id/bottom_toolbar"
android:layout="@layout/bottom_toolbar" />
</FrameLayout>
</LinearLayout>
</org.chromium.chrome.browser.toolbar.bottom.ScrollingBottomViewResourceFrameLayout>
...@@ -6,14 +6,14 @@ ...@@ -6,14 +6,14 @@
<FrameLayout <FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" > android:layout_height="@dimen/bottom_toolbar_height" >
<include layout="@layout/bottom_toolbar_browsing" /> <include layout="@layout/bottom_toolbar_browsing" />
<ViewStub <ViewStub
android:id="@+id/bottom_toolbar_tab_switcher_mode_stub" android:id="@+id/bottom_toolbar_tab_switcher_mode_stub"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/bottom_toolbar_height_with_shadow" android:layout_height="wrap_content"
android:inflatedId="@+id/bottom_toolbar_tab_switcher_mode" android:inflatedId="@+id/bottom_toolbar_tab_switcher_mode"
android:layout="@layout/bottom_toolbar_tab_switcher" /> android:layout="@layout/bottom_toolbar_tab_switcher" />
......
...@@ -3,80 +3,57 @@ ...@@ -3,80 +3,57 @@
Use of this source code is governed by a BSD-style license that can be Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. --> found in the LICENSE file. -->
<org.chromium.chrome.browser.toolbar.bottom.ScrollingBottomViewResourceFrameLayout
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/bottom_toolbar_browsing"
android:id="@+id/bottom_toolbar_control_container" android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="@dimen/bottom_toolbar_height" > android:minHeight="@dimen/bottom_toolbar_height"
android:background="@color/modern_primary_color"
<ImageView android:layout_gravity="top|center_horizontal"
android:id="@+id/bottom_toolbar_top_shadow" android:paddingStart="@dimen/bottom_toolbar_start_padding"
android:layout_width="match_parent" android:paddingEnd="@dimen/bottom_toolbar_end_padding" >
android:layout_height="@dimen/toolbar_shadow_height"
android:src="@drawable/modern_toolbar_shadow"
android:scaleType="fitXY"
android:scaleY="-1"
tools:ignore="ContentDescription" />
<org.chromium.chrome.browser.widget.bottomsheet.TouchRestrictingFrameLayout
android:id="@+id/bottom_toolbar_container"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_toolbar_height"
android:layout_marginTop="@dimen/toolbar_shadow_height" >
<LinearLayout
android:id="@+id/bottom_toolbar_buttons"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/modern_primary_color"
android:layout_gravity="top|center_horizontal"
android:paddingStart="@dimen/bottom_toolbar_start_padding"
android:paddingEnd="@dimen/bottom_toolbar_end_padding" >
<org.chromium.chrome.browser.toolbar.HomeButton
android:id="@+id/home_button"
app:tint="@color/standard_mode_tint"
style="@style/BottomToolbarButton"
android:contentDescription="@string/accessibility_toolbar_btn_home" />
<include layout="@layout/toolbar_space" /> <org.chromium.chrome.browser.toolbar.HomeButton
android:id="@+id/home_button"
app:tint="@color/standard_mode_tint"
style="@style/BottomToolbarButton"
android:contentDescription="@string/accessibility_toolbar_btn_home" />
<org.chromium.chrome.browser.toolbar.bottom.ShareButton <include layout="@layout/toolbar_space" />
android:id="@+id/share_button"
style="@style/BottomToolbarButton"
android:src="@drawable/ic_share_white_24dp"
app:tint="@color/standard_mode_tint"
android:contentDescription="@string/share" />
<include layout="@layout/toolbar_space" /> <org.chromium.chrome.browser.toolbar.bottom.ShareButton
android:id="@+id/share_button"
style="@style/BottomToolbarButton"
android:src="@drawable/ic_share_white_24dp"
app:tint="@color/standard_mode_tint"
android:contentDescription="@string/share" />
<org.chromium.chrome.browser.toolbar.bottom.SearchAccelerator <include layout="@layout/toolbar_space" />
android:id="@+id/search_accelerator"
android:layout_width="@dimen/search_accelerator_width"
android:layout_height="@dimen/search_accelerator_height"
android:layout_gravity="center"
android:paddingTop="@dimen/search_accelerator_height_padding"
android:paddingBottom="@dimen/search_accelerator_height_padding"
android:src="@drawable/ic_search"
android:contentDescription="@string/accessibility_toolbar_btn_search_accelerator" />
<include layout="@layout/toolbar_space" /> <org.chromium.chrome.browser.toolbar.bottom.SearchAccelerator
android:id="@+id/search_accelerator"
android:layout_width="@dimen/search_accelerator_width"
android:layout_height="@dimen/search_accelerator_height"
android:layout_gravity="center"
android:paddingTop="@dimen/search_accelerator_height_padding"
android:paddingBottom="@dimen/search_accelerator_height_padding"
android:src="@drawable/ic_search"
android:contentDescription="@string/accessibility_toolbar_btn_search_accelerator" />
<org.chromium.chrome.browser.toolbar.TabSwitcherButtonView <include layout="@layout/toolbar_space" />
android:id="@+id/tab_switcher_button"
style="@style/BottomToolbarButton"
android:contentDescription="@string/accessibility_toolbar_btn_tabswitcher_toggle_default" />
<include layout="@layout/toolbar_space" /> <org.chromium.chrome.browser.toolbar.TabSwitcherButtonView
android:id="@+id/tab_switcher_button"
style="@style/BottomToolbarButton"
android:contentDescription="@string/accessibility_toolbar_btn_tabswitcher_toggle_default" />
<include layout="@layout/menu_button" /> <include layout="@layout/toolbar_space" />
</LinearLayout> <include layout="@layout/menu_button" />
</org.chromium.chrome.browser.widget.bottomsheet.TouchRestrictingFrameLayout> </LinearLayout>
</org.chromium.chrome.browser.toolbar.bottom.ScrollingBottomViewResourceFrameLayout>
...@@ -14,15 +14,6 @@ ...@@ -14,15 +14,6 @@
android:visibility="gone" android:visibility="gone"
android:clickable="true" > android:clickable="true" >
<ImageView
android:id="@+id/bottom_toolbar_top_shadow"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_shadow_height"
android:src="@drawable/modern_toolbar_shadow"
android:scaleType="fitXY"
android:scaleY="-1"
tools:ignore="ContentDescription" />
<LinearLayout <LinearLayout
android:id="@+id/bottom_toolbar_buttons" android:id="@+id/bottom_toolbar_buttons"
android:orientation="horizontal" android:orientation="horizontal"
......
...@@ -84,12 +84,12 @@ ...@@ -84,12 +84,12 @@
android:visibility="gone" /> android:visibility="gone" />
<ViewStub <ViewStub
android:id="@+id/bottom_toolbar_stub" android:id="@+id/bottom_controls_stub"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="start|bottom" android:layout_gravity="start|bottom"
android:inflatedId="@+id/bottom_toolbar" android:inflatedId="@+id/bottom_controls"
android:layout="@layout/bottom_toolbar" /> android:layout="@layout/bottom_control_container" />
<ViewStub <ViewStub
android:id="@+id/control_container_stub" android:id="@+id/control_container_stub"
......
...@@ -84,7 +84,7 @@ import org.chromium.chrome.browser.tabmodel.TabModelObserver; ...@@ -84,7 +84,7 @@ import org.chromium.chrome.browser.tabmodel.TabModelObserver;
import org.chromium.chrome.browser.tabmodel.TabModelSelector; import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver; import org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver;
import org.chromium.chrome.browser.tabmodel.TabSelectionType; import org.chromium.chrome.browser.tabmodel.TabSelectionType;
import org.chromium.chrome.browser.toolbar.bottom.BottomToolbarCoordinator; import org.chromium.chrome.browser.toolbar.bottom.BottomControlsCoordinator;
import org.chromium.chrome.browser.toolbar.top.ActionModeController; import org.chromium.chrome.browser.toolbar.top.ActionModeController;
import org.chromium.chrome.browser.toolbar.top.ActionModeController.ActionBarDelegate; import org.chromium.chrome.browser.toolbar.top.ActionModeController.ActionBarDelegate;
import org.chromium.chrome.browser.toolbar.top.Toolbar; import org.chromium.chrome.browser.toolbar.top.Toolbar;
...@@ -177,7 +177,7 @@ public class ToolbarManager ...@@ -177,7 +177,7 @@ public class ToolbarManager
private TopToolbarCoordinator mToolbar; private TopToolbarCoordinator mToolbar;
private final ToolbarControlContainer mControlContainer; private final ToolbarControlContainer mControlContainer;
private BottomToolbarCoordinator mBottomToolbarCoordinator; private BottomControlsCoordinator mBottomControlsCoordinator;
private TabModelSelector mTabModelSelector; private TabModelSelector mTabModelSelector;
private TabModelSelectorObserver mTabModelSelectorObserver; private TabModelSelectorObserver mTabModelSelectorObserver;
private TabModelObserver mTabModelObserver; private TabModelObserver mTabModelObserver;
...@@ -782,11 +782,12 @@ public class ToolbarManager ...@@ -782,11 +782,12 @@ public class ToolbarManager
mActivity.onShareMenuItemSelected(false, isIncognito); mActivity.onShareMenuItemSelected(false, isIncognito);
}; };
mBottomToolbarCoordinator = new BottomToolbarCoordinator(mActivity.getFullscreenManager(), mBottomControlsCoordinator = new BottomControlsCoordinator(mActivity.getFullscreenManager(),
mActivity.findViewById(R.id.bottom_toolbar_stub), mActivity.findViewById(R.id.bottom_controls_stub),
mActivity.getActivityTabProvider(), homeButtonListener, searchAcceleratorListener, mActivity.getActivityTabProvider(), homeButtonListener, searchAcceleratorListener,
shareButtonListener); shareButtonListener);
mBottomToolbarCoordinator.setBottomToolbarVisible(mIsBottomToolbarVisible); mBottomControlsCoordinator.setBottomControlsVisible(mIsBottomToolbarVisible);
Toast.setGlobalExtraYOffset( Toast.setGlobalExtraYOffset(
mActivity.getResources().getDimensionPixelSize(R.dimen.bottom_toolbar_height)); mActivity.getResources().getDimensionPixelSize(R.dimen.bottom_toolbar_height));
} }
...@@ -826,8 +827,8 @@ public class ToolbarManager ...@@ -826,8 +827,8 @@ public class ToolbarManager
/** /**
* @return The coordinator for the bottom toolbar if it exists. * @return The coordinator for the bottom toolbar if it exists.
*/ */
public BottomToolbarCoordinator getBottomToolbarCoordinator() { public BottomControlsCoordinator getBottomToolbarCoordinator() {
return mBottomToolbarCoordinator; return mBottomControlsCoordinator;
} }
private void showMenuIPHTextBubble(ChromeActivity activity, Tracker tracker, String featureName, private void showMenuIPHTextBubble(ChromeActivity activity, Tracker tracker, String featureName,
...@@ -964,7 +965,7 @@ public class ToolbarManager ...@@ -964,7 +965,7 @@ public class ToolbarManager
mLayoutManager.addSceneChangeObserver(mSceneChangeObserver); mLayoutManager.addSceneChangeObserver(mSceneChangeObserver);
} }
if (mBottomToolbarCoordinator != null) { if (mBottomControlsCoordinator != null) {
final OnClickListener closeTabsClickListener = v -> { final OnClickListener closeTabsClickListener = v -> {
recordBottomToolbarUseForIPH(); recordBottomToolbarUseForIPH();
final boolean isIncognito = mTabModelSelector.isIncognitoSelected(); final boolean isIncognito = mTabModelSelector.isIncognitoSelected();
...@@ -977,14 +978,14 @@ public class ToolbarManager ...@@ -977,14 +978,14 @@ public class ToolbarManager
mTabModelSelector.getModel(isIncognito).closeAllTabs(); mTabModelSelector.getModel(isIncognito).closeAllTabs();
}; };
mAppMenuButtonHelper.setOnClickRunnable(() -> recordBottomToolbarUseForIPH()); mAppMenuButtonHelper.setOnClickRunnable(() -> recordBottomToolbarUseForIPH());
mBottomToolbarCoordinator.initializeWithNative( mBottomControlsCoordinator.initializeWithNative(
mActivity.getCompositorViewHolder().getResourceManager(), mActivity.getCompositorViewHolder().getResourceManager(),
mActivity.getCompositorViewHolder().getLayoutManager(), mActivity.getCompositorViewHolder().getLayoutManager(),
wrapBottomToolbarClickListenerForIPH(tabSwitcherClickHandler), wrapBottomToolbarClickListenerForIPH(tabSwitcherClickHandler),
wrapBottomToolbarClickListenerForIPH(newTabClickHandler), wrapBottomToolbarClickListenerForIPH(newTabClickHandler),
closeTabsClickListener, mAppMenuButtonHelper, mTabModelSelector, closeTabsClickListener, mAppMenuButtonHelper, mOverviewModeBehavior,
mOverviewModeBehavior, mActivity.getWindowAndroid(), mTabCountProvider, mActivity.getWindowAndroid(), mTabCountProvider, mIncognitoStateProvider,
mIncognitoStateProvider, mActivity.findViewById(R.id.control_container)); mActivity.findViewById(R.id.control_container));
// Allow the bottom toolbar to be focused in accessibility after the top toolbar. // Allow the bottom toolbar to be focused in accessibility after the top toolbar.
ApiCompatibilityUtils.setAccessibilityTraversalBefore( ApiCompatibilityUtils.setAccessibilityTraversalBefore(
...@@ -1007,8 +1008,8 @@ public class ToolbarManager ...@@ -1007,8 +1008,8 @@ public class ToolbarManager
*/ */
public void showAppMenuUpdateBadge() { public void showAppMenuUpdateBadge() {
mToolbar.showAppMenuUpdateBadge(); mToolbar.showAppMenuUpdateBadge();
if (mBottomToolbarCoordinator != null) { if (mBottomControlsCoordinator != null) {
mBottomToolbarCoordinator.showAppMenuUpdateBadge(); mBottomControlsCoordinator.showAppMenuUpdateBadge();
} }
} }
...@@ -1018,8 +1019,8 @@ public class ToolbarManager ...@@ -1018,8 +1019,8 @@ public class ToolbarManager
*/ */
public void removeAppMenuUpdateBadge(boolean animate) { public void removeAppMenuUpdateBadge(boolean animate) {
mToolbar.removeAppMenuUpdateBadge(animate); mToolbar.removeAppMenuUpdateBadge(animate);
if (mBottomToolbarCoordinator != null) { if (mBottomControlsCoordinator != null) {
mBottomToolbarCoordinator.removeAppMenuUpdateBadge(); mBottomControlsCoordinator.removeAppMenuUpdateBadge();
} }
} }
...@@ -1028,8 +1029,8 @@ public class ToolbarManager ...@@ -1028,8 +1029,8 @@ public class ToolbarManager
* TODO(amaralp): Only the top or bottom menu should be visible. * TODO(amaralp): Only the top or bottom menu should be visible.
*/ */
public boolean isShowingAppMenuUpdateBadge() { public boolean isShowingAppMenuUpdateBadge() {
if (mBottomToolbarCoordinator != null if (mBottomControlsCoordinator != null
&& mBottomToolbarCoordinator.isShowingAppMenuUpdateBadge()) { && mBottomControlsCoordinator.isShowingAppMenuUpdateBadge()) {
return true; return true;
} }
return mToolbar.isShowingAppMenuUpdateBadge(); return mToolbar.isShowingAppMenuUpdateBadge();
...@@ -1093,8 +1094,8 @@ public class ToolbarManager ...@@ -1093,8 +1094,8 @@ public class ToolbarManager
* @return The view containing the pop up menu button. * @return The view containing the pop up menu button.
*/ */
public @Nullable View getMenuButton() { public @Nullable View getMenuButton() {
if (mBottomToolbarCoordinator != null && isMenuButtonInBottomToolbar()) { if (mBottomControlsCoordinator != null && isMenuButtonInBottomToolbar()) {
return mBottomToolbarCoordinator.getMenuButtonWrapper().getImageButton(); return mBottomControlsCoordinator.getMenuButtonWrapper().getImageButton();
} }
return mToolbar.getMenuButton(); return mToolbar.getMenuButton();
} }
...@@ -1164,9 +1165,9 @@ public class ToolbarManager ...@@ -1164,9 +1165,9 @@ public class ToolbarManager
mLayoutManager = null; mLayoutManager = null;
} }
if (mBottomToolbarCoordinator != null) { if (mBottomControlsCoordinator != null) {
mBottomToolbarCoordinator.destroy(); mBottomControlsCoordinator.destroy();
mBottomToolbarCoordinator = null; mBottomControlsCoordinator = null;
} }
if (mOmniboxStartupMetrics != null) { if (mOmniboxStartupMetrics != null) {
...@@ -1206,11 +1207,11 @@ public class ToolbarManager ...@@ -1206,11 +1207,11 @@ public class ToolbarManager
public void onOrientationChange() { public void onOrientationChange() {
if (mActionModeController != null) mActionModeController.showControlsOnOrientationChange(); if (mActionModeController != null) mActionModeController.showControlsOnOrientationChange();
if (mBottomToolbarCoordinator != null && FeatureUtilities.isAdaptiveToolbarEnabled()) { if (mBottomControlsCoordinator != null && FeatureUtilities.isAdaptiveToolbarEnabled()) {
mIsBottomToolbarVisible = mActivity.getResources().getConfiguration().orientation mIsBottomToolbarVisible = mActivity.getResources().getConfiguration().orientation
!= Configuration.ORIENTATION_LANDSCAPE; != Configuration.ORIENTATION_LANDSCAPE;
mToolbar.onBottomToolbarVisibilityChanged(mIsBottomToolbarVisible); mToolbar.onBottomToolbarVisibilityChanged(mIsBottomToolbarVisible);
mBottomToolbarCoordinator.setBottomToolbarVisible(mIsBottomToolbarVisible); mBottomControlsCoordinator.setBottomControlsVisible(mIsBottomToolbarVisible);
if (mAppMenuButtonHelper != null) { if (mAppMenuButtonHelper != null) {
mAppMenuButtonHelper.setMenuShowsFromBottom(mIsBottomToolbarVisible); mAppMenuButtonHelper.setMenuShowsFromBottom(mIsBottomToolbarVisible);
} }
...@@ -1345,8 +1346,8 @@ public class ToolbarManager ...@@ -1345,8 +1346,8 @@ public class ToolbarManager
@Nullable @Nullable
private MenuButton getMenuButtonWrapper() { private MenuButton getMenuButtonWrapper() {
if (mBottomToolbarCoordinator != null) { if (mBottomControlsCoordinator != null) {
return mBottomToolbarCoordinator.getMenuButtonWrapper(); return mBottomControlsCoordinator.getMenuButtonWrapper();
} }
return mToolbar.getMenuButtonWrapper(); return mToolbar.getMenuButtonWrapper();
......
// 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.toolbar.bottom;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewStub;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ActivityTabProvider;
import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper;
import org.chromium.chrome.browser.compositor.layouts.LayoutManager;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior;
import org.chromium.chrome.browser.compositor.layouts.ToolbarSwipeLayout;
import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager;
import org.chromium.chrome.browser.toolbar.IncognitoStateProvider;
import org.chromium.chrome.browser.toolbar.MenuButton;
import org.chromium.chrome.browser.toolbar.TabCountProvider;
import org.chromium.chrome.browser.toolbar.bottom.BottomControlsViewBinder.ViewHolder;
import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.modelutil.PropertyModelChangeProcessor;
import org.chromium.ui.resources.ResourceManager;
/**
* The root coordinator for the bottom controls component. This component is intended for use with
* bottom UI that re-sizes the web contents, scrolls off-screen, and hides when the keyboard is
* shown. This class has two primary components, an Android view and a composited texture that draws
* when the controls are being scrolled off-screen. The Android version does not draw unless the
* controls offset is 0.
*/
public class BottomControlsCoordinator {
/** The mediator that handles events from outside the bottom controls. */
private final BottomControlsMediator mMediator;
/** The coordinator for the split toolbar's bottom toolbar component. */
private final BottomToolbarCoordinator mBottomToolbarCoordinator;
/**
* Build the coordinator that manages the bottom controls.
* @param fullscreenManager A {@link ChromeFullscreenManager} to update the bottom controls
* height for the renderer.
* @param stub The bottom controls {@link ViewStub} to inflate.
* @param tabProvider The {@link ActivityTabProvider} used in the bottom toolbar.
* @param homeButtonListener The {@link OnClickListener} for the bottom toolbar's home button.
* @param searchAcceleratorListener The {@link OnClickListener} for the bottom toolbar's
* search accelerator.
* @param shareButtonListener The {@link OnClickListener} for the bottom toolbar's share button.
*/
public BottomControlsCoordinator(ChromeFullscreenManager fullscreenManager, ViewStub stub,
ActivityTabProvider tabProvider, OnClickListener homeButtonListener,
OnClickListener searchAcceleratorListener, OnClickListener shareButtonListener) {
final ScrollingBottomViewResourceFrameLayout root =
(ScrollingBottomViewResourceFrameLayout) stub.inflate();
PropertyModel model = new PropertyModel(BottomControlsProperties.ALL_KEYS);
PropertyModelChangeProcessor.create(
model, new ViewHolder(root), BottomControlsViewBinder::bind);
mMediator = new BottomControlsMediator(model, fullscreenManager,
root.getResources().getDimensionPixelOffset(R.dimen.bottom_toolbar_height));
mBottomToolbarCoordinator = new BottomToolbarCoordinator(
root.findViewById(R.id.bottom_toolbar_stub), tabProvider, homeButtonListener,
searchAcceleratorListener, shareButtonListener);
}
/**
* Initialize the bottom controls with the components that had native initialization
* dependencies.
* <p>
* Calling this must occur after the native library have completely loaded.
* @param resourceManager A {@link ResourceManager} for loading textures into the compositor.
* @param layoutManager A {@link LayoutManager} to attach overlays to.
* @param tabSwitcherListener An {@link OnClickListener} that is triggered when the
* bottom toolbar's tab switcher button is clicked.
* @param newTabClickListener An {@link OnClickListener} that is triggered when the
* bottom toolbar's new tab button is clicked.
* @param menuButtonHelper An {@link AppMenuButtonHelper} that is triggered when the
* bottom toolbar's menu button is clicked.
* @param overviewModeBehavior The overview mode manager.
* @param windowAndroid A {@link WindowAndroid} for watching keyboard visibility events.
* @param tabCountProvider Updates the tab count number in the tab switcher button and in the
* incognito toggle tab layout.
* @param incognitoStateProvider Notifies components when incognito mode is entered or exited.
* @param topToolbarRoot The root {@link ViewGroup} of the top toolbar.
*/
public void initializeWithNative(ResourceManager resourceManager, LayoutManager layoutManager,
OnClickListener tabSwitcherListener, OnClickListener newTabClickListener,
OnClickListener closeTabsClickListener, AppMenuButtonHelper menuButtonHelper,
OverviewModeBehavior overviewModeBehavior, WindowAndroid windowAndroid,
TabCountProvider tabCountProvider, IncognitoStateProvider incognitoStateProvider,
ViewGroup topToolbarRoot) {
mMediator.setLayoutManager(layoutManager);
mMediator.setResourceManager(resourceManager);
mMediator.setToolbarSwipeHandler(layoutManager.getToolbarSwipeHandler());
mMediator.setWindowAndroid(windowAndroid);
mBottomToolbarCoordinator.initializeWithNative(tabSwitcherListener, newTabClickListener,
closeTabsClickListener, menuButtonHelper, overviewModeBehavior, tabCountProvider,
incognitoStateProvider, topToolbarRoot);
}
/**
* @param isVisible Whether the bottom control is visible.
*/
public void setBottomControlsVisible(boolean isVisible) {
mMediator.setBottomControlsVisible(isVisible);
mBottomToolbarCoordinator.setBottomToolbarVisible(isVisible);
}
/**
* Show the update badge over the bottom toolbar's app menu.
*/
public void showAppMenuUpdateBadge() {
mBottomToolbarCoordinator.showAppMenuUpdateBadge();
}
/**
* Remove the update badge.
*/
public void removeAppMenuUpdateBadge() {
mBottomToolbarCoordinator.removeAppMenuUpdateBadge();
}
/**
* @return Whether the update badge is showing.
*/
public boolean isShowingAppMenuUpdateBadge() {
return mBottomToolbarCoordinator.isShowingAppMenuUpdateBadge();
}
/**
* @return The wrapper for the browsing mode toolbar's app menu button.
*/
public MenuButton getMenuButtonWrapper() {
return mBottomToolbarCoordinator.getMenuButtonWrapper();
}
/**
* @param layout The {@link ToolbarSwipeLayout} that the bottom controls will hook into. This
* allows the bottom controls to provide the layout with scene layers with the
* bottom controls' texture.
*/
public void setToolbarSwipeLayout(ToolbarSwipeLayout layout) {
mMediator.setToolbarSwipeLayout(layout);
}
/**
* Clean up any state when the bottom controls component is destroyed.
*/
public void destroy() {
mBottomToolbarCoordinator.destroy();
mMediator.destroy();
}
}
// 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.toolbar.bottom;
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanelManager;
import org.chromium.chrome.browser.compositor.layouts.Layout;
import org.chromium.chrome.browser.compositor.layouts.LayoutManager;
import org.chromium.chrome.browser.compositor.layouts.SceneChangeObserver;
import org.chromium.chrome.browser.compositor.layouts.ToolbarSwipeLayout;
import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeHandler;
import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager;
import org.chromium.ui.KeyboardVisibilityDelegate;
import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.resources.ResourceManager;
/**
* This class is responsible for reacting to events from the outside world, interacting with other
* coordinators, running most of the business logic associated with the bottom controls component,
* and updating the model accordingly.
*/
class BottomControlsMediator implements ChromeFullscreenManager.FullscreenListener,
KeyboardVisibilityDelegate.KeyboardVisibilityListener,
SceneChangeObserver,
OverlayPanelManager.OverlayPanelManagerObserver {
/** The model for the bottom controls component that holds all of its view state. */
private final PropertyModel mModel;
/** The fullscreen manager to observe browser controls events. */
private final ChromeFullscreenManager mFullscreenManager;
/** The height of the bottom bar in pixels */
private final int mBottomControlContainerHeight;
/** A {@link WindowAndroid} for watching keyboard visibility events. */
private WindowAndroid mWindowAndroid;
/** The bottom controls visibility. */
private boolean mIsBottomControlsVisible;
/** Whether any overlay panel is showing. */
private boolean mIsOverlayPanelShowing;
/** Whether the swipe layout is currently active. */
private boolean mIsInSwipeLayout;
/** Whether the soft keyboard is visible. */
private boolean mIsKeyboardVisible;
/**
* Build a new mediator that handles events from outside the bottom controls component.
* @param model The {@link BottomControlsProperties} that holds all the view state for the
* bottom
* controls component.
* @param fullscreenManager A {@link ChromeFullscreenManager} for events related to the browser
* controls.
* @param bottomControlContainerHeight The height of the bottom bar in pixels.
*/
BottomControlsMediator(PropertyModel model, ChromeFullscreenManager fullscreenManager,
int bottomControlContainerHeight) {
mModel = model;
mFullscreenManager = fullscreenManager;
mFullscreenManager.addListener(this);
mBottomControlContainerHeight = bottomControlContainerHeight;
}
/**
* @param swipeHandler The handler that controls the bottom toolbar's swipe behavior.
*/
void setToolbarSwipeHandler(EdgeSwipeHandler swipeHandler) {
mModel.set(BottomControlsProperties.TOOLBAR_SWIPE_HANDLER, swipeHandler);
}
void setResourceManager(ResourceManager resourceManager) {
mModel.set(BottomControlsProperties.RESOURCE_MANAGER, resourceManager);
}
void setToolbarSwipeLayout(ToolbarSwipeLayout layout) {
mModel.set(BottomControlsProperties.TOOLBAR_SWIPE_LAYOUT, layout);
}
void setWindowAndroid(WindowAndroid windowAndroid) {
assert mWindowAndroid == null : "#setWindowAndroid should only be called once per toolbar.";
// Watch for keyboard events so we can hide the bottom toolbar when the keyboard is showing.
mWindowAndroid = windowAndroid;
mWindowAndroid.getKeyboardDelegate().addKeyboardVisibilityListener(this);
}
void setLayoutManager(LayoutManager layoutManager) {
mModel.set(BottomControlsProperties.LAYOUT_MANAGER, layoutManager);
layoutManager.addSceneChangeObserver(this);
layoutManager.getOverlayPanelManager().addObserver(this);
}
void setBottomControlsVisible(boolean visible) {
mIsBottomControlsVisible = visible;
updateCompositedViewVisibility();
updateAndroidViewVisibility();
}
/**
* Clean up anything that needs to be when the bottom controls component is destroyed.
*/
void destroy() {
mFullscreenManager.removeListener(this);
if (mWindowAndroid != null) {
mWindowAndroid.getKeyboardDelegate().removeKeyboardVisibilityListener(this);
mWindowAndroid = null;
}
if (mModel.get(BottomControlsProperties.LAYOUT_MANAGER) != null) {
LayoutManager manager = mModel.get(BottomControlsProperties.LAYOUT_MANAGER);
manager.getOverlayPanelManager().removeObserver(this);
manager.removeSceneChangeObserver(this);
}
}
@Override
public void onContentOffsetChanged(int offset) {}
@Override
public void onControlsOffsetChanged(int topOffset, int bottomOffset, boolean needsAnimate) {
mModel.set(BottomControlsProperties.Y_OFFSET, bottomOffset);
updateAndroidViewVisibility();
}
@Override
public void onToggleOverlayVideoMode(boolean enabled) {}
@Override
public void onBottomControlsHeightChanged(int bottomControlsHeight) {}
@Override
public void onOverlayPanelShown() {
mIsOverlayPanelShowing = true;
updateAndroidViewVisibility();
}
@Override
public void onOverlayPanelHidden() {
mIsOverlayPanelShowing = false;
updateAndroidViewVisibility();
}
@Override
public void keyboardVisibilityChanged(boolean isShowing) {
mIsKeyboardVisible = isShowing;
updateCompositedViewVisibility();
updateAndroidViewVisibility();
}
@Override
public void onTabSelectionHinted(int tabId) {}
@Override
public void onSceneChange(Layout layout) {
mIsInSwipeLayout = layout instanceof ToolbarSwipeLayout;
updateAndroidViewVisibility();
}
/**
* The composited view is the composited version of the Android View. It is used to be able to
* scroll the bottom controls off-screen synchronously. Since the bottom controls live below
* the webcontents we re-size the webcontents through
* {@link ChromeFullscreenManager#setBottomControlsHeight(int)} whenever the composited view
* visibility changes.
*/
private void updateCompositedViewVisibility() {
final boolean isCompositedViewVisible = mIsBottomControlsVisible && !mIsKeyboardVisible;
mModel.set(BottomControlsProperties.COMPOSITED_VIEW_VISIBLE, isCompositedViewVisible);
mFullscreenManager.setBottomControlsHeight(
isCompositedViewVisible ? mBottomControlContainerHeight : 0);
}
/**
* The Android View is the interactive view. The composited view should always be behind the
* Android view which means we hide the Android view whenever the composited view is hidden.
* We also hide the Android view as we are scrolling the bottom controls off screen this is
* done by checking if {@link ChromeFullscreenManager#getBottomControlOffset()} is
* non-zero.
*/
private void updateAndroidViewVisibility() {
mModel.set(BottomControlsProperties.ANDROID_VIEW_VISIBLE,
mIsBottomControlsVisible && !mIsKeyboardVisible && !mIsOverlayPanelShowing
&& !mIsInSwipeLayout && mFullscreenManager.getBottomControlOffset() == 0);
}
}
\ No newline at end of file
// 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.toolbar.bottom;
import org.chromium.chrome.browser.compositor.layouts.LayoutManager;
import org.chromium.chrome.browser.compositor.layouts.ToolbarSwipeLayout;
import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeHandler;
import org.chromium.ui.modelutil.PropertyKey;
import org.chromium.ui.modelutil.PropertyModel.WritableBooleanPropertyKey;
import org.chromium.ui.modelutil.PropertyModel.WritableIntPropertyKey;
import org.chromium.ui.modelutil.PropertyModel.WritableObjectPropertyKey;
import org.chromium.ui.resources.ResourceManager;
class BottomControlsProperties {
/** The Y offset of the view in px. */
static final WritableIntPropertyKey Y_OFFSET = new WritableIntPropertyKey();
/** Whether the Android view version of the bottom controls component is visible. */
static final WritableBooleanPropertyKey ANDROID_VIEW_VISIBLE = new WritableBooleanPropertyKey();
/** Whether the composited version of the bottom controls component is visible. */
static final WritableBooleanPropertyKey COMPOSITED_VIEW_VISIBLE =
new WritableBooleanPropertyKey();
/** A {@link LayoutManager} to attach overlays to. */
static final WritableObjectPropertyKey<LayoutManager> LAYOUT_MANAGER =
new WritableObjectPropertyKey<>();
/** The browser's {@link ToolbarSwipeLayout}. */
static final WritableObjectPropertyKey<ToolbarSwipeLayout> TOOLBAR_SWIPE_LAYOUT =
new WritableObjectPropertyKey<>();
/** A {@link ResourceManager} for loading textures into the compositor. */
static final WritableObjectPropertyKey<ResourceManager> RESOURCE_MANAGER =
new WritableObjectPropertyKey<>();
/** A handler for swipe events on the toolbar. */
static final WritableObjectPropertyKey<EdgeSwipeHandler> TOOLBAR_SWIPE_HANDLER =
new WritableObjectPropertyKey<>();
static final PropertyKey[] ALL_KEYS =
new PropertyKey[] {Y_OFFSET, ANDROID_VIEW_VISIBLE, COMPOSITED_VIEW_VISIBLE,
LAYOUT_MANAGER, TOOLBAR_SWIPE_LAYOUT, RESOURCE_MANAGER, TOOLBAR_SWIPE_HANDLER};
}
// 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.toolbar.bottom;
import android.view.View;
import org.chromium.chrome.browser.compositor.scene_layer.ScrollingBottomViewSceneLayer;
import org.chromium.ui.modelutil.PropertyKey;
import org.chromium.ui.modelutil.PropertyModel;
class BottomControlsViewBinder {
/**
* A wrapper class that holds a {@link ScrollingBottomViewResourceFrameLayout}
* and a composited layer to be used with the {@link BottomControlsViewBinder}.
*/
static class ViewHolder {
/** A handle to the Android View based version of the bottom controls. */
public final ScrollingBottomViewResourceFrameLayout root;
/** A handle to the composited bottom controls layer. */
public ScrollingBottomViewSceneLayer sceneLayer;
/**
* @param bottomControlsRootView The Android View based bottom controls.
*/
public ViewHolder(ScrollingBottomViewResourceFrameLayout bottomControlsRootView) {
root = bottomControlsRootView;
}
}
static void bind(PropertyModel model, ViewHolder view, PropertyKey propertyKey) {
if (BottomControlsProperties.Y_OFFSET == propertyKey) {
// Native may not have completely initialized by the time this is set.
if (view.sceneLayer == null) return;
view.sceneLayer.setYOffset(model.get(BottomControlsProperties.Y_OFFSET));
} else if (BottomControlsProperties.ANDROID_VIEW_VISIBLE == propertyKey) {
view.root.setVisibility(model.get(BottomControlsProperties.ANDROID_VIEW_VISIBLE)
? View.VISIBLE
: View.INVISIBLE);
} else if (BottomControlsProperties.COMPOSITED_VIEW_VISIBLE == propertyKey) {
if (view.sceneLayer == null) return;
final boolean showCompositedView =
model.get(BottomControlsProperties.COMPOSITED_VIEW_VISIBLE);
view.sceneLayer.setIsVisible(showCompositedView);
model.get(BottomControlsProperties.TOOLBAR_SWIPE_LAYOUT)
.setBottomToolbarSceneLayersVisibility(showCompositedView);
model.get(BottomControlsProperties.LAYOUT_MANAGER).requestUpdate();
} else if (BottomControlsProperties.LAYOUT_MANAGER == propertyKey) {
assert view.sceneLayer == null;
view.sceneLayer =
new ScrollingBottomViewSceneLayer(view.root, view.root.getTopShadowHeight());
view.sceneLayer.setIsVisible(
model.get(BottomControlsProperties.COMPOSITED_VIEW_VISIBLE));
model.get(BottomControlsProperties.LAYOUT_MANAGER)
.addSceneOverlayToBack(view.sceneLayer);
} else if (BottomControlsProperties.TOOLBAR_SWIPE_LAYOUT == propertyKey) {
assert view.sceneLayer != null;
model.get(BottomControlsProperties.TOOLBAR_SWIPE_LAYOUT)
.setBottomToolbarSceneLayers(new ScrollingBottomViewSceneLayer(view.sceneLayer),
new ScrollingBottomViewSceneLayer(view.sceneLayer),
model.get(BottomControlsProperties.COMPOSITED_VIEW_VISIBLE));
} else if (BottomControlsProperties.RESOURCE_MANAGER == propertyKey) {
model.get(BottomControlsProperties.RESOURCE_MANAGER)
.getDynamicResourceLoader()
.registerResource(view.root.getId(), view.root.getResourceAdapter());
} else if (BottomControlsProperties.TOOLBAR_SWIPE_HANDLER == propertyKey) {
view.root.setSwipeDetector(model.get(BottomControlsProperties.TOOLBAR_SWIPE_HANDLER));
} else {
assert false : "Unhandled property detected in BottomControlsViewBinder!";
}
}
}
...@@ -12,22 +12,16 @@ import android.view.ViewStub; ...@@ -12,22 +12,16 @@ import android.view.ViewStub;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ActivityTabProvider; import org.chromium.chrome.browser.ActivityTabProvider;
import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper; import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper;
import org.chromium.chrome.browser.compositor.layouts.LayoutManager;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior; import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior;
import org.chromium.chrome.browser.compositor.layouts.ToolbarSwipeLayout;
import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.toolbar.IncognitoStateProvider; import org.chromium.chrome.browser.toolbar.IncognitoStateProvider;
import org.chromium.chrome.browser.toolbar.MenuButton; import org.chromium.chrome.browser.toolbar.MenuButton;
import org.chromium.chrome.browser.toolbar.TabCountProvider; import org.chromium.chrome.browser.toolbar.TabCountProvider;
import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.resources.ResourceManager;
/** /**
* The root coordinator for the bottom toolbar. It has two subcomponents. The browing mode bottom * The root coordinator for the bottom toolbar. It has two sub-components: the browsing mode bottom
* toolbar and the tab switcher mode bottom toolbar. * toolbar and the tab switcher mode bottom toolbar.
*/ */
public class BottomToolbarCoordinator { class BottomToolbarCoordinator {
/** The browsing mode bottom toolbar component */ /** The browsing mode bottom toolbar component */
private final BrowsingModeBottomToolbarCoordinator mBrowsingModeCoordinator; private final BrowsingModeBottomToolbarCoordinator mBrowsingModeCoordinator;
...@@ -40,31 +34,25 @@ public class BottomToolbarCoordinator { ...@@ -40,31 +34,25 @@ public class BottomToolbarCoordinator {
/** A provider that notifies components when the theme color changes.*/ /** A provider that notifies components when the theme color changes.*/
private final BottomToolbarThemeColorProvider mBottomToolbarThemeColorProvider; private final BottomToolbarThemeColorProvider mBottomToolbarThemeColorProvider;
/** The root view of the bottom toolbar. */
private final View mRoot;
/** /**
* Build the coordinator that manages the bottom toolbar. * Build the coordinator that manages the bottom toolbar.
* @param fullscreenManager A {@link ChromeFullscreenManager} to update the bottom controls
* height for the renderer.
* @param stub The bottom toolbar {@link ViewStub} to inflate. * @param stub The bottom toolbar {@link ViewStub} to inflate.
* @param tabProvider The {@link ActivityTabProvider} used for making the IPH. * @param tabProvider The {@link ActivityTabProvider} used for making the IPH.
* @param homeButtonListener The {@link OnClickListener} for the home button. * @param homeButtonListener The {@link OnClickListener} for the home button.
* @param searchAcceleratorListener The {@link OnClickListener} for the search accelerator. * @param searchAcceleratorListener The {@link OnClickListener} for the search accelerator.
* @param shareButtonListener The {@link OnClickListener} for the share button. * @param shareButtonListener The {@link OnClickListener} for the share button.
*/ */
public BottomToolbarCoordinator(ChromeFullscreenManager fullscreenManager, ViewStub stub, BottomToolbarCoordinator(ViewStub stub, ActivityTabProvider tabProvider,
ActivityTabProvider tabProvider, OnClickListener homeButtonListener, OnClickListener homeButtonListener, OnClickListener searchAcceleratorListener,
OnClickListener searchAcceleratorListener, OnClickListener shareButtonListener) { OnClickListener shareButtonListener) {
mRoot = stub.inflate(); View root = stub.inflate();
mBrowsingModeCoordinator = mBrowsingModeCoordinator = new BrowsingModeBottomToolbarCoordinator(root, tabProvider,
new BrowsingModeBottomToolbarCoordinator(mRoot, fullscreenManager, tabProvider, homeButtonListener, searchAcceleratorListener, shareButtonListener);
homeButtonListener, searchAcceleratorListener, shareButtonListener);
mTabSwitcherModeStub = mRoot.findViewById(R.id.bottom_toolbar_tab_switcher_mode_stub); mTabSwitcherModeStub = root.findViewById(R.id.bottom_toolbar_tab_switcher_mode_stub);
mBottomToolbarThemeColorProvider = new BottomToolbarThemeColorProvider(mRoot.getContext()); mBottomToolbarThemeColorProvider = new BottomToolbarThemeColorProvider(root.getContext());
} }
/** /**
...@@ -72,50 +60,38 @@ public class BottomToolbarCoordinator { ...@@ -72,50 +60,38 @@ public class BottomToolbarCoordinator {
* dependencies. * dependencies.
* <p> * <p>
* Calling this must occur after the native library have completely loaded. * Calling this must occur after the native library have completely loaded.
* @param resourceManager A {@link ResourceManager} for loading textures into the compositor.
* @param layoutManager A {@link LayoutManager} to attach overlays to.
* @param tabSwitcherListener An {@link OnClickListener} that is triggered when the * @param tabSwitcherListener An {@link OnClickListener} that is triggered when the
* tab switcher button is clicked. * tab switcher button is clicked.
* @param newTabClickListener An {@link OnClickListener} that is triggered when the * @param newTabClickListener An {@link OnClickListener} that is triggered when the
* new tab button is clicked. * new tab button is clicked.
* @param menuButtonHelper An {@link AppMenuButtonHelper} that is triggered when the * @param menuButtonHelper An {@link AppMenuButtonHelper} that is triggered when the
* menu button is clicked. * menu button is clicked.
* @param tabModelSelector A {@link TabModelSelector} that incognito toggle tab layout uses to
switch between normal and incognito tabs.
* @param overviewModeBehavior The overview mode manager. * @param overviewModeBehavior The overview mode manager.
* @param windowAndroid A {@link WindowAndroid} for watching keyboard visibility events.
* @param tabCountProvider Updates the tab count number in the tab switcher button and in the * @param tabCountProvider Updates the tab count number in the tab switcher button and in the
* incognito toggle tab layout. * incognito toggle tab layout.
* @param incognitoStateProvider Notifies components when incognito mode is entered or exited. * @param incognitoStateProvider Notifies components when incognito mode is entered or exited.
* @param topToolbarRoot The root {@link ViewGroup} of the top toolbar. * @param topToolbarRoot The root {@link ViewGroup} of the top toolbar.
*/ */
public void initializeWithNative(ResourceManager resourceManager, LayoutManager layoutManager, void initializeWithNative(OnClickListener tabSwitcherListener,
OnClickListener tabSwitcherListener, OnClickListener newTabClickListener, OnClickListener newTabClickListener, OnClickListener closeTabsClickListener,
OnClickListener closeTabsClickListener, AppMenuButtonHelper menuButtonHelper, AppMenuButtonHelper menuButtonHelper, OverviewModeBehavior overviewModeBehavior,
TabModelSelector tabModelSelector, OverviewModeBehavior overviewModeBehavior, TabCountProvider tabCountProvider, IncognitoStateProvider incognitoStateProvider,
WindowAndroid windowAndroid, TabCountProvider tabCountProvider, ViewGroup topToolbarRoot) {
IncognitoStateProvider incognitoStateProvider, ViewGroup topToolbarRoot) {
mBottomToolbarThemeColorProvider.setIncognitoStateProvider(incognitoStateProvider); mBottomToolbarThemeColorProvider.setIncognitoStateProvider(incognitoStateProvider);
mBottomToolbarThemeColorProvider.setOverviewModeBehavior(overviewModeBehavior); mBottomToolbarThemeColorProvider.setOverviewModeBehavior(overviewModeBehavior);
mBrowsingModeCoordinator.initializeWithNative(resourceManager, layoutManager, mBrowsingModeCoordinator.initializeWithNative(tabSwitcherListener, menuButtonHelper,
tabSwitcherListener, menuButtonHelper, overviewModeBehavior, windowAndroid, overviewModeBehavior, tabCountProvider, mBottomToolbarThemeColorProvider);
tabCountProvider, mBottomToolbarThemeColorProvider, tabModelSelector);
mTabSwitcherModeCoordinator = new TabSwitcherBottomToolbarCoordinator(mTabSwitcherModeStub, mTabSwitcherModeCoordinator = new TabSwitcherBottomToolbarCoordinator(mTabSwitcherModeStub,
topToolbarRoot, incognitoStateProvider, mBottomToolbarThemeColorProvider, topToolbarRoot, incognitoStateProvider, mBottomToolbarThemeColorProvider,
newTabClickListener, closeTabsClickListener, menuButtonHelper, tabModelSelector, newTabClickListener, closeTabsClickListener, menuButtonHelper, overviewModeBehavior,
overviewModeBehavior, tabCountProvider); tabCountProvider);
} }
/** /**
* @param isVisible Whether the bottom toolbar is visible. * @param isVisible Whether the bottom toolbar is visible.
*/ */
public void setBottomToolbarVisible(boolean isVisible) { void setBottomToolbarVisible(boolean isVisible) {
// TODO (amaralp): The coordinator should not have direct access to the view.
mRoot.setVisibility(isVisible ? View.VISIBLE : View.GONE);
mBrowsingModeCoordinator.setVisible(isVisible);
if (mTabSwitcherModeCoordinator != null) { if (mTabSwitcherModeCoordinator != null) {
mTabSwitcherModeCoordinator.showToolbarOnTop(!isVisible); mTabSwitcherModeCoordinator.showToolbarOnTop(!isVisible);
} }
...@@ -124,44 +100,35 @@ public class BottomToolbarCoordinator { ...@@ -124,44 +100,35 @@ public class BottomToolbarCoordinator {
/** /**
* Show the update badge over the bottom toolbar's app menu. * Show the update badge over the bottom toolbar's app menu.
*/ */
public void showAppMenuUpdateBadge() { void showAppMenuUpdateBadge() {
mBrowsingModeCoordinator.showAppMenuUpdateBadge(); mBrowsingModeCoordinator.showAppMenuUpdateBadge();
} }
/** /**
* Remove the update badge. * Remove the update badge.
*/ */
public void removeAppMenuUpdateBadge() { void removeAppMenuUpdateBadge() {
mBrowsingModeCoordinator.removeAppMenuUpdateBadge(); mBrowsingModeCoordinator.removeAppMenuUpdateBadge();
} }
/** /**
* @return Whether the update badge is showing. * @return Whether the update badge is showing.
*/ */
public boolean isShowingAppMenuUpdateBadge() { boolean isShowingAppMenuUpdateBadge() {
return mBrowsingModeCoordinator.isShowingAppMenuUpdateBadge(); return mBrowsingModeCoordinator.isShowingAppMenuUpdateBadge();
} }
/**
* @param layout The {@link ToolbarSwipeLayout} that the bottom toolbar will hook into. This
* allows the bottom toolbar to provide the layout with scene layers with the
* bottom toolbar's texture.
*/
public void setToolbarSwipeLayout(ToolbarSwipeLayout layout) {
mBrowsingModeCoordinator.setToolbarSwipeLayout(layout);
}
/** /**
* @return The wrapper for the browsing mode toolbar's app menu button. * @return The wrapper for the browsing mode toolbar's app menu button.
*/ */
public MenuButton getMenuButtonWrapper() { MenuButton getMenuButtonWrapper() {
return mBrowsingModeCoordinator.getMenuButton(); return mBrowsingModeCoordinator.getMenuButton();
} }
/** /**
* Clean up any state when the bottom toolbar is destroyed. * Clean up any state when the bottom toolbar is destroyed.
*/ */
public void destroy() { void destroy() {
mBrowsingModeCoordinator.destroy(); mBrowsingModeCoordinator.destroy();
if (mTabSwitcherModeCoordinator != null) { if (mTabSwitcherModeCoordinator != null) {
mTabSwitcherModeCoordinator.destroy(); mTabSwitcherModeCoordinator.destroy();
......
...@@ -6,28 +6,22 @@ package org.chromium.chrome.browser.toolbar.bottom; ...@@ -6,28 +6,22 @@ package org.chromium.chrome.browser.toolbar.bottom;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ActivityTabProvider; import org.chromium.chrome.browser.ActivityTabProvider;
import org.chromium.chrome.browser.ActivityTabProvider.HintlessActivityTabObserver; import org.chromium.chrome.browser.ActivityTabProvider.HintlessActivityTabObserver;
import org.chromium.chrome.browser.ThemeColorProvider; import org.chromium.chrome.browser.ThemeColorProvider;
import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper; import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper;
import org.chromium.chrome.browser.compositor.layouts.LayoutManager;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior; import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior;
import org.chromium.chrome.browser.compositor.layouts.ToolbarSwipeLayout;
import org.chromium.chrome.browser.feature_engagement.TrackerFactory; import org.chromium.chrome.browser.feature_engagement.TrackerFactory;
import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.toolbar.HomeButton; import org.chromium.chrome.browser.toolbar.HomeButton;
import org.chromium.chrome.browser.toolbar.MenuButton; import org.chromium.chrome.browser.toolbar.MenuButton;
import org.chromium.chrome.browser.toolbar.TabCountProvider; import org.chromium.chrome.browser.toolbar.TabCountProvider;
import org.chromium.chrome.browser.toolbar.TabSwitcherButtonCoordinator; import org.chromium.chrome.browser.toolbar.TabSwitcherButtonCoordinator;
import org.chromium.chrome.browser.toolbar.bottom.BrowsingModeBottomToolbarViewBinder.ViewHolder;
import org.chromium.components.feature_engagement.Tracker; import org.chromium.components.feature_engagement.Tracker;
import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.modelutil.PropertyModelChangeProcessor; import org.chromium.ui.modelutil.PropertyModelChangeProcessor;
import org.chromium.ui.resources.ResourceManager;
/** /**
* The coordinator for the browsing mode bottom toolbar. This class has two primary components, * The coordinator for the browsing mode bottom toolbar. This class has two primary components,
...@@ -44,7 +38,7 @@ public class BrowsingModeBottomToolbarCoordinator { ...@@ -44,7 +38,7 @@ public class BrowsingModeBottomToolbarCoordinator {
/** The share button that lives in the bottom toolbar. */ /** The share button that lives in the bottom toolbar. */
private final ShareButton mShareButton; private final ShareButton mShareButton;
/** The search acceleartor that lives in the bottom toolbar. */ /** The search accelerator that lives in the bottom toolbar. */
private final SearchAccelerator mSearchAccelerator; private final SearchAccelerator mSearchAccelerator;
/** The tab switcher button component that lives in the bottom toolbar. */ /** The tab switcher button component that lives in the bottom toolbar. */
...@@ -56,32 +50,22 @@ public class BrowsingModeBottomToolbarCoordinator { ...@@ -56,32 +50,22 @@ public class BrowsingModeBottomToolbarCoordinator {
/** /**
* Build the coordinator that manages the browsing mode bottom toolbar. * Build the coordinator that manages the browsing mode bottom toolbar.
* @param root The root {@link View} for locating the views to inflate. * @param root The root {@link View} for locating the views to inflate.
* @param fullscreenManager A {@link ChromeFullscreenManager} to update the bottom controls
* height for the renderer.
* @param tabProvider The {@link ActivityTabProvider} used for making the IPH. * @param tabProvider The {@link ActivityTabProvider} used for making the IPH.
* @param homeButtonListener The {@link OnClickListener} for the home button. * @param homeButtonListener The {@link OnClickListener} for the home button.
* @param searchAcceleratorListener The {@link OnClickListener} for the search accelerator. * @param searchAcceleratorListener The {@link OnClickListener} for the search accelerator.
* @param shareButtonListener The {@link OnClickListener} for the share button. * @param shareButtonListener The {@link OnClickListener} for the share button.
*/ */
public BrowsingModeBottomToolbarCoordinator(View root, BrowsingModeBottomToolbarCoordinator(View root, ActivityTabProvider tabProvider,
ChromeFullscreenManager fullscreenManager, ActivityTabProvider tabProvider,
OnClickListener homeButtonListener, OnClickListener searchAcceleratorListener, OnClickListener homeButtonListener, OnClickListener searchAcceleratorListener,
OnClickListener shareButtonListener) { OnClickListener shareButtonListener) {
BrowsingModeBottomToolbarModel model = new BrowsingModeBottomToolbarModel(); BrowsingModeBottomToolbarModel model = new BrowsingModeBottomToolbarModel();
final ScrollingBottomViewResourceFrameLayout toolbarRoot = final ViewGroup toolbarRoot = root.findViewById(R.id.bottom_toolbar_browsing);
(ScrollingBottomViewResourceFrameLayout) root.findViewById(
R.id.bottom_toolbar_control_container);
final int shadowHeight =
toolbarRoot.getResources().getDimensionPixelOffset(R.dimen.toolbar_shadow_height);
toolbarRoot.setTopShadowHeight(shadowHeight);
PropertyModelChangeProcessor.create( PropertyModelChangeProcessor.create(
model, new ViewHolder(toolbarRoot), new BrowsingModeBottomToolbarViewBinder()); model, toolbarRoot, new BrowsingModeBottomToolbarViewBinder());
mMediator = new BrowsingModeBottomToolbarMediator( mMediator = new BrowsingModeBottomToolbarMediator(model);
model, fullscreenManager, toolbarRoot.getResources());
mHomeButton = toolbarRoot.findViewById(R.id.home_button); mHomeButton = toolbarRoot.findViewById(R.id.home_button);
mHomeButton.setOnClickListener(homeButtonListener); mHomeButton.setOnClickListener(homeButtonListener);
...@@ -98,14 +82,13 @@ public class BrowsingModeBottomToolbarCoordinator { ...@@ -98,14 +82,13 @@ public class BrowsingModeBottomToolbarCoordinator {
mMenuButton = toolbarRoot.findViewById(R.id.menu_button_wrapper); mMenuButton = toolbarRoot.findViewById(R.id.menu_button_wrapper);
final View iphAnchor = toolbarRoot.findViewById(R.id.search_accelerator);
tabProvider.addObserverAndTrigger(new HintlessActivityTabObserver() { tabProvider.addObserverAndTrigger(new HintlessActivityTabObserver() {
@Override @Override
public void onActivityTabChanged(Tab tab) { public void onActivityTabChanged(Tab tab) {
if (tab == null) return; if (tab == null) return;
final Tracker tracker = TrackerFactory.getTrackerForProfile(tab.getProfile()); final Tracker tracker = TrackerFactory.getTrackerForProfile(tab.getProfile());
tracker.addOnInitializedCallback( tracker.addOnInitializedCallback((ready) -> mMediator.showIPH(tab.getActivity(),
(ready) -> mMediator.showIPH(tab.getActivity(), iphAnchor, tracker)); mSearchAccelerator, tracker));
tabProvider.removeObserver(this); tabProvider.removeObserver(this);
} }
}); });
...@@ -116,28 +99,17 @@ public class BrowsingModeBottomToolbarCoordinator { ...@@ -116,28 +99,17 @@ public class BrowsingModeBottomToolbarCoordinator {
* dependencies. * dependencies.
* <p> * <p>
* Calling this must occur after the native library have completely loaded. * Calling this must occur after the native library have completely loaded.
* @param resourceManager A {@link ResourceManager} for loading textures into the compositor.
* @param layoutManager A {@link LayoutManager} to attach overlays to.
* @param tabSwitcherListener An {@link OnClickListener} that is triggered when the * @param tabSwitcherListener An {@link OnClickListener} that is triggered when the
* tab switcher button is clicked. * tab switcher button is clicked.
* @param menuButtonHelper An {@link AppMenuButtonHelper} that is triggered when the * @param menuButtonHelper An {@link AppMenuButtonHelper} that is triggered when the
* menu button is clicked. * menu button is clicked.
* @param overviewModeBehavior The overview mode manager. * @param overviewModeBehavior The overview mode manager.
* @param windowAndroid A {@link WindowAndroid} for watching keyboard visibility events.
* @param tabCountProvider Updates the tab count number in the tab switcher button. * @param tabCountProvider Updates the tab count number in the tab switcher button.
* @param themeColorProvider Notifies components when theme color changes. * @param themeColorProvider Notifies components when theme color changes.
* @param tabModelSelector A {@link TabModelSelector} that the share button uses to know whether
* or not to be enabled.
*/ */
public void initializeWithNative(ResourceManager resourceManager, LayoutManager layoutManager, void initializeWithNative(OnClickListener tabSwitcherListener,
OnClickListener tabSwitcherListener, AppMenuButtonHelper menuButtonHelper, AppMenuButtonHelper menuButtonHelper, OverviewModeBehavior overviewModeBehavior,
OverviewModeBehavior overviewModeBehavior, WindowAndroid windowAndroid, TabCountProvider tabCountProvider, ThemeColorProvider themeColorProvider) {
TabCountProvider tabCountProvider, ThemeColorProvider themeColorProvider,
TabModelSelector tabModelSelector) {
mMediator.setLayoutManager(layoutManager);
mMediator.setResourceManager(resourceManager);
mMediator.setToolbarSwipeHandler(layoutManager.getToolbarSwipeHandler());
mMediator.setWindowAndroid(windowAndroid);
mMediator.setOverviewModeBehavior(overviewModeBehavior); mMediator.setOverviewModeBehavior(overviewModeBehavior);
mMediator.setThemeColorProvider(themeColorProvider); mMediator.setThemeColorProvider(themeColorProvider);
...@@ -153,57 +125,34 @@ public class BrowsingModeBottomToolbarCoordinator { ...@@ -153,57 +125,34 @@ public class BrowsingModeBottomToolbarCoordinator {
mMenuButton.setThemeColorProvider(themeColorProvider); mMenuButton.setThemeColorProvider(themeColorProvider);
} }
/**
* @param isVisible Whether the browsing mode bottom toolbar is visible.
*/
public void setVisible(boolean isVisible) {
mMediator.setVisible(isVisible);
}
/** /**
* Show the update badge over the bottom toolbar's app menu. * Show the update badge over the bottom toolbar's app menu.
*/ */
public void showAppMenuUpdateBadge() { void showAppMenuUpdateBadge() {
mMenuButton.showAppMenuUpdateBadgeIfAvailable(true); mMenuButton.showAppMenuUpdateBadgeIfAvailable(true);
} }
/** /**
* Remove the update badge. * Remove the update badge.
*/ */
public void removeAppMenuUpdateBadge() { void removeAppMenuUpdateBadge() {
mMenuButton.removeAppMenuUpdateBadge(true); mMenuButton.removeAppMenuUpdateBadge(true);
} }
/** /**
* @return Whether the update badge is showing. * @return Whether the update badge is showing.
*/ */
public boolean isShowingAppMenuUpdateBadge() { boolean isShowingAppMenuUpdateBadge() {
return mMenuButton.isShowingAppMenuUpdateBadge(); return mMenuButton.isShowingAppMenuUpdateBadge();
} }
/**
* @param layout The {@link ToolbarSwipeLayout} that the bottom toolbar will hook into. This
* allows the bottom toolbar to provide the layout with scene layers with the
* bottom toolbar's texture.
*/
public void setToolbarSwipeLayout(ToolbarSwipeLayout layout) {
mMediator.setToolbarSwipeLayout(layout);
}
/** /**
* @return The browsing mode bottom toolbar's menu button. * @return The browsing mode bottom toolbar's menu button.
*/ */
public MenuButton getMenuButton() { MenuButton getMenuButton() {
return mMenuButton; return mMenuButton;
} }
/**
* @return Whether the browsing mode toolbar is visible.
*/
public boolean isVisible() {
return mMediator.isVisible();
}
/** /**
* Clean up any state when the browsing mode bottom toolbar is destroyed. * Clean up any state when the browsing mode bottom toolbar is destroyed.
*/ */
......
...@@ -4,55 +4,22 @@ ...@@ -4,55 +4,22 @@
package org.chromium.chrome.browser.toolbar.bottom; package org.chromium.chrome.browser.toolbar.bottom;
import org.chromium.chrome.browser.compositor.layouts.LayoutManager;
import org.chromium.chrome.browser.compositor.layouts.ToolbarSwipeLayout;
import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeHandler;
import org.chromium.ui.modelutil.PropertyModel; import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.resources.ResourceManager;
/** /**
* All of the state for the bottom toolbar, updated by the {@link * All of the state for the bottom toolbar, updated by the {@link
* BrowsingModeBottomToolbarCoordinator}. * BrowsingModeBottomToolbarCoordinator}.
*/ */
public class BrowsingModeBottomToolbarModel extends PropertyModel { public class BrowsingModeBottomToolbarModel extends PropertyModel {
/** The Y offset of the view in px. */
public static final WritableIntPropertyKey Y_OFFSET = new WritableIntPropertyKey();
/** Whether the Android view version of the toolbar is visible. */
public static final WritableBooleanPropertyKey ANDROID_VIEW_VISIBLE =
new WritableBooleanPropertyKey();
/** Whether the composited version of the toolbar is visible. */
public static final WritableBooleanPropertyKey COMPOSITED_VIEW_VISIBLE =
new WritableBooleanPropertyKey();
/** A {@link LayoutManager} to attach overlays to. */
public static final WritableObjectPropertyKey<LayoutManager> LAYOUT_MANAGER =
new WritableObjectPropertyKey<>();
/** The browser's {@link ToolbarSwipeLayout}. */
public static final WritableObjectPropertyKey<ToolbarSwipeLayout> TOOLBAR_SWIPE_LAYOUT =
new WritableObjectPropertyKey<>();
/** A {@link ResourceManager} for loading textures into the compositor. */
public static final WritableObjectPropertyKey<ResourceManager> RESOURCE_MANAGER =
new WritableObjectPropertyKey<>();
/** A handler for swipe events on the toolbar. */
public static final WritableObjectPropertyKey<EdgeSwipeHandler> TOOLBAR_SWIPE_HANDLER =
new WritableObjectPropertyKey<>();
/** Primary color of bottom toolbar. */ /** Primary color of bottom toolbar. */
public static final WritableIntPropertyKey PRIMARY_COLOR = new WritableIntPropertyKey(); static final WritableIntPropertyKey PRIMARY_COLOR = new WritableIntPropertyKey();
/** Whether the browsing mode bottom toolbar is visible */ /** Whether the browsing mode bottom toolbar is visible */
public static final WritableBooleanPropertyKey IS_VISIBLE = new WritableBooleanPropertyKey(); static final WritableBooleanPropertyKey IS_VISIBLE = new WritableBooleanPropertyKey();
/** Default constructor. */ /** Default constructor. */
public BrowsingModeBottomToolbarModel() { BrowsingModeBottomToolbarModel() {
super(Y_OFFSET, ANDROID_VIEW_VISIBLE, COMPOSITED_VIEW_VISIBLE, LAYOUT_MANAGER, super(IS_VISIBLE, PRIMARY_COLOR);
TOOLBAR_SWIPE_LAYOUT, RESOURCE_MANAGER, TOOLBAR_SWIPE_HANDLER, IS_VISIBLE,
PRIMARY_COLOR);
set(IS_VISIBLE, true); set(IS_VISIBLE, true);
} }
} }
...@@ -5,10 +5,7 @@ ...@@ -5,10 +5,7 @@
package org.chromium.chrome.browser.toolbar.bottom; package org.chromium.chrome.browser.toolbar.bottom;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.compositor.scene_layer.ScrollingBottomViewSceneLayer;
import org.chromium.ui.modelutil.PropertyKey; import org.chromium.ui.modelutil.PropertyKey;
import org.chromium.ui.modelutil.PropertyModelChangeProcessor; import org.chromium.ui.modelutil.PropertyModelChangeProcessor;
...@@ -18,81 +15,22 @@ import org.chromium.ui.modelutil.PropertyModelChangeProcessor; ...@@ -18,81 +15,22 @@ import org.chromium.ui.modelutil.PropertyModelChangeProcessor;
* {@link BrowsingModeBottomToolbarModel} when a notification of an update is received. * {@link BrowsingModeBottomToolbarModel} when a notification of an update is received.
*/ */
public class BrowsingModeBottomToolbarViewBinder public class BrowsingModeBottomToolbarViewBinder
implements PropertyModelChangeProcessor.ViewBinder<BrowsingModeBottomToolbarModel, implements PropertyModelChangeProcessor
BrowsingModeBottomToolbarViewBinder.ViewHolder, PropertyKey> { .ViewBinder<BrowsingModeBottomToolbarModel, View, PropertyKey> {
/**
* A wrapper class that holds a {@link ViewGroup} (the toolbar view) and a composited layer to
* be used with the {@link BrowsingModeBottomToolbarViewBinder}.
*/
public static class ViewHolder {
/** A handle to the Android View based version of the toolbar. */
public final ScrollingBottomViewResourceFrameLayout toolbarRoot;
/** A handle to the composited bottom toolbar layer. */
public ScrollingBottomViewSceneLayer sceneLayer;
/**
* @param toolbarRootView The Android View based toolbar.
*/
public ViewHolder(ScrollingBottomViewResourceFrameLayout toolbarRootView) {
toolbarRoot = toolbarRootView;
}
}
/** /**
* Build a binder that handles interaction between the model and the views that make up the * Build a binder that handles interaction between the model and the views that make up the
* browsing mode bottom toolbar. * browsing mode bottom toolbar.
*/ */
public BrowsingModeBottomToolbarViewBinder() {} BrowsingModeBottomToolbarViewBinder() {}
@Override @Override
public final void bind( public final void bind(
BrowsingModeBottomToolbarModel model, ViewHolder view, PropertyKey propertyKey) { BrowsingModeBottomToolbarModel model, View view, PropertyKey propertyKey) {
if (BrowsingModeBottomToolbarModel.Y_OFFSET == propertyKey) { if (BrowsingModeBottomToolbarModel.PRIMARY_COLOR == propertyKey) {
// Native may not have completely initialized by the time this is set. view.setBackgroundColor(model.get(BrowsingModeBottomToolbarModel.PRIMARY_COLOR));
if (view.sceneLayer == null) return;
view.sceneLayer.setYOffset(model.get(BrowsingModeBottomToolbarModel.Y_OFFSET));
} else if (BrowsingModeBottomToolbarModel.ANDROID_VIEW_VISIBLE == propertyKey) {
view.toolbarRoot.setVisibility(
model.get(BrowsingModeBottomToolbarModel.ANDROID_VIEW_VISIBLE)
? View.VISIBLE
: View.INVISIBLE);
} else if (BrowsingModeBottomToolbarModel.COMPOSITED_VIEW_VISIBLE == propertyKey) {
if (view.sceneLayer == null) return;
final boolean showCompositedView =
model.get(BrowsingModeBottomToolbarModel.COMPOSITED_VIEW_VISIBLE);
view.sceneLayer.setIsVisible(showCompositedView);
model.get(BrowsingModeBottomToolbarModel.TOOLBAR_SWIPE_LAYOUT)
.setBottomToolbarSceneLayersVisibility(showCompositedView);
model.get(BrowsingModeBottomToolbarModel.LAYOUT_MANAGER).requestUpdate();
} else if (BrowsingModeBottomToolbarModel.LAYOUT_MANAGER == propertyKey) {
assert view.sceneLayer == null;
view.sceneLayer = new ScrollingBottomViewSceneLayer(
view.toolbarRoot, view.toolbarRoot.getTopShadowHeight());
view.sceneLayer.setIsVisible(
model.get(BrowsingModeBottomToolbarModel.COMPOSITED_VIEW_VISIBLE));
model.get(BrowsingModeBottomToolbarModel.LAYOUT_MANAGER)
.addSceneOverlayToBack(view.sceneLayer);
} else if (BrowsingModeBottomToolbarModel.TOOLBAR_SWIPE_LAYOUT == propertyKey) {
assert view.sceneLayer != null;
model.get(BrowsingModeBottomToolbarModel.TOOLBAR_SWIPE_LAYOUT)
.setBottomToolbarSceneLayers(new ScrollingBottomViewSceneLayer(view.sceneLayer),
new ScrollingBottomViewSceneLayer(view.sceneLayer),
model.get(BrowsingModeBottomToolbarModel.COMPOSITED_VIEW_VISIBLE));
} else if (BrowsingModeBottomToolbarModel.RESOURCE_MANAGER == propertyKey) {
model.get(BrowsingModeBottomToolbarModel.RESOURCE_MANAGER)
.getDynamicResourceLoader()
.registerResource(
view.toolbarRoot.getId(), view.toolbarRoot.getResourceAdapter());
} else if (BrowsingModeBottomToolbarModel.TOOLBAR_SWIPE_HANDLER == propertyKey) {
view.toolbarRoot.setSwipeDetector(
model.get(BrowsingModeBottomToolbarModel.TOOLBAR_SWIPE_HANDLER));
} else if (BrowsingModeBottomToolbarModel.PRIMARY_COLOR == propertyKey) {
view.toolbarRoot.findViewById(R.id.bottom_toolbar_buttons)
.setBackgroundColor(model.get(BrowsingModeBottomToolbarModel.PRIMARY_COLOR));
} else if (BrowsingModeBottomToolbarModel.IS_VISIBLE == propertyKey) { } else if (BrowsingModeBottomToolbarModel.IS_VISIBLE == propertyKey) {
final boolean isVisible = model.get(BrowsingModeBottomToolbarModel.IS_VISIBLE); view.setVisibility(model.get(BrowsingModeBottomToolbarModel.IS_VISIBLE) ? View.VISIBLE
view.toolbarRoot.setVisibility(isVisible ? View.VISIBLE : View.GONE); : View.GONE);
} else { } else {
assert false : "Unhandled property detected in BrowsingModeBottomToolbarViewBinder!"; assert false : "Unhandled property detected in BrowsingModeBottomToolbarViewBinder!";
} }
......
...@@ -11,6 +11,7 @@ import android.graphics.Rect; ...@@ -11,6 +11,7 @@ import android.graphics.Rect;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.MotionEvent; import android.view.MotionEvent;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeHandler; import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeHandler;
import org.chromium.chrome.browser.contextualsearch.SwipeRecognizer; import org.chromium.chrome.browser.contextualsearch.SwipeRecognizer;
import org.chromium.chrome.browser.widget.ViewResourceFrameLayout; import org.chromium.chrome.browser.widget.ViewResourceFrameLayout;
...@@ -25,13 +26,14 @@ public class ScrollingBottomViewResourceFrameLayout extends ViewResourceFrameLay ...@@ -25,13 +26,14 @@ public class ScrollingBottomViewResourceFrameLayout extends ViewResourceFrameLay
private final Rect mCachedRect = new Rect(); private final Rect mCachedRect = new Rect();
/** The height of the shadow sitting above the bottom view in px. */ /** The height of the shadow sitting above the bottom view in px. */
private int mTopShadowHeightPx; private final int mTopShadowHeightPx;
/** A swipe recognizer for handling swipe gestures. */ /** A swipe recognizer for handling swipe gestures. */
private SwipeRecognizer mSwipeRecognizer; private SwipeRecognizer mSwipeRecognizer;
public ScrollingBottomViewResourceFrameLayout(Context context, AttributeSet attrs) { public ScrollingBottomViewResourceFrameLayout(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
mTopShadowHeightPx = getResources().getDimensionPixelOffset(R.dimen.toolbar_shadow_height);
} }
/** /**
...@@ -88,13 +90,6 @@ public class ScrollingBottomViewResourceFrameLayout extends ViewResourceFrameLay ...@@ -88,13 +90,6 @@ public class ScrollingBottomViewResourceFrameLayout extends ViewResourceFrameLay
}; };
} }
/**
* @param height The height of the view's top shadow in px.
*/
public void setTopShadowHeight(int height) {
mTopShadowHeightPx = height;
}
/** /**
* @return The height of the view's top shadow in px. * @return The height of the view's top shadow in px.
*/ */
......
...@@ -13,7 +13,6 @@ import org.chromium.chrome.R; ...@@ -13,7 +13,6 @@ import org.chromium.chrome.R;
import org.chromium.chrome.browser.ThemeColorProvider; import org.chromium.chrome.browser.ThemeColorProvider;
import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper; import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior; import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.toolbar.IncognitoStateProvider; import org.chromium.chrome.browser.toolbar.IncognitoStateProvider;
import org.chromium.chrome.browser.toolbar.MenuButton; import org.chromium.chrome.browser.toolbar.MenuButton;
import org.chromium.chrome.browser.toolbar.TabCountProvider; import org.chromium.chrome.browser.toolbar.TabCountProvider;
...@@ -48,17 +47,15 @@ public class TabSwitcherBottomToolbarCoordinator { ...@@ -48,17 +47,15 @@ public class TabSwitcherBottomToolbarCoordinator {
* close all tabs button is clicked. * close all tabs button is clicked.
* @param menuButtonHelper An {@link AppMenuButtonHelper} that is triggered when the * @param menuButtonHelper An {@link AppMenuButtonHelper} that is triggered when the
* menu button is clicked. * menu button is clicked.
* @param tabModelSelector A {@link TabModelSelector} that incognito toggle tab layout uses to
* switch between normal and incognito tabs.
* @param overviewModeBehavior The overview mode manager. * @param overviewModeBehavior The overview mode manager.
* @param tabCountProvider Updates the tab count number in the tab switcher button and in the * @param tabCountProvider Updates the tab count number in the tab switcher button and in the
* incognito toggle tab layout. * incognito toggle tab layout.
*/ */
public TabSwitcherBottomToolbarCoordinator(ViewStub stub, ViewGroup topToolbarRoot, TabSwitcherBottomToolbarCoordinator(ViewStub stub, ViewGroup topToolbarRoot,
IncognitoStateProvider incognitoStateProvider, ThemeColorProvider themeColorProvider, IncognitoStateProvider incognitoStateProvider, ThemeColorProvider themeColorProvider,
OnClickListener newTabClickListener, OnClickListener closeTabsClickListener, OnClickListener newTabClickListener, OnClickListener closeTabsClickListener,
AppMenuButtonHelper menuButtonHelper, TabModelSelector tabModelSelector, AppMenuButtonHelper menuButtonHelper, OverviewModeBehavior overviewModeBehavior,
OverviewModeBehavior overviewModeBehavior, TabCountProvider tabCountProvider) { TabCountProvider tabCountProvider) {
final View root = stub.inflate(); final View root = stub.inflate();
TabSwitcherBottomToolbarModel model = new TabSwitcherBottomToolbarModel(); TabSwitcherBottomToolbarModel model = new TabSwitcherBottomToolbarModel();
...@@ -90,7 +87,7 @@ public class TabSwitcherBottomToolbarCoordinator { ...@@ -90,7 +87,7 @@ public class TabSwitcherBottomToolbarCoordinator {
/** /**
* @param showOnTop Whether to show the tab switcher bottom toolbar on the top of the screen. * @param showOnTop Whether to show the tab switcher bottom toolbar on the top of the screen.
*/ */
public void showToolbarOnTop(boolean showOnTop) { void showToolbarOnTop(boolean showOnTop) {
mMediator.showToolbarOnTop(showOnTop); mMediator.showToolbarOnTop(showOnTop);
} }
......
...@@ -27,7 +27,7 @@ public class TabSwitcherBottomToolbarViewBinder ...@@ -27,7 +27,7 @@ public class TabSwitcherBottomToolbarViewBinder
* Build a binder that handles interaction between the model and the tab switcher bottom toolbar * Build a binder that handles interaction between the model and the tab switcher bottom toolbar
* view. * view.
*/ */
public TabSwitcherBottomToolbarViewBinder(ViewGroup topRoot, ViewGroup bottomRoot) { TabSwitcherBottomToolbarViewBinder(ViewGroup topRoot, ViewGroup bottomRoot) {
mTopRoot = topRoot; mTopRoot = topRoot;
mBottomRoot = bottomRoot; mBottomRoot = bottomRoot;
} }
...@@ -43,8 +43,6 @@ public class TabSwitcherBottomToolbarViewBinder ...@@ -43,8 +43,6 @@ public class TabSwitcherBottomToolbarViewBinder
.setBackgroundColor(model.get(TabSwitcherBottomToolbarModel.PRIMARY_COLOR)); .setBackgroundColor(model.get(TabSwitcherBottomToolbarModel.PRIMARY_COLOR));
} else if (TabSwitcherBottomToolbarModel.SHOW_ON_TOP == propertyKey) { } else if (TabSwitcherBottomToolbarModel.SHOW_ON_TOP == propertyKey) {
final boolean showOnTop = model.get(TabSwitcherBottomToolbarModel.SHOW_ON_TOP); final boolean showOnTop = model.get(TabSwitcherBottomToolbarModel.SHOW_ON_TOP);
view.findViewById(R.id.bottom_toolbar_top_shadow)
.setVisibility(showOnTop ? View.GONE : View.VISIBLE);
view.findViewById(R.id.bottom_toolbar_bottom_shadow) view.findViewById(R.id.bottom_toolbar_bottom_shadow)
.setVisibility(showOnTop ? View.VISIBLE : View.GONE); .setVisibility(showOnTop ? View.VISIBLE : View.GONE);
reparentView(view, showOnTop ? mTopRoot : mBottomRoot); reparentView(view, showOnTop ? mTopRoot : mBottomRoot);
......
...@@ -1600,6 +1600,10 @@ chrome_java_sources = [ ...@@ -1600,6 +1600,10 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/toolbar/ToolbarDataProvider.java", "java/src/org/chromium/chrome/browser/toolbar/ToolbarDataProvider.java",
"java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java", "java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java",
"java/src/org/chromium/chrome/browser/toolbar/ToolbarTabController.java", "java/src/org/chromium/chrome/browser/toolbar/ToolbarTabController.java",
"java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsCoordinator.java",
"java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsMediator.java",
"java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsProperties.java",
"java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsViewBinder.java",
"java/src/org/chromium/chrome/browser/toolbar/bottom/BottomToolbarNewTabButton.java", "java/src/org/chromium/chrome/browser/toolbar/bottom/BottomToolbarNewTabButton.java",
"java/src/org/chromium/chrome/browser/toolbar/bottom/BottomToolbarCoordinator.java", "java/src/org/chromium/chrome/browser/toolbar/bottom/BottomToolbarCoordinator.java",
"java/src/org/chromium/chrome/browser/toolbar/bottom/BrowsingModeBottomToolbarCoordinator.java", "java/src/org/chromium/chrome/browser/toolbar/bottom/BrowsingModeBottomToolbarCoordinator.java",
......
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