Bug 1254663 - Approach 1 Part 2: upscale TwoLinePageRow favicons to consistent physical size r?sebastian
This ensure we don't show tiny speck-sized favicons on e.g. an N6P for sites that supply small
icons (e.g. 32x32px icons).
MozReview-Commit-ID: EB5YH38dg1X
--- a/mobile/android/base/java/org/mozilla/gecko/home/TwoLinePageRow.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/TwoLinePageRow.java
@@ -69,17 +69,17 @@ public class TwoLinePageRow extends Line
return;
}
if (favicon == null) {
v.showDefaultFavicon(url);
return;
}
- v.updateImage(favicon, faviconURL);
+ v.updateAndScaleImage(favicon, faviconURL);
}
}
// Listener for handling Favicon loads.
private final OnFaviconLoadedListener mFaviconListener;
// The URL for the page corresponding to this view.
private String mPageUrl;
--- a/mobile/android/base/java/org/mozilla/gecko/tabs/TabHistoryItemRow.java
+++ b/mobile/android/base/java/org/mozilla/gecko/tabs/TabHistoryItemRow.java
@@ -84,12 +84,12 @@ public class TabHistoryItemRow extends R
return;
}
if (favicon == null) {
v.showDefaultFavicon(url);
return;
}
- v.updateImage(favicon, faviconURL);
+ v.updateAndScaleImage(favicon, faviconURL);
}
}
}
--- a/mobile/android/base/java/org/mozilla/gecko/widget/FaviconView.java
+++ b/mobile/android/base/java/org/mozilla/gecko/widget/FaviconView.java
@@ -156,23 +156,22 @@ public class FaviconView extends ImageVi
mDominantColor = 0;
}
} else {
mDominantColor = 0;
}
}
private void scaleBitmap() {
- // If the Favicon can be resized to fill the view exactly without an enlargment of more than
- // a factor of two, do so.
- int doubledSize = mIconBitmap.getWidth() * 2;
- if (mActualWidth > doubledSize) {
- // If the view is more than twice the size of the image, just double the image size
- // and do the rest with padding.
- mIconBitmap = Bitmap.createScaledBitmap(mIconBitmap, doubledSize, doubledSize, true);
+ // Ensure at least a consistent minimal physical size for the favicon. This helps avoid
+ // tiny icons on high density devices, without doing too much enlargement.
+ int scaledSize = getResources().getDimensionPixelSize(R.dimen.favicon_largest_interesting_size);
+ if (mActualWidth > scaledSize) {
+ // Scale to the desired physical size - padding is later added around this icon as needed
+ mIconBitmap = Bitmap.createScaledBitmap(mIconBitmap, scaledSize, scaledSize, true);
} else {
// Otherwise, scale the image to fill the view.
mIconBitmap = Bitmap.createScaledBitmap(mIconBitmap, mActualWidth, mActualWidth, true);
}
}
/**
* Sets the icon displayed in this Favicon view to the bitmap provided. If the size of the view