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

Commit 89ee93e0 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Use the icon bounds for all calculations." into jb-ub-now-jolly-elf

parents 4e2683a4 eeb5bbc9
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -915,6 +915,13 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
        return true;
    }

    @Override
    public float getIntrinsicIconScaleFactor() {
        LauncherAppState app = LauncherAppState.getInstance();
        DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
        return (float) grid.allAppsIconSizePx / grid.iconSizePx;
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
+2 −1
Original line number Diff line number Diff line
@@ -198,7 +198,7 @@ public class DragController {
     * @param dragRegion Coordinates within the bitmap b for the position of item being dragged.
     *          Makes dragging feel more precise, e.g. you can clip out a transparent border
     */
    public void startDrag(Bitmap b, int dragLayerX, int dragLayerY,
    public DragView startDrag(Bitmap b, int dragLayerX, int dragLayerY,
            DragSource source, Object dragInfo, int dragAction, Point dragOffset, Rect dragRegion,
            float initialDragViewScale) {
        if (PROFILE_DRAWING_DURING_DRAG) {
@@ -245,6 +245,7 @@ public class DragController {
        mLauncher.getDragLayer().performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
        dragView.show(mMotionDownX, mMotionDownY);
        handleMoveEvent(mMotionDownX, mMotionDownY);
        return dragView;
    }

    /**
+7 −3
Original line number Diff line number Diff line
@@ -522,14 +522,18 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
        scale *= childScale;
        int toX = coord[0];
        int toY = coord[1];
        float toScale = scale;
        if (child instanceof TextView) {
            TextView tv = (TextView) child;
            // Account for the source scale of the icon (ie. from AllApps to Workspace, in which
            // the workspace may have smaller icon bounds).
            toScale = scale / dragView.getIntrinsicIconScaleFactor();

            // The child may be scaled (always about the center of the view) so to account for it,
            // we have to offset the position by the scaled size.  Once we do that, we can center
            // the drag view about the scaled child view.
            toY += Math.round(scale * tv.getPaddingTop());
            toY -= dragView.getMeasuredHeight() * (1 - scale) / 2;
            toY += Math.round(toScale * tv.getPaddingTop());
            toY -= dragView.getMeasuredHeight() * (1 - toScale) / 2;
            toX -= (dragView.getMeasuredWidth() - Math.round(scale * child.getMeasuredWidth())) / 2;
        } else if (child instanceof FolderIcon) {
            // Account for holographic blur padding on the drag view
@@ -555,7 +559,7 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
                }
            }
        };
        animateViewIntoPosition(dragView, fromX, fromY, toX, toY, 1, 1, 1, scale, scale,
        animateViewIntoPosition(dragView, fromX, fromY, toX, toY, 1, 1, 1, toScale, toScale,
                onCompleteRunnable, ANIMATION_END_DISAPPEAR, duration, anchorView);
    }

+5 −0
Original line number Diff line number Diff line
@@ -30,6 +30,11 @@ public interface DragSource {
     */
    boolean supportsFlingToDelete();

    /*
     * @return the scale of the icons over the workspace icon size
     */
    float getIntrinsicIconScaleFactor();

    /**
     * A callback specifically made back to the source after an item from this source has been flung
     * to be deleted on a DropTarget.  In such a situation, this method will be called after
+12 −0
Original line number Diff line number Diff line
@@ -51,6 +51,9 @@ public class DragView extends View {
    private float mOffsetX = 0.0f;
    private float mOffsetY = 0.0f;
    private float mInitialScale = 1f;
    // The intrinsic icon scale factor is the scale factor for a drag icon over the workspace
    // size.  This is ignored for non-icons.
    private float mIntrinsicIconScale = 1f;

    /**
     * Construct the drag view.
@@ -120,6 +123,15 @@ public class DragView extends View {
        mPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
    }

    /** Sets the scale of the view over the normal workspace icon size. */
    public void setIntrinsicIconScaleFactor(float scale) {
        mIntrinsicIconScale = scale;
    }

    public float getIntrinsicIconScaleFactor() {
        return mIntrinsicIconScale;
    }

    public float getOffsetY() {
        return mOffsetY;
    }
Loading