author | Sriram Ramasubramanian <sriram@mozilla.com> |
Wed, 26 Dec 2012 11:10:14 -0800 | |
changeset 117056 | 30607c0b98c21d8d7541eeb84f6847e7f998f8ab |
parent 117055 | d092140b20df742fe0bccce47f60398ffd5ce551 |
child 117057 | 869f370625c66d30965f318ab9dc3af833256b3b |
push id | 20283 |
push user | sramasubramanian@mozilla.com |
push date | Wed, 26 Dec 2012 19:15:54 +0000 |
treeherder | mozilla-inbound@7b206ae3187e [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mfinkle |
bugs | 824132 |
milestone | 20.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
|
--- 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.