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

Commit 370164c4 authored by Adam Cohen's avatar Adam Cohen
Browse files

Fix drag and drop regression when dragging a scaled widget

Missed this case in ag/10736229; the symptom was that if you picked up a widget when it was scaled due to split-screen, the widget would disappear

Test: manual

Change-Id: I26810fcf820f7053b6445989dce6598e1df55a8e
parent e32f4846
Loading
Loading
Loading
Loading
+7 −2
Original line number Original line Diff line number Diff line
@@ -959,8 +959,13 @@ public class CellLayout extends ViewGroup {
                height = r.height();
                height = r.height();
            }
            }


            if (v != null && v.getViewType() == DraggableView.DRAGGABLE_ICON) {
            // Center horizontaly
            left += ((mCellWidth * spanX) - dragOutline.getWidth()) / 2;
            left += ((mCellWidth * spanX) - dragOutline.getWidth()) / 2;

            if (v != null && v.getViewType() == DraggableView.DRAGGABLE_WIDGET) {
                // Center vertically
                top += ((mCellHeight * spanY) - dragOutline.getHeight()) / 2;
            } else if (v != null && v.getViewType() == DraggableView.DRAGGABLE_ICON) {
                int cHeight = getShortcutsAndWidgets().getCellContentHeight();
                int cHeight = getShortcutsAndWidgets().getCellContentHeight();
                int cellPaddingY = (int) Math.max(0, ((mCellHeight - cHeight) / 2f));
                int cellPaddingY = (int) Math.max(0, ((mCellHeight - cHeight) / 2f));
                top += cellPaddingY;
                top += cellPaddingY;
+3 −1
Original line number Original line Diff line number Diff line
@@ -92,6 +92,8 @@ public class DragPreviewProvider {
    public Bitmap createDragBitmap() {
    public Bitmap createDragBitmap() {
        int width = 0;
        int width = 0;
        int height = 0;
        int height = 0;
        // Assume scaleX == scaleY, which is always the case for workspace items.
        float scale = mView.getScaleX();
        if (mView instanceof DraggableView) {
        if (mView instanceof DraggableView) {
            ((DraggableView) mView).getVisualDragBounds(mTempRect);
            ((DraggableView) mView).getVisualDragBounds(mTempRect);
            width = mTempRect.width();
            width = mTempRect.width();
@@ -102,7 +104,7 @@ public class DragPreviewProvider {
        }
        }


        return BitmapRenderer.createHardwareBitmap(width + blurSizeOutline,
        return BitmapRenderer.createHardwareBitmap(width + blurSizeOutline,
                height + blurSizeOutline, (c) -> drawDragView(c, 1));
                height + blurSizeOutline, (c) -> drawDragView(c, scale));
    }
    }


    public final void generateDragOutline(Bitmap preview) {
    public final void generateDragOutline(Bitmap preview) {
+4 −5
Original line number Original line Diff line number Diff line
@@ -365,10 +365,9 @@ public class LauncherAppWidgetHostView extends NavigableAppWidgetHostView


    @Override
    @Override
    public void getVisualDragBounds(Rect bounds) {
    public void getVisualDragBounds(Rect bounds) {
        int x = (int) (1 - getScaleToFit()) * getMeasuredWidth() / 2;
        int width = (int) (getMeasuredWidth() * mScaleToFit);
        int y = (int) (1 - getScaleToFit()) * getMeasuredWidth() / 2;
        int height = (int) (getMeasuredHeight() * mScaleToFit);
        int width = (int) getScaleToFit() * getMeasuredWidth();

        int height = (int) getScaleToFit() * getMeasuredHeight();
        bounds.set(0, 0 , width, height);
        bounds.set(x, y , x + width, y + height);
    }
    }
}
}