Bug 1254944 - Move changes to generated ThemedImageButton to generator script. r=grisha, a=ritu
authorChenxia Liu <liuche@mozilla.com>
Wed, 09 Mar 2016 10:48:02 -0800
changeset 323494 e58f03852f8f562ce45df22cc41f28f21c008c83
parent 323493 7c64765b8752deebff5415d171274b2407e0a451
child 323495 4ff247b3d6e8a5be7f79a387b82c7c0c2e183f89
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgrisha, ritu
bugs1254944
milestone47.0a2
Bug 1254944 - Move changes to generated ThemedImageButton to generator script. r=grisha, a=ritu MozReview-Commit-ID: Gsnyf1CYE2e
mobile/android/base/java/org/mozilla/gecko/widget/themed/ThemedImageButton.java
mobile/android/base/java/org/mozilla/gecko/widget/themed/ThemedImageView.java
mobile/android/base/java/org/mozilla/gecko/widget/themed/ThemedView.java.frag
mobile/android/base/java/org/mozilla/gecko/widget/themed/generate_themed_views.py
--- a/mobile/android/base/java/org/mozilla/gecko/widget/themed/ThemedImageButton.java
+++ b/mobile/android/base/java/org/mozilla/gecko/widget/themed/ThemedImageButton.java
@@ -173,20 +173,19 @@ public class ThemedImageButton extends a
     @Override
     public void setImageDrawable(final Drawable drawable) {
         setTintedImageDrawable(drawable);
     }
 
     private void setTintedImageDrawable(final Drawable drawable) {
         final Drawable tintedDrawable;
         if (drawableColors == null || R.id.bookmark == getId()) {
+            // NB: The bookmarked state uses a blue star, so this is a hack to keep it untinted.
             // NB: If we tint a drawable with a null ColorStateList, it will override
             // any existing colorFilters and tint... so don't!
-
-            // NB: The bookmarked state uses a blue star, so this is a hack to keep it from being tinted.
             tintedDrawable = drawable;
         } else if (drawable == null) {
             tintedDrawable = null;
         } else {
             tintedDrawable = DrawableUtil.tintDrawableWithStateList(drawable, drawableColors);
         }
         super.setImageDrawable(tintedDrawable);
     }
--- a/mobile/android/base/java/org/mozilla/gecko/widget/themed/ThemedImageView.java
+++ b/mobile/android/base/java/org/mozilla/gecko/widget/themed/ThemedImageView.java
@@ -173,17 +173,17 @@ public class ThemedImageView extends and
     @Override
     public void setImageDrawable(final Drawable drawable) {
         setTintedImageDrawable(drawable);
     }
 
     private void setTintedImageDrawable(final Drawable drawable) {
         final Drawable tintedDrawable;
         if (drawableColors == null) {
-            // If we tint a drawable with a null ColorStateList, it will override
+            // NB: If we tint a drawable with a null ColorStateList, it will override
             // any existing colorFilters and tint... so don't!
             tintedDrawable = drawable;
         } else if (drawable == null) {
             tintedDrawable = null;
         } else {
             tintedDrawable = DrawableUtil.tintDrawableWithStateList(drawable, drawableColors);
         }
         super.setImageDrawable(tintedDrawable);
--- a/mobile/android/base/java/org/mozilla/gecko/widget/themed/ThemedView.java.frag
+++ b/mobile/android/base/java/org/mozilla/gecko/widget/themed/ThemedView.java.frag
@@ -178,18 +178,23 @@ public class Themed@VIEW_NAME_SUFFIX@ ex
 //#ifdef TINT_FOREGROUND_DRAWABLE
     @Override
     public void setImageDrawable(final Drawable drawable) {
         setTintedImageDrawable(drawable);
     }
 
     private void setTintedImageDrawable(final Drawable drawable) {
         final Drawable tintedDrawable;
+//#ifdef BOOKMARK_NO_TINT
+        if (drawableColors == null || R.id.bookmark == getId()) {
+            // NB: The bookmarked state uses a blue star, so this is a hack to keep it untinted.
+//#else
         if (drawableColors == null) {
-            // If we tint a drawable with a null ColorStateList, it will override
+//#endif
+            // NB: If we tint a drawable with a null ColorStateList, it will override
             // any existing colorFilters and tint... so don't!
             tintedDrawable = drawable;
         } else if (drawable == null) {
             tintedDrawable = null;
         } else {
             tintedDrawable = DrawableUtil.tintDrawableWithStateList(drawable, drawableColors);
         }
         super.setImageDrawable(tintedDrawable);
--- a/mobile/android/base/java/org/mozilla/gecko/widget/themed/generate_themed_views.py
+++ b/mobile/android/base/java/org/mozilla/gecko/widget/themed/generate_themed_views.py
@@ -7,17 +7,17 @@
 
 '''
 Script to generate Themed*.java source files for Fennec.
 
 This script runs the preprocessor on a input template and writes
 updated files into the source directory.
 
 To update the themed views, update the input template
-(ThemedView.java.frag) and run the script.  Use version control to
+(ThemedView.java.frag) and run the script using 'mach python <script.py>'.  Use version control to
 examine the differences, and don't forget to commit the changes to the
 template and the outputs.
 '''
 
 from __future__ import (
     print_function,
     unicode_literals,
 )
@@ -36,17 +36,18 @@ views = [
          BASE_TYPE='android.widget.EditText',
          STYLE_CONSTRUCTOR=1),
     dict(VIEW_NAME_SUFFIX='FrameLayout',
          BASE_TYPE='android.widget.FrameLayout',
          STYLE_CONSTRUCTOR=1),
     dict(VIEW_NAME_SUFFIX='ImageButton',
          BASE_TYPE='android.widget.ImageButton',
          STYLE_CONSTRUCTOR=1,
-         TINT_FOREGROUND_DRAWABLE=1),
+         TINT_FOREGROUND_DRAWABLE=1,
+         BOOKMARK_NO_TINT=1),
     dict(VIEW_NAME_SUFFIX='ImageView',
          BASE_TYPE='android.widget.ImageView',
          STYLE_CONSTRUCTOR=1,
          TINT_FOREGROUND_DRAWABLE=1),
     dict(VIEW_NAME_SUFFIX='LinearLayout',
          BASE_TYPE='android.widget.LinearLayout'),
     dict(VIEW_NAME_SUFFIX='RelativeLayout',
          BASE_TYPE='android.widget.RelativeLayout',