Commit d72db906 authored by Matthew Jones's avatar Matthew Jones Committed by Commit Bot

Only remove menu button for duet in ToolbarPhone

FeatureUtilities#isBottomToolbarEnabled is agnostic to whether Chrome
is in an activity that supports Duet. This patch moves the logic for
whether to remove the menu button from the top toolbar to
ToolbarPhone, where Duet is always supported.

Bug: 865061
Change-Id: Icfceddf92d04722bb9e8d20266e671642c50033d
Reviewed-on: https://chromium-review.googlesource.com/1142137Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576101}
parent d1063a05
...@@ -41,7 +41,6 @@ import org.chromium.chrome.browser.omnibox.UrlBarData; ...@@ -41,7 +41,6 @@ import org.chromium.chrome.browser.omnibox.UrlBarData;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
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.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.util.FeatureUtilities;
import org.chromium.chrome.browser.util.ViewUtils; import org.chromium.chrome.browser.util.ViewUtils;
import org.chromium.chrome.browser.widget.PulseDrawable; import org.chromium.chrome.browser.widget.PulseDrawable;
import org.chromium.chrome.browser.widget.ScrimView; import org.chromium.chrome.browser.widget.ScrimView;
...@@ -149,6 +148,17 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar { ...@@ -149,6 +148,17 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar {
getContext(), getProgressBarHeight(), getProgressBarTopMargin(), false); getContext(), getProgressBarHeight(), getProgressBarTopMargin(), false);
} }
/**
* Disable the menu button. This removes the view from the hierarchy and nulls the related
* instance vars.
*/
protected void disableMenuButton() {
UiUtils.removeViewFromParent(mMenuButtonWrapper);
mMenuButtonWrapper = null;
mMenuButton = null;
mMenuBadge = null;
}
@Override @Override
protected void onFinishInflate() { protected void onFinishInflate() {
super.onFinishInflate(); super.onFinishInflate();
...@@ -156,12 +166,6 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar { ...@@ -156,12 +166,6 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar {
mMenuButton = (TintedImageButton) findViewById(R.id.menu_button); mMenuButton = (TintedImageButton) findViewById(R.id.menu_button);
mMenuBadge = (ImageView) findViewById(R.id.menu_badge); mMenuBadge = (ImageView) findViewById(R.id.menu_badge);
mMenuButtonWrapper = findViewById(R.id.menu_button_wrapper); mMenuButtonWrapper = findViewById(R.id.menu_button_wrapper);
if (FeatureUtilities.isBottomToolbarEnabled()) {
UiUtils.removeViewFromParent(mMenuButtonWrapper);
mMenuButtonWrapper = null;
mMenuButton = null;
mMenuBadge = null;
}
// Initialize the provider to an empty version to avoid null checking everywhere. // Initialize the provider to an empty version to avoid null checking everywhere.
mToolbarDataProvider = new ToolbarDataProvider() { mToolbarDataProvider = new ToolbarDataProvider() {
......
...@@ -383,9 +383,12 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -383,9 +383,12 @@ public class ToolbarPhone extends ToolbarLayout
mToolbarButtonsContainer = (ViewGroup) findViewById(R.id.toolbar_buttons); mToolbarButtonsContainer = (ViewGroup) findViewById(R.id.toolbar_buttons);
mHomeButton = (TintedImageButton) findViewById(R.id.home_button); mHomeButton = (TintedImageButton) findViewById(R.id.home_button);
if (FeatureUtilities.isBottomToolbarEnabled() && mHomeButton != null) { if (FeatureUtilities.isBottomToolbarEnabled()) {
UiUtils.removeViewFromParent(mHomeButton); disableMenuButton();
mHomeButton = null; if (mHomeButton != null) {
UiUtils.removeViewFromParent(mHomeButton);
mHomeButton = null;
}
} }
mUrlBar = (TextView) findViewById(R.id.url_bar); mUrlBar = (TextView) findViewById(R.id.url_bar);
......
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