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

Fixing CCT App Menu issues introduced by refactor

This CL undoes some of the changes that could impact CCT that was
introduced in the MenuButton refactor CL:
https://chromium-review.googlesource.com/c/chromium/src/+/1419203

Bug: 925271
Change-Id: Ifb9575f8cf52934981c12b1a6c5114993997cc5e
Reviewed-on: https://chromium-review.googlesource.com/c/1447834Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Theresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#628296}
parent 53d7b87b
...@@ -27,7 +27,6 @@ import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper; ...@@ -27,7 +27,6 @@ import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper;
import org.chromium.chrome.browser.omaha.UpdateMenuItemHelper; import org.chromium.chrome.browser.omaha.UpdateMenuItemHelper;
import org.chromium.chrome.browser.omaha.UpdateMenuItemHelper.MenuButtonState; import org.chromium.chrome.browser.omaha.UpdateMenuItemHelper.MenuButtonState;
import org.chromium.chrome.browser.widget.PulseDrawable; import org.chromium.chrome.browser.widget.PulseDrawable;
import org.chromium.ui.UiUtils;
import org.chromium.ui.interpolators.BakedBezierInterpolator; import org.chromium.ui.interpolators.BakedBezierInterpolator;
/** /**
...@@ -108,6 +107,10 @@ public class MenuButton extends FrameLayout implements TintObserver { ...@@ -108,6 +107,10 @@ public class MenuButton extends FrameLayout implements TintObserver {
ApiCompatibilityUtils.getDrawable(getResources(), drawable)); ApiCompatibilityUtils.getDrawable(getResources(), drawable));
} }
/**
* Show the update badge on the app menu button.
* @param animate Whether to animate the showing of the update badge.
*/
public void showAppMenuUpdateBadge(boolean animate) { public void showAppMenuUpdateBadge(boolean animate) {
if (mUpdateBadgeView == null) return; if (mUpdateBadgeView == null) return;
mShowMenuBadge = true; mShowMenuBadge = true;
...@@ -116,6 +119,10 @@ public class MenuButton extends FrameLayout implements TintObserver { ...@@ -116,6 +119,10 @@ public class MenuButton extends FrameLayout implements TintObserver {
setAppMenuUpdateBadgeToVisible(animate); setAppMenuUpdateBadgeToVisible(animate);
} }
/**
* Remove the update badge on the app menu button.
* @param animate Whether to animate the hiding of the update badge.
*/
public void removeAppMenuUpdateBadge(boolean animate) { public void removeAppMenuUpdateBadge(boolean animate) {
if (mUpdateBadgeView == null) return; if (mUpdateBadgeView == null) return;
boolean wasShowingMenuBadge = mShowMenuBadge; boolean wasShowingMenuBadge = mShowMenuBadge;
...@@ -264,7 +271,6 @@ public class MenuButton extends FrameLayout implements TintObserver { ...@@ -264,7 +271,6 @@ public class MenuButton extends FrameLayout implements TintObserver {
mThemeColorProvider.removeTintObserver(this); mThemeColorProvider.removeTintObserver(this);
mThemeColorProvider = null; mThemeColorProvider = null;
} }
UiUtils.removeViewFromParent(this);
} }
/** /**
......
...@@ -136,6 +136,7 @@ public class CustomTabToolbar ...@@ -136,6 +136,7 @@ public class CustomTabToolbar
private ImageButton mSecurityButton; private ImageButton mSecurityButton;
private LinearLayout mCustomActionButtons; private LinearLayout mCustomActionButtons;
private ImageButton mCloseButton; private ImageButton mCloseButton;
private ImageButton mMenuButton;
// Whether dark tint should be applied to icons and text. // Whether dark tint should be applied to icons and text.
private boolean mUseDarkColors = true; private boolean mUseDarkColors = true;
...@@ -183,6 +184,7 @@ public class CustomTabToolbar ...@@ -183,6 +184,7 @@ public class CustomTabToolbar
mCustomActionButtons = findViewById(R.id.action_buttons); mCustomActionButtons = findViewById(R.id.action_buttons);
mCloseButton = findViewById(R.id.close_button); mCloseButton = findViewById(R.id.close_button);
mCloseButton.setOnLongClickListener(this); mCloseButton.setOnLongClickListener(this);
mMenuButton = findViewById(R.id.menu_button);
mAnimDelegate = new CustomTabToolbarAnimationDelegate(mSecurityButton, mTitleUrlContainer); mAnimDelegate = new CustomTabToolbarAnimationDelegate(mSecurityButton, mTitleUrlContainer);
} }
...@@ -782,6 +784,9 @@ public class CustomTabToolbar ...@@ -782,6 +784,9 @@ public class CustomTabToolbar
@Override @Override
public void setAutocompleteProfile(Profile profile) {} public void setAutocompleteProfile(Profile profile) {}
@Override
void showAppMenuUpdateBadge(boolean animate) {}
@Override @Override
boolean isShowingAppMenuUpdateBadge() { boolean isShowingAppMenuUpdateBadge() {
return false; return false;
...@@ -796,9 +801,15 @@ public class CustomTabToolbar ...@@ -796,9 +801,15 @@ public class CustomTabToolbar
return getMenuButton(); return getMenuButton();
} }
@Override
ImageButton getMenuButton() {
return mMenuButton;
}
@Override @Override
void disableMenuButton() { void disableMenuButton() {
super.disableMenuButton(); super.disableMenuButton();
mMenuButton = null;
// In addition to removing the menu button, we also need to remove the margin on the custom // In addition to removing the menu button, we also need to remove the margin on the custom
// action button. // action button.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
......
...@@ -111,6 +111,12 @@ public abstract class ToolbarLayout extends FrameLayout { ...@@ -111,6 +111,12 @@ public abstract class ToolbarLayout extends FrameLayout {
mToolbarTabController = tabController; mToolbarTabController = tabController;
if (mMenuButtonWrapper != null) { if (mMenuButtonWrapper != null) {
mMenuButtonWrapper.setAppMenuButtonHelper(appMenuButtonHelper); mMenuButtonWrapper.setAppMenuButtonHelper(appMenuButtonHelper);
} else {
final ImageButton menuButton = getMenuButton();
if (menuButton != null) {
menuButton.setOnTouchListener(appMenuButtonHelper);
menuButton.setAccessibilityDelegate(appMenuButtonHelper);
}
} }
} }
...@@ -139,6 +145,8 @@ public abstract class ToolbarLayout extends FrameLayout { ...@@ -139,6 +145,8 @@ public abstract class ToolbarLayout extends FrameLayout {
* instance vars. * instance vars.
*/ */
void disableMenuButton() { void disableMenuButton() {
UiUtils.removeViewFromParent(getMenuButtonWrapper());
if (mMenuButtonWrapper != null) { if (mMenuButtonWrapper != null) {
mMenuButtonWrapper.destroy(); mMenuButtonWrapper.destroy();
mMenuButtonWrapper = null; mMenuButtonWrapper = null;
......
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