Bug 1357781 - To tint state drawawble in MenuItem draft
authorJulian_Chu <walkingice0204@gmail.com>
Wed, 17 May 2017 20:23:47 +0800
changeset 579962 350c51ec640723ee766cf2d0147d895ceb080acf
parent 579961 b008f4186330cf8e09b38ca4431b4f0d35988742
child 629170 4f109f8eb8d17c78c2a264de8d819f2da065a137
push id59427
push userbmo:walkingice0204@gmail.com
push dateThu, 18 May 2017 03:33:48 +0000
bugs1357781
milestone55.0a1
Bug 1357781 - To tint state drawawble in MenuItem The drawable mState in MenuItemDefault is to present state image for MORE(">"), CHECKED or UNCHECKED. In CustomTabs there might be dark theme. So we need to tint this drawable by text-color. MozReview-Commit-ID: CPvaWKkTR9
mobile/android/base/java/org/mozilla/gecko/menu/MenuItemDefault.java
--- a/mobile/android/base/java/org/mozilla/gecko/menu/MenuItemDefault.java
+++ b/mobile/android/base/java/org/mozilla/gecko/menu/MenuItemDefault.java
@@ -6,17 +6,19 @@ package org.mozilla.gecko.menu;
 
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.util.ResourceDrawableUtils;
 
 import android.content.Context;
 import android.content.res.Resources;
 import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
+import android.support.v4.graphics.drawable.DrawableCompat;
 import android.support.v4.widget.TextViewCompat;
+import android.support.v7.graphics.drawable.DrawableWrapper;
 import android.util.AttributeSet;
 import android.widget.TextView;
 
 public class MenuItemDefault extends TextView
                              implements GeckoMenuItem.Layout {
     private static final int[] STATE_MORE = new int[] { R.attr.state_more };
     private static final int[] STATE_CHECKED = new int[] { android.R.attr.state_checkable, android.R.attr.state_checked };
     private static final int[] STATE_UNCHECKED = new int[] { android.R.attr.state_checkable };
@@ -45,17 +47,19 @@ public class MenuItemDefault extends Tex
         int width = res.getDimensionPixelSize(R.dimen.menu_item_row_width);
         int height = res.getDimensionPixelSize(R.dimen.menu_item_row_height);
         setMinimumWidth(width);
         setMinimumHeight(height);
 
         int stateIconSize = res.getDimensionPixelSize(R.dimen.menu_item_state_icon);
         Rect stateIconBounds = new Rect(0, 0, stateIconSize, stateIconSize);
 
-        mState = res.getDrawable(R.drawable.menu_item_state).mutate();
+        Drawable wrapped = DrawableCompat.wrap(res.getDrawable(R.drawable.menu_item_state));
+        DrawableCompat.setTint(wrapped, getCurrentTextColor());
+        mState = wrapped.mutate();
         mState.setBounds(stateIconBounds);
 
         if (sIconBounds == null) {
             int iconSize = res.getDimensionPixelSize(R.dimen.menu_item_icon);
             sIconBounds = new Rect(0, 0, iconSize, iconSize);
         }
 
         TextViewCompat.setCompoundDrawablesRelative(this, mIcon, null, mState, null);