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

Don't show top toolbar items when bottom toolbar is enabled

The original CL for this (https://chromium-review.googlesource.com/1105569)
was reverted because of a null pointer bug. This CL does the same thing
as the reverted CL and fixes the null pointer exception by having
ToolbarManager#getMenuButton() return the bottom toolbar menu button when
the bottom toolbar is enabled.

Bug: 852117

Change-Id: Ic2668a3cac6a552bee4476d1cfb58f8e6c290bfd
Reviewed-on: https://chromium-review.googlesource.com/1135776Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Pedro Amaral <amaralp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575372}
parent e5eea8bd
...@@ -143,6 +143,10 @@ public class BottomToolbarCoordinator { ...@@ -143,6 +143,10 @@ public class BottomToolbarCoordinator {
mMediator.setToolbarSwipeLayout(layout); mMediator.setToolbarSwipeLayout(layout);
} }
public View getMenuButton() {
return mMenuButton.getMenuButton();
}
/** /**
* Clean up any state when the bottom toolbar is destroyed. * Clean up any state when the bottom toolbar is destroyed.
*/ */
......
...@@ -54,4 +54,8 @@ class MenuButton extends FrameLayout { ...@@ -54,4 +54,8 @@ class MenuButton extends FrameLayout {
boolean isShowingAppMenuUpdateBadge() { boolean isShowingAppMenuUpdateBadge() {
return mUpdateBadgeView.getVisibility() == View.VISIBLE; return mUpdateBadgeView.getVisibility() == View.VISIBLE;
} }
View getMenuButton() {
return mMenuButtonView;
}
} }
...@@ -41,6 +41,7 @@ import org.chromium.chrome.browser.omnibox.UrlBarData; ...@@ -41,6 +41,7 @@ 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;
...@@ -155,6 +156,12 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar { ...@@ -155,6 +156,12 @@ 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() {
...@@ -271,8 +278,10 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar { ...@@ -271,8 +278,10 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar {
mAppMenuButtonHelper = appMenuButtonHelper; mAppMenuButtonHelper = appMenuButtonHelper;
mMenuButton.setOnTouchListener(mAppMenuButtonHelper); if (mMenuButton != null) {
mMenuButton.setAccessibilityDelegate(mAppMenuButtonHelper); mMenuButton.setOnTouchListener(mAppMenuButtonHelper);
mMenuButton.setAccessibilityDelegate(mAppMenuButtonHelper);
}
} }
/** Notified that the menu was shown. */ /** Notified that the menu was shown. */
...@@ -818,6 +827,7 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar { ...@@ -818,6 +827,7 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar {
@Override @Override
public void removeAppMenuUpdateBadge(boolean animate) { public void removeAppMenuUpdateBadge(boolean animate) {
if (mMenuBadge == null) return;
boolean wasShowingMenuBadge = mShowMenuBadge; boolean wasShowingMenuBadge = mShowMenuBadge;
mShowMenuBadge = false; mShowMenuBadge = false;
setMenuButtonContentDescription(false); setMenuButtonContentDescription(false);
...@@ -876,6 +886,7 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar { ...@@ -876,6 +886,7 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar {
* bitmap. * bitmap.
*/ */
protected void setAppMenuUpdateBadgeToVisible(boolean animate) { protected void setAppMenuUpdateBadgeToVisible(boolean animate) {
if (mMenuBadge == null || mMenuButton == null) return;
setMenuButtonContentDescription(true); setMenuButtonContentDescription(true);
if (!animate || mIsMenuBadgeAnimationRunning) { if (!animate || mIsMenuBadgeAnimationRunning) {
mMenuBadge.setVisibility(View.VISIBLE); mMenuBadge.setVisibility(View.VISIBLE);
...@@ -920,6 +931,7 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar { ...@@ -920,6 +931,7 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar {
* @param useLightDrawable Whether the light drawable should be used. * @param useLightDrawable Whether the light drawable should be used.
*/ */
protected void setAppMenuUpdateBadgeDrawable(boolean useLightDrawable) { protected void setAppMenuUpdateBadgeDrawable(boolean useLightDrawable) {
if (mMenuBadge == null) return;
mMenuBadge.setImageResource(useLightDrawable ? R.drawable.badge_update_light mMenuBadge.setImageResource(useLightDrawable ? R.drawable.badge_update_light
: R.drawable.badge_update_dark); : R.drawable.badge_update_dark);
} }
...@@ -931,7 +943,7 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar { ...@@ -931,7 +943,7 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar {
*/ */
protected void setMenuButtonHighlightDrawable(boolean highlighting) { protected void setMenuButtonHighlightDrawable(boolean highlighting) {
// Return if onFinishInflate didn't finish // Return if onFinishInflate didn't finish
if (mMenuButtonWrapper == null) return; if (mMenuButtonWrapper == null || mMenuButton == null) return;
if (highlighting) { if (highlighting) {
if (mHighlightDrawable == null) { if (mHighlightDrawable == null) {
...@@ -953,6 +965,7 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar { ...@@ -953,6 +965,7 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar {
* @param isUpdateBadgeVisible Whether the update menu badge is visible. * @param isUpdateBadgeVisible Whether the update menu badge is visible.
*/ */
protected void setMenuButtonContentDescription(boolean isUpdateBadgeVisible) { protected void setMenuButtonContentDescription(boolean isUpdateBadgeVisible) {
if (mMenuButton == null) return;
if (isUpdateBadgeVisible) { if (isUpdateBadgeVisible) {
mMenuButton.setContentDescription(getResources().getString( mMenuButton.setContentDescription(getResources().getString(
R.string.accessibility_toolbar_btn_menu_update)); R.string.accessibility_toolbar_btn_menu_update));
......
...@@ -866,6 +866,8 @@ public class ToolbarManager implements ToolbarTabController, UrlFocusChangeListe ...@@ -866,6 +866,8 @@ public class ToolbarManager implements ToolbarTabController, UrlFocusChangeListe
* @return The view containing the pop up menu button. * @return The view containing the pop up menu button.
*/ */
public View getMenuButton() { public View getMenuButton() {
if (mBottomToolbarCoordinator != null) return mBottomToolbarCoordinator.getMenuButton();
return mToolbar.getMenuButton(); return mToolbar.getMenuButton();
} }
...@@ -1313,7 +1315,9 @@ public class ToolbarManager implements ToolbarTabController, UrlFocusChangeListe ...@@ -1313,7 +1315,9 @@ public class ToolbarManager implements ToolbarTabController, UrlFocusChangeListe
updateReloadState(tabCrashed); updateReloadState(tabCrashed);
updateBookmarkButtonStatus(); updateBookmarkButtonStatus();
mToolbar.getMenuButtonWrapper().setVisibility(View.VISIBLE); if (mToolbar.getMenuButtonWrapper() != null) {
mToolbar.getMenuButtonWrapper().setVisibility(View.VISIBLE);
}
} }
private void updateBookmarkButtonStatus() { private void updateBookmarkButtonStatus() {
......
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