From 023a60e37c0f3374aed57531ab11b7f20ece232b Mon Sep 17 00:00:00 2001 From: John Reck Date: Wed, 15 Dec 2010 15:51:33 -0800 Subject: Use touch icon in the widget if available Bug: 3289421 Change-Id: I45f435e2949f2749b9221e007037dedd69781cd6 --- res/layout/bookmarklistwidget_item.xml | 2 +- .../browser/widget/BookmarkListWidgetService.java | 37 ++++++++++++++-------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/res/layout/bookmarklistwidget_item.xml b/res/layout/bookmarklistwidget_item.xml index 039bc2c..9d1f8ec 100644 --- a/res/layout/bookmarklistwidget_item.xml +++ b/res/layout/bookmarklistwidget_item.xml @@ -28,7 +28,7 @@ android:layout_width="32dp" android:layout_gravity="center_vertical" android:layout_marginLeft="16dp" - android:scaleType="fitXY"/> + android:scaleType="fitCenter"/> mFactories; private Handler mUiHandler; @@ -350,19 +356,24 @@ public class BookmarkListWidgetService extends RemoteViewsService { bookmarks.add(res); } while (c.moveToNext()) { - long id = c.getLong(0); - String title = c.getString(1); - String url = c.getString(2); + long id = c.getLong(BOOKMARK_INDEX_ID); + String title = c.getString(BOOKMARK_INDEX_TITLE); + String url = c.getString(BOOKMARK_INDEX_URL); RenderResult res = new RenderResult(id, title, url); - byte[] blob = c.getBlob(3); - 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); + res.mIsFolder = c.getInt(BOOKMARK_INDEX_IS_FOLDER) != 0; + if (!res.mIsFolder) { + byte[] blob = c.getBlob(BOOKMARK_INDEX_TOUCH_ICON); + if (blob == null || blob.length == 0) { + blob = c.getBlob(BOOKMARK_INDEX_FAVICON); + } + 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); + } } - res.mIsFolder = c.getInt(4) != 0; bookmarks.add(res); } return bookmarks; -- cgit v1.1