From 8e8e71ca9a24996eedfacba2bf5a4b587149727f Mon Sep 17 00:00:00 2001 From: John Reck Date: Thu, 16 Dec 2010 11:17:54 -0800 Subject: Bookmark widget favicon drawing cleanup Bug: 3289421 Changes the favicon drawing for the bookmark widget to keep the favicon at its original size and draw a mostly transparent rounded white rectangle behind it. Change-Id: I8267bbcc3d805d0266281f231e38393eec4d0bc2 --- .../browser/widget/BookmarkListWidgetService.java | 36 +++++++++++++++++----- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'src/com/android/browser/widget') diff --git a/src/com/android/browser/widget/BookmarkListWidgetService.java b/src/com/android/browser/widget/BookmarkListWidgetService.java index 30671fc..39751e6 100644 --- a/src/com/android/browser/widget/BookmarkListWidgetService.java +++ b/src/com/android/browser/widget/BookmarkListWidgetService.java @@ -16,6 +16,7 @@ package com.android.browser.widget; +import com.android.browser.BookmarkUtils; import com.android.browser.BrowserBookmarksPage; import com.android.browser.R; @@ -362,16 +363,37 @@ public class BookmarkListWidgetService extends RemoteViewsService { RenderResult res = new RenderResult(id, title, url); res.mIsFolder = c.getInt(BOOKMARK_INDEX_IS_FOLDER) != 0; if (!res.mIsFolder) { + // RemoteViews require a valid bitmap config + Options options = new Options(); + options.inPreferredConfig = Config.ARGB_8888; + Bitmap favIcon = null; + Bitmap touchIcon = null; byte[] blob = c.getBlob(BOOKMARK_INDEX_TOUCH_ICON); - if (blob == null || blob.length == 0) { + if (blob != null && blob.length > 0) { + touchIcon = BitmapFactory.decodeByteArray( + blob, 0, blob.length, options); + } else { blob = c.getBlob(BOOKMARK_INDEX_FAVICON); + if (blob != null && blob.length > 0) { + favIcon = BitmapFactory.decodeByteArray( + blob, 0, blob.length, options); + } } - if (blob != null) { - // RemoteViews require a valid bitmap config - Options options = new Options(); - options.inPreferredConfig = Config.ARGB_8888; - res.mBitmap = BitmapFactory.decodeByteArray( - blob, 0, blob.length, options); + + if (favIcon == null) { + favIcon = BitmapFactory.decodeResource( + mContext.getResources(), + R.drawable.app_web_browser_sm); + } + if (touchIcon != null || favIcon != null) { + res.mBitmap = BookmarkUtils.createListWidgetIcon( + mContext, touchIcon, favIcon); + } + if (touchIcon != null) { + touchIcon.recycle(); + } + if (favIcon != null) { + favIcon.recycle(); } } bookmarks.add(res); -- cgit v1.1