Bug 714975 - [ICS] Home Screen icons are too small on ICS [r=wesj]
authorMark Finkle <mfinkle@mozilla.com>
Wed, 04 Jan 2012 15:52:22 -0500
changeset 83764 0cdaf07730732e1a2523d8fbed9810de3da4d7a6
parent 83763 bc1196840c427c6212743e79f71c066fbed69f47
child 83765 5af79a8f877e7dea6aadb587694cee15c9aadb74
child 83807 8e3d4ad9e413e9d84ecf5ca20a76823e3096a54a
push id21790
push userbmo@edmorley.co.uk
push dateThu, 05 Jan 2012 01:00:04 +0000
treeherdermozilla-central@0cdaf0773073 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs714975
milestone12.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 714975 - [ICS] Home Screen icons are too small on ICS [r=wesj]
mobile/android/base/GeckoAppShell.java
--- a/mobile/android/base/GeckoAppShell.java
+++ b/mobile/android/base/GeckoAppShell.java
@@ -655,22 +655,34 @@ public class GeckoAppShell
                 intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, getLauncherIcon(aIcon));
                 intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
                 GeckoApp.mAppContext.sendBroadcast(intent);
             }
         });
     }
 
     static private Bitmap getLauncherIcon(Bitmap aSource) {
-        // The background images are 72px, but Android will resize as needed.
-        // Bigger is better than too small.
-        final int kIconSize = 72;
-        final int kOverlaySize = 32;
         final int kOffset = 6;
         final int kRadius = 5;
+        int kIconSize;
+        int kOverlaySize;
+        switch (getDpi()) {
+            case DisplayMetrics.DENSITY_MEDIUM:
+                kIconSize = 48;
+                kOverlaySize = 32;
+                break;
+            case DisplayMetrics.DENSITY_XHIGH:
+                kIconSize = 96;
+                kOverlaySize = 48;
+                break;
+            case DisplayMetrics.DENSITY_HIGH:
+            default:
+                kIconSize = 72;
+                kOverlaySize = 32;
+        }
 
         Bitmap bitmap = Bitmap.createBitmap(kIconSize, kIconSize, Bitmap.Config.ARGB_8888);
         Canvas canvas = new Canvas(bitmap);
 
         // draw a base color
         Paint paint = new Paint();
         
         if (aSource == null) {
@@ -685,17 +697,17 @@ public class GeckoAppShell
             paint.setColor(color);
             canvas.drawRoundRect(new RectF(kOffset, kOffset, kIconSize - kOffset, kIconSize - kOffset), kRadius, kRadius, paint);
             paint.setColor(Color.argb(100, 255, 255, 255));
             canvas.drawRoundRect(new RectF(kOffset, kOffset, kIconSize - kOffset, kIconSize - kOffset), kRadius, kRadius, paint);
         }
 
         // draw the overlay
         Bitmap overlay = BitmapFactory.decodeResource(GeckoApp.mAppContext.getResources(), R.drawable.home_bg);
-        canvas.drawBitmap(overlay, null, new Rect(0,0,kIconSize, kIconSize), null);
+        canvas.drawBitmap(overlay, null, new Rect(0, 0, kIconSize, kIconSize), null);
 
         // draw the bitmap
         if (aSource == null)
             aSource = BitmapFactory.decodeResource(GeckoApp.mAppContext.getResources(), R.drawable.home_star);
 
         if (aSource.getWidth() < kOverlaySize || aSource.getHeight() < kOverlaySize) {
             canvas.drawBitmap(aSource,
                               null,