summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2011-01-26 20:17:08 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-01-26 20:17:08 -0800
commit02dd4e94bfb4fa3f8827190ccccc9bf2a836ee8e (patch)
tree76c2b7958607a52f0dbc8ad2cc2b1b84ffe7d7f1
parent8e7178ddb9620a64e10ff762c33134daeb40a1e4 (diff)
parentc65991b2d2bf0cfdaa922cb3073aed498b929447 (diff)
downloadpackages_apps_Browser-02dd4e94bfb4fa3f8827190ccccc9bf2a836ee8e.tar.gz
packages_apps_Browser-02dd4e94bfb4fa3f8827190ccccc9bf2a836ee8e.tar.bz2
packages_apps_Browser-02dd4e94bfb4fa3f8827190ccccc9bf2a836ee8e.zip
Merge "Use APIs to determine Launcher icon size" into honeycomb
-rw-r--r--res/values-xlarge/dimensions.xml2
-rw-r--r--src/com/android/browser/BookmarkUtils.java34
2 files changed, 24 insertions, 12 deletions
diff --git a/res/values-xlarge/dimensions.xml b/res/values-xlarge/dimensions.xml
index 05a4087e6..27c1ce2a2 100644
--- a/res/values-xlarge/dimensions.xml
+++ b/res/values-xlarge/dimensions.xml
@@ -16,7 +16,7 @@
<dimen name="widgetThumbnailHeight">104dip</dimen>
<dimen name="widgetHorizontalSpacing">14dip</dimen>
<dimen name="widgetVerticalSpacing">12dip</dimen>
- <dimen name="favicon_padded_size">24dip</dimen>
+ <dimen name="favicon_padded_size">28dip</dimen>
<!-- For the most visited page -->
<dimen name="mv_max_width">1010dp</dimen>
<dimen name="mv_item_width">231dp</dimen>
diff --git a/src/com/android/browser/BookmarkUtils.java b/src/com/android/browser/BookmarkUtils.java
index 379b22d63..cfb8e469e 100644
--- a/src/com/android/browser/BookmarkUtils.java
+++ b/src/com/android/browser/BookmarkUtils.java
@@ -16,6 +16,7 @@
package com.android.browser;
+import android.app.ActivityManager;
import android.app.AlertDialog;
import android.content.ContentUris;
import android.content.Context;
@@ -33,6 +34,7 @@ import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
+import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.PaintDrawable;
import android.net.Uri;
@@ -40,6 +42,7 @@ import android.os.Message;
import android.preference.PreferenceManager;
import android.provider.Browser;
import android.provider.BrowserContract;
+import android.util.DisplayMetrics;
public class BookmarkUtils {
private final static String LOGTAG = "BookmarkUtils";
@@ -60,10 +63,11 @@ public class BookmarkUtils {
*/
static Bitmap createIcon(Context context, Bitmap touchIcon, Bitmap favicon,
BookmarkIconType type) {
- int iconDimension = context.getResources().getDimensionPixelSize(
- android.R.dimen.app_icon_size);
-
- return createIcon(context, touchIcon, favicon, type, iconDimension);
+ final ActivityManager am = (ActivityManager) context
+ .getSystemService(Context.ACTIVITY_SERVICE);
+ final int iconDimension = am.getLauncherLargeIconSize();
+ final int iconDensity = am.getLauncherLargeIconDensity();
+ return createIcon(context, touchIcon, favicon, type, iconDimension, iconDensity);
}
static Drawable createListFaviconBackground(Context context) {
@@ -79,7 +83,7 @@ public class BookmarkUtils {
}
private static Bitmap createIcon(Context context, Bitmap touchIcon,
- Bitmap favicon, BookmarkIconType type, int iconDimension) {
+ Bitmap favicon, BookmarkIconType type, int iconDimension, int iconDensity) {
Bitmap bm = Bitmap.createBitmap(iconDimension, iconDimension, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bm);
Rect iconBounds = new Rect(0, 0, bm.getWidth(), bm.getHeight());
@@ -90,7 +94,7 @@ public class BookmarkUtils {
} else {
// No touch icon so create our own.
// Set the background based on the type of shortcut (either webapp or home shortcut).
- Bitmap icon = getIconBackground(context, type);
+ Bitmap icon = getIconBackground(context, type, iconDensity);
if (icon != null) {
// Now draw the correct icon background into our new bitmap.
@@ -127,17 +131,25 @@ public class BookmarkUtils {
return i;
}
- private static Bitmap getIconBackground(Context context, BookmarkIconType type) {
+ private static Bitmap getIconBackground(Context context, BookmarkIconType type, int density) {
if (type == BookmarkIconType.ICON_HOME_SHORTCUT) {
// Want to create a shortcut icon on the homescreen, so the icon
// background is the red bookmark.
- return BitmapFactory.decodeResource(context.getResources(),
- R.mipmap.ic_launcher_shortcut_browser_bookmark);
+ Drawable drawable = context.getResources().getDrawableForDensity(
+ R.mipmap.ic_launcher_shortcut_browser_bookmark, density);
+ if (drawable instanceof BitmapDrawable) {
+ BitmapDrawable bd = (BitmapDrawable) drawable;
+ return bd.getBitmap();
+ }
} else if (type == BookmarkIconType.ICON_INSTALLABLE_WEB_APP) {
// Use the web browser icon as the background for the icon for an installable
// web app.
- return BitmapFactory.decodeResource(context.getResources(),
- R.mipmap.ic_launcher_browser);
+ Drawable drawable = context.getResources().getDrawableForDensity(
+ R.mipmap.ic_launcher_browser, density);
+ if (drawable instanceof BitmapDrawable) {
+ BitmapDrawable bd = (BitmapDrawable) drawable;
+ return bd.getBitmap();
+ }
}
return null;
}