summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android.mk2
-rw-r--r--src/com/android/launcher2/AppsCustomizePagedView.java16
-rw-r--r--src/com/android/launcher2/HolographicOutlineHelper.java30
-rw-r--r--src/com/android/launcher2/Workspace.java8
4 files changed, 26 insertions, 30 deletions
diff --git a/Android.mk b/Android.mk
index abcca40..8a3d276 100644
--- a/Android.mk
+++ b/Android.mk
@@ -22,7 +22,7 @@ LOCAL_MODULE_TAGS := optional
LOCAL_STATIC_JAVA_LIBRARIES := android-common android-support-v13
LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
-
+LOCAL_SDK_VERSION := 16
LOCAL_PACKAGE_NAME := Launcher2
LOCAL_CERTIFICATE := shared
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index d7bb438..0b8b268 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -41,7 +41,6 @@ import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
-import android.graphics.TableMaskFilter;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
@@ -774,24 +773,17 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
createItemInfo.spanX = createItemInfo.spanY = 1;
}
- // We use a custom alpha clip table for the default widget previews
- Paint alphaClipPaint = null;
- if (createItemInfo instanceof PendingAddWidgetInfo) {
- if (((PendingAddWidgetInfo) createItemInfo).previewImage != 0) {
- MaskFilter alphaClipTable = TableMaskFilter.CreateClipTable(0, 255);
- alphaClipPaint = new Paint();
- alphaClipPaint.setMaskFilter(alphaClipTable);
- }
- }
+ // Don't clip alpha values for the drag outline if we're using the default widget preview
+ boolean clipAlpha = !(createItemInfo instanceof PendingAddWidgetInfo &&
+ (((PendingAddWidgetInfo) createItemInfo).previewImage == 0));
// Save the preview for the outline generation, then dim the preview
outline = Bitmap.createScaledBitmap(preview, preview.getWidth(), preview.getHeight(),
false);
// Start the drag
- alphaClipPaint = null;
mLauncher.lockScreenOrientation();
- mLauncher.getWorkspace().onDragStartedWithItem(createItemInfo, outline, alphaClipPaint);
+ mLauncher.getWorkspace().onDragStartedWithItem(createItemInfo, outline, clipAlpha);
mDragController.startDrag(image, preview, this, createItemInfo,
DragController.DRAG_ACTION_COPY, null, scale);
outline.recycle();
diff --git a/src/com/android/launcher2/HolographicOutlineHelper.java b/src/com/android/launcher2/HolographicOutlineHelper.java
index 56d194d..625c467 100644
--- a/src/com/android/launcher2/HolographicOutlineHelper.java
+++ b/src/com/android/launcher2/HolographicOutlineHelper.java
@@ -23,13 +23,11 @@ import android.graphics.MaskFilter;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
-import android.graphics.TableMaskFilter;
public class HolographicOutlineHelper {
private final Paint mHolographicPaint = new Paint();
private final Paint mBlurPaint = new Paint();
private final Paint mErasePaint = new Paint();
- private final Paint mAlphaClipPaint = new Paint();
public static final int MAX_OUTER_BLUR_RADIUS;
public static final int MIN_OUTER_BLUR_RADIUS;
@@ -61,8 +59,6 @@ public class HolographicOutlineHelper {
sMediumInnerBlurMaskFilter = new BlurMaskFilter(scale * 2.0f, BlurMaskFilter.Blur.NORMAL);
}
- private int[] mTempOffset = new int[2];
-
HolographicOutlineHelper() {
mHolographicPaint.setFilterBitmap(true);
mHolographicPaint.setAntiAlias(true);
@@ -71,8 +67,6 @@ public class HolographicOutlineHelper {
mErasePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
mErasePaint.setFilterBitmap(true);
mErasePaint.setAntiAlias(true);
- MaskFilter alphaClipTable = TableMaskFilter.CreateClipTable(180, 255);
- mAlphaClipPaint.setMaskFilter(alphaClipTable);
}
/**
@@ -102,18 +96,28 @@ public class HolographicOutlineHelper {
*/
void applyExpensiveOutlineWithBlur(Bitmap srcDst, Canvas srcDstCanvas, int color,
int outlineColor, int thickness) {
- applyExpensiveOutlineWithBlur(srcDst, srcDstCanvas, color, outlineColor, mAlphaClipPaint,
+ applyExpensiveOutlineWithBlur(srcDst, srcDstCanvas, color, outlineColor, true,
thickness);
}
void applyExpensiveOutlineWithBlur(Bitmap srcDst, Canvas srcDstCanvas, int color,
- int outlineColor, Paint alphaClipPaint, int thickness) {
+ int outlineColor, boolean clipAlpha, int thickness) {
// We start by removing most of the alpha channel so as to ignore shadows, and
// other types of partial transparency when defining the shape of the object
- if (alphaClipPaint == null) {
- alphaClipPaint = mAlphaClipPaint;
+ if (clipAlpha) {
+ int[] srcBuffer = new int[srcDst.getWidth() * srcDst.getHeight()];
+ srcDst.getPixels(srcBuffer,
+ 0, srcDst.getWidth(), 0, 0, srcDst.getWidth(), srcDst.getHeight());
+ for (int i = 0; i < srcBuffer.length; i++) {
+ final int alpha = srcBuffer[i] >>> 24;
+ if (alpha < 188) {
+ srcBuffer[i] = 0;
+ }
+ }
+ srcDst.setPixels(srcBuffer,
+ 0, srcDst.getWidth(), 0, 0, srcDst.getWidth(), srcDst.getHeight());
}
- Bitmap glowShape = srcDst.extractAlpha(alphaClipPaint, mTempOffset);
+ Bitmap glowShape = srcDst.extractAlpha();
// calculate the outer blur first
BlurMaskFilter outerBlurMaskFilter;
@@ -205,8 +209,8 @@ public class HolographicOutlineHelper {
}
void applyMediumExpensiveOutlineWithBlur(Bitmap srcDst, Canvas srcDstCanvas, int color,
- int outlineColor, Paint alphaClipPaint) {
- applyExpensiveOutlineWithBlur(srcDst, srcDstCanvas, color, outlineColor, alphaClipPaint,
+ int outlineColor, boolean clipAlpha) {
+ applyExpensiveOutlineWithBlur(srcDst, srcDstCanvas, color, outlineColor, clipAlpha,
MEDIUM);
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 83b0329..87b0c3d 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -1478,14 +1478,14 @@ public class Workspace extends SmoothPagedView
mDragOutline = createDragOutline(v, canvas, DRAG_BITMAP_PADDING);
}
- public void onDragStartedWithItem(PendingAddItemInfo info, Bitmap b, Paint alphaClipPaint) {
+ public void onDragStartedWithItem(PendingAddItemInfo info, Bitmap b, boolean clipAlpha) {
final Canvas canvas = new Canvas();
int[] size = estimateItemSize(info.spanX, info.spanY, info, false);
// The outline is used to visualize where the item will land if dropped
mDragOutline = createDragOutline(b, canvas, DRAG_BITMAP_PADDING, size[0],
- size[1], alphaClipPaint);
+ size[1], clipAlpha);
}
public void exitWidgetResizeMode() {
@@ -1798,7 +1798,7 @@ public class Workspace extends SmoothPagedView
* Responsibility for the bitmap is transferred to the caller.
*/
private Bitmap createDragOutline(Bitmap orig, Canvas canvas, int padding, int w, int h,
- Paint alphaClipPaint) {
+ boolean clipAlpha) {
final int outlineColor = getResources().getColor(android.R.color.holo_blue_light);
final Bitmap b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
canvas.setBitmap(b);
@@ -1815,7 +1815,7 @@ public class Workspace extends SmoothPagedView
canvas.drawBitmap(orig, src, dst, null);
mOutlineHelper.applyMediumExpensiveOutlineWithBlur(b, canvas, outlineColor, outlineColor,
- alphaClipPaint);
+ clipAlpha);
canvas.setBitmap(null);
return b;