diff --git a/mobile/android/base/awesomebar/AllPagesTab.java b/mobile/android/base/awesomebar/AllPagesTab.java index 0f784fa2c39..ef9e2ba897a 100644 --- a/mobile/android/base/awesomebar/AllPagesTab.java +++ b/mobile/android/base/awesomebar/AllPagesTab.java @@ -27,6 +27,7 @@ import android.os.Handler; import android.os.Message; import android.os.SystemClock; import android.text.TextUtils; +import android.util.Base64; import android.util.Log; import android.view.animation.AccelerateInterpolator; import android.view.animation.AlphaAnimation; @@ -460,7 +461,7 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener { // set the search engine icon (e.g., Google) for the row FlowLayout suggestionView = viewHolder.suggestionView; - viewHolder.iconView.setImageDrawable(engine.icon); + updateFavicon(viewHolder.iconView, engine.icon); // user-entered search term is first suggestion viewHolder.userEnteredTextView.setText(mSearchTerm); @@ -510,14 +511,14 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener { private class SearchEngine { public String name; - public Drawable icon; + public Bitmap icon; public ArrayList suggestions; public SearchEngine(String name) { this(name, null); } - public SearchEngine(String name, Drawable icon) { + public SearchEngine(String name, Bitmap icon) { this.name = name; this.icon = icon; this.suggestions = new ArrayList(); @@ -552,7 +553,7 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener { JSONObject engineJSON = engines.getJSONObject(i); String name = engineJSON.getString("name"); String iconURI = engineJSON.getString("iconURI"); - Drawable icon = getDrawableFromDataURI(iconURI); + Bitmap icon = getBitmapFromDataURI(iconURI); if (name.equals(suggestEngine) && suggestTemplate != null) { // suggest engine should be at the front of the list mSearchEngines.add(0, new SearchEngine(name, icon)); @@ -574,18 +575,9 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener { filterSuggestions(mSearchTerm); } - private Drawable getDrawableFromDataURI(String dataURI) { - String base64 = dataURI.substring(dataURI.indexOf(',') + 1); - Drawable drawable = null; - try { - byte[] bytes = GeckoAppShell.decodeBase64(base64, GeckoAppShell.BASE64_DEFAULT); - ByteArrayInputStream stream = new ByteArrayInputStream(bytes); - drawable = Drawable.createFromStream(stream, "src"); - stream.close(); - } catch (IllegalArgumentException e) { - Log.i(LOGTAG, "exception while decoding drawable: " + base64, e); - } catch (IOException e) { } - return drawable; + private Bitmap getBitmapFromDataURI(String dataURI) { + byte[] raw = Base64.decode(dataURI.substring(22), Base64.DEFAULT); + return BitmapFactory.decodeByteArray(raw, 0, raw.length); } private void showSuggestionsOptIn() { diff --git a/mobile/android/base/resources/layout/awesomebar_suggestion_row.xml.in b/mobile/android/base/resources/layout/awesomebar_suggestion_row.xml.in index 5ca803409e0..4829171ac07 100644 --- a/mobile/android/base/resources/layout/awesomebar_suggestion_row.xml.in +++ b/mobile/android/base/resources/layout/awesomebar_suggestion_row.xml.in @@ -12,13 +12,14 @@ android:padding="7dip"> + android:minWidth="@dimen/awesomebar_row_favicon_bg" + android:minHeight="@dimen/awesomebar_row_favicon_bg" + android:scaleType="center" + android:background="@drawable/awesomebar_row_favicon_bg"/>