mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 23:35:34 +00:00
Bug 1170289 - Set default search engine favicon to magnifying glass. r?Margaret
This doesn't work for the Settings screen (bug 1170346). --HG-- extra : commitid : 4Nfxo9FZGRp extra : rebase_source : 0246d346d8ba5c21624d9bbfa26f14d6c30d37fd
This commit is contained in:
parent
48cbb5d34a
commit
a028b2a171
@ -554,7 +554,7 @@ public class BrowserSearch extends HomeFragment
|
||||
ArrayList<SearchEngine> searchEngines = new ArrayList<SearchEngine>();
|
||||
for (int i = 0; i < engines.length(); i++) {
|
||||
final JSONObject engineJSON = engines.getJSONObject(i);
|
||||
final SearchEngine engine = new SearchEngine(engineJSON);
|
||||
final SearchEngine engine = new SearchEngine((Context) getActivity(), engineJSON);
|
||||
|
||||
if (engine.name.equals(suggestEngine) && suggestTemplate != null) {
|
||||
// Suggest engine should be at the front of the list.
|
||||
|
@ -6,11 +6,14 @@
|
||||
package org.mozilla.gecko.home;
|
||||
|
||||
import org.mozilla.gecko.gfx.BitmapUtils;
|
||||
import org.mozilla.gecko.R;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -25,7 +28,7 @@ public class SearchEngine {
|
||||
private final Bitmap icon;
|
||||
private volatile List<String> suggestions = new ArrayList<String>(); // Never null.
|
||||
|
||||
public SearchEngine(JSONObject engineJSON) throws JSONException {
|
||||
public SearchEngine(final Context context, final JSONObject engineJSON) throws JSONException {
|
||||
if (engineJSON == null) {
|
||||
throw new IllegalArgumentException("Can't instantiate SearchEngine from null JSON.");
|
||||
}
|
||||
@ -40,10 +43,14 @@ public class SearchEngine {
|
||||
final String iconURI = getString(engineJSON, "iconURI");
|
||||
if (iconURI == null) {
|
||||
Log.w(LOG_TAG, "iconURI is null for search engine " + this.name);
|
||||
this.icon = null;
|
||||
return;
|
||||
}
|
||||
this.icon = BitmapUtils.getBitmapFromDataURI(iconURI);
|
||||
final Bitmap tempIcon = BitmapUtils.getBitmapFromDataURI(iconURI);
|
||||
|
||||
this.icon = (tempIcon != null) ? tempIcon : getDefaultFavicon(context);
|
||||
}
|
||||
|
||||
private Bitmap getDefaultFavicon(final Context context) {
|
||||
return BitmapFactory.decodeResource(context.getResources(), R.drawable.favicon_search);
|
||||
}
|
||||
|
||||
private static String getString(JSONObject data, String key) throws JSONException {
|
||||
|
Loading…
Reference in New Issue
Block a user