Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 00f89fbb authored by Tony Wickham's avatar Tony Wickham
Browse files

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
parent 16cfed3d
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -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,
+8 −3
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ public abstract class DragView<T extends Context & ActivityContext> extends Fram
    protected final int mRegistrationX;
    protected final int mRegistrationY;
    private final float mInitialScale;
    private final float mEndScale;
    protected final float mScaleOnDrop;
    protected final int[] mTempLoc = new int[2];

@@ -158,7 +159,7 @@ public abstract class DragView<T extends Context & ActivityContext> extends Fram
            setClipToPadding(false);
        }

        final float scale = (width + finalScaleDps) / width;
        mEndScale = (width + finalScaleDps) / width;

        // Set the initial scale to avoid any jumps
        setScaleX(initialScale);
@@ -169,8 +170,8 @@ public abstract class DragView<T extends Context & ActivityContext> extends Fram
        mAnim.setDuration(VIEW_ZOOM_DURATION);
        mAnim.addUpdateListener(animation -> {
            final float value = (Float) animation.getAnimatedValue();
            setScaleX(initialScale + (value * (scale - initialScale)));
            setScaleY(initialScale + (value * (scale - initialScale)));
            setScaleX(Utilities.mapRange(value, initialScale, mEndScale));
            setScaleY(Utilities.mapRange(value, initialScale, mEndScale));
            if (!isAttachedToWindow()) {
                animation.cancel();
            }
@@ -508,6 +509,10 @@ public abstract class DragView<T extends Context & ActivityContext> extends Fram
        return mInitialScale;
    }

    public float getEndScale() {
        return mEndScale;
    }

    @Override
    public boolean hasOverlappingRendering() {
        return false;