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");
}
}
}
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");
}
}
}
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);
}
}
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);
}
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);
}
Aggregations