Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3291)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java

Issue 2779543005: Add support for highlighting menu items (Closed)
Patch Set: Moved PulseDrawable Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java
index 4d9c22fd61696cbff715443d437381ea9c6aa390..14c83bdcc902c637b661aa10f7ec6a210de6d2e3 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java
@@ -34,6 +34,7 @@ import org.chromium.chrome.browser.omaha.UpdateMenuItemHelper;
import org.chromium.chrome.browser.omnibox.LocationBar;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.util.ViewUtils;
+import org.chromium.chrome.browser.widget.PulseDrawable;
import org.chromium.chrome.browser.widget.TintedImageButton;
import org.chromium.chrome.browser.widget.ToolbarProgressBar;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet;
@@ -77,6 +78,9 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar {
private boolean mFindInPageToolbarShowing;
+ protected boolean mHighlightingMenu;
+ private PulseDrawable mHighlightDrawable;
+
protected boolean mShowMenuBadge;
private AnimatorSet mMenuBadgeAnimatorSet;
private boolean mIsMenuBadgeAnimationRunning;
@@ -654,6 +658,11 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar {
public abstract LocationBar getLocationBar();
/**
+ * @return Whether or not this toolbar should use light or dark assets based on the theme.
+ */
+ public abstract boolean useLightDrawables();
+
+ /**
* Navigates the current Tab back.
* @return Whether or not the current Tab did go back.
*/
@@ -691,6 +700,12 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar {
}
@Override
+ public void setMenuButtonHighlight(boolean highlight) {
+ mHighlightingMenu = highlight;
+ setMenuButtonHighlightDrawable(mHighlightingMenu);
+ }
+
+ @Override
public void showAppMenuUpdateBadge() {
mShowMenuBadge = true;
}
@@ -795,6 +810,28 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar {
}
/**
+ * Sets the menu button's background depending on whether or not we are highlighting and whether
+ * or not we are using light or dark assets.
+ * @param highlighting Whether or not the menu button should be highlighted.
+ */
+ protected void setMenuButtonHighlightDrawable(boolean highlighting) {
+ if (highlighting) {
+ if (mHighlightDrawable == null) {
+ mHighlightDrawable = PulseDrawable.createCircle();
+ mHighlightDrawable.setInset(ApiCompatibilityUtils.getPaddingStart(mMenuButton),
+ mMenuButton.getPaddingTop(),
+ ApiCompatibilityUtils.getPaddingEnd(mMenuButton),
+ mMenuButton.getPaddingBottom());
+ }
+ mHighlightDrawable.setUseLightPulseColor(useLightDrawables());
+ mMenuButtonWrapper.setBackground(mHighlightDrawable);
+ mHighlightDrawable.start();
+ } else {
+ mMenuButtonWrapper.setBackground(null);
+ }
+ }
+
+ /**
* Sets the content description for the menu button.
* @param isUpdateBadgeVisible Whether the update menu badge is visible.
*/

Powered by Google App Engine
This is Rietveld 408576698