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

Commit 715774bb authored by Abhishek Aggarwal's avatar Abhishek Aggarwal Committed by Saalim Quadri
Browse files

iconloader: Add unchanges constructor for aosp



Saalim: Adapt to a15

Signed-off-by: default avatarSaalim Quadri <danascape@gmail.com>
parent b8867fe7
Loading
Loading
Loading
Loading
+5 −39
Original line number Diff line number Diff line
@@ -62,6 +62,10 @@ public class DotRenderer {
    private final Rect mTextRect = new Rect();
    private boolean mDisplayCount;

    public DotRenderer(int iconSizePx, Path iconShapePath, int pathSize) {
        this(iconSizePx, iconShapePath, pathSize, false, null);
    }

    public DotRenderer(int iconSizePx, Path iconShapePath, int pathSize, Boolean displayCount, Typeface typeface) {
        mDisplayCount = displayCount;
        int size = Math.round((displayCount ? SIZE_PERCENTAGE_WITH_COUNT : SIZE_PERCENTAGE) * iconSizePx);
@@ -84,17 +88,6 @@ public class DotRenderer {
        mTextPaint.setTypeface(typeface);
    }

    public DotRenderer(int iconSizePx, Path iconShapePath, int pathSize) {
        int size = Math.round(SIZE_PERCENTAGE * iconSizePx);

        if (size <= 0) {
            size = MIN_DOT_SIZE;
        }
        // Find the points on the path that are closest to the top left and right corners.
        mLeftDotPosition = getPathPoint(iconShapePath, pathSize, -1);
        mRightDotPosition = getPathPoint(iconShapePath, pathSize, 1);
    }

    private static float[] getPathPoint(Path path, float size, float direction) {
        float halfSize = size / 2;
        // Small delta so that we don't get a zero size triangle
@@ -128,34 +121,7 @@ public class DotRenderer {
     * Draw a circle on top of the canvas according to the given params.
     */
    public void draw(Canvas canvas, DrawParams params) {
        if (params == null) {
            Log.e(TAG, "Invalid null argument(s) passed in call to draw.");
            return;
        }
        canvas.save();

        Rect iconBounds = params.iconBounds;
        float[] dotPosition = params.leftAlign ? mLeftDotPosition : mRightDotPosition;
        float dotCenterX = iconBounds.left + iconBounds.width() * dotPosition[0];
        float dotCenterY = iconBounds.top + iconBounds.height() * dotPosition[1];

        // Ensure dot fits entirely in canvas clip bounds.
        Rect canvasBounds = canvas.getClipBounds();
        float offsetX = params.leftAlign
                ? Math.max(0, canvasBounds.left - (dotCenterX + mBitmapOffset))
                : Math.min(0, canvasBounds.right - (dotCenterX - mBitmapOffset));
        float offsetY = Math.max(0, canvasBounds.top - (dotCenterY + mBitmapOffset));

        // We draw the dot relative to its center.
        canvas.translate(dotCenterX + offsetX, dotCenterY + offsetY);
        canvas.scale(params.scale, params.scale);

        mCirclePaint.setColor(Color.BLACK);
        canvas.drawBitmap(mBackgroundWithShadow, mBitmapOffset, mBitmapOffset, mCirclePaint);
        mCirclePaint.setColor(params.dotColor);
        canvas.drawCircle(0, 0, mCircleRadius, mCirclePaint);

        canvas.restore();
        draw(canvas, params, 0);
    }

    /**