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

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

Issue 2779543005: Add support for highlighting menu items (Closed)
Patch Set: Debugged drawable issues 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..a3d588fff57d7e5c9416cdac64ab1e343cb29f18 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
@@ -26,6 +26,8 @@ import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper;
+import org.chromium.chrome.browser.appmenu.PulseDrawable;
+import org.chromium.chrome.browser.appmenu.PulseDrawableFactory;
import org.chromium.chrome.browser.compositor.Invalidator;
import org.chromium.chrome.browser.compositor.layouts.LayoutUpdateHost;
import org.chromium.chrome.browser.fullscreen.BrowserStateBrowserControlsVisibilityDelegate;
@@ -77,6 +79,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;
@@ -653,6 +658,8 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar {
*/
public abstract LocationBar getLocationBar();
+ public abstract boolean useLightDrawables();
Ted C 2017/04/12 18:05:57 javadoc
David Trainor- moved to gerrit 2017/04/12 18:59:37 Done.
+
/**
* Navigates the current Tab back.
* @return Whether or not the current Tab did go back.
@@ -691,6 +698,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 +808,30 @@ 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.
Ted C 2017/04/12 18:05:57 too much space after highlighting
David Trainor- moved to gerrit 2017/04/12 18:59:37 Done.
+ */
+ protected void setMenuButtonHighlightDrawable(boolean highlighting) {
+ if (highlighting) {
+ if (mHighlightDrawable == null) {
+ mHighlightDrawable = PulseDrawableFactory.createCircle();
+ mHighlightDrawable.setInset(ApiCompatibilityUtils.getPaddingStart(mMenuButton),
+ mMenuButton.getPaddingTop(),
+ ApiCompatibilityUtils.getPaddingEnd(mMenuButton),
+ mMenuButton.getPaddingBottom());
+ }
+ int colorRes = useLightDrawables() ? R.color.google_grey_100 : R.color.google_blue_500;
+ int color = ApiCompatibilityUtils.getColor(getResources(), colorRes);
+ mHighlightDrawable.setColor(color);
Ted C 2017/04/12 18:05:57 ah...so we already use different colors. Can we j
David Trainor- moved to gerrit 2017/04/12 18:59:37 Yeah good idea
+ 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