summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2011-01-26 19:45:07 -0800
committerKenny Root <kroot@google.com>2011-01-26 19:48:14 -0800
commitc65991b2d2bf0cfdaa922cb3073aed498b929447 (patch)
treed4af31695df105e1c4b17aad5d6cbec4713231a9
parent5df5be97861107511d618a4d1d25a92f1dd81030 (diff)
downloadpackages_apps_Browser-c65991b2d2bf0cfdaa922cb3073aed498b929447.zip
packages_apps_Browser-c65991b2d2bf0cfdaa922cb3073aed498b929447.tar.gz
packages_apps_Browser-c65991b2d2bf0cfdaa922cb3073aed498b929447.tar.bz2
Use APIs to determine Launcher icon size
The app_icon_size didn't look good in the Launcher, so we introduced some APIs to determine the preferred size and density. Now we can use those to determine how large to make our shortcut icon. Bug: 3224340 Change-Id: I6ad7581435065ea1f1ce82e0e19f985549f127c3
-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 05a4087..27c1ce2 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 379b22d..cfb8e46 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;
}