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
--- 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);