Search in sources :

Example 1 with QuoteSpan

use of android.text.style.QuoteSpan in project android_frameworks_base by ParanoidAndroid.

the class HtmlToSpannedConverter method handleEndTag.

private void handleEndTag(String tag) {
    if (tag.equalsIgnoreCase("br")) {
        handleBr(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("p")) {
        handleP(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("div")) {
        handleP(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("strong")) {
        end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("b")) {
        end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("em")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("cite")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("dfn")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("i")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("big")) {
        end(mSpannableStringBuilder, Big.class, new RelativeSizeSpan(1.25f));
    } else if (tag.equalsIgnoreCase("small")) {
        end(mSpannableStringBuilder, Small.class, new RelativeSizeSpan(0.8f));
    } else if (tag.equalsIgnoreCase("font")) {
        endFont(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("blockquote")) {
        handleP(mSpannableStringBuilder);
        end(mSpannableStringBuilder, Blockquote.class, new QuoteSpan());
    } else if (tag.equalsIgnoreCase("tt")) {
        end(mSpannableStringBuilder, Monospace.class, new TypefaceSpan("monospace"));
    } else if (tag.equalsIgnoreCase("a")) {
        endA(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("u")) {
        end(mSpannableStringBuilder, Underline.class, new UnderlineSpan());
    } else if (tag.equalsIgnoreCase("sup")) {
        end(mSpannableStringBuilder, Super.class, new SuperscriptSpan());
    } else if (tag.equalsIgnoreCase("sub")) {
        end(mSpannableStringBuilder, Sub.class, new SubscriptSpan());
    } else if (tag.length() == 2 && Character.toLowerCase(tag.charAt(0)) == 'h' && tag.charAt(1) >= '1' && tag.charAt(1) <= '6') {
        handleP(mSpannableStringBuilder);
        endHeader(mSpannableStringBuilder);
    } else if (mTagHandler != null) {
        mTagHandler.handleTag(false, tag, mSpannableStringBuilder, mReader);
    }
}
Also used : SuperscriptSpan(android.text.style.SuperscriptSpan) RelativeSizeSpan(android.text.style.RelativeSizeSpan) QuoteSpan(android.text.style.QuoteSpan) UnderlineSpan(android.text.style.UnderlineSpan) StyleSpan(android.text.style.StyleSpan) SubscriptSpan(android.text.style.SubscriptSpan) TypefaceSpan(android.text.style.TypefaceSpan)

Example 2 with QuoteSpan

use of android.text.style.QuoteSpan in project android_frameworks_base by ParanoidAndroid.

the class HtmlToSpannedConverter method withinDiv.

private static void withinDiv(StringBuilder out, Spanned text, int start, int end) {
    int next;
    for (int i = start; i < end; i = next) {
        next = text.nextSpanTransition(i, end, QuoteSpan.class);
        QuoteSpan[] quotes = text.getSpans(i, next, QuoteSpan.class);
        for (QuoteSpan quote : quotes) {
            out.append("<blockquote>");
        }
        withinBlockquote(out, text, i, next);
        for (QuoteSpan quote : quotes) {
            out.append("</blockquote>\n");
        }
    }
}
Also used : QuoteSpan(android.text.style.QuoteSpan)

Example 3 with QuoteSpan

use of android.text.style.QuoteSpan in project android_frameworks_base by ParanoidAndroid.

the class HtmlTest method testBlockquote.

@SmallTest
public void testBlockquote() throws Exception {
    SpannableString s;
    s = new SpannableString("Hello world");
    s.setSpan(new QuoteSpan(), 0, s.length(), Spannable.SPAN_PARAGRAPH);
    assertEquals(Html.toHtml(s), "<blockquote><p>Hello world</p>\n</blockquote>\n");
    s = new SpannableString("Hello\n\nworld");
    s.setSpan(new QuoteSpan(), 0, 7, Spannable.SPAN_PARAGRAPH);
    assertEquals(Html.toHtml(s), "<blockquote><p>Hello</p>\n</blockquote>\n<p>world</p>\n");
}
Also used : QuoteSpan(android.text.style.QuoteSpan) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 4 with QuoteSpan

use of android.text.style.QuoteSpan in project XobotOS by xamarin.

the class HtmlToSpannedConverter method withinDiv.

private static void withinDiv(StringBuilder out, Spanned text, int start, int end) {
    int next;
    for (int i = start; i < end; i = next) {
        next = text.nextSpanTransition(i, end, QuoteSpan.class);
        QuoteSpan[] quotes = text.getSpans(i, next, QuoteSpan.class);
        for (QuoteSpan quote : quotes) {
            out.append("<blockquote>");
        }
        withinBlockquote(out, text, i, next);
        for (QuoteSpan quote : quotes) {
            out.append("</blockquote>\n");
        }
    }
}
Also used : QuoteSpan(android.text.style.QuoteSpan)

Example 5 with QuoteSpan

use of android.text.style.QuoteSpan in project android_frameworks_base by ResurrectionRemix.

the class HtmlToSpannedConverter method endBlockquote.

private static void endBlockquote(Editable text) {
    endBlockElement(text);
    end(text, Blockquote.class, new QuoteSpan());
}
Also used : QuoteSpan(android.text.style.QuoteSpan)

Aggregations

QuoteSpan (android.text.style.QuoteSpan)38 StyleSpan (android.text.style.StyleSpan)9 StrikethroughSpan (android.text.style.StrikethroughSpan)7 RelativeSizeSpan (android.text.style.RelativeSizeSpan)6 TypefaceSpan (android.text.style.TypefaceSpan)6 SubscriptSpan (android.text.style.SubscriptSpan)5 SuperscriptSpan (android.text.style.SuperscriptSpan)5 SpannableStringBuilder (android.text.SpannableStringBuilder)4 URLSpan (android.text.style.URLSpan)4 UnderlineSpan (android.text.style.UnderlineSpan)4 ForegroundColorSpan (android.text.style.ForegroundColorSpan)3 TextView (android.widget.TextView)3 WPUnderlineSpan (org.wordpress.android.util.helpers.WPUnderlineSpan)3 Spannable (android.text.Spannable)2 SpannableString (android.text.SpannableString)2 TextPaint (android.text.TextPaint)2 BackgroundColorSpan (android.text.style.BackgroundColorSpan)2 BulletSpan (android.text.style.BulletSpan)2 ImageSpan (android.text.style.ImageSpan)2 View (android.view.View)2