OSDN Git Service

Update the shortcut icons with new assets.
authorPatrick Scott <phanna@android.com>
Thu, 25 Feb 2010 19:40:11 +0000 (14:40 -0500)
committerPatrick Scott <phanna@android.com>
Thu, 25 Feb 2010 19:40:11 +0000 (14:40 -0500)
Position the favicon in the (almost) center of the asset.

Bug: 2168561

res/drawable-hdpi/ic_launcher_shortcut_browser_bookmark.png
res/drawable-hdpi/ic_launcher_shortcut_browser_bookmark_icon.png [new file with mode: 0644]
res/drawable-mdpi/ic_launcher_shortcut_browser_bookmark_icon.png [new file with mode: 0644]
src/com/android/browser/BrowserBookmarksPage.java

index f861650..7b2c680 100644 (file)
Binary files a/res/drawable-hdpi/ic_launcher_shortcut_browser_bookmark.png and b/res/drawable-hdpi/ic_launcher_shortcut_browser_bookmark.png differ
diff --git a/res/drawable-hdpi/ic_launcher_shortcut_browser_bookmark_icon.png b/res/drawable-hdpi/ic_launcher_shortcut_browser_bookmark_icon.png
new file mode 100644 (file)
index 0000000..57fc915
Binary files /dev/null and b/res/drawable-hdpi/ic_launcher_shortcut_browser_bookmark_icon.png differ
diff --git a/res/drawable-mdpi/ic_launcher_shortcut_browser_bookmark_icon.png b/res/drawable-mdpi/ic_launcher_shortcut_browser_bookmark_icon.png
new file mode 100644 (file)
index 0000000..ba82911
Binary files /dev/null and b/res/drawable-mdpi/ic_launcher_shortcut_browser_bookmark_icon.png differ
index d835f84..1183b70 100644 (file)
@@ -30,6 +30,7 @@ import android.graphics.Paint;
 import android.graphics.Path;
 import android.graphics.PorterDuff;
 import android.graphics.PorterDuffXfermode;
+import android.graphics.Rect;
 import android.graphics.RectF;
 import android.net.Uri;
 import android.os.Bundle;
@@ -445,7 +446,7 @@ public class BrowserBookmarksPage extends Activity implements
                                 R.drawable.ic_launcher_shortcut_browser_bookmark));
             } else {
                 Bitmap icon = BitmapFactory.decodeResource(getResources(),
-                        R.drawable.ic_launcher_shortcut_browser_bookmark);
+                        R.drawable.ic_launcher_shortcut_browser_bookmark_icon);
 
                 // Make a copy of the regular icon so we can modify the pixels.
                 Bitmap copy = icon.copy(Bitmap.Config.ARGB_8888, true);
@@ -458,13 +459,22 @@ public class BrowserBookmarksPage extends Activity implements
                 p.setStyle(Paint.Style.FILL_AND_STROKE);
                 p.setColor(Color.WHITE);
 
-                float density = getResources().getDisplayMetrics().density;
+                final float density =
+                        getResources().getDisplayMetrics().density;
                 // Create a rectangle that is slightly wider than the favicon
                 final float iconSize = 16 * density; // 16x16 favicon
-                final float padding = 2; // white padding around icon
+                final float padding = 2 * density; // white padding around icon
                 final float rectSize = iconSize + 2 * padding;
-                final float y = icon.getHeight() - rectSize;
-                RectF r = new RectF(0, y, rectSize, y + rectSize);
+
+                final Rect iconBounds =
+                        new Rect(0, 0, icon.getWidth(), icon.getHeight());
+                final float x = iconBounds.exactCenterX() - (rectSize / 2);
+                // Note: Subtract 2 dip 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);
 
                 // Draw a white rounded rectangle behind the favicon
                 canvas.drawRoundRect(r, 2, 2, p);