Bug 1394378 - Wrap drawable to support tinting across different API levels. r=nechen
authorJing-wei Wu <topwu.tw@gmail.com>
Wed, 06 Sep 2017 10:15:14 +0800
changeset 428645 0f782497fb09c037fd5a7bf977641cde1dd2202e
parent 428644 926d1e8e07414f8622933ef61435ad475fad63f4
child 428646 9698cc8c675274d5c787a1c4fbb3bc0817dd6729
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnechen
bugs1394378
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1394378 - Wrap drawable to support tinting across different API levels. r=nechen According to the comment of `DrawableCompat.wrap(Drawable)`[1], a drawable should be wrapped to support tinting across the different API levels. [1] https://android.googlesource.com/platform/frameworks/support/+/android-6.0.1_r67/v4/java/android/support/v4/graphics/drawable/DrawableCompat.java#329 MozReview-Commit-ID: JJ4alkFF1og
mobile/android/base/java/org/mozilla/gecko/home/TabMenuStripLayout.java
--- a/mobile/android/base/java/org/mozilla/gecko/home/TabMenuStripLayout.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/TabMenuStripLayout.java
@@ -65,17 +65,17 @@ class TabMenuStripLayout extends ThemedL
         tabContentStart = a.getDimensionPixelSize(R.styleable.TabMenuStrip_tabsMarginLeft, 0);
         activeTextColor = a.getColor(R.styleable.TabMenuStrip_activeTextColor,
                                      ResourcesCompat.getColor(getResources(), R.color.text_and_tabs_tray_grey, null));
         inactiveTextColor = a.getColorStateList(R.styleable.TabMenuStrip_inactiveTextColor);
         stripColor = a.getColorStateList(R.styleable.TabMenuStrip_stripColor);
         a.recycle();
 
         if (stripResId != -1) {
-            strip = getResources().getDrawable(stripResId);
+            strip = ResourcesCompat.getDrawable(getResources(), stripResId, null);
 
             if (stripColor != null) {
                 final int backgroundTintColor = stripColor.getColorForState(getDrawableState(), Color.TRANSPARENT);
                 DrawableCompat.setTint(strip, backgroundTintColor);
             }
         }
 
         setWillNotDraw(false);
@@ -292,16 +292,17 @@ class TabMenuStripLayout extends ThemedL
 
     @Override
     public void setPrivateMode(boolean isPrivate) {
         final boolean modeChanged = (isPrivateMode() != isPrivate);
 
         super.setPrivateMode(isPrivate);
 
         if (modeChanged && stripColor != null) {
+            strip = DrawableCompat.wrap(strip);
             final int backgroundTintColor = stripColor.getColorForState(getDrawableState(), Color.TRANSPARENT);
             DrawableCompat.setTint(strip, backgroundTintColor);
         }
     }
 
     private class ViewClickListener implements OnClickListener {
         private final int mIndex;