diff --git a/mobile/android/base/GeckoJarReader.java b/mobile/android/base/GeckoJarReader.java index a160c66a3193..4d408139ca82 100644 --- a/mobile/android/base/GeckoJarReader.java +++ b/mobile/android/base/GeckoJarReader.java @@ -118,6 +118,11 @@ public final class GeckoJarReader { entry = zip.getEntry(fileName); } + if (entry == null) { + Log.d(LOGTAG, "No Entry for " + fileName); + return null; + } + // if there is nothing else on the stack, this will throw and break us out of the loop jarUrls.peek(); @@ -126,11 +131,6 @@ public final class GeckoJarReader { } else { inputStream = new ZipInputStream(zip.getInputStream(entry)); } - - if (entry == null) { - Log.d(LOGTAG, "No Entry for " + fileName); - return null; - } } } catch (EmptyStackException ex) { Log.d(LOGTAG, "Jar reader reached end of stack"); diff --git a/mobile/android/base/Makefile.in b/mobile/android/base/Makefile.in index add7aac9588b..d53a46042c8e 100644 --- a/mobile/android/base/Makefile.in +++ b/mobile/android/base/Makefile.in @@ -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 \ diff --git a/mobile/android/base/db/BrowserProvider.java.in b/mobile/android/base/db/BrowserProvider.java.in index b2df70a2eec5..dc506ead9fd8 100644 --- a/mobile/android/base/db/BrowserProvider.java.in +++ b/mobile/android/base/db/BrowserProvider.java.in @@ -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); diff --git a/mobile/android/base/strings.xml.in b/mobile/android/base/strings.xml.in index 8a83491a96b5..920e94badf37 100644 --- a/mobile/android/base/strings.xml.in +++ b/mobile/android/base/strings.xml.in @@ -209,12 +209,14 @@ profile/bookmarks.inc. Don't expose the URLs to L10N. --> @bookmarks_aboutBrowser@ about:firefox + chrome/chrome/content/branding/favicon64.png @bookmarks_addons@ https://addons.mozilla.org/@AB_CD@/android/ @bookmarks_support@ http://support.mozilla.org/@AB_CD@/mobile + chrome/chrome/content/branding/favicon64.png @bookmarks_aboutHome@ about:home diff --git a/mobile/android/branding/aurora/android-resources.mn b/mobile/android/branding/aurora/android-resources.mn index b75b87171113..b85e33467d96 100644 --- a/mobile/android/branding/aurora/android-resources.mn +++ b/mobile/android/branding/aurora/android-resources.mn @@ -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 diff --git a/mobile/android/branding/aurora/content/bookmarkdefaults_favicon_aboutfirefox.png b/mobile/android/branding/aurora/content/bookmarkdefaults_favicon_aboutfirefox.png deleted file mode 100644 index f515b5d337e2..000000000000 Binary files a/mobile/android/branding/aurora/content/bookmarkdefaults_favicon_aboutfirefox.png and /dev/null differ diff --git a/mobile/android/branding/aurora/content/favicon32.png b/mobile/android/branding/aurora/content/favicon32.png index f515b5d337e2..40421cc7948a 100644 Binary files a/mobile/android/branding/aurora/content/favicon32.png and b/mobile/android/branding/aurora/content/favicon32.png differ diff --git a/mobile/android/branding/aurora/content/favicon64.png b/mobile/android/branding/aurora/content/favicon64.png new file mode 100644 index 000000000000..bb949ccbade8 Binary files /dev/null and b/mobile/android/branding/aurora/content/favicon64.png differ diff --git a/mobile/android/branding/aurora/content/jar.mn b/mobile/android/branding/aurora/content/jar.mn index 0052ad0243df..32eae6af95bb 100644 --- a/mobile/android/branding/aurora/content/jar.mn +++ b/mobile/android/branding/aurora/content/jar.mn @@ -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) diff --git a/mobile/android/branding/beta/android-resources.mn b/mobile/android/branding/beta/android-resources.mn index 7c6e5de0423b..22ad106ed4a8 100644 --- a/mobile/android/branding/beta/android-resources.mn +++ b/mobile/android/branding/beta/android-resources.mn @@ -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 diff --git a/mobile/android/branding/beta/content/bookmarkdefaults_favicon_aboutfirefox.png b/mobile/android/branding/beta/content/bookmarkdefaults_favicon_aboutfirefox.png deleted file mode 100644 index ac4a6968bf27..000000000000 Binary files a/mobile/android/branding/beta/content/bookmarkdefaults_favicon_aboutfirefox.png and /dev/null differ diff --git a/mobile/android/branding/beta/content/favicon64.png b/mobile/android/branding/beta/content/favicon64.png new file mode 100644 index 000000000000..20bae0717c7b Binary files /dev/null and b/mobile/android/branding/beta/content/favicon64.png differ diff --git a/mobile/android/branding/beta/content/jar.mn b/mobile/android/branding/beta/content/jar.mn index 0052ad0243df..32eae6af95bb 100644 --- a/mobile/android/branding/beta/content/jar.mn +++ b/mobile/android/branding/beta/content/jar.mn @@ -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) diff --git a/mobile/android/branding/nightly/android-resources.mn b/mobile/android/branding/nightly/android-resources.mn index 62e901eeef18..53b5afd77155 100644 --- a/mobile/android/branding/nightly/android-resources.mn +++ b/mobile/android/branding/nightly/android-resources.mn @@ -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 diff --git a/mobile/android/branding/nightly/content/bookmarkdefaults_favicon_aboutfirefox.png b/mobile/android/branding/nightly/content/bookmarkdefaults_favicon_aboutfirefox.png deleted file mode 100644 index 43ad466c6152..000000000000 Binary files a/mobile/android/branding/nightly/content/bookmarkdefaults_favicon_aboutfirefox.png and /dev/null differ diff --git a/mobile/android/branding/nightly/content/favicon64.png b/mobile/android/branding/nightly/content/favicon64.png new file mode 100644 index 000000000000..1ac6eaf51978 Binary files /dev/null and b/mobile/android/branding/nightly/content/favicon64.png differ diff --git a/mobile/android/branding/nightly/content/jar.mn b/mobile/android/branding/nightly/content/jar.mn index 0052ad0243df..32eae6af95bb 100644 --- a/mobile/android/branding/nightly/content/jar.mn +++ b/mobile/android/branding/nightly/content/jar.mn @@ -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) diff --git a/mobile/android/branding/official/android-resources.mn b/mobile/android/branding/official/android-resources.mn index c380a12da366..9e3ca743cceb 100644 --- a/mobile/android/branding/official/android-resources.mn +++ b/mobile/android/branding/official/android-resources.mn @@ -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 diff --git a/mobile/android/branding/official/content/bookmarkdefaults_favicon_aboutfirefox.png b/mobile/android/branding/official/content/bookmarkdefaults_favicon_aboutfirefox.png deleted file mode 100644 index ac4a6968bf27..000000000000 Binary files a/mobile/android/branding/official/content/bookmarkdefaults_favicon_aboutfirefox.png and /dev/null differ diff --git a/mobile/android/branding/official/content/favicon64.png b/mobile/android/branding/official/content/favicon64.png new file mode 100644 index 000000000000..20bae0717c7b Binary files /dev/null and b/mobile/android/branding/official/content/favicon64.png differ diff --git a/mobile/android/branding/official/content/jar.mn b/mobile/android/branding/official/content/jar.mn index 0052ad0243df..32eae6af95bb 100644 --- a/mobile/android/branding/official/content/jar.mn +++ b/mobile/android/branding/official/content/jar.mn @@ -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) diff --git a/mobile/android/branding/unofficial/android-resources.mn b/mobile/android/branding/unofficial/android-resources.mn index a5eab084ae80..03c8177bd900 100644 --- a/mobile/android/branding/unofficial/android-resources.mn +++ b/mobile/android/branding/unofficial/android-resources.mn @@ -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 diff --git a/mobile/android/branding/unofficial/content/bookmarkdefaults_favicon_aboutfirefox.png b/mobile/android/branding/unofficial/content/bookmarkdefaults_favicon_aboutfirefox.png deleted file mode 100644 index 3f04acd50d30..000000000000 Binary files a/mobile/android/branding/unofficial/content/bookmarkdefaults_favicon_aboutfirefox.png and /dev/null differ diff --git a/mobile/android/branding/unofficial/content/favicon64.png b/mobile/android/branding/unofficial/content/favicon64.png new file mode 100644 index 000000000000..d6263c9d2403 Binary files /dev/null and b/mobile/android/branding/unofficial/content/favicon64.png differ diff --git a/mobile/android/branding/unofficial/content/fennec_72x72.png b/mobile/android/branding/unofficial/content/fennec_72x72.png index c7874013f6af..1cdb4df2fcb7 100644 Binary files a/mobile/android/branding/unofficial/content/fennec_72x72.png and b/mobile/android/branding/unofficial/content/fennec_72x72.png differ diff --git a/mobile/android/branding/unofficial/content/jar.mn b/mobile/android/branding/unofficial/content/jar.mn index 0052ad0243df..32eae6af95bb 100644 --- a/mobile/android/branding/unofficial/content/jar.mn +++ b/mobile/android/branding/unofficial/content/jar.mn @@ -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) diff --git a/mobile/android/chrome/content/about.xhtml b/mobile/android/chrome/content/about.xhtml index b6fcd2336278..3122ccf07f9e 100644 --- a/mobile/android/chrome/content/about.xhtml +++ b/mobile/android/chrome/content/about.xhtml @@ -18,7 +18,7 @@ &aboutPage.title; - + diff --git a/mobile/android/chrome/content/aboutAddons.xhtml b/mobile/android/chrome/content/aboutAddons.xhtml index 518d65b3ef2b..5a3877fe7036 100644 --- a/mobile/android/chrome/content/aboutAddons.xhtml +++ b/mobile/android/chrome/content/aboutAddons.xhtml @@ -18,7 +18,7 @@ &aboutAddons.title2; - +