package com.github.javiersantos.materialstyleddialogs;

import android.content.Context;
import android.os.Build;
import android.support.annotation.ColorRes;
import android.util.TypedValue;

class UtilsLibrary {

    static int getPrimaryColor(Context context) {
        TypedValue typedValue = new TypedValue();

        context.getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, true);

        return typedValue.data;
    }

    static int dpToPixels(Context context, int dp) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dp * scale + 0.5f);
    }

    /**
     * Returns a color associated with a particular resource ID
     * <p/>
     * Starting in {@link android.os.Build.VERSION_CODES#M}, the returned
     * color will be styled for the specified Context's theme.
     *
     * @param colorId The desired resource identifier, as generated by the aapt
     *                tool. This integer encodes the package, type, and resource
     *                entry. The value 0 is an invalid identifier.
     * @return A single color value in the form 0xAARRGGBB.
     */
    static int getColor(Context context, @ColorRes int colorId) {
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
            // Noinspection deprecation
            return context.getResources().getColor(colorId);
        } else {
            return context.getColor(colorId);
        }
    }

    static boolean checkApiGreaterThan(int api) {
        return Build.VERSION.SDK_INT >= api;
    }

}

@@ -150,16 +150,65 @@
 lorRes;%0A
+import android.support.v4.content.ContextCompat;%0A
 import a
@@ -669,711 +669,70 @@
     
-/**%0A     * Returns a color associated with a particular resource ID%0A     * %3Cp/%3E%0A     * Starting in %7B@link android.os.Build.VERSION_CODES#M%7D, the returned%0A     * color will be styled for the specified Context's theme.%0A     *%0A     * @param colorId The desired resource identifier, as generated by the aapt%0A     *                tool. This integer encodes the package, type, and resource%0A     *                entry. The value 0 is an invalid identifier.%0A     * @return A single color value in the form 0xAARRGGBB.%0A     */%0A    static int getColor(Context context, @ColorRes int colorId) %7B%0A        if (Build.VERSION.SDK_INT %3C= Build.VERSION_CODES.LOLLIPOP_MR1) %7B%0A            // Noinspection deprecation%0A    
+static int getColor(Context context, @ColorRes int colorId) %7B%0A
     
@@ -746,122 +746,49 @@
 urn 
-c
+C
 ontext
-.getResources().getColor(colorId);%0A        %7D else %7B%0A            return context.getColor(colorId);%0A        %7D
+Compat.getColor(context, colorId);
 %0A   

Update method to get color