// Path: library/src/main/java/com/yarolegovich/mp/util/Utils.java
// public class Utils {
// 
//     private Utils() {}
// 
//     public static int dpToPixels(Context context, int dp) {
//         Resources resources = context.getResources();
//         DisplayMetrics metrics = resources.getDisplayMetrics();
//         return Math.round(dp * ((float)metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT));
//     }
// 
//     public static int clickableBackground(Context context) {
//         TypedValue outValue = new TypedValue();
//         context.getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
//         return outValue.resourceId;
//     }
// }


import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Build;
import androidx.annotation.ColorInt;
import android.util.AttributeSet;
import android.view.View;
import com.yarolegovich.mp.R;
import com.yarolegovich.mp.util.Utils;
        int borderWidth = 0;

        if (attrs != null) {
            TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.ColorView);
            try {
                shapeType = ta.getInt(R.styleable.ColorView_mp_cv_shape, SHAPE_CIRCLE);
                shapeColor = ta.getColor(R.styleable.ColorView_mp_cv_color, Color.WHITE);
                borderColor = ta.getColor(R.styleable.ColorView_mp_cv_border_color, Color.BLACK);
                borderWidth = ta.getDimensionPixelSize(R.styleable.ColorView_mp_cv_border_width, 0);
            } finally {
                ta.recycle();
            }
        }

        currentShape = shapeType == SHAPE_CIRCLE ? new CircleShape() : new SquareShape();
        shapePaint = new Paint();
        shapePaint.setStyle(Paint.Style.FILL);
        shapePaint.setColor(shapeColor);

        borderPaint = new Paint();
        borderPaint.setStyle(Paint.Style.STROKE);
        borderPaint.setAntiAlias(true);
        borderPaint.setStrokeWidth(borderWidth);
        borderPaint.setColor(borderColor);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int width = MeasureSpec.getSize(widthMeasureSpec);
        int height = MeasureSpec.getSize(heightMeasureSpec);
// Path: library/src/main/java/com/yarolegovich/mp/util/Utils.java
// public class Utils {
// 
//     private Utils() {}
// 
//     public static int dpToPixels(Context context, int dp) {
//         Resources resources = context.getResources();
//         DisplayMetrics metrics = resources.getDisplayMetrics();
//         return Math.round(dp * ((float)metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT));
//     }
// 
//     public static int clickableBackground(Context context) {
//         TypedValue outValue = new TypedValue();
//         context.getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
//         return outValue.resourceId;
//     }
// }


// Path: library/src/main/java/com/yarolegovich/mp/view/ColorView.java
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Build;
import androidx.annotation.ColorInt;
import android.util.AttributeSet;
import android.view.View;
import com.yarolegovich.mp.R;
import com.yarolegovich.mp.util.Utils;

        int borderWidth = 0;

        if (attrs != null) {
            TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.ColorView);
            try {
                shapeType = ta.getInt(R.styleable.ColorView_mp_cv_shape, SHAPE_CIRCLE);
                shapeColor = ta.getColor(R.styleable.ColorView_mp_cv_color, Color.WHITE);
                borderColor = ta.getColor(R.styleable.ColorView_mp_cv_border_color, Color.BLACK);
                borderWidth = ta.getDimensionPixelSize(R.styleable.ColorView_mp_cv_border_width, 0);
            } finally {
                ta.recycle();
            }
        }

        currentShape = shapeType == SHAPE_CIRCLE ? new CircleShape() : new SquareShape();
        shapePaint = new Paint();
        shapePaint.setStyle(Paint.Style.FILL);
        shapePaint.setColor(shapeColor);

        borderPaint = new Paint();
        borderPaint.setStyle(Paint.Style.STROKE);
        borderPaint.setAntiAlias(true);
        borderPaint.setStrokeWidth(borderWidth);
        borderPaint.setColor(borderColor);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int width = MeasureSpec.getSize(widthMeasureSpec);
        int height = MeasureSpec.getSize(heightMeasureSpec);
        int padding = Utils.dpToPixels(getContext(), PADDING_DP);