Search in sources :

Example 31 with QuoteSpan

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

the class HtmlToSpannedConverter method withinDiv.

private static void withinDiv(StringBuilder out, Spanned text, int start, int end, int option) {
    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, option);
        for (QuoteSpan quote : quotes) {
            out.append("</blockquote>\n");
        }
    }
}
Also used : QuoteSpan(android.text.style.QuoteSpan)

Example 32 with QuoteSpan

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

the class HtmlToSpannedConverter method withinDiv.

private static void withinDiv(StringBuilder out, Spanned text, int start, int end, int option) {
    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, option);
        for (QuoteSpan quote : quotes) {
            out.append("</blockquote>\n");
        }
    }
}
Also used : QuoteSpan(android.text.style.QuoteSpan)

Example 33 with QuoteSpan

use of android.text.style.QuoteSpan in project BBS-Android by bdpqchen.

the class QuoteReplaceUtil method replaceQuoteSpans.

public static void replaceQuoteSpans(Spannable spannable) {
    QuoteSpan[] quoteSpans = spannable.getSpans(0, spannable.length(), QuoteSpan.class);
    for (QuoteSpan quoteSpan : quoteSpans) {
        int start = spannable.getSpanStart(quoteSpan);
        int end = spannable.getSpanEnd(quoteSpan);
        int flags = spannable.getSpanFlags(quoteSpan);
        spannable.removeSpan(quoteSpan);
        spannable.setSpan(new CustomQuoteSpan(Color.parseColor("#EFF0F1"), Color.parseColor("#EFF0F1"), 16, 4), start, end, flags);
    }
}
Also used : QuoteSpan(android.text.style.QuoteSpan)

Example 34 with QuoteSpan

use of android.text.style.QuoteSpan in project RespawnIRC-Android by FranckRJ.

the class JVCTopicAdapter method replaceNeededSpansAndEmojis.

private CharSequence replaceNeededSpansAndEmojis(Spanned spanToChange, final JVCParser.MessageInfos infosOfMessage) {
    Spannable spannable = new SpannableString(spanToChange);
    QuoteSpan[] quoteSpanArray = spannable.getSpans(0, spannable.length(), QuoteSpan.class);
    for (QuoteSpan quoteSpan : quoteSpanArray) {
        Utils.replaceSpanByAnotherSpan(spannable, quoteSpan, new CustomQuoteSpan(ThemeManager.getColorInt(R.attr.themedQuoteBackgroundColor, parentActivity), ThemeManager.getColorInt(R.attr.colorPrimary, parentActivity), parentActivity.getResources().getDimensionPixelSize(R.dimen.quoteStripSize), parentActivity.getResources().getDimensionPixelSize(R.dimen.quoteStripGap)));
    }
    URLSpan[] urlSpanArray = spannable.getSpans(0, spannable.length(), URLSpan.class);
    for (final URLSpan urlSpan : urlSpanArray) {
        Utils.replaceSpanByAnotherSpan(spannable, urlSpan, new LongClickableSpan() {

            @Override
            public void onClick(View view) {
                if (urlCLickedListener != null) {
                    urlCLickedListener.getClickedURL(urlSpan.getURL(), false);
                }
            }

            @Override
            public void onLongClick(View v) {
                if (urlCLickedListener != null) {
                    urlCLickedListener.getClickedURL(urlSpan.getURL(), true);
                }
            }
        });
    }
    HoldingStringSpan[] holdingStringSpanArray = spannable.getSpans(0, spannable.length(), HoldingStringSpan.class);
    for (final HoldingStringSpan holdingStringSpan : holdingStringSpanArray) {
        Utils.replaceSpanByAnotherSpan(spannable, holdingStringSpan, new ClickableSpan() {

            @Override
            public void onClick(View view) {
                updateListOfSpoidIdToShow(infosOfMessage, holdingStringSpan.getString());
            }

            @Override
            public void updateDrawState(TextPaint ds) {
            // rien
            }
        });
    }
    return Utils.applyEmojiCompatIfPossible(spannable);
}
Also used : HoldingStringSpan(com.franckrj.respawnirc.utils.HoldingStringSpan) LongClickableSpan(com.franckrj.respawnirc.utils.LongClickableSpan) QuoteSpan(android.text.style.QuoteSpan) URLSpan(android.text.style.URLSpan) ImageView(android.widget.ImageView) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) ClickableSpan(android.text.style.ClickableSpan) LongClickableSpan(com.franckrj.respawnirc.utils.LongClickableSpan) TextPaint(android.text.TextPaint) SpannableString(android.text.SpannableString) Spannable(android.text.Spannable)

Example 35 with QuoteSpan

use of android.text.style.QuoteSpan in project Android-Rich-text-Editor by chinalwb.

the class AREditText method onSelectionChanged.

/*
	 * ----------------------------------------- * Rich Text Style Area
	 * -----------------------------------------
	 */
@Override
public void onSelectionChanged(int selStart, int selEnd) {
    if (sToolbar == null) {
        return;
    }
    Util.log(" on Selection changed == " + this);
    boolean boldExists = false;
    boolean italicsExists = false;
    boolean underlinedExists = false;
    boolean striketrhoughExists = false;
    boolean backgroundColorExists = false;
    boolean quoteExists = false;
    // 
    // Two cases:
    // 1. Selection is just a pure cursor
    // 2. Selection is a range
    Editable editable = this.getEditableText();
    if (selStart > 0 && selStart == selEnd) {
        CharacterStyle[] styleSpans = editable.getSpans(selStart - 1, selStart, CharacterStyle.class);
        for (int i = 0; i < styleSpans.length; i++) {
            if (styleSpans[i] instanceof StyleSpan) {
                if (((StyleSpan) styleSpans[i]).getStyle() == android.graphics.Typeface.BOLD) {
                    boldExists = true;
                } else if (((StyleSpan) styleSpans[i]).getStyle() == android.graphics.Typeface.ITALIC) {
                    italicsExists = true;
                } else if (((StyleSpan) styleSpans[i]).getStyle() == android.graphics.Typeface.BOLD_ITALIC) {
                // TODO
                }
            } else if (styleSpans[i] instanceof AreUnderlineSpan) {
                underlinedExists = true;
            } else if (styleSpans[i] instanceof StrikethroughSpan) {
                striketrhoughExists = true;
            } else if (styleSpans[i] instanceof BackgroundColorSpan) {
                backgroundColorExists = true;
            }
        }
        QuoteSpan[] quoteSpans = editable.getSpans(selStart - 1, selStart, QuoteSpan.class);
        if (quoteSpans != null && quoteSpans.length > 0) {
            quoteExists = true;
        }
    // To check Quote!!
    } else {
        // 
        // Selection is a range
        CharacterStyle[] styleSpans = editable.getSpans(selStart, selEnd, CharacterStyle.class);
        for (int i = 0; i < styleSpans.length; i++) {
            if (styleSpans[i] instanceof StyleSpan) {
                if (((StyleSpan) styleSpans[i]).getStyle() == android.graphics.Typeface.BOLD) {
                    if (editable.getSpanStart(styleSpans[i]) <= selStart && editable.getSpanEnd(styleSpans[i]) >= selEnd) {
                        boldExists = true;
                    }
                } else if (((StyleSpan) styleSpans[i]).getStyle() == android.graphics.Typeface.ITALIC) {
                    if (editable.getSpanStart(styleSpans[i]) <= selStart && editable.getSpanEnd(styleSpans[i]) >= selEnd) {
                        italicsExists = true;
                    }
                } else if (((StyleSpan) styleSpans[i]).getStyle() == android.graphics.Typeface.BOLD_ITALIC) {
                    if (editable.getSpanStart(styleSpans[i]) <= selStart && editable.getSpanEnd(styleSpans[i]) >= selEnd) {
                        italicsExists = true;
                        boldExists = true;
                    }
                }
            } else if (styleSpans[i] instanceof AreUnderlineSpan) {
                if (editable.getSpanStart(styleSpans[i]) <= selStart && editable.getSpanEnd(styleSpans[i]) >= selEnd) {
                    underlinedExists = true;
                }
            } else if (styleSpans[i] instanceof StrikethroughSpan) {
                if (editable.getSpanStart(styleSpans[i]) <= selStart && editable.getSpanEnd(styleSpans[i]) >= selEnd) {
                    striketrhoughExists = true;
                }
            } else if (styleSpans[i] instanceof BackgroundColorSpan) {
                if (editable.getSpanStart(styleSpans[i]) <= selStart && editable.getSpanEnd(styleSpans[i]) >= selEnd) {
                    backgroundColorExists = true;
                }
            }
        }
    }
    QuoteSpan[] quoteSpans = editable.getSpans(selStart, selEnd, QuoteSpan.class);
    if (quoteSpans != null && quoteSpans.length > 0) {
        if (editable.getSpanStart(quoteSpans[0]) <= selStart && editable.getSpanEnd(quoteSpans[0]) >= selEnd) {
            quoteExists = true;
        }
    }
    // 
    // Set style checked status
    ARE_Helper.updateCheckStatus(sToolbar.getBoldStyle(), boldExists);
    ARE_Helper.updateCheckStatus(sToolbar.getItalicStyle(), italicsExists);
    ARE_Helper.updateCheckStatus(sToolbar.getUnderlineStyle(), underlinedExists);
    ARE_Helper.updateCheckStatus(sToolbar.getStrikethroughStyle(), striketrhoughExists);
    ARE_Helper.updateCheckStatus(sToolbar.getBackgroundColoStyle(), backgroundColorExists);
    ARE_Helper.updateCheckStatus(sToolbar.getQuoteStyle(), quoteExists);
}
Also used : AreUnderlineSpan(com.chinalwb.are.spans.AreUnderlineSpan) StyleSpan(android.text.style.StyleSpan) Editable(android.text.Editable) QuoteSpan(android.text.style.QuoteSpan) CharacterStyle(android.text.style.CharacterStyle) BackgroundColorSpan(android.text.style.BackgroundColorSpan) StrikethroughSpan(android.text.style.StrikethroughSpan)

Aggregations

QuoteSpan (android.text.style.QuoteSpan)39 StyleSpan (android.text.style.StyleSpan)9 StrikethroughSpan (android.text.style.StrikethroughSpan)7 RelativeSizeSpan (android.text.style.RelativeSizeSpan)6 TypefaceSpan (android.text.style.TypefaceSpan)6 SpannableStringBuilder (android.text.SpannableStringBuilder)5 SubscriptSpan (android.text.style.SubscriptSpan)5 SuperscriptSpan (android.text.style.SuperscriptSpan)5 ForegroundColorSpan (android.text.style.ForegroundColorSpan)4 URLSpan (android.text.style.URLSpan)4 UnderlineSpan (android.text.style.UnderlineSpan)4 TextView (android.widget.TextView)3 WPHtmlTagHandler (org.wordpress.android.util.helpers.WPHtmlTagHandler)3 WPQuoteSpan (org.wordpress.android.util.helpers.WPQuoteSpan)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