Bug 1324028 - Pre: move favicon colour fading to color generator draft
authorAndrzej Hunt <ahunt@mozilla.com>
Sat, 10 Dec 2016 20:31:55 -0800
changeset 450460 e42f383221b142b00fcf548c1de19316990ddc23
parent 447228 88437b3066a7544d3229276c1302704f44b45868
child 450461 ef60eedb1282d4e47f56006ded1fdad3ce58ae93
push id38858
push userahunt@mozilla.com
push dateFri, 16 Dec 2016 17:16:58 +0000
bugs1324028
milestone53.0a1
Bug 1324028 - Pre: move favicon colour fading to color generator In order to allow for a background which merges into a favicon, we need to allow for solid (non faded) colours. It is simplest to do this by letting the colour generator (i.e. either the colour extractor, or the favicon generator) fade the dominant colour as it wishes. That also means the colour generator can in future choose to not fade the colour if appropriate. MozReview-Commit-ID: LsI8PlZsaGn
mobile/android/base/java/org/mozilla/gecko/icons/loader/IconGenerator.java
mobile/android/base/java/org/mozilla/gecko/icons/processing/ColorProcessor.java
mobile/android/base/java/org/mozilla/gecko/widget/FaviconView.java
--- a/mobile/android/base/java/org/mozilla/gecko/icons/loader/IconGenerator.java
+++ b/mobile/android/base/java/org/mozilla/gecko/icons/loader/IconGenerator.java
@@ -91,17 +91,17 @@ public class IconGenerator implements Ic
         paint.setTextSize(textSize);
         paint.setAntiAlias(true);
 
         canvas.drawText(character,
                 canvas.getWidth() / 2,
                 (int) ((canvas.getHeight() / 2) - ((paint.descent() + paint.ascent()) / 2)),
                 paint);
 
-        return IconResponse.createGenerated(favicon, color);
+        return IconResponse.createGenerated(favicon, color & 0x7FFFFFFF);
     }
 
     /**
      * Get a representative character for the given URL.
      *
      * For example this method will return "f" for "http://m.facebook.com/foobar".
      */
     @VisibleForTesting static String getRepresentativeCharacter(String url) {
--- a/mobile/android/base/java/org/mozilla/gecko/icons/processing/ColorProcessor.java
+++ b/mobile/android/base/java/org/mozilla/gecko/icons/processing/ColorProcessor.java
@@ -23,17 +23,17 @@ public class ColorProcessor implements P
     @Override
     public void process(IconRequest request, IconResponse response) {
         if (response.hasColor()) {
             return;
         }
 
         try {
             final Palette palette = Palette.from(response.getBitmap()).generate();
-            response.updateColor(palette.getVibrantColor(DEFAULT_COLOR));
+            response.updateColor(palette.getVibrantColor(DEFAULT_COLOR) & 0x7FFFFFFF);
         } catch (ArrayIndexOutOfBoundsException e) {
             // We saw the palette library fail with an ArrayIndexOutOfBoundsException intermittently
             // in automation. In this case lets just swallow the exception and move on without a
             // color. This is a valid condition and callers should handle this gracefully (Bug 1318560).
             Log.e(LOGTAG, "Palette generation failed with ArrayIndexOutOfBoundsException", e);
 
             response.updateColor(DEFAULT_COLOR);
         }
--- a/mobile/android/base/java/org/mozilla/gecko/widget/FaviconView.java
+++ b/mobile/android/base/java/org/mozilla/gecko/widget/FaviconView.java
@@ -112,17 +112,17 @@ public class FaviconView extends ImageVi
         mBackgroundRect.bottom = h;
 
         formatImage();
     }
 
     @Override
     public void onDraw(Canvas canvas) {
         if (isDominantBorderEnabled) {
-            sBackgroundPaint.setColor(mDominantColor & 0x7FFFFFFF);
+            sBackgroundPaint.setColor(mDominantColor);
 
             if (areRoundCornersEnabled) {
                 canvas.drawRoundRect(mBackgroundRect, mBackgroundCornerRadius, mBackgroundCornerRadius, sBackgroundPaint);
             } else {
                 canvas.drawRect(mBackgroundRect, sBackgroundPaint);
             }
         }