// Path: GreenMatter/src/main/java/com/negusoft/greenmatter/util/ColorUtils.java
// public class ColorUtils {
// 
//     /** Modify the colors translucency by alpha [0..1] with respect to the original color alpha. */
//     public static int applyColorAlpha(int color, float alpha) {
//         final int originalAlpha = Color.alpha(color);
//         // Return the color, multiplying the original alpha by the disabled value
//         return (color & 0x00ffffff) | (Math.round(originalAlpha * alpha) << 24);
//     }
// 
//     /** Override the colors alpha and set it to the given value [0..255]. */
//     public static int replaceColorAlpha(int color, int alpha) {
//         return (color & 0x00ffffff) | (alpha << 24);
//     }
// 
//     /** Calculate the resulting alpha from the original color and the relative alpha. */
//     public static int calculateAlpha(int alpha, int originalColor) {
//         int originalAlpha = Color.alpha(originalColor);
//         return originalAlpha * alpha / 255;
//     }
// 
// 
// }


import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import com.negusoft.greenmatter.util.ColorUtils;
		result.setColor(fillColor);
		result.setStyle(Paint.Style.FILL);
		result.setAntiAlias(true);
		return result;
	}
	
	@Override
	public void draw(Canvas canvas) {
		Rect r = getBounds();
		float centerX = (r.left + r.right) / 2f;
		float centerY = (r.top + r.bottom) / 2f;
		float radius = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mState.mRadiusDp, mState.mDisplayMetrics);
		if (mBorderPaint != null) {
			canvas.drawCircle(centerX, centerY, radius, mBorderPaint);
		}
		if (mFillPaint != null) {
			if (mBorderPaint != null)
				radius -= (mBorderPaint.getStrokeWidth() / 2);
			canvas.drawCircle(centerX, centerY, radius, mFillPaint);
		}
	}

	@Override
	public int getOpacity() {
		return PixelFormat.TRANSLUCENT;
	}

	@Override
	public void setAlpha(int alpha) {
        if (mBorderPaint != null) {
// Path: GreenMatter/src/main/java/com/negusoft/greenmatter/util/ColorUtils.java
// public class ColorUtils {
// 
//     /** Modify the colors translucency by alpha [0..1] with respect to the original color alpha. */
//     public static int applyColorAlpha(int color, float alpha) {
//         final int originalAlpha = Color.alpha(color);
//         // Return the color, multiplying the original alpha by the disabled value
//         return (color & 0x00ffffff) | (Math.round(originalAlpha * alpha) << 24);
//     }
// 
//     /** Override the colors alpha and set it to the given value [0..255]. */
//     public static int replaceColorAlpha(int color, int alpha) {
//         return (color & 0x00ffffff) | (alpha << 24);
//     }
// 
//     /** Calculate the resulting alpha from the original color and the relative alpha. */
//     public static int calculateAlpha(int alpha, int originalColor) {
//         int originalAlpha = Color.alpha(originalColor);
//         return originalAlpha * alpha / 255;
//     }
// 
// 
// }


// Path: GreenMatter/src/main/java/com/negusoft/greenmatter/drawable/CircleDrawable.java
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import com.negusoft.greenmatter.util.ColorUtils;

		result.setColor(fillColor);
		result.setStyle(Paint.Style.FILL);
		result.setAntiAlias(true);
		return result;
	}
	
	@Override
	public void draw(Canvas canvas) {
		Rect r = getBounds();
		float centerX = (r.left + r.right) / 2f;
		float centerY = (r.top + r.bottom) / 2f;
		float radius = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mState.mRadiusDp, mState.mDisplayMetrics);
		if (mBorderPaint != null) {
			canvas.drawCircle(centerX, centerY, radius, mBorderPaint);
		}
		if (mFillPaint != null) {
			if (mBorderPaint != null)
				radius -= (mBorderPaint.getStrokeWidth() / 2);
			canvas.drawCircle(centerX, centerY, radius, mFillPaint);
		}
	}

	@Override
	public int getOpacity() {
		return PixelFormat.TRANSLUCENT;
	}

	@Override
	public void setAlpha(int alpha) {
        if (mBorderPaint != null) {
            int borderAlpha = ColorUtils.calculateAlpha(alpha, mState.mBorderColor);