From 3f6bc94b3f7000868aebe3846437aeae73776b68 Mon Sep 17 00:00:00 2001 From: Sebastian Franco Date: Thu, 17 Aug 2023 16:54:32 -0700 Subject: [PATCH] If the view for the drag preview is a BubbleTextVie use the icon drawable for the preview Test: Manual Testing Fix: 286080714 Change-Id: I240521765312b37694ea0185c95ecb766b45c371 --- .../launcher3/graphics/DragPreviewProvider.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/graphics/DragPreviewProvider.java b/src/com/android/launcher3/graphics/DragPreviewProvider.java index 7457f3057c..b51373cb82 100644 --- a/src/com/android/launcher3/graphics/DragPreviewProvider.java +++ b/src/com/android/launcher3/graphics/DragPreviewProvider.java @@ -21,10 +21,12 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.drawable.Drawable; +import android.graphics.drawable.InsetDrawable; import android.view.View; import androidx.annotation.Nullable; +import com.android.launcher3.BubbleTextView; import com.android.launcher3.R; import com.android.launcher3.dragndrop.DraggableView; import com.android.launcher3.icons.BitmapRenderer; @@ -37,7 +39,6 @@ import com.android.launcher3.widget.LauncherAppWidgetHostView; * A utility class to generate preview bitmap for dragging. */ public class DragPreviewProvider { - private final Rect mTempRect = new Rect(); protected final View mView; @@ -99,6 +100,14 @@ public class DragPreviewProvider { height = mView.getHeight(); } + if (mView instanceof BubbleTextView) { + FastBitmapDrawable icon = ((BubbleTextView) mView).getIcon(); + Drawable drawable = icon.getConstantState().newDrawable(); + float xInset = (float) blurSizeOutline / (float) (width + blurSizeOutline); + float yInset = (float) blurSizeOutline / (float) (height + blurSizeOutline); + return new InsetDrawable(drawable, xInset / 2, yInset / 2, xInset / 2, yInset / 2); + } + return new FastBitmapDrawable( BitmapRenderer.createHardwareBitmap(width + blurSizeOutline, height + blurSizeOutline, (c) -> drawDragView(c, scale)));