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

Commit 99d814e5 authored by Jonathan Miranda's avatar Jonathan Miranda Committed by Android (Google) Code Review
Browse files

Merge "Restore original scaleRectAboutCenter method." into ub-launcher3-master

parents 6c46a6d3 6f6a06ac
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -1018,8 +1018,7 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
                cellToRect(cellX, cellY, spanX, spanY, r);
                if (v instanceof LauncherAppWidgetHostView) {
                    DeviceProfile profile = mLauncher.getDeviceProfile();
                    Utilities.shrinkRectAboutCenter(r, profile.appWidgetScale.x,
                            profile.appWidgetScale.y);
                    Utilities.shrinkRect(r, profile.appWidgetScale.x, profile.appWidgetScale.y);
                }
            } else {
                // Find the top left corner of the rect the object will occupy
@@ -1059,7 +1058,7 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
                r.set(left, top, left + dragOutline.getWidth(), top + dragOutline.getHeight());
            }

            Utilities.shrinkRectAboutCenter(r, mChildScale, mChildScale);
            Utilities.scaleRectAboutCenter(r, mChildScale);
            mDragOutlineAnims[mDragOutlineCurrent].setTag(dragOutline);
            mDragOutlineAnims[mDragOutlineCurrent].animateIn();

+16 −1
Original line number Diff line number Diff line
@@ -249,7 +249,22 @@ public final class Utilities {
        return delta;
    }

    public static float shrinkRectAboutCenter(Rect r, float scaleX, float scaleY) {
    public static void scaleRectAboutCenter(Rect r, float scale) {
        if (scale != 1.0f) {
            int cx = r.centerX();
            int cy = r.centerY();
            r.offset(-cx, -cy);

            r.left = (int) (r.left * scale + 0.5f);
            r.top = (int) (r.top * scale + 0.5f);
            r.right = (int) (r.right * scale + 0.5f);
            r.bottom = (int) (r.bottom * scale + 0.5f);

            r.offset(cx, cy);
        }
    }

    public static float shrinkRect(Rect r, float scaleX, float scaleY) {
        float scale = Math.min(Math.min(scaleX, scaleY), 1.0f);
        if (scale < 1.0f) {
            int deltaX = (int) (r.width() * (scaleX - scale) * 0.5f);
+2 −3
Original line number Diff line number Diff line
@@ -399,8 +399,7 @@ public class Workspace extends PagedView
            float scale = 1;
            if (isWidget) {
                DeviceProfile profile = mLauncher.getDeviceProfile();
                scale = Utilities.shrinkRectAboutCenter(r, profile.appWidgetScale.x,
                        profile.appWidgetScale.y);
                scale = Utilities.shrinkRect(r, profile.appWidgetScale.x, profile.appWidgetScale.y);
            }
            size[0] = r.width();
            size[1] = r.height();
@@ -3475,7 +3474,7 @@ public class Workspace extends PagedView
        Rect r = estimateItemPosition(layout, targetCell[0], targetCell[1], spanX, spanY);
        if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET) {
            DeviceProfile profile = mLauncher.getDeviceProfile();
            Utilities.shrinkRectAboutCenter(r, profile.appWidgetScale.x, profile.appWidgetScale.y);
            Utilities.shrinkRect(r, profile.appWidgetScale.x, profile.appWidgetScale.y);
        }
        loc[0] = r.left;
        loc[1] = r.top;