Merge "Keep Predicted icon same size when dragging" into ub-launcher3-rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
650da4bbd1
+26
@@ -46,6 +46,7 @@ import com.android.launcher3.model.data.ItemInfo;
|
|||||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||||
import com.android.launcher3.touch.ItemClickHandler;
|
import com.android.launcher3.touch.ItemClickHandler;
|
||||||
import com.android.launcher3.touch.ItemLongClickListener;
|
import com.android.launcher3.touch.ItemLongClickListener;
|
||||||
|
import com.android.launcher3.util.SafeCloseable;
|
||||||
import com.android.launcher3.views.DoubleShadowBubbleTextView;
|
import com.android.launcher3.views.DoubleShadowBubbleTextView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,6 +66,7 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView implements
|
|||||||
private final int mNormalizedIconRadius;
|
private final int mNormalizedIconRadius;
|
||||||
private final BlurMaskFilter mShadowFilter;
|
private final BlurMaskFilter mShadowFilter;
|
||||||
private int mPlateColor;
|
private int mPlateColor;
|
||||||
|
boolean mDrawForDrag = false;
|
||||||
|
|
||||||
|
|
||||||
public PredictedAppIcon(Context context) {
|
public PredictedAppIcon(Context context) {
|
||||||
@@ -188,6 +190,10 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void drawEffect(Canvas canvas, boolean isBadged) {
|
private void drawEffect(Canvas canvas, boolean isBadged) {
|
||||||
|
// Don't draw ring effect if item is about to be dragged.
|
||||||
|
if (mDrawForDrag) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
mRingPath.reset();
|
mRingPath.reset();
|
||||||
getShape().addToPath(mRingPath, getOutlineOffsetX(), getOutlineOffsetY(),
|
getShape().addToPath(mRingPath, getOutlineOffsetX(), getOutlineOffsetY(),
|
||||||
mNormalizedIconRadius);
|
mNormalizedIconRadius);
|
||||||
@@ -208,6 +214,26 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView implements
|
|||||||
canvas.drawPath(mRingPath, mIconRingPaint);
|
canvas.drawPath(mRingPath, mIconRingPaint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getSourceVisualDragBounds(Rect bounds) {
|
||||||
|
super.getSourceVisualDragBounds(bounds);
|
||||||
|
if (!mIsPinned) {
|
||||||
|
int internalSize = (int) (bounds.width() * RING_EFFECT_RATIO);
|
||||||
|
bounds.inset(internalSize, internalSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SafeCloseable prepareDrawDragView() {
|
||||||
|
mDrawForDrag = true;
|
||||||
|
invalidate();
|
||||||
|
SafeCloseable r = super.prepareDrawDragView();
|
||||||
|
return () -> {
|
||||||
|
r.close();
|
||||||
|
mDrawForDrag = false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns a new instance of PredictedAppIcon from WorkspaceItemInfo
|
* Creates and returns a new instance of PredictedAppIcon from WorkspaceItemInfo
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ import com.android.launcher3.model.data.ItemInfoWithIcon;
|
|||||||
import com.android.launcher3.model.data.PackageItemInfo;
|
import com.android.launcher3.model.data.PackageItemInfo;
|
||||||
import com.android.launcher3.model.data.PromiseAppInfo;
|
import com.android.launcher3.model.data.PromiseAppInfo;
|
||||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||||
|
import com.android.launcher3.util.SafeCloseable;
|
||||||
import com.android.launcher3.views.ActivityContext;
|
import com.android.launcher3.views.ActivityContext;
|
||||||
import com.android.launcher3.views.IconLabelDotView;
|
import com.android.launcher3.views.IconLabelDotView;
|
||||||
|
|
||||||
@@ -744,11 +745,12 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prepareDrawDragView() {
|
public SafeCloseable prepareDrawDragView() {
|
||||||
if (getIcon() instanceof FastBitmapDrawable) {
|
if (getIcon() instanceof FastBitmapDrawable) {
|
||||||
FastBitmapDrawable icon = (FastBitmapDrawable) getIcon();
|
FastBitmapDrawable icon = (FastBitmapDrawable) getIcon();
|
||||||
icon.setScale(1f);
|
icon.setScale(1f);
|
||||||
}
|
}
|
||||||
setForceHideDot(true);
|
setForceHideDot(true);
|
||||||
|
return () -> { };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ package com.android.launcher3.dragndrop;
|
|||||||
|
|
||||||
import android.graphics.Rect;
|
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
|
* Interface defining methods required for drawing and previewing DragViews, drag previews, and
|
||||||
* related animations
|
* related animations
|
||||||
@@ -42,9 +46,12 @@ public interface DraggableView {
|
|||||||
int getViewType();
|
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)
|
* If an actual View subclass, this method returns the rectangle (within the View's coordinates)
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import com.android.launcher3.R;
|
|||||||
import com.android.launcher3.config.FeatureFlags;
|
import com.android.launcher3.config.FeatureFlags;
|
||||||
import com.android.launcher3.dragndrop.DraggableView;
|
import com.android.launcher3.dragndrop.DraggableView;
|
||||||
import com.android.launcher3.icons.BitmapRenderer;
|
import com.android.launcher3.icons.BitmapRenderer;
|
||||||
|
import com.android.launcher3.util.SafeCloseable;
|
||||||
import com.android.launcher3.widget.LauncherAppWidgetHostView;
|
import com.android.launcher3.widget.LauncherAppWidgetHostView;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
@@ -76,11 +77,12 @@ public class DragPreviewProvider {
|
|||||||
|
|
||||||
if (mView instanceof DraggableView) {
|
if (mView instanceof DraggableView) {
|
||||||
DraggableView dv = (DraggableView) mView;
|
DraggableView dv = (DraggableView) mView;
|
||||||
dv.prepareDrawDragView();
|
try (SafeCloseable t = dv.prepareDrawDragView()) {
|
||||||
dv.getSourceVisualDragBounds(mTempRect);
|
dv.getSourceVisualDragBounds(mTempRect);
|
||||||
destCanvas.translate(blurSizeOutline / 2 - mTempRect.left,
|
destCanvas.translate(blurSizeOutline / 2 - mTempRect.left,
|
||||||
blurSizeOutline / 2 - mTempRect.top);
|
blurSizeOutline / 2 - mTempRect.top);
|
||||||
mView.draw(destCanvas);
|
mView.draw(destCanvas);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
destCanvas.restoreToCount(saveCount);
|
destCanvas.restoreToCount(saveCount);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user