Bug 1254663 - Approach 1 Part 2: upscale TwoLinePageRow favicons to consistent physical size r?sebastian draft
authorAndrzej Hunt <ahunt@mozilla.com>
Wed, 01 Jun 2016 09:59:55 -0700
changeset 374098 70f62991bd7fe59a664dd6cf4f620ec91721938b
parent 374097 563681d8f89ea9c358730ea42117869fe73364a7
child 374099 701042633d4eb66f75926525a6031481960da345
push id19923
push userahunt@mozilla.com
push dateWed, 01 Jun 2016 19:52:03 +0000
reviewerssebastian
bugs1254663
milestone49.0a1
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
mobile/android/base/java/org/mozilla/gecko/home/TwoLinePageRow.java
mobile/android/base/java/org/mozilla/gecko/tabs/TabHistoryItemRow.java
mobile/android/base/java/org/mozilla/gecko/widget/FaviconView.java
--- 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