package com.philliphsu.bottomsheetpickers.date;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.util.TypedValue;

import com.philliphsu.bottomsheetpickers.R;
import com.philliphsu.bottomsheetpickers.Utils;

/**
 * A derivative of {@link TextViewWithCircularIndicator} for use in {@link
 * YearPickerView}, that matches the style in the Material Design spec.
 */
public class TextViewWithHighlightIndicator extends TextViewWithIndicator {

    private final int    mHighlightColor;
    private final String mItemIsSelectedText;
    private final float  mDefaultTextSize;
    private final float  mSelectedTextSize;

    private boolean mDrawHighlight;

    public TextViewWithHighlightIndicator(Context context, AttributeSet attrs) {
        super(context, attrs);
        Resources res = context.getResources();
        mHighlightColor = Utils.getThemeAccentColor(context);
        mItemIsSelectedText = context.getResources().getString(R.string.item_is_selected);
        mDefaultTextSize = getTextSize();
        mSelectedTextSize = res.getDimension(R.dimen.year_label_selected_text_size);
    }

    public void drawIndicator(boolean drawHighlight) {
        mDrawHighlight = drawHighlight;
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        setTextColor(mDrawHighlight ? mHighlightColor : mDefaultTextColor);
        setTextSize(TypedValue.COMPLEX_UNIT_PX, mDrawHighlight ? mSelectedTextSize : mDefaultTextSize);
    }

    @Override
    public CharSequence getContentDescription() {
        CharSequence itemText = getText();
        if (mDrawHighlight) {
            return String.format(mItemIsSelectedText, itemText);
        } else {
            return itemText;
        }
    }

}

@@ -144,16 +144,75 @@
 Canvas;%0A
+import android.graphics.Typeface;%0Aimport android.os.Build;%0A
 import a
@@ -237,16 +237,16 @@
 uteSet;%0A
-
 import a
@@ -595,16 +595,626 @@
 ator %7B%0A%0A
+    // --------------------------------------------------------------------------------------------%0A    // TODO: Consider moving this to Utils so other classes may make use of the light typeface.%0A    private static final Typeface HIGHLIGHT_TYPEFACE;%0A%0A    static %7B%0A        if (Build.VERSION.SDK_INT %3E= Build.VERSION_CODES.JELLY_BEAN) %7B%0A            HIGHLIGHT_TYPEFACE = Typeface.create(%22sans-serif-light%22, Typeface.BOLD);%0A        %7D else %7B%0A            HIGHLIGHT_TYPEFACE = Typeface.DEFAULT_BOLD;%0A        %7D%0A    %7D%0A    // --------------------------------------------------------------------------------------------%0A%0A
     priv
@@ -2130,16 +2130,16 @@
 Color);%0A
-
         
@@ -2230,24 +2230,101 @@
 tTextSize);%0A
+        setTypeface(mDrawHighlight ? HIGHLIGHT_TYPEFACE : Typeface.DEFAULT);%0A
     %7D%0A%0A    @

Use bold typeface for selected year indicator