Bug 820868 - Lightweight theme previews do not work on Firefox for Android, breaking the preview/install flow r=sriram
authorMark Finkle <mfinkle@mozilla.com>
Thu, 13 Dec 2012 13:06:05 -0500
changeset 115954 d468da47eef0f7f8065710788df3e9203e71ed3f
parent 115953 1b3ec53cab896c46cae054fa079aa7e97b1fa862
child 115955 0ba4220f82ff42b773bbb1d4527d7fa59cf359a8
push id24034
push useremorley@mozilla.com
push dateFri, 14 Dec 2012 15:28:57 +0000
treeherdermozilla-central@50d8f411d305 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssriram
bugs820868
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 820868 - Lightweight theme previews do not work on Firefox for Android, breaking the preview/install flow r=sriram
mobile/android/base/LightweightTheme.java
--- a/mobile/android/base/LightweightTheme.java
+++ b/mobile/android/base/LightweightTheme.java
@@ -72,26 +72,28 @@ public class LightweightTheme implements
     }
 
     public void removeListener(OnChangeListener listener) {
         mListeners.remove(listener);
     }
 
     public void setLightweightTheme(String headerURL) {
         try {
-            // Wait till gecko downloads and gives us the file, don't download.
-            if (headerURL.indexOf("http") != -1)
-                return;
-
             // Get the image and convert it to a bitmap.
             URL url = new URL(headerURL);
             InputStream stream = url.openStream();
             mBitmap = BitmapFactory.decodeStream(stream);
             stream.close();
 
+            // The download could be HTTP for previews, so let's be sure we have a bitmap
+            if (mBitmap != null || mBitmap.getWidth() == 0 || mBitmap.getHeight() == 0) {
+                mBitmap = null;
+                return;
+            }
+
             // To find the dominant color only once, take the bottom 25% of pixels.
             DisplayMetrics dm = mApplication.getResources().getDisplayMetrics();
             int maxWidth = Math.max(dm.widthPixels, dm.heightPixels);
             int height = (int) (mBitmap.getHeight() * 0.25);
             Bitmap cropped = Bitmap.createBitmap(mBitmap, mBitmap.getWidth() - maxWidth,
                                                           mBitmap.getHeight() - height, 
                                                           maxWidth, height);
             mColor = BitmapUtils.getDominantColor(cropped, false);