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

Commit c9c57631 authored by Jon Miranda's avatar Jon Miranda
Browse files

Fix clipping of drag outline by increasing padding.

Low resolution will be addressed in future CL.

Bug: 31915722
Change-Id: I6bdd32b7a30819fde1f15473a63ac280029b6715
parent 3285da35
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -247,7 +247,6 @@ public class Workspace extends PagedView
    private boolean mStripScreensOnPageStopMoving = false;

    private DragPreviewProvider mOutlineProvider = null;
    public static final int DRAG_BITMAP_PADDING = DragPreviewProvider.DRAG_BITMAP_PADDING;
    private boolean mWorkspaceFadeInAdjacentScreens;

    final WallpaperOffsetInterpolator mWallpaperOffset;
+1 −1
Original line number Diff line number Diff line
@@ -655,7 +655,7 @@ public class DragLayer extends InsettableFrameLayout {
        } else if (child instanceof FolderIcon) {
            // Account for holographic blur padding on the drag view
            toY += Math.round(scale * (child.getPaddingTop() - dragView.getDragRegionTop()));
            toY -= scale * Workspace.DRAG_BITMAP_PADDING / 2;
            toY -= scale * dragView.getBlurSizeOutline() / 2;
            toY -= (1 - scale) * dragView.getMeasuredHeight() / 2;
            // Center in the x coordinate about the target's drawable
            toX -= (dragView.getMeasuredWidth() - Math.round(scale * child.getMeasuredWidth())) / 2;
+7 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ public class DragView extends View {
    private Bitmap mBitmap;
    private Bitmap mCrossFadeBitmap;
    @Thunk Paint mPaint;
    private final int mBlurSizeOutline;
    private final int mRegistrationX;
    private final int mRegistrationY;
    private final float mInitialScale;
@@ -144,6 +145,8 @@ public class DragView extends View {
        measure(ms, ms);
        mPaint = new Paint(Paint.FILTER_BITMAP_FLAG);

        mBlurSizeOutline = getResources().getDimensionPixelSize(R.dimen.blur_size_medium_outline);

        if (Utilities.ATLEAST_LOLLIPOP) {
            setElevation(getResources().getDimension(R.dimen.drag_elevation));
        }
@@ -397,4 +400,8 @@ public class DragView extends View {
        target.setScale(Color.red(color) / 255f, Color.green(color) / 255f,
                Color.blue(color) / 255f, Color.alpha(color) / 255f);
    }

    public int getBlurSizeOutline() {
        return mBlurSizeOutline;
    }
}
+4 −4
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ public class ExternalDragPreviewProvider extends DragPreviewProvider {
    private final int[] mOutlineSize;

    public ExternalDragPreviewProvider(Launcher launcher, ItemInfo addInfo) {
        super(null);
        super(null, launcher);
        mLauncher = launcher;
        mAddInfo = addInfo;

@@ -51,7 +51,7 @@ public class ExternalDragPreviewProvider extends DragPreviewProvider {
    public Rect getPreviewBounds() {
        Rect rect = new Rect();
        DeviceProfile dp = mLauncher.getDeviceProfile();
        rect.left = DRAG_BITMAP_PADDING / 2;
        rect.left = blurSizeOutline / 2;
        rect.top = (mOutlineSize[1] - dp.cellHeightPx) / 2;
        rect.right = rect.left + dp.iconSizePx;
        rect.bottom = rect.top + dp.iconSizePx;
@@ -69,8 +69,8 @@ public class ExternalDragPreviewProvider extends DragPreviewProvider {

        // Use 0.9f times the radius for the actual circle to account for icon normalization.
        float radius = getPreviewBounds().width() * 0.5f;
        canvas.drawCircle(DRAG_BITMAP_PADDING / 2 + radius,
                DRAG_BITMAP_PADDING / 2 + radius, radius * 0.9f, paint);
        canvas.drawCircle(blurSizeOutline / 2 + radius,
                blurSizeOutline / 2 + radius, radius * 0.9f, paint);

        HolographicOutlineHelper.getInstance(mLauncher).applyExpensiveOutlineWithBlur(b, canvas);
        canvas.setBitmap(null);
+18 −10
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.launcher3.graphics;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
@@ -28,6 +29,7 @@ import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppWidgetHostView;
import com.android.launcher3.PreloadIconDrawable;
import com.android.launcher3.R;
import com.android.launcher3.Workspace;
import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.folder.FolderIcon;
@@ -37,8 +39,6 @@ import com.android.launcher3.folder.FolderIcon;
 */
public class DragPreviewProvider {

    public static final int DRAG_BITMAP_PADDING = 2;

    private final Rect mTempRect = new Rect();

    protected final View mView;
@@ -46,17 +46,25 @@ public class DragPreviewProvider {
    // The padding added to the drag view during the preview generation.
    public final int previewPadding;

    protected final int blurSizeOutline;

    public Bitmap generatedDragOutline;

    public DragPreviewProvider(View view) {
        this(view, view.getContext());
    }

    public DragPreviewProvider(View view, Context context) {
        mView = view;
        blurSizeOutline =
                context.getResources().getDimensionPixelSize(R.dimen.blur_size_medium_outline);

        if (mView instanceof TextView) {
            Drawable d = Workspace.getTextViewIcon((TextView) mView);
            Rect bounds = getDrawableBounds(d);
            previewPadding = DRAG_BITMAP_PADDING - bounds.left - bounds.top;
            previewPadding = blurSizeOutline - bounds.left - bounds.top;
        } else {
            previewPadding = DRAG_BITMAP_PADDING;
            previewPadding = blurSizeOutline;
        }
    }

@@ -68,8 +76,8 @@ public class DragPreviewProvider {
        if (mView instanceof TextView) {
            Drawable d = Workspace.getTextViewIcon((TextView) mView);
            Rect bounds = getDrawableBounds(d);
            destCanvas.translate(DRAG_BITMAP_PADDING / 2 - bounds.left,
                    DRAG_BITMAP_PADDING / 2 - bounds.top);
            destCanvas.translate(blurSizeOutline / 2 - bounds.left,
                    blurSizeOutline / 2 - bounds.top);
            d.draw(destCanvas);
        } else {
            final Rect clipRect = mTempRect;
@@ -84,8 +92,8 @@ public class DragPreviewProvider {
                    textVisible = true;
                }
            }
            destCanvas.translate(-mView.getScrollX() + DRAG_BITMAP_PADDING / 2,
                    -mView.getScrollY() + DRAG_BITMAP_PADDING / 2);
            destCanvas.translate(-mView.getScrollX() + blurSizeOutline / 2,
                    -mView.getScrollY() + blurSizeOutline / 2);
            destCanvas.clipRect(clipRect, Op.REPLACE);
            mView.draw(destCanvas);

@@ -118,7 +126,7 @@ public class DragPreviewProvider {
            height = (int) (mView.getHeight() * scale);
        }

        Bitmap b = Bitmap.createBitmap(width + DRAG_BITMAP_PADDING, height + DRAG_BITMAP_PADDING,
        Bitmap b = Bitmap.createBitmap(width + blurSizeOutline, height + blurSizeOutline,
                Bitmap.Config.ARGB_8888);
        canvas.setBitmap(b);

@@ -156,7 +164,7 @@ public class DragPreviewProvider {
            height = (int) Math.floor(mView.getHeight() * scale);
        }

        Bitmap b = Bitmap.createBitmap(width + DRAG_BITMAP_PADDING, height + DRAG_BITMAP_PADDING,
        Bitmap b = Bitmap.createBitmap(width + blurSizeOutline, height + blurSizeOutline,
                Bitmap.Config.ALPHA_8);
        canvas.setBitmap(b);

Loading