From 77835fd4a5ab14a21e5cc3382922755328ed81a9 Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Mon, 29 Nov 2010 15:41:15 +0000 Subject: Update homescreen icon generator to look better on xlarge devices. Copy mipmap-hdpi resources into mipmap-xlarge to provide larger assets for xlarge devices (previously we were picking them up from mipmap-mdpi). With the larger icons, we also need to increase the size of the rectangle we draw the favicon onto (otherwise we see the points of the star coming out of the favicon). Bug: 3224340 Change-Id: If0a297836c288104a32e5dbcd5d886d5849f9698 --- src/com/android/browser/BookmarkUtils.java | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/com/android/browser/BookmarkUtils.java') diff --git a/src/com/android/browser/BookmarkUtils.java b/src/com/android/browser/BookmarkUtils.java index a63b90fb0..c72cbd1da 100644 --- a/src/com/android/browser/BookmarkUtils.java +++ b/src/com/android/browser/BookmarkUtils.java @@ -70,14 +70,14 @@ class BookmarkUtils { if (icon != null) { // Now draw the correct icon background into our new bitmap. - canvas.drawBitmap(icon, null, iconBounds, null); + Paint p = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG); + canvas.drawBitmap(icon, null, iconBounds, p); } // If we have a favicon, overlay it in a nice rounded white box on top of the // background. if (favicon != null) { - drawFaviconToCanvas(favicon, canvas, iconBounds, - context.getResources().getDisplayMetrics().density); + drawFaviconToCanvas(context, favicon, canvas, iconBounds); } } return bm; @@ -139,8 +139,8 @@ class BookmarkUtils { canvas.drawPath(path, paint); } - private static void drawFaviconToCanvas(Bitmap favicon, Canvas canvas, Rect iconBounds, - float density) { + private static void drawFaviconToCanvas(Context context, Bitmap favicon, Canvas canvas, + Rect iconBounds) { // Make a Paint for the white background rectangle and for // filtering the favicon. Paint p = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG); @@ -148,15 +148,16 @@ class BookmarkUtils { p.setColor(Color.WHITE); // Create a rectangle that is slightly wider than the favicon - final float iconSize = 16 * density; // 16x16 favicon - final float padding = 2 * density; // white padding around icon - final float rectSize = iconSize + 2 * padding; - final float x = iconBounds.exactCenterX() - (rectSize / 2); - // Note: Subtract 2 dip from the y position since the box is + int faviconDimension = context.getResources().getDimensionPixelSize(R.dimen.favicon_size); + int faviconPaddedRectDimension = context.getResources().getDimensionPixelSize( + R.dimen.favicon_padded_size); + float padding = (faviconPaddedRectDimension - faviconDimension) / 2; + final float x = iconBounds.exactCenterX() - (faviconPaddedRectDimension / 2); + // Note: Subtract from the y position since the box is // slightly higher than center. Use padding since it is already - // 2 * density. - final float y = iconBounds.exactCenterY() - (rectSize / 2) - padding; - RectF r = new RectF(x, y, x + rectSize, y + rectSize); + // device independent. + final float y = iconBounds.exactCenterY() - (faviconPaddedRectDimension / 2) - padding; + RectF r = new RectF(x, y, x + faviconPaddedRectDimension, y + faviconPaddedRectDimension); // Draw a white rounded rectangle behind the favicon canvas.drawRoundRect(r, 2, 2, p); @@ -165,7 +166,7 @@ class BookmarkUtils { // rectangle but inset by the padding // (results in a 16x16 favicon). r.inset(padding, padding); - canvas.drawBitmap(favicon, null, r, p); + canvas.drawBitmap(favicon, null, r, null); } /* package */ static Uri getBookmarksUri(Context context) { -- cgit v1.2.3