MCPcopy Create free account
hub / github.com/M66B/FairEmail / withinParagraph

Method withinParagraph

app/src/main/java/eu/faircode/email/HtmlEx.java:376–547  ·  view source on GitHub ↗
(StringBuilder out, Spanned text, int start, int end)

Source from the content-addressed store, hash-verified

374 }
375
376 private /* static */ void withinParagraph(StringBuilder out, Spanned text, int start, int end) {
377 int next;
378 for (int i = start; i < end; i = next) {
379 next = nextSpanTransition(text, i, end, CharacterStyle.class);
380 try {
381 CharacterStyle[] style = getSpans(text, i, next, CharacterStyle.class);
382
383 for (int j = 0; j < style.length; j++) {
384 if (style[j] instanceof StyleSpan) {
385 int s = ((StyleSpan) style[j]).getStyle();
386
387 if ((s & Typeface.BOLD) != 0) {
388 out.append("<b>");
389 }
390 if ((s & Typeface.ITALIC) != 0) {
391 out.append("<i>");
392 }
393 }
394 if (style[j] instanceof TypefaceSpan) {
395 String s = ((TypefaceSpan) style[j]).getFamily();
396
397 //if ("monospace".equals(s)) {
398 // out.append("<tt>");
399 //}
400
401 out.append("<span style='font-family:" + s + ";'>");
402 }
403 if (style[j] instanceof SuperscriptSpan) {
404 out.append("<sup>");
405 }
406 if (style[j] instanceof SubscriptSpan) {
407 out.append("<sub>");
408 }
409 if (style[j] instanceof UnderlineSpan) {
410 out.append("<u>");
411 }
412 if (style[j] instanceof StyleHelper.MarkSpan) {
413 out.append("<mark>");
414 }
415 if (style[j] instanceof StrikethroughSpan) {
416 out.append("<span style=\"text-decoration:line-through;\">");
417 }
418 if (style[j] instanceof URLSpan) {
419 out.append("<a href=\"");
420 out.append(((URLSpan) style[j]).getURL());
421 out.append("\">");
422 }
423 if (style[j] instanceof AbsoluteSizeSpan) {
424 AbsoluteSizeSpan s = ((AbsoluteSizeSpan) style[j]);
425 float sizeDip = s.getSize();
426 if (!s.getDip()) {
427 //Application application = ActivityThread.currentApplication();
428 sizeDip /= context.getResources().getDisplayMetrics().density;
429 }
430
431 // px in CSS is the equivalance of dip in Android
432 out.append(String.format("<span style=\"font-size:%.0fpx\";>", sizeDip));
433 }

Callers 2

Calls 15

nextSpanTransitionMethod · 0.95
getSpansMethod · 0.95
getWidthMethod · 0.95
getHeightMethod · 0.95
withinStyleMethod · 0.95
eMethod · 0.95
getFamilyMethod · 0.80
encodeWebColorMethod · 0.80
getSourceMethod · 0.80
getSizeMethod · 0.65
appendMethod · 0.45
getURLMethod · 0.45

Tested by

no test coverage detected