Bug 715258 - Favicons are of low quality for local/internal pages
@ -573,8 +573,6 @@ RES_DRAWABLE_BASE = \
|
||||
res/drawable/validation_arrow.png \
|
||||
res/drawable/validation_arrow_inverted.png \
|
||||
res/drawable/validation_bg.9.png \
|
||||
res/drawable/bookmarkdefaults_favicon_support.png \
|
||||
res/drawable/bookmarkdefaults_favicon_addons.png \
|
||||
res/drawable/handle_end.png \
|
||||
res/drawable/handle_middle.png \
|
||||
res/drawable/handle_start.png \
|
||||
|
@ -41,6 +41,7 @@ import org.mozilla.gecko.db.DBUtils;
|
||||
import org.mozilla.gecko.ProfileMigrator;
|
||||
import org.mozilla.gecko.sync.Utils;
|
||||
import org.mozilla.gecko.util.GeckoBackgroundThread;
|
||||
import org.mozilla.gecko.util.GeckoJarReader;
|
||||
|
||||
import android.app.SearchManager;
|
||||
import android.content.ContentProvider;
|
||||
@ -60,6 +61,7 @@ import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.database.sqlite.SQLiteQueryBuilder;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
@ -1018,25 +1020,10 @@ public class BrowserProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
private void setDefaultFavicon(SQLiteDatabase db, String name, String url) {
|
||||
Class<?> drawablesClass = R.drawable.class;
|
||||
ByteArrayOutputStream stream = null;
|
||||
try {
|
||||
// Look for a drawable with the id R.drawable.bookmarkdefaults_favicon_*
|
||||
Field faviconField = drawablesClass.getField(name.replace("_title_", "_favicon_"));
|
||||
if (faviconField == null)
|
||||
return;
|
||||
|
||||
int faviconId = faviconField.getInt(null);
|
||||
Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(), faviconId);
|
||||
stream = new ByteArrayOutputStream();
|
||||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
|
||||
} catch (java.lang.IllegalAccessException ex) {
|
||||
Log.e(LOGTAG, "Can't create favicon " + name, ex);
|
||||
} catch (java.lang.NoSuchFieldException ex) {
|
||||
// if there is no such field, create the bookmark without a favicon
|
||||
Log.d(LOGTAG, "Can't create favicon " + name);
|
||||
ByteArrayOutputStream stream = getDefaultFaviconFromPath(db, name, url);
|
||||
if (stream == null) {
|
||||
stream = getDefaultFaviconFromDrawable(db, name, url);
|
||||
}
|
||||
|
||||
if (stream != null) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(Favicons.DATA, stream.toByteArray());
|
||||
@ -1045,6 +1032,62 @@ public class BrowserProvider extends ContentProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private ByteArrayOutputStream getDefaultFaviconFromPath(SQLiteDatabase db, String name, String url) {
|
||||
ByteArrayOutputStream stream = null;
|
||||
Class stringClass = R.string.class;
|
||||
try {
|
||||
// Look for a drawable with the id R.drawable.bookmarkdefaults_favicon_*
|
||||
Field faviconField = stringClass.getField(name.replace("_title_", "_favicon_"));
|
||||
if (faviconField == null)
|
||||
return null;
|
||||
int faviconId = faviconField.getInt(null);
|
||||
String path = mContext.getString(faviconId);
|
||||
|
||||
String apkPath = mContext.getPackageResourcePath();
|
||||
File apkFile = new File(apkPath);
|
||||
BitmapDrawable bitmapDrawable = GeckoJarReader.getBitmapDrawable(mContext.getResources(),
|
||||
"jar:jar:" + apkFile.toURI() + "!/omni.ja!/" + path);
|
||||
if (bitmapDrawable == null) {
|
||||
return null;
|
||||
}
|
||||
Bitmap bitmap = bitmapDrawable.getBitmap();
|
||||
if (bitmap == null) {
|
||||
return null;
|
||||
}
|
||||
stream = new ByteArrayOutputStream();
|
||||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
|
||||
} catch (java.lang.IllegalAccessException ex) {
|
||||
Log.e(LOGTAG, "[Path] Can't create favicon " + name, ex);
|
||||
} catch (java.lang.NoSuchFieldException ex) {
|
||||
// if there is no such field, create the bookmark without a favicon
|
||||
Log.d(LOGTAG, "[Path] Can't create favicon " + name);
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
private ByteArrayOutputStream getDefaultFaviconFromDrawable(SQLiteDatabase db, String name, String url) {
|
||||
Class<?> drawablesClass = R.drawable.class;
|
||||
ByteArrayOutputStream stream = null;
|
||||
try {
|
||||
// Look for a drawable with the id R.drawable.bookmarkdefaults_favicon_*
|
||||
Field faviconField = drawablesClass.getField(name.replace("_title_", "_favicon_"));
|
||||
if (faviconField == null)
|
||||
return null;
|
||||
|
||||
int faviconId = faviconField.getInt(null);
|
||||
Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(), faviconId);
|
||||
stream = new ByteArrayOutputStream();
|
||||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
|
||||
} catch (java.lang.IllegalAccessException ex) {
|
||||
Log.e(LOGTAG, "[Drawable] Can't create favicon " + name, ex);
|
||||
} catch (java.lang.NoSuchFieldException ex) {
|
||||
// if there is no such field, create the bookmark without a favicon
|
||||
Log.d(LOGTAG, "[Drawable] Can't create favicon " + name);
|
||||
}
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
private void createOrUpdateAllSpecialFolders(SQLiteDatabase db) {
|
||||
createOrUpdateSpecialFolder(db, Bookmarks.MOBILE_FOLDER_GUID,
|
||||
R.string.bookmarks_folder_mobile, 0);
|
||||
|
@ -209,12 +209,14 @@
|
||||
profile/bookmarks.inc. Don't expose the URLs to L10N. -->
|
||||
<string name="bookmarkdefaults_title_aboutfirefox">@bookmarks_aboutBrowser@</string>
|
||||
<string name="bookmarkdefaults_url_aboutfirefox">about:firefox</string>
|
||||
<string name="bookmarkdefaults_favicon_aboutfirefox">chrome/chrome/content/branding/favicon64.png</string>
|
||||
|
||||
<string name="bookmarkdefaults_title_addons">@bookmarks_addons@</string>
|
||||
<string name="bookmarkdefaults_url_addons">https://addons.mozilla.org/@AB_CD@/android/</string>
|
||||
|
||||
<string name="bookmarkdefaults_title_support">@bookmarks_support@</string>
|
||||
<string name="bookmarkdefaults_url_support">http://support.mozilla.org/@AB_CD@/mobile</string>
|
||||
<string name="bookmarkdefaults_favicon_abouthome">chrome/chrome/content/branding/favicon64.png</string>
|
||||
|
||||
<string name="bookmarkdefaults_title_abouthome">@bookmarks_aboutHome@</string>
|
||||
<string name="bookmarkdefaults_url_abouthome">about:home</string>
|
||||
|
@ -1,4 +1,3 @@
|
||||
mobile/android/branding/aurora/content/logo.png
|
||||
mobile/android/branding/aurora/content/favicon32.png
|
||||
mobile/android/branding/aurora/content/bookmarkdefaults_favicon_aboutfirefox.png
|
||||
mobile/android/branding/aurora/content/mdpi/widget_icon.png
|
||||
|
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 2.5 KiB |
BIN
mobile/android/branding/aurora/content/favicon64.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
@ -8,3 +8,4 @@ chrome.jar:
|
||||
content/branding/logoWordmark.png (logoWordmark.png)
|
||||
content/branding/logo.png (logo.png)
|
||||
content/branding/favicon32.png (favicon32.png)
|
||||
content/branding/favicon64.png (favicon64.png)
|
||||
|
@ -1,4 +1,3 @@
|
||||
mobile/android/branding/beta/content/logo.png
|
||||
mobile/android/branding/beta/content/favicon32.png
|
||||
mobile/android/branding/beta/content/bookmarkdefaults_favicon_aboutfirefox.png
|
||||
mobile/android/branding/beta/content/mdpi/widget_icon.png
|
||||
|
Before Width: | Height: | Size: 2.6 KiB |
BIN
mobile/android/branding/beta/content/favicon64.png
Normal file
After Width: | Height: | Size: 8.1 KiB |
@ -8,3 +8,4 @@ chrome.jar:
|
||||
content/branding/logoWordmark.png (logoWordmark.png)
|
||||
content/branding/logo.png (logo.png)
|
||||
content/branding/favicon32.png (favicon32.png)
|
||||
content/branding/favicon64.png (favicon64.png)
|
||||
|
@ -1,4 +1,3 @@
|
||||
mobile/android/branding/nightly/content/logo.png
|
||||
mobile/android/branding/nightly/content/favicon32.png
|
||||
mobile/android/branding/nightly/content/bookmarkdefaults_favicon_aboutfirefox.png
|
||||
mobile/android/branding/nightly/content/mdpi/widget_icon.png
|
||||
|
Before Width: | Height: | Size: 3.4 KiB |
BIN
mobile/android/branding/nightly/content/favicon64.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
@ -8,3 +8,4 @@ chrome.jar:
|
||||
content/branding/logoWordmark.png (logoWordmark.png)
|
||||
content/branding/logo.png (logo.png)
|
||||
content/branding/favicon32.png (favicon32.png)
|
||||
content/branding/favicon64.png (favicon64.png)
|
||||
|
@ -1,4 +1,3 @@
|
||||
mobile/android/branding/official/content/logo.png
|
||||
mobile/android/branding/official/content/favicon32.png
|
||||
mobile/android/branding/official/content/bookmarkdefaults_favicon_aboutfirefox.png
|
||||
mobile/android/branding/official/content/mdpi/widget_icon.png
|
||||
|
Before Width: | Height: | Size: 2.6 KiB |
BIN
mobile/android/branding/official/content/favicon64.png
Normal file
After Width: | Height: | Size: 8.1 KiB |
@ -8,3 +8,4 @@ chrome.jar:
|
||||
content/branding/logoWordmark.png (logoWordmark.png)
|
||||
content/branding/logo.png (logo.png)
|
||||
content/branding/favicon32.png (favicon32.png)
|
||||
content/branding/favicon64.png (favicon64.png)
|
||||
|
@ -1,4 +1,3 @@
|
||||
mobile/android/branding/unofficial/content/favicon32.png
|
||||
mobile/android/branding/unofficial/content/logo.png
|
||||
mobile/android/branding/unofficial/content/bookmarkdefaults_favicon_aboutfirefox.png
|
||||
mobile/android/branding/unofficial/content/mdpi/widget_icon.png
|
||||
|
Before Width: | Height: | Size: 1.7 KiB |
BIN
mobile/android/branding/unofficial/content/favicon64.png
Normal file
After Width: | Height: | Size: 6.0 KiB |
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.0 KiB |
@ -8,3 +8,4 @@ chrome.jar:
|
||||
content/branding/logoWordmark.png (logoWordmark.png)
|
||||
content/branding/logo.png (logo.png)
|
||||
content/branding/favicon32.png (favicon32.png)
|
||||
content/branding/favicon64.png (favicon64.png)
|
||||
|
@ -18,7 +18,7 @@
|
||||
<meta name="viewport" content="width=480; initial-scale=.6667; user-scalable=no"/>
|
||||
<title>&aboutPage.title;</title>
|
||||
<link rel="stylesheet" href="chrome://browser/skin/aboutPage.css" type="text/css"/>
|
||||
<link rel="icon" type="image/png" href="chrome://branding/content/favicon32.png" />
|
||||
<link rel="icon" type="image/png" sizes="64x64" href="chrome://branding/content/favicon64.png" />
|
||||
</head>
|
||||
|
||||
<body dir="&locale.dir;">
|
||||
|
@ -18,7 +18,7 @@
|
||||
<head>
|
||||
<title>&aboutAddons.title2;</title>
|
||||
<meta name="viewport" content="width=480; initial-scale=.6667; user-scalable=0" />
|
||||
<link rel="icon" type="image/png" href="chrome://branding/content/favicon32.png" />
|
||||
<link rel="icon" type="image/png" sizes="64x64" href="chrome://branding/content/favicon64.png" />
|
||||
<link rel="stylesheet" href="chrome://browser/skin/aboutAddons.css" type="text/css"/>
|
||||
<style>
|
||||
.hide-on-enable,
|
||||
|
@ -21,7 +21,7 @@
|
||||
<head>
|
||||
<title>&aboutApps.title2;</title>
|
||||
<meta name="viewport" content="width=480; initial-scale=.6667; user-scalable=0" />
|
||||
<link rel="icon" type="image/png" href="chrome://branding/content/favicon32.png" />
|
||||
<link rel="icon" type="image/png" sizes="64x64" href="chrome://branding/content/favicon64.png" />
|
||||
<link rel="stylesheet" type="text/css" href="chrome://browser/skin/aboutApps.css" media="all" />
|
||||
<script type="text/javascript;version=1.8" src="chrome://browser/content/aboutApps.js"></script>
|
||||
</head>
|
||||
|
@ -27,7 +27,7 @@
|
||||
should be updated. If this page starts using a different favicon
|
||||
than neterrorm nsFaviconService->SetAndLoadFaviconForPage
|
||||
should be updated to ignore this one as well. -->
|
||||
<link rel="icon" type="image/png" id="favicon" href="chrome://global/skin/icons/warning-16.png"/>
|
||||
<link rel="icon" type="image/png" id="favicon" sizes="64x64" href="chrome://global/skin/icons/warning-64.png"/>
|
||||
|
||||
<script type="application/javascript"><![CDATA[
|
||||
// Error url MUST be formatted like this:
|
||||
|
@ -19,7 +19,7 @@
|
||||
<head>
|
||||
<title>&aboutDownloads.title;</title>
|
||||
<meta name="viewport" content="width=480; initial-scale=.6667; user-scalable=0" />
|
||||
<link rel="icon" type="image/png" href="chrome://branding/content/favicon32.png" />
|
||||
<link rel="icon" type="image/png" sizes="64x64" href="chrome://branding/content/favicon64.png" />
|
||||
<link rel="stylesheet" href="chrome://browser/skin/aboutDownloads.css" type="text/css"/>
|
||||
</head>
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
<title>&pageTitle;</title>
|
||||
<meta name="viewport" content="width=device-width; user-scalable=0" />
|
||||
<link rel="stylesheet" href="chrome://browser/skin/aboutFeedback.css" type="text/css"/>
|
||||
<link rel="icon" type="image/png" href="chrome://branding/content/favicon32.png" />
|
||||
<link rel="icon" type="image/png" sizes="64x64" href="chrome://branding/content/favicon64.png" />
|
||||
</head>
|
||||
|
||||
<body dir="&locale.dir;" onload="init();" onunload="uninit();">
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<link rel="icon" type="image/png" href="chrome://branding/content/favicon32.png" />
|
||||
<link rel="icon" type="image/png" sizes="64x64" href="chrome://branding/content/favicon64.png" />
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
|
@ -19,7 +19,7 @@
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width; user-scalable=false" />
|
||||
<link rel="stylesheet" href="chrome://global/skin/netError.css" type="text/css" media="all" />
|
||||
<link rel="icon" type="image/png" id="favicon" href="chrome://global/skin/icons/blacklist_favicon.png"/>
|
||||
<link rel="icon" type="image/png" id="favicon" sizes="64x64" href="chrome://global/skin/icons/blacklist_large.png"/>
|
||||
|
||||
<script type="application/javascript"><![CDATA[
|
||||
// Error url MUST be formatted like this:
|
||||
|
@ -24,7 +24,7 @@
|
||||
<link rel="stylesheet" href="chrome://global/skin/netError.css" type="text/css" media="all" />
|
||||
<!-- If the location of the favicon is changed here, the FAVICON_ERRORPAGE_URL symbol in
|
||||
toolkit/components/places/src/nsFaviconService.h should be updated. -->
|
||||
<link rel="icon" type="image/png" id="favicon" href="chrome://global/skin/icons/warning-16.png"/>
|
||||
<link rel="icon" type="image/png" id="favicon" sizes="64x64" href="chrome://global/skin/icons/warning-64.png"/>
|
||||
|
||||
<script type="application/javascript"><![CDATA[
|
||||
// Error url MUST be formatted like this:
|
||||
|