From 2fea3c89ff770ed6c17edcd413662c244d5faad0 Mon Sep 17 00:00:00 2001 From: Sriram Ramasubramanian Date: Wed, 26 Dec 2012 11:10:14 -0800 Subject: [PATCH] Bug 824132: Persona sends a Reset message on start. [r=mfinkle] --HG-- extra : rebase_source : e8e47801fbc3f4ec55e6d7637e4586a587cdda16 --- mobile/android/base/LightweightTheme.java | 39 ++++++++++++++++------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/mobile/android/base/LightweightTheme.java b/mobile/android/base/LightweightTheme.java index 2fd44cc8d3e..7478a540d08 100644 --- a/mobile/android/base/LightweightTheme.java +++ b/mobile/android/base/LightweightTheme.java @@ -113,18 +113,20 @@ public class LightweightTheme implements GeckoEventListener { } 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(); + } + }); + } } } @@ -162,6 +164,21 @@ public class LightweightTheme implements GeckoEventListener { } } + + /** + * 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; }