Fix taskbar drag view scale when returning to original icon

- Use getSourceVisualDragBounds() if the target view is BubbleTextView;
  this accounts for padding as well as extra ring inset for
  PredictedAppIcon
- Also ensure we always use the final drag view scale when switching to
  the system drag and drop, instead of using the current scale which
  might be in the process of animating

Test: drag regular and predicted icons in taskbar, but drop it in a
region that doesn't accept it (e.g. the taskbar itself), check that the
return animation scales and offsets more correctly than before
Bug: 269814838

Change-Id: Ie8398b2617340e1d2568773563aa0263a3366940
This commit is contained in:
Tony Wickham
2023-02-22 02:21:20 +00:00
parent 16cfed3d1f
commit 00f89fbbf6
2 changed files with 18 additions and 5 deletions

View File

@@ -340,7 +340,7 @@ public class TaskbarDragController extends DragController<BaseTaskbarContext> im
if (DEBUG_DRAG_SHADOW_SURFACE) {
canvas.drawColor(0xffff0000);
}
float scale = mDragObject.dragView.getScaleX();
float scale = mDragObject.dragView.getEndScale();
canvas.scale(scale, scale);
mDragObject.dragView.draw(canvas);
canvas.restore();
@@ -601,7 +601,15 @@ public class TaskbarDragController extends DragController<BaseTaskbarContext> im
View target = findTaskbarTargetForIconView(originalView);
int[] toPosition = target.getLocationOnScreen();
float toScale = (float) target.getWidth() / mDragIconSize;
float iconSize = target.getWidth();
if (target instanceof BubbleTextView) {
Rect bounds = new Rect();
((BubbleTextView) target).getSourceVisualDragBounds(bounds);
toPosition[0] += bounds.left;
toPosition[1] += bounds.top;
iconSize = bounds.width();
}
float toScale = iconSize / mDragIconSize;
float toAlpha = (target == originalView) ? 1f : 0f;
MultiValueUpdateListener listener = new MultiValueUpdateListener() {
final FloatProp mDx = new FloatProp(fromX, toPosition[0], 0,