diff options
author | Winson Chung <winsonc@google.com> | 2011-08-08 15:31:33 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2011-08-08 15:53:57 -0700 |
commit | 70fc438583779ef903541bf9ec546a8235a18785 (patch) | |
tree | ed646f2b72c531987e135aec91b8f0fa11a971c1 | |
parent | 8fcce0f5b440a8285c6a5b3e72b37b494ac0c462 (diff) | |
download | android_packages_apps_Trebuchet-70fc438583779ef903541bf9ec546a8235a18785.tar.gz android_packages_apps_Trebuchet-70fc438583779ef903541bf9ec546a8235a18785.tar.bz2 android_packages_apps_Trebuchet-70fc438583779ef903541bf9ec546a8235a18785.zip |
Adding opacity to drag views. (5064535)
Change-Id: I6eb96edf203a53e55a0d20dd97ff383d0b51da0e
-rw-r--r-- | res/values/colors.xml | 3 | ||||
-rw-r--r-- | src/com/android/launcher2/AppsCustomizePagedView.java | 17 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 8 |
3 files changed, 22 insertions, 6 deletions
diff --git a/res/values/colors.xml b/res/values/colors.xml index 1efeb9e49..ece0fd895 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -23,6 +23,9 @@ <color name="delete_target_hover_tint">#DAFF0000</color> <color name="info_target_hover_tint">#DA0099CC</color> + <!-- The alpha/color to apply to the drag image --> + <color name="drag_view_multiply_color">#CCFFFFFF</color> + <color name="bubble_dark_background">#20000000</color> <color name="appwidget_error_color">#FCCC</color> diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 53d154ff0..893e91d25 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -33,6 +33,7 @@ import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.Canvas; +import android.graphics.PorterDuff; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.AsyncTask; @@ -172,6 +173,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen private Canvas mCanvas; private Drawable mDefaultWidgetBackground; private IconCache mIconCache; + private int mDragViewMultiplyColor; // Dimens private int mContentWidth; @@ -202,7 +204,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // Save the default widget preview background Resources resources = context.getResources(); mDefaultWidgetBackground = resources.getDrawable(R.drawable.default_widget_preview_holo); - mAppIconSize = getResources().getDimensionPixelSize(R.dimen.app_icon_size); + mAppIconSize = resources.getDimensionPixelSize(R.dimen.app_icon_size); + mDragViewMultiplyColor = resources.getColor(R.color.drag_view_multiply_color); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagedView, 0, 0); // TODO-APPS_CUSTOMIZE: remove these unnecessary attrs after @@ -409,7 +412,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen createItemInfo.spanY = spanXY[1]; b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); - renderDrawableToBitmap(preview, b, 0, 0, w, h, 1, 1); + renderDrawableToBitmap(preview, b, 0, 0, w, h, 1, 1, mDragViewMultiplyColor); } else { // Workaround for the fact that we don't keep the original ResolveInfo associated with // the shortcut around. To get the icon, we just render the preview image (which has @@ -420,6 +423,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen mCanvas.save(); preview.draw(mCanvas); mCanvas.restore(); + mCanvas.drawColor(mDragViewMultiplyColor, PorterDuff.Mode.MULTIPLY); mCanvas.setBitmap(null); createItemInfo.spanX = createItemInfo.spanY = 1; } @@ -745,6 +749,10 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } private void renderDrawableToBitmap(Drawable d, Bitmap bitmap, int x, int y, int w, int h, float scaleX, float scaleY) { + renderDrawableToBitmap(d, bitmap, x, y, w, h, scaleX, scaleY, 0xFFFFFFFF); + } + private void renderDrawableToBitmap(Drawable d, Bitmap bitmap, int x, int y, int w, int h, + float scaleX, float scaleY, int multiplyColor) { if (bitmap != null) { Canvas c = new Canvas(bitmap); c.scale(scaleX, scaleY); @@ -752,6 +760,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen d.setBounds(x, y, x + w, y + h); d.draw(c); d.setBounds(oldBounds); // Restore the bounds + if (multiplyColor != 0xFFFFFFFF) { + c.drawColor(mDragViewMultiplyColor, PorterDuff.Mode.MULTIPLY); + } c.setBitmap(null); } } @@ -828,7 +839,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen preview = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Config.ARGB_8888); renderDrawableToBitmap(mDefaultWidgetBackground, preview, 0, 0, expectedWidth, - expectedHeight, 1f,1f); + expectedHeight, 1f, 1f); // Draw the icon in the top left corner try { diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index ce3aad4fb..a45d2b8f8 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -17,12 +17,12 @@ package com.android.launcher2; import android.animation.Animator; +import android.animation.Animator.AnimatorListener; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.TimeInterpolator; import android.animation.ValueAnimator; -import android.animation.Animator.AnimatorListener; import android.animation.ValueAnimator.AnimatorUpdateListener; import android.app.AlertDialog; import android.app.WallpaperManager; @@ -33,15 +33,14 @@ import android.content.ClipDescription; import android.content.ComponentName; import android.content.Context; import android.content.Intent; -import android.content.pm.PackageManager; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Camera; import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; +import android.graphics.PorterDuff; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Region.Op; @@ -183,6 +182,7 @@ public class Workspace extends SmoothPagedView private Bitmap mDragOutline = null; private final Rect mTempRect = new Rect(); private final int[] mTempXY = new int[2]; + private int mDragViewMultiplyColor; // Paint used to draw external drop outline private final Paint mExternalDragOutlinePaint = new Paint(); @@ -306,6 +306,7 @@ public class Workspace extends SmoothPagedView mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f; + mDragViewMultiplyColor = res.getColor(R.color.drag_view_multiply_color); // if the value is manually specified, use that instead cellCountX = a.getInt(R.styleable.Workspace_cellCountX, cellCountX); @@ -1964,6 +1965,7 @@ public class Workspace extends SmoothPagedView canvas.setBitmap(b); drawDragView(v, canvas, padding, true); mOutlineHelper.applyOuterBlur(b, canvas, outlineColor); + canvas.drawColor(mDragViewMultiplyColor, PorterDuff.Mode.MULTIPLY); canvas.setBitmap(null); return b; |