Sriram Ramasubramanian <sriram@mozilla.com>

This commit is contained in:
Sriram Ramasubramanian 2011-10-05 17:21:00 -04:00
parent 6e669b10cf
commit f9e19fc2e5
2 changed files with 7 additions and 3 deletions

View File

@ -129,8 +129,11 @@ public class LauncherShortcuts extends ListActivity {
size = 72;
}
Bitmap bitmap = Bitmap.createScaledBitmap(BitmapFactory.decodeFile(favicon), size, size, true);
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap);
Bitmap bitmap = BitmapFactory.decodeFile(favicon);
if (bitmap != null) {
Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, size, size, true);
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, scaledBitmap);
}
// Now, return the result to the launcher
setResult(RESULT_OK, intent);

View File

@ -141,9 +141,10 @@ let OpenWebapps = {
this._writeFile(this.appsFile, JSON.stringify(this.webapps));
// now save the icon as icon.png in the app directory
let iconURI = aApplication.iconURI ? aApplication.iconURI : "chrome://browser/skin/images/homescreen-default-hdpi.png";
let iconFile = dir.clone();
iconFile.append("icon.png");
let uri = Services.io.newURI(aApplication.iconURI, null, null);
let uri = Services.io.newURI(iconURI, null, null);
let persist = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"].createInstance(Ci.nsIWebBrowserPersist);
persist.persistFlags = persist.PERSIST_FLAGS_REPLACE_EXISTING_FILES | persist.PERSIST_FLAGS_BYPASS_CACHE;
persist.saveURI(uri, null, null, null, "", iconFile);