mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 808663 - Use new favicon style for search providers. r=bnicholson
This commit is contained in:
parent
576c5bc30e
commit
899d46f43b
@ -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<String> 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<String>();
|
||||
@ -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() {
|
||||
|
@ -12,13 +12,14 @@
|
||||
android:padding="7dip">
|
||||
|
||||
<ImageView android:id="@+id/suggestion_icon"
|
||||
android:layout_width="32dip"
|
||||
android:layout_height="32dip"
|
||||
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="32dip"
|
||||
android:minHeight="32dip"
|
||||
android:scaleType="fitCenter"/>
|
||||
android:minWidth="@dimen/awesomebar_row_favicon_bg"
|
||||
android:minHeight="@dimen/awesomebar_row_favicon_bg"
|
||||
android:scaleType="center"
|
||||
android:background="@drawable/awesomebar_row_favicon_bg"/>
|
||||
|
||||
<org.mozilla.gecko.FlowLayout android:id="@+id/suggestion_layout"
|
||||
android:layout_toRightOf="@id/suggestion_icon"
|
||||
|
Loading…
Reference in New Issue
Block a user