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
--- 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);
}
}