Bug 839855 - Update tabs from last time favicons to match awesomescreen favicons. r=bnicholson
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Mon, 29 Apr 2013 17:05:55 -0700
changeset 141243 d5502bd1039665c02a7962a42cb3c681882a8833
parent 141242 360472327b09f8535f514ef32e717b34f4587632
child 141244 48ba682136ecd3a7155769a9a02da60ba310f9b5
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbnicholson
bugs839855
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 839855 - Update tabs from last time favicons to match awesomescreen favicons. r=bnicholson
CLOBBER
mobile/android/base/GeckoViewsFactory.java
mobile/android/base/Makefile.in
mobile/android/base/awesomebar/AllPagesTab.java
mobile/android/base/awesomebar/AwesomeBarTab.java
mobile/android/base/awesomebar/BookmarksTab.java
mobile/android/base/awesomebar/HistoryTab.java
mobile/android/base/resources/drawable/awesomebar_row_favicon_bg.xml
mobile/android/base/resources/drawable/favicon_bg.xml
mobile/android/base/resources/layout/abouthome_last_tabs_row.xml
mobile/android/base/resources/layout/awesomebar_folder_row.xml
mobile/android/base/resources/layout/awesomebar_row.xml
mobile/android/base/resources/layout/awesomebar_suggestion_row.xml
mobile/android/base/resources/values/dimens.xml
mobile/android/base/widget/FaviconView.java
mobile/android/base/widget/LastTabsSection.java
--- a/CLOBBER
+++ b/CLOBBER
@@ -12,9 +12,9 @@
 #          O               O
 #          |               |
 #          O <-- Clobber   O  <-- Clobber
 #
 # Note: The description below will be part of the error message shown to users.
 #
 # Modifying this file will now automatically clobber the buildbot machines \o/
 #
-Bug 856358: Needs a clobber because it renames an IDL file. See also bug 860894.
+Bug 839855 - Android resource file changes (only affects Android builds)
--- a/mobile/android/base/GeckoViewsFactory.java
+++ b/mobile/android/base/GeckoViewsFactory.java
@@ -2,16 +2,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko;
 
 import org.mozilla.gecko.gfx.LayerView;
 import org.mozilla.gecko.widget.AboutHomeView;
 import org.mozilla.gecko.widget.AddonsSection;
+import org.mozilla.gecko.widget.FaviconView;
 import org.mozilla.gecko.widget.IconTabWidget;
 import org.mozilla.gecko.widget.LastTabsSection;
 import org.mozilla.gecko.widget.LinkTextView;
 import org.mozilla.gecko.widget.PromoBox;
 import org.mozilla.gecko.widget.RemoteTabsSection;
 import org.mozilla.gecko.widget.TabRow;
 import org.mozilla.gecko.widget.ThumbnailView;
 import org.mozilla.gecko.widget.TopSitesView;
@@ -79,16 +80,17 @@ public final class GeckoViewsFactory imp
             mFactoryMap.put("EditText", GeckoEditText.class.getConstructor(arg1Class, arg2Class));
             mFactoryMap.put("FrameLayout", GeckoFrameLayout.class.getConstructor(arg1Class, arg2Class));
             mFactoryMap.put("ImageButton", GeckoImageButton.class.getConstructor(arg1Class, arg2Class));
             mFactoryMap.put("ImageView", GeckoImageView.class.getConstructor(arg1Class, arg2Class));
             mFactoryMap.put("LinearLayout", GeckoLinearLayout.class.getConstructor(arg1Class, arg2Class));
             mFactoryMap.put("RelativeLayout", GeckoRelativeLayout.class.getConstructor(arg1Class, arg2Class));
             mFactoryMap.put("TextSwitcher", GeckoTextSwitcher.class.getConstructor(arg1Class, arg2Class));
             mFactoryMap.put("TextView", GeckoTextView.class.getConstructor(arg1Class, arg2Class));
+            mFactoryMap.put("FaviconView", FaviconView.class.getConstructor(arg1Class, arg2Class));
         } catch (NoSuchMethodException nsme) {
             Log.e(LOGTAG, "Unable to initialize views factory", nsme);
         }
     }
 
     // Making this a singleton class.
     private static final GeckoViewsFactory INSTANCE = new GeckoViewsFactory();
 
--- a/mobile/android/base/Makefile.in
+++ b/mobile/android/base/Makefile.in
@@ -216,16 +216,17 @@ FENNEC_JAVA_FILES = \
   gfx/TouchEventHandler.java \
   gfx/ViewTransform.java \
   gfx/VirtualLayer.java \
   widget/AboutHome.java \
   widget/AboutHomeView.java \
   widget/AboutHomeSection.java \
   widget/AddonsSection.java \
   widget/DateTimePicker.java \
+  widget/FaviconView.java \
   widget/IconTabWidget.java \
   widget/LastTabsSection.java \
   widget/LinkTextView.java \
   widget/PromoBox.java \
   widget/RemoteTabsSection.java \
   widget/TopSitesView.java \
   widget/TabRow.java \
   widget/ThumbnailView.java \
@@ -993,20 +994,20 @@ MOZ_ANDROID_DRAWABLES += \
   mobile/android/base/resources/drawable/action_bar_button_inverse.xml          \
   mobile/android/base/resources/drawable/address_bar_bg.xml                     \
   mobile/android/base/resources/drawable/address_bar_bg_shadow_repeat.xml       \
   mobile/android/base/resources/drawable/address_bar_nav_button.xml             \
   mobile/android/base/resources/drawable/address_bar_right_edge.xml             \
   mobile/android/base/resources/drawable/address_bar_url.xml                    \
   mobile/android/base/resources/drawable/awesomebar_listview_divider.xml        \
   mobile/android/base/resources/drawable/awesomebar_header_row.xml              \
-  mobile/android/base/resources/drawable/awesomebar_row_favicon_bg.xml          \
   mobile/android/base/resources/drawable/awesomebar_tab_indicator.xml           \
   mobile/android/base/resources/drawable/awesomebar_tab_selected.xml            \
   mobile/android/base/resources/drawable/awesomebar_tab_unselected.xml          \
+  mobile/android/base/resources/drawable/favicon_bg.xml                         \
   mobile/android/base/resources/drawable/handle_end_level.xml                   \
   mobile/android/base/resources/drawable/handle_start_level.xml                 \
   mobile/android/base/resources/drawable/ic_menu_back.xml                       \
   mobile/android/base/resources/drawable/ic_menu_desktop_mode_off.xml           \
   mobile/android/base/resources/drawable/ic_menu_desktop_mode_on.xml            \
   mobile/android/base/resources/drawable/ic_menu_quit.xml                       \
   mobile/android/base/resources/drawable/menu_item_state.xml                    \
   mobile/android/base/resources/drawable/menu_level.xml                         \
--- a/mobile/android/base/awesomebar/AllPagesTab.java
+++ b/mobile/android/base/awesomebar/AllPagesTab.java
@@ -10,16 +10,17 @@ import org.mozilla.gecko.db.BrowserContr
 import org.mozilla.gecko.db.BrowserDB;
 import org.mozilla.gecko.db.BrowserDB.URLColumns;
 import org.mozilla.gecko.gfx.BitmapUtils;
 import org.mozilla.gecko.util.GamepadUtils;
 import org.mozilla.gecko.util.GeckoEventListener;
 import org.mozilla.gecko.util.StringUtils;
 import org.mozilla.gecko.util.ThreadUtils;
 import org.mozilla.gecko.util.UiAsyncTask;
+import org.mozilla.gecko.widget.FaviconView;
 
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
 
 import android.app.Activity;
 import android.content.Context;
 import android.database.Cursor;
@@ -81,17 +82,17 @@ public class AllPagesTab extends Awesome
     private volatile AutocompleteHandler mAutocompleteHandler = null;
 
     private static final int MESSAGE_LOAD_FAVICONS = 1;
     private static final int MESSAGE_UPDATE_FAVICONS = 2;
     private static final int DELAY_SHOW_THUMBNAILS = 550;
 
     private class SearchEntryViewHolder {
         public FlowLayout suggestionView;
-        public ImageView iconView;
+        public FaviconView iconView;
         public LinearLayout userEnteredView;
         public TextView userEnteredTextView;
     }
 
     public AllPagesTab(Context context) {
         super(context);
         mSearchEngines = new ArrayList<SearchEngine>();
 
@@ -486,17 +487,17 @@ public class AllPagesTab extends Awesome
             if (type == ROW_SEARCH || type == ROW_SUGGEST) {
                 SearchEntryViewHolder viewHolder = null;
 
                 if (convertView == null || !(convertView.getTag() instanceof SearchEntryViewHolder)) {
                     convertView = getInflater().inflate(R.layout.awesomebar_suggestion_row, getListView(), false);
 
                     viewHolder = new SearchEntryViewHolder();
                     viewHolder.suggestionView = (FlowLayout) convertView.findViewById(R.id.suggestion_layout);
-                    viewHolder.iconView = (ImageView) convertView.findViewById(R.id.suggestion_icon);
+                    viewHolder.iconView = (FaviconView) convertView.findViewById(R.id.suggestion_icon);
                     viewHolder.userEnteredView = (LinearLayout) convertView.findViewById(R.id.suggestion_user_entered);
                     viewHolder.userEnteredTextView = (TextView) convertView.findViewById(R.id.suggestion_text);
 
                     convertView.setTag(viewHolder);
                 } else {
                     viewHolder = (SearchEntryViewHolder) convertView.getTag();
                 }
 
@@ -505,17 +506,17 @@ public class AllPagesTab extends Awesome
                 AwesomeEntryViewHolder viewHolder = null;
 
                 if (convertView == null || !(convertView.getTag() instanceof AwesomeEntryViewHolder)) {
                     convertView = getInflater().inflate(R.layout.awesomebar_row, null);
 
                     viewHolder = new AwesomeEntryViewHolder();
                     viewHolder.titleView = (TextView) convertView.findViewById(R.id.title);
                     viewHolder.urlView = (TextView) convertView.findViewById(R.id.url);
-                    viewHolder.faviconView = (ImageView) convertView.findViewById(R.id.favicon);
+                    viewHolder.faviconView = (FaviconView) convertView.findViewById(R.id.favicon);
                     viewHolder.bookmarkIconView = (ImageView) convertView.findViewById(R.id.bookmark_icon);
 
                     convertView.setTag(viewHolder);
                 } else {
                     viewHolder = (AwesomeEntryViewHolder) convertView.getTag();
                 }
 
                 position -= getSuggestEngineCount();
--- a/mobile/android/base/awesomebar/AwesomeBarTab.java
+++ b/mobile/android/base/awesomebar/AwesomeBarTab.java
@@ -95,26 +95,17 @@ abstract public class AwesomeBarTab {
             if (bitmap != null) {
                 favicon = Favicons.getInstance().scaleImage(bitmap);
             }
         }
         updateFavicon(faviconView, favicon);
     }
 
     protected void updateFavicon(ImageView faviconView, Bitmap bitmap) {
-        if (bitmap == null) {
-            faviconView.setImageDrawable(null);
-        } else if (Favicons.getInstance().isLargeFavicon(bitmap)) {
-            // If the icon is large, hide the background
-            faviconView.setImageBitmap(bitmap);
-            faviconView.setBackgroundResource(0);
-        } else {
-            faviconView.setImageBitmap(bitmap);
-            faviconView.setBackgroundResource(R.drawable.awesomebar_row_favicon_bg);
-        }
+        faviconView.setImageBitmap(bitmap);
     }
 
     protected void updateTitle(TextView titleView, Cursor cursor) {
         int titleIndex = cursor.getColumnIndexOrThrow(URLColumns.TITLE);
         String title = cursor.getString(titleIndex);
 
         // Use the URL instead of an empty title for consistency with the normal URL
         // bar view - this is the equivalent of getDisplayTitle() in Tab.java
--- a/mobile/android/base/awesomebar/BookmarksTab.java
+++ b/mobile/android/base/awesomebar/BookmarksTab.java
@@ -7,31 +7,31 @@ package org.mozilla.gecko;
 
 import org.mozilla.gecko.AwesomeBar.ContextMenuSubject;
 import org.mozilla.gecko.db.BrowserContract.Bookmarks;
 import org.mozilla.gecko.db.BrowserContract.Combined;
 import org.mozilla.gecko.db.BrowserDB;
 import org.mozilla.gecko.db.BrowserDB.URLColumns;
 import org.mozilla.gecko.util.GamepadUtils;
 import org.mozilla.gecko.util.ThreadUtils;
+import org.mozilla.gecko.widget.FaviconView;
 
 import android.app.Activity;
 import android.content.Context;
 import android.database.Cursor;
 import android.os.AsyncTask;
 import android.util.Log;
 import android.util.Pair;
 import android.view.ContextMenu;
 import android.view.ContextMenu.ContextMenuInfo;
 import android.view.LayoutInflater;
 import android.view.MenuInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.AdapterView;
-import android.widget.ImageView;
 import android.widget.ListView;
 import android.widget.SimpleCursorAdapter;
 import android.widget.TextView;
 
 import java.util.LinkedList;
 
 public class BookmarksTab extends AwesomeBarTab {
     public static final String LOGTAG = "BOOKMARKS_TAB";
@@ -320,17 +320,17 @@ public class BookmarksTab extends Awesom
             if (convertView == null) {
                 if (viewType == VIEW_TYPE_ITEM)
                     convertView = getInflater().inflate(R.layout.awesomebar_row, null);
                 else
                     convertView = getInflater().inflate(R.layout.awesomebar_folder_row, null);
 
                 viewHolder = new AwesomeEntryViewHolder();
                 viewHolder.titleView = (TextView) convertView.findViewById(R.id.title);
-                viewHolder.faviconView = (ImageView) convertView.findViewById(R.id.favicon);
+                viewHolder.faviconView = (FaviconView) convertView.findViewById(R.id.favicon);
 
                 if (viewType == VIEW_TYPE_ITEM)
                     viewHolder.urlView = (TextView) convertView.findViewById(R.id.url);
 
                 convertView.setTag(viewHolder);
             } else {
                 viewHolder = (AwesomeEntryViewHolder) convertView.getTag();
             }
--- a/mobile/android/base/awesomebar/HistoryTab.java
+++ b/mobile/android/base/awesomebar/HistoryTab.java
@@ -7,16 +7,17 @@ package org.mozilla.gecko;
 
 import org.mozilla.gecko.AwesomeBar.ContextMenuSubject;
 import org.mozilla.gecko.db.BrowserContract.Combined;
 import org.mozilla.gecko.db.BrowserDB;
 import org.mozilla.gecko.db.BrowserDB.URLColumns;
 import org.mozilla.gecko.gfx.BitmapUtils;
 import org.mozilla.gecko.util.GamepadUtils;
 import org.mozilla.gecko.util.ThreadUtils;
+import org.mozilla.gecko.widget.FaviconView;
 
 import android.app.Activity;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.res.Resources;
 import android.database.ContentObserver;
 import android.database.Cursor;
 import android.graphics.Bitmap;
@@ -158,17 +159,17 @@ public class HistoryTab extends AwesomeB
             AwesomeEntryViewHolder viewHolder = null;
 
             if (convertView == null) {
                 convertView = getInflater().inflate(R.layout.awesomebar_row, null);
 
                 viewHolder = new AwesomeEntryViewHolder();
                 viewHolder.titleView = (TextView) convertView.findViewById(R.id.title);
                 viewHolder.urlView = (TextView) convertView.findViewById(R.id.url);
-                viewHolder.faviconView = (ImageView) convertView.findViewById(R.id.favicon);
+                viewHolder.faviconView = (FaviconView) convertView.findViewById(R.id.favicon);
                 viewHolder.bookmarkIconView = (ImageView) convertView.findViewById(R.id.bookmark_icon);
 
                 convertView.setTag(viewHolder);
             } else {
                 viewHolder = (AwesomeEntryViewHolder) convertView.getTag();
             }
 
             HistoryListAdapter adapter = getCursorAdapter();
rename from mobile/android/base/resources/drawable/awesomebar_row_favicon_bg.xml
rename to mobile/android/base/resources/drawable/favicon_bg.xml
--- a/mobile/android/base/resources/drawable/awesomebar_row_favicon_bg.xml
+++ b/mobile/android/base/resources/drawable/favicon_bg.xml
@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <shape xmlns:android="http://schemas.android.com/apk/res/android">
        android:shape="rectangle">
-     <corners android:radius="@dimen/awesomebar_row_favicon_bg_radius"/>
-     <size android:height="@dimen/awesomebar_row_favicon_bg"/>
+     <corners android:radius="@dimen/favicon_bg_radius"/>
+     <size android:height="@dimen/favicon_bg"/>
      <solid android:color="#FAFBFC"/>
 </shape>
--- a/mobile/android/base/resources/layout/abouthome_last_tabs_row.xml
+++ b/mobile/android/base/resources/layout/abouthome_last_tabs_row.xml
@@ -4,22 +4,24 @@
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 android:layout_width="fill_parent"
                 android:layout_height="@dimen/abouthome_rowitem_height"
                 android:gravity="left|center_vertical"
                 style="@style/AboutHome.RowItem">
 
-    <ImageView android:id="@+id/last_tab_favicon"
-               android:layout_width="32dip"
-               android:layout_height="32dip"
-               android:layout_centerVertical="true"
-               android:layout_marginLeft="@dimen/abouthome_rowitem_left_padding"
-               android:src="@drawable/favicon"/>
+    <Gecko.FaviconView android:id="@+id/last_tab_favicon"
+                       android:layout_width="@dimen/favicon_bg"
+                       android:layout_height="@dimen/favicon_bg"
+                       android:layout_marginLeft="@dimen/abouthome_rowitem_left_padding"
+                       android:layout_centerVertical="true"
+                       android:minWidth="@dimen/favicon_bg"
+                       android:minHeight="@dimen/favicon_bg"
+                       android:background="@drawable/favicon_bg"/>
 
     <Gecko.TextView android:id="@+id/last_tab_title"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:layout_toRightOf="@id/last_tab_favicon"
                     android:layout_marginTop="2dip"
                     android:layout_marginLeft="12dip"
                     android:layout_marginRight="12dip"
--- a/mobile/android/base/resources/layout/awesomebar_folder_row.xml
+++ b/mobile/android/base/resources/layout/awesomebar_folder_row.xml
@@ -3,25 +3,24 @@
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 android:layout_width="fill_parent"
                 android:layout_height="@dimen/awesomebar_row_height"
                 android:padding="6dip">
 
-    <ImageView android:id="@+id/favicon"
-               android:src="@drawable/folder"
-               android:layout_width="32dip"
-               android:layout_height="32dip"
-               android:layout_marginRight="6dip"
-               android:layout_centerVertical="true"
-               android:minWidth="32dip"
-               android:minHeight="32dip"
-               android:scaleType="fitCenter"/>
+    <Gecko.FaviconView android:id="@+id/favicon"
+                       android:src="@drawable/folder"
+                       android:layout_width="@dimen/favicon_bg"
+                       android:layout_height="@dimen/favicon_bg"
+                       android:layout_marginRight="6dip"
+                       android:layout_centerVertical="true"
+                       android:minWidth="@dimen/favicon_bg"
+                       android:minHeight="@dimen/favicon_bg"/>
 
     <TextView android:id="@+id/title"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:layout_marginLeft="6dip"
               android:layout_marginRight="6dip"
               android:layout_centerVertical="true"
               android:textColor="#222222"
--- a/mobile/android/base/resources/layout/awesomebar_row.xml
+++ b/mobile/android/base/resources/layout/awesomebar_row.xml
@@ -3,26 +3,24 @@
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 android:layout_width="fill_parent"
                 android:layout_height="@dimen/awesomebar_row_height"
                 android:padding="6dip">
 
-    <ImageView android:id="@+id/favicon"
-               android:layout_width="@dimen/awesomebar_row_favicon_bg"
-               android:layout_height="@dimen/awesomebar_row_favicon_bg"
-               android:layout_marginLeft="6dip"
-               android:layout_marginRight="6dip"
-               android:layout_centerVertical="true"
-               android:minWidth="@dimen/awesomebar_row_favicon_bg"
-               android:minHeight="@dimen/awesomebar_row_favicon_bg"
-               android:scaleType="center"
-               android:background="@drawable/awesomebar_row_favicon_bg"/>
+    <Gecko.FaviconView android:id="@+id/favicon"
+                       android:layout_width="@dimen/favicon_bg"
+                       android:layout_height="@dimen/favicon_bg"
+                       android:layout_marginLeft="6dip"
+                       android:layout_marginRight="6dip"
+                       android:layout_centerVertical="true"
+                       android:minWidth="@dimen/favicon_bg"
+                       android:minHeight="@dimen/favicon_bg"/>
 
     <ImageView android:id="@+id/bookmark_icon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_alignParentRight="true"
                android:visibility="gone"
                android:minHeight="32dip"
--- a/mobile/android/base/resources/layout/awesomebar_suggestion_row.xml
+++ b/mobile/android/base/resources/layout/awesomebar_suggestion_row.xml
@@ -4,25 +4,24 @@
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <org.mozilla.gecko.AnimatedHeightLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content"
                 android:minHeight="@dimen/awesomebar_row_height"
                 android:padding="7dip">
 
-    <ImageView android:id="@+id/suggestion_icon"
-               android:layout_width="@dimen/awesomebar_row_favicon_bg"
-               android:layout_height="@dimen/awesomebar_row_favicon_bg"
-               android:layout_marginLeft="6dip"
-               android:layout_marginRight="6dip"
-               android:minWidth="@dimen/awesomebar_row_favicon_bg"
-               android:minHeight="@dimen/awesomebar_row_favicon_bg"
-               android:scaleType="center"
-               android:background="@drawable/awesomebar_row_favicon_bg"/>
+    <Gecko.FaviconView android:id="@+id/suggestion_icon"
+                       android:layout_width="@dimen/favicon_bg"
+                       android:layout_height="@dimen/favicon_bg"
+                       android:layout_marginLeft="6dip"
+                       android:layout_marginRight="6dip"
+                       android:layout_centerVertical="true"
+                       android:minWidth="@dimen/favicon_bg"
+                       android:minHeight="@dimen/favicon_bg"/>
 
     <org.mozilla.gecko.FlowLayout android:id="@+id/suggestion_layout"
                                   android:layout_toRightOf="@id/suggestion_icon"
                                   android:layout_width="wrap_content"
                                   android:layout_height="wrap_content">
 
         <include layout="@layout/awesomebar_suggestion_item"
                  android:id="@+id/suggestion_user_entered"/>
--- a/mobile/android/base/resources/values/dimens.xml
+++ b/mobile/android/base/resources/values/dimens.xml
@@ -20,24 +20,24 @@
 
     <!-- Padding on either side of the lists in AwesomeBar -->
     <dimen name="awesomebar_list_padding">0dp</dimen>
 
     <dimen name="awesomebar_header_row_height">20dp</dimen>
     <dimen name="awesomebar_row_height">48dp</dimen>
     <dimen name="awesomebar_row_favicon_size_small">16dp</dimen>
     <dimen name="awesomebar_row_favicon_size_large">32dp</dimen>
-    <dimen name="awesomebar_row_favicon_bg">32dp</dimen>
-    <dimen name="awesomebar_row_favicon_bg_radius">1dp</dimen>
     <dimen name="awesomebar_tab_transparency_height">38dp</dimen>
     <dimen name="browser_toolbar_height">48dp</dimen>
     <dimen name="browser_toolbar_button_padding">12dp</dimen>
     <dimen name="browser_toolbar_icon_width">48dp</dimen>
     <dimen name="browser_toolbar_lock_width">20dp</dimen>
     <dimen name="browser_toolbar_favicon_size">29.33dip</dimen>
+    <dimen name="favicon_bg">32dp</dimen>
+    <dimen name="favicon_bg_radius">1dp</dimen>
 
     <!-- Max width of the doorhanger on tablets -->
     <dimen name="doorhanger_width">400dp</dimen>
 
     <dimen name="flow_layout_spacing">6dp</dimen>
     <dimen name="menu_item_icon">21dp</dimen>
     <dimen name="menu_item_state_icon">18dp</dimen>
     <dimen name="menu_item_row_height">44dp</dimen>
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/widget/FaviconView.java
@@ -0,0 +1,44 @@
+/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+package org.mozilla.gecko.widget;
+
+import org.mozilla.gecko.Favicons;
+import org.mozilla.gecko.R;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.util.AttributeSet;
+import android.widget.ImageView;
+
+/*
+ * Special version of ImageView for favicons.
+ * Changes image background depending on favicon size.
+ */
+public class FaviconView extends ImageView {
+
+    public FaviconView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        setScaleType(ImageView.ScaleType.CENTER);
+    }
+
+    @Override
+    public void setImageBitmap(Bitmap bitmap) {
+        if (bitmap == null) {
+            // Call setImageDrawable directly to avoid creating a useless BitmapDrawable.
+            setImageDrawable(null);
+            // If the bitmap is null, show a blank background.
+            setBackgroundResource(R.drawable.favicon_bg);
+        } else if (Favicons.getInstance().isLargeFavicon(bitmap)) {
+            super.setImageBitmap(bitmap);
+            // If the icon is large, hide the background.
+            setBackgroundResource(0);
+        } else {
+            super.setImageBitmap(bitmap);
+            // XXX Otherwise show a dominant color background.
+            setBackgroundResource(R.drawable.favicon_bg);
+        }
+    }
+}
--- a/mobile/android/base/widget/LastTabsSection.java
+++ b/mobile/android/base/widget/LastTabsSection.java
@@ -1,32 +1,33 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.widget;
 
+import org.mozilla.gecko.Favicons;
 import org.mozilla.gecko.GeckoProfile;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.SessionParser;
 import org.mozilla.gecko.Tabs;
 import org.mozilla.gecko.db.BrowserDB;
 import org.mozilla.gecko.util.GamepadUtils;
 import org.mozilla.gecko.util.ThreadUtils;
 import org.mozilla.gecko.util.UiAsyncTask;
+import org.mozilla.gecko.widget.FaviconView;
 
 import android.content.ContentResolver;
 import android.content.Context;
 import android.graphics.Bitmap;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.ImageView;
 import android.widget.TextView;
 
 import java.util.ArrayList;
 
 public class LastTabsSection extends AboutHomeSection {
     private Context mContext;
 
     private class TabInfo {
@@ -117,17 +118,19 @@ public class LastTabsSection extends Abo
     View createTabView(final TabInfo tab, ViewGroup parent) {
         final String url = tab.url;
         final Bitmap favicon = tab.favicon;
 
         View tabView = LayoutInflater.from(mContext).inflate(R.layout.abouthome_last_tabs_row, parent, false);
         ((TextView) tabView.findViewById(R.id.last_tab_title)).setText(tab.title);
         ((TextView) tabView.findViewById(R.id.last_tab_url)).setText(url);
         if (favicon != null) {
-            ((ImageView) tabView.findViewById(R.id.last_tab_favicon)).setImageBitmap(favicon);
+            FaviconView faviconView = (FaviconView) tabView.findViewById(R.id.last_tab_favicon);
+            Bitmap bitmap = Favicons.getInstance().scaleImage(favicon);
+            faviconView.setImageBitmap(favicon);
         }
 
         tabView.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 int flags = Tabs.LOADURL_NEW_TAB;
                 if (Tabs.getInstance().getSelectedTab().isPrivate())
                     flags |= Tabs.LOADURL_PRIVATE;