diff --git a/mobile/android/base/awesomebar/AllPagesTab.java b/mobile/android/base/awesomebar/AllPagesTab.java
index ef9e2ba897af..52763733d3b9 100644
--- a/mobile/android/base/awesomebar/AllPagesTab.java
+++ b/mobile/android/base/awesomebar/AllPagesTab.java
@@ -576,8 +576,13 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
}
private Bitmap getBitmapFromDataURI(String dataURI) {
- byte[] raw = Base64.decode(dataURI.substring(22), Base64.DEFAULT);
- return BitmapFactory.decodeByteArray(raw, 0, raw.length);
+ try {
+ byte[] raw = Base64.decode(dataURI.substring(22), Base64.DEFAULT);
+ return BitmapFactory.decodeByteArray(raw, 0, raw.length);
+ } catch(Exception ex) {
+ Log.i(LOGTAG, "exception while decoding bitmap: " + dataURI, ex);
+ }
+ return null;
}
private void showSuggestionsOptIn() {
diff --git a/mobile/android/base/awesomebar/AwesomeBarTab.java b/mobile/android/base/awesomebar/AwesomeBarTab.java
index fa0e3ace0566..9cda95be2b3f 100644
--- a/mobile/android/base/awesomebar/AwesomeBarTab.java
+++ b/mobile/android/base/awesomebar/AwesomeBarTab.java
@@ -41,12 +41,16 @@ abstract public class AwesomeBarTab {
// FIXME: This value should probably come from a prefs key
public static final int MAX_RESULTS = 100;
protected Context mContext = null;
- private static int sFaviconSize = -1;
+ private static int sFaviconSmallSize = -1;
+ private static int sFaviconLargeSize = -1;
public AwesomeBarTab(Context context) {
mContext = context;
- if (sFaviconSize < 0) {
- sFaviconSize = Math.round(mContext.getResources().getDimension(R.dimen.awesomebar_row_favicon_size));
+ if (sFaviconSmallSize < 0) {
+ sFaviconSmallSize = Math.round(mContext.getResources().getDimension(R.dimen.awesomebar_row_favicon_size_small));
+ }
+ if (sFaviconLargeSize < 0) {
+ sFaviconLargeSize = Math.round(mContext.getResources().getDimension(R.dimen.awesomebar_row_favicon_size_large));
}
}
@@ -105,9 +109,16 @@ abstract public class AwesomeBarTab {
protected void updateFavicon(ImageView faviconView, Bitmap bitmap) {
if (bitmap == null) {
faviconView.setImageDrawable(null);
- } else {
- bitmap = Bitmap.createScaledBitmap(bitmap, sFaviconSize, sFaviconSize, false);
+ } else if (bitmap.getWidth() > 16 || bitmap.getHeight() > 16) {
+ // If the icon is larger than 16px, scale it to sFaviconLargeSize and hide the background
+ bitmap = Bitmap.createScaledBitmap(bitmap, sFaviconLargeSize, sFaviconLargeSize, false);
faviconView.setImageBitmap(bitmap);
+ faviconView.setBackgroundResource(0);
+ } else {
+ // If the icon is 16px or smaller, don't scale it up to full size
+ bitmap = Bitmap.createScaledBitmap(bitmap, sFaviconSmallSize, sFaviconSmallSize, false);
+ faviconView.setImageBitmap(bitmap);
+ faviconView.setBackgroundResource(R.drawable.awesomebar_row_favicon_bg);
}
}
diff --git a/mobile/android/base/resources/values/dimens.xml b/mobile/android/base/resources/values/dimens.xml
index 938cc9523fac..d9e1e0f33909 100644
--- a/mobile/android/base/resources/values/dimens.xml
+++ b/mobile/android/base/resources/values/dimens.xml
@@ -15,7 +15,8 @@
32dp
20dp
48dp
- 16dp
+ 16dp
+ 32dp
32dp
1dp
38dp