Commit da4bf3f0 authored by Matt Simmons's avatar Matt Simmons Committed by Commit Bot

Hide the tab switcher toolbar on focusing the omnibox.

If the omnibox is showing in tab switcher mode, fade out the tab
switcher toolbar when the url bar gains focus. Ideally, this would
be done on text change (!isEmpty) but the TopToolbarCoordinator
has no observer for text changes.

R=yusufo@chromium.org

Bug: 967961
Change-Id: I962f51d3247bf2cc936343988e2ff497b5a74fd4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1635352Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Commit-Queue: Matt Simmons <mattsimmons@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664372}
parent f57ac37d
......@@ -4,6 +4,8 @@
package org.chromium.chrome.browser.toolbar.top;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.view.View;
import android.view.ViewStub;
......@@ -135,6 +137,27 @@ class TabSwitcherModeTTCoordinatorPhone {
}
}
void setTabSwitcherToolbarVisibility(boolean shouldShowTabSwitcherToolbar) {
final float targetAlpha = shouldShowTabSwitcherToolbar ? 1.0f : 0.0f;
mTabSwitcherModeToolbar.animate()
.alpha(targetAlpha)
.setDuration(TopToolbarCoordinator.TAB_SWITCHER_MODE_NORMAL_ANIMATION_DURATION_MS)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
if (shouldShowTabSwitcherToolbar)
mTabSwitcherModeToolbar.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd(Animator animation) {
if (!shouldShowTabSwitcherToolbar)
mTabSwitcherModeToolbar.setVisibility(View.GONE);
}
});
}
private void initializeTabSwitcherToolbar() {
mTabSwitcherModeToolbar = (TabSwitcherModeTTPhone) mTabSwitcherToolbarStub.inflate();
......
......@@ -397,18 +397,6 @@ public class TopToolbarCoordinator implements Toolbar {
mToolbarLayout.setContentAttached(attached);
}
/**
* Overrides tab switcher launching behavior.
* @param newClickListener The new {@link OnClickListener} for tab switcher button clicks.
*
*/
public void setTabSwitcherClickListener(OnClickListener newClickListener) {
if (mTabSwitcherModeCoordinatorPhone != null) {
mTabSwitcherModeCoordinatorPhone.setOnTabSwitcherClickHandler(newClickListener);
}
mToolbarLayout.setOnTabSwitcherClickHandler(newClickListener);
}
/**
* Gives inheriting classes the chance to show or hide the TabSwitcher mode of this toolbar.
* @param inTabSwitcherMode Whether or not TabSwitcher mode should be shown or hidden.
......@@ -493,6 +481,12 @@ public class TopToolbarCoordinator implements Toolbar {
*/
public void onUrlFocusChange(boolean hasFocus) {
mToolbarLayout.onUrlFocusChange(hasFocus);
if (mToolbarLayout.getToolbarDataProvider() != null
&& mToolbarLayout.getToolbarDataProvider().isInOverviewAndShowingOmnibox()
&& mTabSwitcherModeCoordinatorPhone != null) {
mTabSwitcherModeCoordinatorPhone.setTabSwitcherToolbarVisibility(!hasFocus);
}
}
/**
......
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