// Path: library/src/main/java/com/yarolegovich/mp/util/Utils.java
// 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));
// }


import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.cardview.widget.CardView;
import androidx.core.content.ContextCompat;
import static com.yarolegovich.mp.util.Utils.dpToPixels;
    public MaterialPreferenceCategory(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(attrs);
    }

    public MaterialPreferenceCategory(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(attrs);
    }

    private void init(AttributeSet attrs) {
        int titleColor = -1;
        String titleText = "";
        if (attrs != null) {
            TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.MaterialPreferenceCategory);
            try {
                if (ta.hasValue(R.styleable.MaterialPreferenceCategory_mpc_title)) {
                    titleText = ta.getString(R.styleable.MaterialPreferenceCategory_mpc_title);
                }
                titleColor = ta.getColor(R.styleable.MaterialPreferenceCategory_mpc_title_color, -1);
            } finally {
                ta.recycle();
            }
        }

        inflate(getContext(), R.layout.view_preference_category, this);

        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
// Path: library/src/main/java/com/yarolegovich/mp/util/Utils.java
// 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));
// }


// Path: library/src/main/java/com/yarolegovich/mp/MaterialPreferenceCategory.java
import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.cardview.widget.CardView;
import androidx.core.content.ContextCompat;
import static com.yarolegovich.mp.util.Utils.dpToPixels;

    public MaterialPreferenceCategory(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(attrs);
    }

    public MaterialPreferenceCategory(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(attrs);
    }

    private void init(AttributeSet attrs) {
        int titleColor = -1;
        String titleText = "";
        if (attrs != null) {
            TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.MaterialPreferenceCategory);
            try {
                if (ta.hasValue(R.styleable.MaterialPreferenceCategory_mpc_title)) {
                    titleText = ta.getString(R.styleable.MaterialPreferenceCategory_mpc_title);
                }
                titleColor = ta.getColor(R.styleable.MaterialPreferenceCategory_mpc_title_color, -1);
            } finally {
                ta.recycle();
            }
        }

        inflate(getContext(), R.layout.view_preference_category, this);

        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        params.setMargins(0, 0, 0, dpToPixels(getContext(), 4));