diff options
author | Winson Chung <winsonc@google.com> | 2011-02-24 18:09:44 -0800 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2011-02-25 13:48:14 -0800 |
commit | 1908d07151e0d3f82899f368874e41ed1e49ba16 (patch) | |
tree | 3fb2446187a953e3204d66948640ea4762490fce /src/com/android/launcher2/PagedViewWidget.java | |
parent | f4204b8c1ab1ccfc99ed3bc9a0e113f6722769cc (diff) | |
download | packages_apps_trebuchet-1908d07151e0d3f82899f368874e41ed1e49ba16.zip packages_apps_trebuchet-1908d07151e0d3f82899f368874e41ed1e49ba16.tar.gz packages_apps_trebuchet-1908d07151e0d3f82899f368874e41ed1e49ba16.tar.bz2 |
Refactoring and fixing bugs in Customize tray.
Change-Id: Ia37d3033d64036fd09f5f33443eb9f575e311c7c
Diffstat (limited to 'src/com/android/launcher2/PagedViewWidget.java')
-rw-r--r-- | src/com/android/launcher2/PagedViewWidget.java | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/com/android/launcher2/PagedViewWidget.java b/src/com/android/launcher2/PagedViewWidget.java index 07b215d..72f928b 100644 --- a/src/com/android/launcher2/PagedViewWidget.java +++ b/src/com/android/launcher2/PagedViewWidget.java @@ -27,7 +27,11 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; +import android.graphics.PorterDuff; import android.graphics.PorterDuff.Mode; +import android.graphics.PorterDuffXfermode; +import android.graphics.Rect; +import android.graphics.RectF; import android.os.Handler; import android.os.HandlerThread; import android.os.Message; @@ -52,6 +56,10 @@ public class PagedViewWidget extends LinearLayout implements Checkable { private Bitmap mHolographicOutline; private final Canvas mHolographicOutlineCanvas = new Canvas(); private FastBitmapDrawable mPreview; + private ImageView mPreviewImageView; + private final RectF mTmpScaleRect = new RectF(); + private final Rect mEraseStrokeRect = new Rect(); + private final Paint mEraseStrokeRectPaint = new Paint(); private PagedViewIconCache.Key mIconCacheKey; private PagedViewIconCache mIconCache; @@ -81,8 +89,11 @@ public class PagedViewWidget extends LinearLayout implements Checkable { public void handleMessage(Message msg) { final PagedViewWidget widget = (PagedViewWidget) msg.obj; final int prevAlpha = widget.mPreview.getAlpha(); - final Bitmap outline = Bitmap.createBitmap(widget.getWidth(), widget.getHeight(), - Bitmap.Config.ARGB_8888); + final int width = Math.max(widget.mPreview.getIntrinsicWidth(), + widget.getMeasuredWidth()); + final int height = Math.max(widget.mPreview.getIntrinsicHeight(), + widget.getMeasuredHeight()); + final Bitmap outline = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); widget.mHolographicOutlineCanvas.setBitmap(outline); widget.mHolographicOutlineCanvas.save(); @@ -94,6 +105,12 @@ public class PagedViewWidget extends LinearLayout implements Checkable { widget.mHolographicOutlineCanvas.drawColor(Color.argb(156, 0, 0, 0), Mode.SRC_OVER); widget.mHolographicOutlineCanvas.restore(); + // To account for the fact that some previews run up straight to the edge (we subtract + // the edge from the holographic preview (before we apply the holograph) + widget.mEraseStrokeRect.set(0, 0, width, height); + widget.mHolographicOutlineCanvas.drawRect(widget.mEraseStrokeRect, + widget.mEraseStrokeRectPaint); + sHolographicOutlineHelper.applyThickExpensiveOutlineWithBlur(outline, widget.mHolographicOutlineCanvas, widget.mHoloBlurColor, widget.mHoloOutlineColor); @@ -123,6 +140,11 @@ public class PagedViewWidget extends LinearLayout implements Checkable { defStyle, 0); mHoloBlurColor = a.getColor(R.styleable.PagedViewWidget_blurColor, 0); mHoloOutlineColor = a.getColor(R.styleable.PagedViewWidget_outlineColor, 0); + mEraseStrokeRectPaint.setStyle(Paint.Style.STROKE); + mEraseStrokeRectPaint.setStrokeWidth(HolographicOutlineHelper.MIN_OUTER_BLUR_RADIUS); + mEraseStrokeRectPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); + mEraseStrokeRectPaint.setFilterBitmap(true); + mEraseStrokeRectPaint.setAntiAlias(true); a.recycle(); if (sHolographicOutlineHelper == null) { @@ -158,6 +180,7 @@ public class PagedViewWidget extends LinearLayout implements Checkable { final ImageView image = (ImageView) findViewById(R.id.widget_preview); image.setMaxWidth(maxWidth); image.setImageDrawable(preview); + mPreviewImageView = image; final TextView name = (TextView) findViewById(R.id.widget_name); name.setText(info.label); name.setLayerType(View.LAYER_TYPE_SOFTWARE, null); @@ -179,6 +202,7 @@ public class PagedViewWidget extends LinearLayout implements Checkable { ImageView image = (ImageView) findViewById(R.id.wallpaper_preview); image.setMaxWidth(maxWidth); image.setImageDrawable(preview); + mPreviewImageView = image; TextView name = (TextView) findViewById(R.id.wallpaper_name); name.setText(info.loadLabel(packageManager)); name.setLayerType(View.LAYER_TYPE_SOFTWARE, null); @@ -211,8 +235,15 @@ public class PagedViewWidget extends LinearLayout implements Checkable { // draw any blended overlays if (mHolographicOutline != null && mHolographicAlpha > 0) { + // Calculate how much to scale the holographic preview + mTmpScaleRect.set(0,0,1,1); + mPreviewImageView.getImageMatrix().mapRect(mTmpScaleRect); + mPaint.setAlpha(mHolographicAlpha); + canvas.save(); + canvas.scale(mTmpScaleRect.right, mTmpScaleRect.bottom); canvas.drawBitmap(mHolographicOutline, 0, 0, mPaint); + canvas.restore(); } } |