Keep Predicted icon same size when dragging
-> In addition, this also prevents the drawing of ring effect for predicted icon when view is about to be copied to drag bitmap. Icon will scale to full size (without ring) when dropped.
Video attached to bug report
Bug: 152325754
Test: Manual
Change-Id: Ibd1a5dbf76c41bdc30ae851ad914a4d0e32703c8
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 79ed2b8..60b6da6 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -60,6 +60,7 @@
import com.android.launcher3.model.data.PackageItemInfo;
import com.android.launcher3.model.data.PromiseAppInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
+import com.android.launcher3.util.SafeCloseable;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.IconLabelDotView;
@@ -744,11 +745,12 @@
}
@Override
- public void prepareDrawDragView() {
+ public SafeCloseable prepareDrawDragView() {
if (getIcon() instanceof FastBitmapDrawable) {
FastBitmapDrawable icon = (FastBitmapDrawable) getIcon();
icon.setScale(1f);
}
setForceHideDot(true);
+ return () -> { };
}
}
diff --git a/src/com/android/launcher3/dragndrop/DraggableView.java b/src/com/android/launcher3/dragndrop/DraggableView.java
index 287c781..f7dcf6b 100644
--- a/src/com/android/launcher3/dragndrop/DraggableView.java
+++ b/src/com/android/launcher3/dragndrop/DraggableView.java
@@ -18,6 +18,10 @@
import android.graphics.Rect;
+import androidx.annotation.NonNull;
+
+import com.android.launcher3.util.SafeCloseable;
+
/**
* Interface defining methods required for drawing and previewing DragViews, drag previews, and
* related animations
@@ -42,9 +46,12 @@
int getViewType();
/**
- * Before rendering as a DragView bitmap, some views need a preparation step.
+ * Before rendering as a DragView bitmap, some views need a preparation step. Returns a
+ * callback to clear any preparation work
*/
- default void prepareDrawDragView() { }
+ @NonNull default SafeCloseable prepareDrawDragView() {
+ return () -> { };
+ }
/**
* If an actual View subclass, this method returns the rectangle (within the View's coordinates)
diff --git a/src/com/android/launcher3/graphics/DragPreviewProvider.java b/src/com/android/launcher3/graphics/DragPreviewProvider.java
index 634d07e..21822a3 100644
--- a/src/com/android/launcher3/graphics/DragPreviewProvider.java
+++ b/src/com/android/launcher3/graphics/DragPreviewProvider.java
@@ -35,6 +35,7 @@
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dragndrop.DraggableView;
import com.android.launcher3.icons.BitmapRenderer;
+import com.android.launcher3.util.SafeCloseable;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
import java.nio.ByteBuffer;
@@ -76,11 +77,12 @@
if (mView instanceof DraggableView) {
DraggableView dv = (DraggableView) mView;
- dv.prepareDrawDragView();
- dv.getSourceVisualDragBounds(mTempRect);
- destCanvas.translate(blurSizeOutline / 2 - mTempRect.left,
- blurSizeOutline / 2 - mTempRect.top);
- mView.draw(destCanvas);
+ try (SafeCloseable t = dv.prepareDrawDragView()) {
+ dv.getSourceVisualDragBounds(mTempRect);
+ destCanvas.translate(blurSizeOutline / 2 - mTempRect.left,
+ blurSizeOutline / 2 - mTempRect.top);
+ mView.draw(destCanvas);
+ }
}
destCanvas.restoreToCount(saveCount);
}