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:
Michael Comella 2015-06-01 15:33:11 -07:00
parent 48cbb5d34a
commit a028b2a171
2 changed files with 12 additions and 5 deletions

View File

@ -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.

View File

@ -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 {