Bug 824132: Persona sends a Reset message on start. [r=mfinkle]
authorSriram Ramasubramanian <sriram@mozilla.com>
Wed, 26 Dec 2012 11:10:14 -0800
changeset 117058 30607c0b98c21d8d7541eeb84f6847e7f998f8ab
parent 117057 d092140b20df742fe0bccce47f60398ffd5ce551
child 117059 869f370625c66d30965f318ab9dc3af833256b3b
push id24083
push userdholbert@mozilla.com
push dateThu, 27 Dec 2012 21:54:50 +0000
treeherdermozilla-central@65de3fdfe888 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs824132
milestone20.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 824132: Persona sends a Reset message on start. [r=mfinkle]
mobile/android/base/LightweightTheme.java
--- a/mobile/android/base/LightweightTheme.java
+++ b/mobile/android/base/LightweightTheme.java
@@ -108,28 +108,30 @@ public class LightweightTheme implements
         } catch(java.net.MalformedURLException e) {
             mBitmap = null;
         } catch(java.io.IOException e) {
             mBitmap = null;
         }
     }
 
     public void resetLightweightTheme() {
-        // Reset the bitmap.
-        mBitmap = null;
+        if (mBitmap != null) {
+            // Reset the bitmap.
+            mBitmap = null;
 
-        // Post the reset on the UI thread.
-        for (OnChangeListener listener : mListeners) {
-             final OnChangeListener oneListener = listener;
-             oneListener.post(new Runnable() {
-                 @Override
-                 public void run() {
-                     oneListener.onLightweightThemeReset();
-                 }
-             });
+            // Post the reset on the UI thread.
+            for (OnChangeListener listener : mListeners) {
+                 final OnChangeListener oneListener = listener;
+                 oneListener.post(new Runnable() {
+                     @Override
+                     public void run() {
+                         oneListener.onLightweightThemeReset();
+                     }
+                 });
+            }
         }
     }
 
     public void notifyListeners() {
         if (mBitmap == null)
             return;
 
         // Post the change on the UI thread.
@@ -157,16 +159,31 @@ public class LightweightTheme implements
             } else if (event.equals("LightweightTheme:Disable")) {
                 resetLightweightTheme();
             }
         } catch (Exception e) {
             Log.e(LOGTAG, "Exception handling message \"" + event + "\":", e);
         }
     }
 
+
+    /**
+     * A lightweight theme is enabled only if there is an active bitmap.
+     *
+     * @return True if the theme is enabled.
+     */
+    public boolean isEnabled() {
+        return (mBitmap != null);
+    }
+
+    /**
+     * Based on the luminance of the domanint color, a theme is classified as light or dark.
+     *
+     * @return True if the theme is light.
+     */
     public boolean isLightTheme() {
         return mIsLight;
     }
 
     /**
      * Crop the image based on the position of the view on the window.
      * Either the View or one of its ancestors might have scrolled or translated.
      * This value should be taken into account while mapping the View to the Bitmap.