summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/graphics/DragPreviewProvider.java
diff options
context:
space:
mode:
authorJon Miranda <jonmiranda@google.com>2016-10-12 20:35:59 -0700
committerJon Miranda <jonmiranda@google.com>2016-12-20 10:08:42 -0800
commitc9c57631a985a8e1a4eac17ef0952bd344e281a2 (patch)
treed14caa8b6c013f1d744e1262b501b55fce13a715 /src/com/android/launcher3/graphics/DragPreviewProvider.java
parent3285da35cb357d09a98ff7bdf6c5b9f6fabbee8b (diff)
downloadandroid_packages_apps_Trebuchet-c9c57631a985a8e1a4eac17ef0952bd344e281a2.tar.gz
android_packages_apps_Trebuchet-c9c57631a985a8e1a4eac17ef0952bd344e281a2.tar.bz2
android_packages_apps_Trebuchet-c9c57631a985a8e1a4eac17ef0952bd344e281a2.zip
Fix clipping of drag outline by increasing padding.
Low resolution will be addressed in future CL. Bug: 31915722 Change-Id: I6bdd32b7a30819fde1f15473a63ac280029b6715
Diffstat (limited to 'src/com/android/launcher3/graphics/DragPreviewProvider.java')
-rw-r--r--src/com/android/launcher3/graphics/DragPreviewProvider.java28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/com/android/launcher3/graphics/DragPreviewProvider.java b/src/com/android/launcher3/graphics/DragPreviewProvider.java
index e205c4211..7f1790a12 100644
--- a/src/com/android/launcher3/graphics/DragPreviewProvider.java
+++ b/src/com/android/launcher3/graphics/DragPreviewProvider.java
@@ -16,6 +16,7 @@
package com.android.launcher3.graphics;
+import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
@@ -28,6 +29,7 @@ import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppWidgetHostView;
import com.android.launcher3.PreloadIconDrawable;
+import com.android.launcher3.R;
import com.android.launcher3.Workspace;
import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.folder.FolderIcon;
@@ -37,8 +39,6 @@ import com.android.launcher3.folder.FolderIcon;
*/
public class DragPreviewProvider {
- public static final int DRAG_BITMAP_PADDING = 2;
-
private final Rect mTempRect = new Rect();
protected final View mView;
@@ -46,17 +46,25 @@ public class DragPreviewProvider {
// The padding added to the drag view during the preview generation.
public final int previewPadding;
+ protected final int blurSizeOutline;
+
public Bitmap generatedDragOutline;
public DragPreviewProvider(View view) {
+ this(view, view.getContext());
+ }
+
+ public DragPreviewProvider(View view, Context context) {
mView = view;
+ blurSizeOutline =
+ context.getResources().getDimensionPixelSize(R.dimen.blur_size_medium_outline);
if (mView instanceof TextView) {
Drawable d = Workspace.getTextViewIcon((TextView) mView);
Rect bounds = getDrawableBounds(d);
- previewPadding = DRAG_BITMAP_PADDING - bounds.left - bounds.top;
+ previewPadding = blurSizeOutline - bounds.left - bounds.top;
} else {
- previewPadding = DRAG_BITMAP_PADDING;
+ previewPadding = blurSizeOutline;
}
}
@@ -68,8 +76,8 @@ public class DragPreviewProvider {
if (mView instanceof TextView) {
Drawable d = Workspace.getTextViewIcon((TextView) mView);
Rect bounds = getDrawableBounds(d);
- destCanvas.translate(DRAG_BITMAP_PADDING / 2 - bounds.left,
- DRAG_BITMAP_PADDING / 2 - bounds.top);
+ destCanvas.translate(blurSizeOutline / 2 - bounds.left,
+ blurSizeOutline / 2 - bounds.top);
d.draw(destCanvas);
} else {
final Rect clipRect = mTempRect;
@@ -84,8 +92,8 @@ public class DragPreviewProvider {
textVisible = true;
}
}
- destCanvas.translate(-mView.getScrollX() + DRAG_BITMAP_PADDING / 2,
- -mView.getScrollY() + DRAG_BITMAP_PADDING / 2);
+ destCanvas.translate(-mView.getScrollX() + blurSizeOutline / 2,
+ -mView.getScrollY() + blurSizeOutline / 2);
destCanvas.clipRect(clipRect, Op.REPLACE);
mView.draw(destCanvas);
@@ -118,7 +126,7 @@ public class DragPreviewProvider {
height = (int) (mView.getHeight() * scale);
}
- Bitmap b = Bitmap.createBitmap(width + DRAG_BITMAP_PADDING, height + DRAG_BITMAP_PADDING,
+ Bitmap b = Bitmap.createBitmap(width + blurSizeOutline, height + blurSizeOutline,
Bitmap.Config.ARGB_8888);
canvas.setBitmap(b);
@@ -156,7 +164,7 @@ public class DragPreviewProvider {
height = (int) Math.floor(mView.getHeight() * scale);
}
- Bitmap b = Bitmap.createBitmap(width + DRAG_BITMAP_PADDING, height + DRAG_BITMAP_PADDING,
+ Bitmap b = Bitmap.createBitmap(width + blurSizeOutline, height + blurSizeOutline,
Bitmap.Config.ALPHA_8);
canvas.setBitmap(b);