/*
 * Copyright (c) 2015 Ha Duy Trung
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.github.hidroh.materialistic.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.support.v4.content.ContextCompat;
import android.text.style.ReplacementSpan;

import io.github.hidroh.materialistic.R;

public class AsteriskSpan extends ReplacementSpan {
    private final int mBackgroundColor;
    private final int mTextColor;
    private final float mPadding;

    public AsteriskSpan(Context context) {
        super();
        mBackgroundColor = ContextCompat.getColor(context, R.color.redA200);
        mTextColor = ContextCompat.getColor(context, R.color.white);
        mPadding = context.getResources().getDimension(R.dimen.padding_asterisk);
    }

    @Override
    public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) {
        return Math.round(paint.measureText(text, start, end) + mPadding * 4);
    }

    @Override
    public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) {
        float textSize = paint.measureText(text, start, end);
        float radius = textSize / 2 + mPadding;
        float centerX = x + radius + mPadding;
        float centerY = y / 2;
        paint.setColor(mBackgroundColor);
        canvas.drawCircle(centerX, centerY, radius, paint);
        paint.setColor(mTextColor);
        canvas.drawText(text, start, end, x + mPadding * 2, y, paint);
    }
}

@@ -830,16 +830,64 @@
 tSpan;%0A%0A
+import io.github.hidroh.materialistic.AppUtils;%0A
 import i
@@ -1203,24 +1203,77 @@
 ext,
- R.color.redA200
+%0A                AppUtils.getThemedResId(context, R.attr.colorAccent)
 );%0A 
@@ -1328,21 +1328,35 @@
 xt, 
-R.color.white
+android.R.color.transparent
 );%0A 
@@ -1589,60 +1589,66 @@
 und(
-paint.measureText(text, start, end) + mP
+mPadding * 4); // padding let + radius * 2 + p
 adding 
-* 4);
+right
 %0A   
@@ -1810,93 +1810,16 @@
 oat 
-textSize = paint.measureText(text, start, end);%0A        float radius = textSize / 2 +
+radius =
  mPa
@@ -1900,13 +1900,31 @@
 Y = 
-y / 2
+top + radius + mPadding
 ;%0A  

Simplify asterisk