Commit 2abccfab authored by Matthew Jones's avatar Matthew Jones Committed by Commit Bot

Fix bottom toolbar showing while in fullscreen

This patch fixes an issue with the bottom toolbar when entering
fullscreen while the keyboard is visible. To conserve space while
the keyboard is showing, the bottom controls height is set to 0
and reset when the keyboard is hidden. This does not account for
fullscreen mode, so when the keyboard is hidden it blindly tells
the controls to become visible again. This patch adds logic to
update the bottom toolbar when the controls height is restored
and only conditionally shows the toolbar if another browser feature
isn't blocking it.

Bug: 872323
Change-Id: Ic3f33fcd7ae207415a5d36b56dba86ec216d3a51
Reviewed-on: https://chromium-review.googlesource.com/1167997Reviewed-by: default avatarPedro Amaral <amaralp@chromium.org>
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581903}
parent 71135040
......@@ -115,10 +115,10 @@ class BottomToolbarMediator implements ContextualSearchObserver, FullscreenListe
@Override
public void onControlsOffsetChanged(float topOffset, float bottomOffset, boolean needsAnimate) {
mModel.setValue(BottomToolbarModel.Y_OFFSET, (int) bottomOffset);
if (bottomOffset > 0) {
if (bottomOffset > 0 || mFullscreenManager.getBottomControlsHeight() == 0) {
mModel.setValue(BottomToolbarModel.ANDROID_VIEW_VISIBLE, false);
} else {
mModel.setValue(BottomToolbarModel.ANDROID_VIEW_VISIBLE, true);
tryShowingAndroidView();
}
}
......@@ -157,30 +157,38 @@ class BottomToolbarMediator implements ContextualSearchObserver, FullscreenListe
@Override
public void onHideContextualSearch() {
// If the scroll offset for the toolbar is non-zero, it needs to remain hidden after
// contextual search is hidden.
if (mModel.getValue(BottomToolbarModel.Y_OFFSET) != 0) return;
mModel.setValue(BottomToolbarModel.ANDROID_VIEW_VISIBLE, true);
tryShowingAndroidView();
}
@Override
public void keyboardVisibilityChanged(boolean isShowing) {
// The toolbars are force shown when the keyboard is visible, so we can blindly set
// the bottom toolbar view to visible or invisible regardless of the previous state.
ChromeFullscreenManager fullscreenManager =
mModel.getValue(BottomToolbarModel.LAYOUT_MANAGER).getFullscreenManager();
if (isShowing) {
mBottomToolbarHeightBeforeHide = fullscreenManager.getBottomControlsHeight();
mBottomToolbarHeightBeforeHide = mFullscreenManager.getBottomControlsHeight();
mModel.setValue(BottomToolbarModel.ANDROID_VIEW_VISIBLE, false);
mModel.setValue(BottomToolbarModel.COMPOSITED_VIEW_VISIBLE, false);
fullscreenManager.setBottomControlsHeight(0);
mFullscreenManager.setBottomControlsHeight(0);
} else {
fullscreenManager.setBottomControlsHeight(mBottomToolbarHeightBeforeHide);
mModel.setValue(BottomToolbarModel.ANDROID_VIEW_VISIBLE, true);
mFullscreenManager.setBottomControlsHeight(mBottomToolbarHeightBeforeHide);
tryShowingAndroidView();
mModel.setValue(
BottomToolbarModel.Y_OFFSET, (int) mFullscreenManager.getBottomControlOffset());
mModel.setValue(BottomToolbarModel.COMPOSITED_VIEW_VISIBLE, true);
}
}
/**
* Try showing the toolbar's Android view after it has been hidden. This accounts for cases
* where a browser signal would ordinarily re-show the view, but others still require it to be
* hidden.
*/
private void tryShowingAndroidView() {
if (mFullscreenManager.getBottomControlOffset() > 0) return;
if (mModel.getValue(BottomToolbarModel.Y_OFFSET) != 0) return;
mModel.setValue(BottomToolbarModel.ANDROID_VIEW_VISIBLE, true);
}
void setLayoutManager(LayoutManager layoutManager) {
mModel.setValue(BottomToolbarModel.LAYOUT_MANAGER, layoutManager);
layoutManager.addSceneChangeObserver(this);
......
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