public AndroidClockTextView(Context context, AttributeSet attrs) {
super(context, attrs);
<<<<<<< HEAD
mUseClockTypeface = attrs.getAttributeBooleanValue(null, ATTR_USE_CLOCK_TYPEFACE, true)
&& !isInEditMode();
sStandardTypeface = Typeface.DEFAULT_BOLD;
if (sClockTypeface == null && mUseClockTypeface) {
sClockTypeface = Typeface.createFromFile(SYSTEM_FONT_TIME_BACKGROUND);
=======
mProperties = new TextView(context, attrs);
mHighlightsEnabled =
attrs.getAttributeBooleanValue(null, ATTR_FONT_HIGHLIGHTS_ENABLED, true);
mShortForm =attrs.getAttributeBooleanValue(null, ATTR_SHORT_FORM, false);
mUseClockTypeface = attrs.getAttributeBooleanValue(null, ATTR_USE_CLOCK_TYPEFACE, true)
&& ! mProperties.isInEditMode();
if (!mUseClockTypeface) {
mHighlightsEnabled = false;
}
mTextSize = mProperties.getTextSize();
mColor = mProperties.getTextColors();
sStandardTypeface = Typeface.DEFAULT_BOLD;
if (sClockTypeface == null && mUseClockTypeface) {
sClockTypeface = Typeface.createFromFile(SYSTEM_FONT_TIME_BACKGROUND);
sHighlightTypeface = Typeface.createFromFile(SYSTEM_FONT_TIME_FOREGROUND);
}
mTextPaint = new Paint();
mTextPaint.setTypeface(mUseClockTypeface ? sClockTypeface : sStandardTypeface);
mTextPaint.setTextAlign(Paint.Align.LEFT);
mTextPaint.setAntiAlias(true);
mTextPaint.setTextSize(mTextSize);
mHighlightPaint = new Paint();
mHighlightPaint.setTypeface(sHighlightTypeface);
mHighlightPaint.setTextAlign(Paint.Align.LEFT);
mHighlightPaint.setAntiAlias(true);
mHighlightPaint.setTextSize(mTextSize);
}
public void setTextColor(int color) {
mColor = ColorStateList.valueOf(color);
mTextPaint.setColor(color);
mHighlightPaint.setColor(color);
refreshDrawableState();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int measuredWidth, measuredHeight;
FontMetrics fontMetrics = mTextPaint.getFontMetrics();
mTextPaint.getTextBounds(mText, 0, mText.length(), mTextBounds);
if (mUseClockTypeface) {
mHighlightPaint.getTextBounds(mText, 0, mText.length(), mTempRect);
mTextBounds.union(mTempRect);
>>>>>>> e1979dec0c1cb45249c2b5cd5131aeeb3c89a2d3
}
Paint paint = getPaint(); |