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

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

Remove the top toolbar buttons (home, tab switcher, and menu buttons)
from their parent view and set them to null. Also add a bunch of
null checks since now things can be null.

Bug: 852117
Change-Id: I620f35f81388d1f4ac8791a9eb45576566474604
Reviewed-on: https://chromium-review.googlesource.com/1105569
Commit-Queue: Pedro Amaral <amaralp@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570578}
parent 3f58aa2b
......@@ -39,6 +39,7 @@ import org.chromium.chrome.browser.omnibox.UrlBarData;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tab.Tab;
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.widget.PulseDrawable;
import org.chromium.chrome.browser.widget.ScrimView;
......@@ -153,6 +154,12 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar {
mMenuButton = (TintedImageButton) findViewById(R.id.menu_button);
mMenuBadge = (ImageView) findViewById(R.id.menu_badge);
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.
mToolbarDataProvider = new ToolbarDataProvider() {
......@@ -269,8 +276,10 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar {
mAppMenuButtonHelper = appMenuButtonHelper;
mMenuButton.setOnTouchListener(mAppMenuButtonHelper);
mMenuButton.setAccessibilityDelegate(mAppMenuButtonHelper);
if (mMenuButton != null) {
mMenuButton.setOnTouchListener(mAppMenuButtonHelper);
mMenuButton.setAccessibilityDelegate(mAppMenuButtonHelper);
}
}
/** Notified that the menu was shown. */
......@@ -816,6 +825,7 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar {
@Override
public void removeAppMenuUpdateBadge(boolean animate) {
if (mMenuBadge == null) return;
boolean wasShowingMenuBadge = mShowMenuBadge;
mShowMenuBadge = false;
setMenuButtonContentDescription(false);
......@@ -860,6 +870,7 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar {
* bitmap.
*/
protected void setAppMenuUpdateBadgeToVisible(boolean animate) {
if (mMenuBadge == null || mMenuButton == null) return;
setMenuButtonContentDescription(true);
if (!animate || mIsMenuBadgeAnimationRunning) {
mMenuBadge.setVisibility(View.VISIBLE);
......@@ -904,6 +915,7 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar {
* @param useLightDrawable Whether the light drawable should be used.
*/
protected void setAppMenuUpdateBadgeDrawable(boolean useLightDrawable) {
if (mMenuBadge == null) return;
mMenuBadge.setImageResource(useLightDrawable ? R.drawable.badge_update_light
: R.drawable.badge_update_dark);
}
......@@ -915,7 +927,7 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar {
*/
protected void setMenuButtonHighlightDrawable(boolean highlighting) {
// Return if onFinishInflate didn't finish
if (mMenuButtonWrapper == null) return;
if (mMenuButtonWrapper == null || mMenuButton == null) return;
if (highlighting) {
if (mHighlightDrawable == null) {
......@@ -937,6 +949,7 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar {
* @param isUpdateBadgeVisible Whether the update menu badge is visible.
*/
protected void setMenuButtonContentDescription(boolean isUpdateBadgeVisible) {
if (mMenuButton == null) return;
if (isUpdateBadgeVisible) {
mMenuButton.setContentDescription(getResources().getString(
R.string.accessibility_toolbar_btn_menu_update));
......
......@@ -1240,7 +1240,9 @@ public class ToolbarManager implements ToolbarTabController, UrlFocusChangeListe
updateReloadState(tabCrashed);
updateBookmarkButtonStatus();
mToolbar.getMenuButtonWrapper().setVisibility(View.VISIBLE);
if (mToolbar.getMenuButtonWrapper() != null) {
mToolbar.getMenuButtonWrapper().setVisibility(View.VISIBLE);
}
}
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