Better preview visuals.

Smaller thumbnail (removed unnecessary padding), more opaque background.
Uses a white background because the dark background interferes with the
new dark widgets.

Change-Id: I7654741d845609200569fce34b6cde891d2b5d29
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 015f187..05fc20c 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -444,6 +444,22 @@
         return mCellHeight;
     }
 
+    int getLeftPadding() {
+        return mPortrait ? mShortAxisStartPadding : mLongAxisStartPadding;
+    }
+
+    int getTopPadding() {
+        return mPortrait ? mLongAxisStartPadding : mShortAxisStartPadding;        
+    }
+
+    int getRightPadding() {
+        return mPortrait ? mShortAxisEndPadding : mLongAxisEndPadding;
+    }
+
+    int getBottomPadding() {
+        return mPortrait ? mLongAxisEndPadding : mShortAxisEndPadding;        
+    }
+
     @Override
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
         // TODO: currently ignoring padding
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index e7a4a3c..a2a3e9a 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -40,6 +40,7 @@
 import android.database.ContentObserver;
 import android.graphics.Bitmap;
 import android.graphics.Rect;
+import android.graphics.Matrix;
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.os.Handler;
@@ -1562,8 +1563,21 @@
         Bitmap cache = source.getDrawingCache();
         if (cache == null) return;
 
-        Bitmap bitmap = Bitmap.createScaledBitmap(cache,
-                (int) (cache.getWidth() / 2.5f), (int) (cache.getHeight() / 2.5f), true);
+        int width = cache.getWidth();
+        int height = cache.getHeight();
+        float sx = (int) (width / 2.5f) / (float) width;
+        float sy = (int) (height / 2.5f) / (float) height;
+
+        Matrix m = new Matrix();
+        m.setScale(sx, sy);
+
+        CellLayout cell = ((CellLayout) source);
+        int x = cell.getLeftPadding();
+        int y = cell.getTopPadding();
+        width -= (x + cell.getRightPadding());
+        height -= (y + cell.getBottomPadding());
+
+        Bitmap bitmap = Bitmap.createBitmap(cache, x, y, width, height, m, true);
 
         ImageView preview = new ImageView(this);
         preview.setImageBitmap(bitmap);