Search in sources :

Example 1 with CustomQuoteSpan

use of me.ccrama.redditslide.Views.CustomQuoteSpan in project Slide by ccrama.

the class SpoilerRobotoTextView method replaceQuoteSpans.

/**
 * Replaces the blue line produced by <blockquote>s with something more visible
 *
 * @param spannable parsed comment text #fromHtml
 */
private void replaceQuoteSpans(Spannable spannable) {
    QuoteSpan[] quoteSpans = spannable.getSpans(0, spannable.length(), QuoteSpan.class);
    for (QuoteSpan quoteSpan : quoteSpans) {
        final int start = spannable.getSpanStart(quoteSpan);
        final int end = spannable.getSpanEnd(quoteSpan);
        final int flags = spannable.getSpanFlags(quoteSpan);
        spannable.removeSpan(quoteSpan);
        // If the theme is Light or Sepia, use a darker blue; otherwise, use a lighter blue
        final int barColor = ContextCompat.getColor(getContext(), SettingValues.currentTheme == 1 || SettingValues.currentTheme == 5 ? R.color.md_blue_600 : R.color.md_blue_400);
        final int BAR_WIDTH = 4;
        final int GAP = 5;
        spannable.setSpan(new CustomQuoteSpan(// bar color
        barColor, // bar width
        BAR_WIDTH, // bar + text gap
        GAP), start, end, flags);
    }
}
Also used : CustomQuoteSpan(me.ccrama.redditslide.Views.CustomQuoteSpan) QuoteSpan(android.text.style.QuoteSpan) CustomQuoteSpan(me.ccrama.redditslide.Views.CustomQuoteSpan) TextPaint(android.text.TextPaint)

Aggregations

TextPaint (android.text.TextPaint)1 QuoteSpan (android.text.style.QuoteSpan)1 CustomQuoteSpan (me.ccrama.redditslide.Views.CustomQuoteSpan)1