Bug 1254663 - Approach 1 Part 1: Scale topsites favicons to consistent physical size r?sebastian draft
authorAndrzej Hunt <ahunt@mozilla.com>
Wed, 01 Jun 2016 09:57:30 -0700
changeset 374097 563681d8f89ea9c358730ea42117869fe73364a7
parent 372305 167e407cb1fcbb08f4f44d40acb2b8bc5f8de382
child 374098 70f62991bd7fe59a664dd6cf4f620ec91721938b
push id19923
push userahunt@mozilla.com
push dateWed, 01 Jun 2016 19:52:03 +0000
reviewerssebastian
bugs1254663
milestone49.0a1
Bug 1254663 - Approach 1 Part 1: Scale topsites favicons to consistent physical size r?sebastian MozReview-Commit-ID: IaHOxaT3p5p
mobile/android/base/java/org/mozilla/gecko/home/TopSitesGridItemView.java
--- a/mobile/android/base/java/org/mozilla/gecko/home/TopSitesGridItemView.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/TopSitesGridItemView.java
@@ -301,16 +301,27 @@ public class TopSitesGridItemView extend
             });
             return;
         }
 
         if (faviconURL != null) {
             mFaviconURL = faviconURL;
         }
 
+        // Similarly to FaviconView: if the icon is too small, we try to scale it to at least a consistent
+        // physical size. Note: the favicon cache downscales larger icons to these dimensions, all
+        // we're doing here is upscaling any smaller icons (some sites supply a 32x32 pixel favicon,
+        // displaying this based on pixel sizes results in a tiny icon on high density displays,
+        // e.g. 0.5cm x 0.5cm on an N6P).
+        int scaledSize = getResources().getDimensionPixelSize(R.dimen.favicon_largest_interesting_size);
+        int actualSize = Math.min(favicon.getHeight(), favicon.getWidth());
+        if (actualSize < scaledSize) {
+            favicon = Bitmap.createScaledBitmap(favicon, scaledSize, scaledSize, true);
+        }
+
         mThumbnailView.setScaleType(SCALE_TYPE_FAVICON);
         mThumbnailView.setImageBitmap(favicon, false);
 
         if (mFaviconURL != null) {
             final int bgColor = Favicons.getFaviconColor(mFaviconURL);
             mThumbnailView.setBackgroundColorWithOpacityFilter(bgColor);
         }
     }