Commit 61b8df4f authored by Gang Wu's avatar Gang Wu Committed by Commit Bot

[duet] Create a new swipe handler for bottom toolbar

Bug: 914501
Change-Id: Iab146b0f40918ca7f91c9927c9922695050c53f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1859678Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Gang Wu <gangwu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710392}
parent b0e0542c
......@@ -867,13 +867,22 @@ public class LayoutManager implements LayoutUpdateHost, LayoutProvider,
}
/**
* @return The {@link EdgeSwipeHandler} responsible for processing swipe events for the toolbar.
* By default this returns null.
* @return The {@link EdgeSwipeHandler} responsible for processing swipe events for the normal
* toolbar. By default this returns null.
*/
public EdgeSwipeHandler getToolbarSwipeHandler() {
return null;
}
/**
* Creates a {@link EdgeSwipeHandler} instance.
* @param supportSwipeDown Whether or not to the handler should support swipe down gesture.
* @return The {@link EdgeSwipeHandler} cerated.
*/
public EdgeSwipeHandler createToolbarSwipeHandler(boolean supportSwipeDown) {
return null;
}
/**
* Should be called when the user presses the back button on the phone.
* @return Whether or not the back button was consumed by the active {@link Layout}.
......
......@@ -82,7 +82,7 @@ public class LayoutManagerChrome extends LayoutManager implements OverviewModeCo
mOverviewModeObservers = new ObserverList<OverviewModeObserver>();
// Build Event Filter Handlers
mToolbarSwipeHandler = new ToolbarSwipeHandler();
mToolbarSwipeHandler = createToolbarSwipeHandler(/* supportSwipeDown = */ true);
// Build Layouts
mOverviewListLayout = new OverviewListLayout(context, this, renderHost);
......@@ -127,6 +127,11 @@ public class LayoutManagerChrome extends LayoutManager implements OverviewModeCo
return mToolbarSwipeHandler;
}
@Override
public EdgeSwipeHandler createToolbarSwipeHandler(boolean supportSwipeDown) {
return new ToolbarSwipeHandler(supportSwipeDown);
}
@Override
public void init(TabModelSelector selector, TabCreatorManager creator,
TabContentManager content, ViewGroup androidContentContainer,
......@@ -424,6 +429,12 @@ public class LayoutManagerChrome extends LayoutManager implements OverviewModeCo
*/
private static final float SWIPE_RANGE_DEG = 25;
private final boolean mSupportSwipeDown;
public ToolbarSwipeHandler(boolean supportSwipeDown) {
mSupportSwipeDown = supportSwipeDown;
}
@Override
public void swipeStarted(@ScrollDirection int direction, float x, float y) {
mScrollDirection = ScrollDirection.UNKNOWN;
......@@ -442,12 +453,12 @@ public class LayoutManagerChrome extends LayoutManager implements OverviewModeCo
mScrollDirection = computeScrollDirection(dx, dy);
if (mScrollDirection == ScrollDirection.UNKNOWN) return;
if (mOverviewLayout != null && mScrollDirection == ScrollDirection.DOWN) {
if (mSupportSwipeDown && mOverviewLayout != null
&& mScrollDirection == ScrollDirection.DOWN) {
RecordUserAction.record("MobileToolbarSwipeOpenStackView");
showOverview(true);
} else if (mToolbarSwipeLayout != null
&& (mScrollDirection == ScrollDirection.LEFT
|| mScrollDirection == ScrollDirection.RIGHT)) {
} else if (mScrollDirection == ScrollDirection.LEFT
|| mScrollDirection == ScrollDirection.RIGHT) {
startShowing(mToolbarSwipeLayout, true);
}
......
......@@ -150,7 +150,8 @@ public class BottomControlsCoordinator {
mBottomToolbarCoordinator.initializeWithNative(tabSwitcherListener, newTabClickListener,
closeTabsClickListener, menuButtonHelper, overviewModeBehavior,
tabCountProvider, incognitoStateProvider, topToolbarRoot);
mMediator.setToolbarSwipeHandler(layoutManager.getToolbarSwipeHandler());
mMediator.setToolbarSwipeHandler(
layoutManager.createToolbarSwipeHandler(/* supportSwipeDown = */ false));
}
if (mTabGroupUi != null) {
......
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