Bug 1179479 - Invalidate Themed* after refreshing drawable state. r=mhaigh, a=sledru
authorMichael Comella <michael.l.comella@gmail.com>
Wed, 05 Aug 2015 14:17:49 -0700
changeset 277187 9032008d56251514e7462f7aae2b48f519220926
parent 277186 ae70f5d5f5b74cb9911fa45de98df87ba1d339b0
child 277188 7c092142102fac5312234bfc9beea307f6910cca
push id8326
push userryanvm@gmail.com
push dateTue, 18 Aug 2015 21:38:05 +0000
treeherdermozilla-aurora@4345fbf90ea4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhaigh, sledru
bugs1179479
milestone42.0a2
Bug 1179479 - Invalidate Themed* after refreshing drawable state. r=mhaigh, a=sledru afaict, refreshDrawableState only sets the appropriate back-end bits to change the state but does not request a redraw. For example, refreshDrawableState eventually calls Drawable.setState, whose docs specify: If the new state you are supplying causes the appearance of the Drawable to change, then it is responsible for calling invalidateSelf in order to have itself redrawn, and true will be returned from this function. Notably, there are no other calls to invalidate in the call hierarchy so I added one. The reason this (sometimes) worked before is because the views would be invalidated in some other way, e.g. setDrawable would be called. Without this patch, the next patch would update the reload menu icon on press (i.e. another invalidate call) but not when the tab was switched from non-private to private.
mobile/android/base/widget/ThemedEditText.java
mobile/android/base/widget/ThemedImageButton.java
mobile/android/base/widget/ThemedImageView.java
mobile/android/base/widget/ThemedLinearLayout.java
mobile/android/base/widget/ThemedRelativeLayout.java
mobile/android/base/widget/ThemedTextSwitcher.java
mobile/android/base/widget/ThemedTextView.java
mobile/android/base/widget/ThemedView.java
mobile/android/base/widget/ThemedView.java.frag
--- a/mobile/android/base/widget/ThemedEditText.java
+++ b/mobile/android/base/widget/ThemedEditText.java
@@ -106,40 +106,43 @@ public class ThemedEditText extends andr
     public boolean isPrivateMode() {
         return mIsPrivate;
     }
 
     public void setPrivateMode(boolean isPrivate) {
         if (mIsPrivate != isPrivate) {
             mIsPrivate = isPrivate;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setTheme(boolean isLight) {
         // Set the theme only if it is different from existing theme.
         if ((isLight && mIsLight != isLight) ||
             (!isLight && mIsDark == isLight)) {
             if (isLight) {
                 mIsLight = true;
                 mIsDark = false;
             } else {
                 mIsLight = false;
                 mIsDark = true;
             }
 
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void resetTheme() {
         if (mIsLight || mIsDark) {
             mIsLight = false;
             mIsDark = false;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setAutoUpdateTheme(boolean autoUpdateTheme) {
         if (mTheme == null) {
             return;
         }
 
--- a/mobile/android/base/widget/ThemedImageButton.java
+++ b/mobile/android/base/widget/ThemedImageButton.java
@@ -106,40 +106,43 @@ public class ThemedImageButton extends a
     public boolean isPrivateMode() {
         return mIsPrivate;
     }
 
     public void setPrivateMode(boolean isPrivate) {
         if (mIsPrivate != isPrivate) {
             mIsPrivate = isPrivate;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setTheme(boolean isLight) {
         // Set the theme only if it is different from existing theme.
         if ((isLight && mIsLight != isLight) ||
             (!isLight && mIsDark == isLight)) {
             if (isLight) {
                 mIsLight = true;
                 mIsDark = false;
             } else {
                 mIsLight = false;
                 mIsDark = true;
             }
 
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void resetTheme() {
         if (mIsLight || mIsDark) {
             mIsLight = false;
             mIsDark = false;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setAutoUpdateTheme(boolean autoUpdateTheme) {
         if (mTheme == null) {
             return;
         }
 
--- a/mobile/android/base/widget/ThemedImageView.java
+++ b/mobile/android/base/widget/ThemedImageView.java
@@ -106,40 +106,43 @@ public class ThemedImageView extends and
     public boolean isPrivateMode() {
         return mIsPrivate;
     }
 
     public void setPrivateMode(boolean isPrivate) {
         if (mIsPrivate != isPrivate) {
             mIsPrivate = isPrivate;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setTheme(boolean isLight) {
         // Set the theme only if it is different from existing theme.
         if ((isLight && mIsLight != isLight) ||
             (!isLight && mIsDark == isLight)) {
             if (isLight) {
                 mIsLight = true;
                 mIsDark = false;
             } else {
                 mIsLight = false;
                 mIsDark = true;
             }
 
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void resetTheme() {
         if (mIsLight || mIsDark) {
             mIsLight = false;
             mIsDark = false;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setAutoUpdateTheme(boolean autoUpdateTheme) {
         if (mTheme == null) {
             return;
         }
 
--- a/mobile/android/base/widget/ThemedLinearLayout.java
+++ b/mobile/android/base/widget/ThemedLinearLayout.java
@@ -101,40 +101,43 @@ public class ThemedLinearLayout extends 
     public boolean isPrivateMode() {
         return mIsPrivate;
     }
 
     public void setPrivateMode(boolean isPrivate) {
         if (mIsPrivate != isPrivate) {
             mIsPrivate = isPrivate;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setTheme(boolean isLight) {
         // Set the theme only if it is different from existing theme.
         if ((isLight && mIsLight != isLight) ||
             (!isLight && mIsDark == isLight)) {
             if (isLight) {
                 mIsLight = true;
                 mIsDark = false;
             } else {
                 mIsLight = false;
                 mIsDark = true;
             }
 
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void resetTheme() {
         if (mIsLight || mIsDark) {
             mIsLight = false;
             mIsDark = false;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setAutoUpdateTheme(boolean autoUpdateTheme) {
         if (mTheme == null) {
             return;
         }
 
--- a/mobile/android/base/widget/ThemedRelativeLayout.java
+++ b/mobile/android/base/widget/ThemedRelativeLayout.java
@@ -106,40 +106,43 @@ public class ThemedRelativeLayout extend
     public boolean isPrivateMode() {
         return mIsPrivate;
     }
 
     public void setPrivateMode(boolean isPrivate) {
         if (mIsPrivate != isPrivate) {
             mIsPrivate = isPrivate;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setTheme(boolean isLight) {
         // Set the theme only if it is different from existing theme.
         if ((isLight && mIsLight != isLight) ||
             (!isLight && mIsDark == isLight)) {
             if (isLight) {
                 mIsLight = true;
                 mIsDark = false;
             } else {
                 mIsLight = false;
                 mIsDark = true;
             }
 
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void resetTheme() {
         if (mIsLight || mIsDark) {
             mIsLight = false;
             mIsDark = false;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setAutoUpdateTheme(boolean autoUpdateTheme) {
         if (mTheme == null) {
             return;
         }
 
--- a/mobile/android/base/widget/ThemedTextSwitcher.java
+++ b/mobile/android/base/widget/ThemedTextSwitcher.java
@@ -101,40 +101,43 @@ public class ThemedTextSwitcher extends 
     public boolean isPrivateMode() {
         return mIsPrivate;
     }
 
     public void setPrivateMode(boolean isPrivate) {
         if (mIsPrivate != isPrivate) {
             mIsPrivate = isPrivate;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setTheme(boolean isLight) {
         // Set the theme only if it is different from existing theme.
         if ((isLight && mIsLight != isLight) ||
             (!isLight && mIsDark == isLight)) {
             if (isLight) {
                 mIsLight = true;
                 mIsDark = false;
             } else {
                 mIsLight = false;
                 mIsDark = true;
             }
 
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void resetTheme() {
         if (mIsLight || mIsDark) {
             mIsLight = false;
             mIsDark = false;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setAutoUpdateTheme(boolean autoUpdateTheme) {
         if (mTheme == null) {
             return;
         }
 
--- a/mobile/android/base/widget/ThemedTextView.java
+++ b/mobile/android/base/widget/ThemedTextView.java
@@ -106,40 +106,43 @@ public class ThemedTextView extends andr
     public boolean isPrivateMode() {
         return mIsPrivate;
     }
 
     public void setPrivateMode(boolean isPrivate) {
         if (mIsPrivate != isPrivate) {
             mIsPrivate = isPrivate;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setTheme(boolean isLight) {
         // Set the theme only if it is different from existing theme.
         if ((isLight && mIsLight != isLight) ||
             (!isLight && mIsDark == isLight)) {
             if (isLight) {
                 mIsLight = true;
                 mIsDark = false;
             } else {
                 mIsLight = false;
                 mIsDark = true;
             }
 
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void resetTheme() {
         if (mIsLight || mIsDark) {
             mIsLight = false;
             mIsDark = false;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setAutoUpdateTheme(boolean autoUpdateTheme) {
         if (mTheme == null) {
             return;
         }
 
--- a/mobile/android/base/widget/ThemedView.java
+++ b/mobile/android/base/widget/ThemedView.java
@@ -106,40 +106,43 @@ public class ThemedView extends android.
     public boolean isPrivateMode() {
         return mIsPrivate;
     }
 
     public void setPrivateMode(boolean isPrivate) {
         if (mIsPrivate != isPrivate) {
             mIsPrivate = isPrivate;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setTheme(boolean isLight) {
         // Set the theme only if it is different from existing theme.
         if ((isLight && mIsLight != isLight) ||
             (!isLight && mIsDark == isLight)) {
             if (isLight) {
                 mIsLight = true;
                 mIsDark = false;
             } else {
                 mIsLight = false;
                 mIsDark = true;
             }
 
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void resetTheme() {
         if (mIsLight || mIsDark) {
             mIsLight = false;
             mIsDark = false;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setAutoUpdateTheme(boolean autoUpdateTheme) {
         if (mTheme == null) {
             return;
         }
 
--- a/mobile/android/base/widget/ThemedView.java.frag
+++ b/mobile/android/base/widget/ThemedView.java.frag
@@ -109,40 +109,43 @@ public class Themed@VIEW_NAME_SUFFIX@ ex
     public boolean isPrivateMode() {
         return mIsPrivate;
     }
 
     public void setPrivateMode(boolean isPrivate) {
         if (mIsPrivate != isPrivate) {
             mIsPrivate = isPrivate;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setTheme(boolean isLight) {
         // Set the theme only if it is different from existing theme.
         if ((isLight && mIsLight != isLight) ||
             (!isLight && mIsDark == isLight)) {
             if (isLight) {
                 mIsLight = true;
                 mIsDark = false;
             } else {
                 mIsLight = false;
                 mIsDark = true;
             }
 
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void resetTheme() {
         if (mIsLight || mIsDark) {
             mIsLight = false;
             mIsDark = false;
             refreshDrawableState();
+            invalidate();
         }
     }
 
     public void setAutoUpdateTheme(boolean autoUpdateTheme) {
         if (mTheme == null) {
             return;
         }