Search in sources :

Example 16 with UnderlineSpan

use of android.text.style.UnderlineSpan in project MyDiary by erttyy8821.

the class NoEntriesDialogFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    this.getDialog().setCanceledOnTouchOutside(true);
    getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    View rootView = inflater.inflate(R.layout.dialog_fragment_no_entries, container);
    TV_no_entries_create = (TextView) rootView.findViewById(R.id.TV_no_entries_create);
    TV_no_entries_create.setOnClickListener(this);
    SpannableString content = new SpannableString(TV_no_entries_create.getText());
    content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
    TV_no_entries_create.setText(content);
    TV_no_entries_create.setTextColor(ThemeManager.getInstance().getThemeMainColor(getActivity()));
    return rootView;
}
Also used : SpannableString(android.text.SpannableString) ColorDrawable(android.graphics.drawable.ColorDrawable) TextView(android.widget.TextView) View(android.view.View) UnderlineSpan(android.text.style.UnderlineSpan) Nullable(android.support.annotation.Nullable)

Example 17 with UnderlineSpan

use of android.text.style.UnderlineSpan in project ExoPlayer by google.

the class WebvttCueParserTest method testParseStrictValidClassesAndTrailingTokens.

public void testParseStrictValidClassesAndTrailingTokens() throws Exception {
    Spanned text = parseCueText("<v.first.loud Esme>" + "This <u.style1.style2 some stuff>is</u> text with <b.foo><i.bar>html</i></b> tags");
    assertEquals("This is text with html tags", text.toString());
    UnderlineSpan[] underlineSpans = getSpans(text, UnderlineSpan.class);
    StyleSpan[] styleSpans = getSpans(text, StyleSpan.class);
    assertEquals(1, underlineSpans.length);
    assertEquals(2, styleSpans.length);
    assertEquals(Typeface.ITALIC, styleSpans[0].getStyle());
    assertEquals(Typeface.BOLD, styleSpans[1].getStyle());
    assertEquals(5, text.getSpanStart(underlineSpans[0]));
    assertEquals(7, text.getSpanEnd(underlineSpans[0]));
    assertEquals(18, text.getSpanStart(styleSpans[0]));
    assertEquals(18, text.getSpanStart(styleSpans[1]));
    assertEquals(22, text.getSpanEnd(styleSpans[0]));
    assertEquals(22, text.getSpanEnd(styleSpans[1]));
}
Also used : StyleSpan(android.text.style.StyleSpan) Spanned(android.text.Spanned) UnderlineSpan(android.text.style.UnderlineSpan)

Example 18 with UnderlineSpan

use of android.text.style.UnderlineSpan in project ExoPlayer by google.

the class WebvttCueParserTest method testParseWellFormedUnclosedEndAtCueEnd.

public void testParseWellFormedUnclosedEndAtCueEnd() throws Exception {
    Spanned text = parseCueText("An <u some trailing stuff>unclosed u tag with " + "<i>italic</i> inside");
    assertEquals("An unclosed u tag with italic inside", text.toString());
    UnderlineSpan[] underlineSpans = getSpans(text, UnderlineSpan.class);
    StyleSpan[] styleSpans = getSpans(text, StyleSpan.class);
    assertEquals(1, underlineSpans.length);
    assertEquals(1, styleSpans.length);
    assertEquals(Typeface.ITALIC, styleSpans[0].getStyle());
    assertEquals(3, text.getSpanStart(underlineSpans[0]));
    assertEquals(23, text.getSpanStart(styleSpans[0]));
    assertEquals(29, text.getSpanEnd(styleSpans[0]));
    assertEquals(36, text.getSpanEnd(underlineSpans[0]));
}
Also used : StyleSpan(android.text.style.StyleSpan) Spanned(android.text.Spanned) UnderlineSpan(android.text.style.UnderlineSpan)

Example 19 with UnderlineSpan

use of android.text.style.UnderlineSpan in project ExoPlayer by google.

the class WebvttCueParserTest method testParseMalformedNestedElements.

public void testParseMalformedNestedElements() throws Exception {
    Spanned text = parseCueText("<b><u>An unclosed u tag with <i>italic</u> inside</i></b>");
    assertEquals("An unclosed u tag with italic inside", text.toString());
    UnderlineSpan[] underlineSpans = getSpans(text, UnderlineSpan.class);
    StyleSpan[] styleSpans = getSpans(text, StyleSpan.class);
    assertEquals(1, underlineSpans.length);
    assertEquals(2, styleSpans.length);
    // all tags applied until matching start tag found
    assertEquals(0, text.getSpanStart(underlineSpans[0]));
    assertEquals(29, text.getSpanEnd(underlineSpans[0]));
    if (styleSpans[0].getStyle() == Typeface.BOLD) {
        assertEquals(0, text.getSpanStart(styleSpans[0]));
        assertEquals(23, text.getSpanStart(styleSpans[1]));
        assertEquals(29, text.getSpanEnd(styleSpans[1]));
        assertEquals(36, text.getSpanEnd(styleSpans[0]));
    } else {
        assertEquals(0, text.getSpanStart(styleSpans[1]));
        assertEquals(23, text.getSpanStart(styleSpans[0]));
        assertEquals(29, text.getSpanEnd(styleSpans[0]));
        assertEquals(36, text.getSpanEnd(styleSpans[1]));
    }
}
Also used : StyleSpan(android.text.style.StyleSpan) Spanned(android.text.Spanned) UnderlineSpan(android.text.style.UnderlineSpan)

Example 20 with UnderlineSpan

use of android.text.style.UnderlineSpan in project ExoPlayer by google.

the class WebvttCueParserTest method testParseWellFormedUnclosedEndAtParent.

public void testParseWellFormedUnclosedEndAtParent() throws Exception {
    Spanned text = parseCueText("An unclosed u tag with <i><u>underline and italic</i> inside");
    assertEquals("An unclosed u tag with underline and italic inside", text.toString());
    UnderlineSpan[] underlineSpans = getSpans(text, UnderlineSpan.class);
    StyleSpan[] styleSpans = getSpans(text, StyleSpan.class);
    assertEquals(1, underlineSpans.length);
    assertEquals(1, styleSpans.length);
    assertEquals(23, text.getSpanStart(underlineSpans[0]));
    assertEquals(23, text.getSpanStart(styleSpans[0]));
    assertEquals(43, text.getSpanEnd(underlineSpans[0]));
    assertEquals(43, text.getSpanEnd(styleSpans[0]));
    assertEquals(Typeface.ITALIC, styleSpans[0].getStyle());
}
Also used : StyleSpan(android.text.style.StyleSpan) Spanned(android.text.Spanned) UnderlineSpan(android.text.style.UnderlineSpan)

Aggregations

UnderlineSpan (android.text.style.UnderlineSpan)34 StyleSpan (android.text.style.StyleSpan)16 ForegroundColorSpan (android.text.style.ForegroundColorSpan)13 BackgroundColorSpan (android.text.style.BackgroundColorSpan)11 ImageSpan (android.text.style.ImageSpan)10 URLSpan (android.text.style.URLSpan)9 TextView (android.widget.TextView)9 SpannableStringBuilder (android.text.SpannableStringBuilder)8 StrikethroughSpan (android.text.style.StrikethroughSpan)8 SubscriptSpan (android.text.style.SubscriptSpan)8 SuperscriptSpan (android.text.style.SuperscriptSpan)8 TypefaceSpan (android.text.style.TypefaceSpan)8 View (android.view.View)8 SpannableString (android.text.SpannableString)7 AbsoluteSizeSpan (android.text.style.AbsoluteSizeSpan)7 RelativeSizeSpan (android.text.style.RelativeSizeSpan)7 LinearLayout (android.widget.LinearLayout)7 Application (android.app.Application)5 CharacterStyle (android.text.style.CharacterStyle)5 SuggestionSpan (android.text.style.SuggestionSpan)5