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

Method setColor

app/src/main/java/eu/faircode/email/StyleHelper.java:763–783  ·  view source on GitHub ↗
(EditText etBody, int start, int end, Integer color, boolean select)

Source from the content-addressed store, hash-verified

761 }
762
763 static void setColor(EditText etBody, int start, int end, Integer color, boolean select) {
764 Log.breadcrumb("style", "action", "color");
765
766 Editable edit = etBody.getText();
767 ForegroundColorSpan spans[] = edit.getSpans(start, end, ForegroundColorSpan.class);
768 for (ForegroundColorSpan span : spans) {
769 int s = edit.getSpanStart(span);
770 int e = edit.getSpanEnd(span);
771 int f = edit.getSpanFlags(span);
772 edit.removeSpan(span);
773 splitSpan(edit, start, end, s, e, f, false,
774 new ForegroundColorSpan(span.getForegroundColor()),
775 new ForegroundColorSpan(span.getForegroundColor()));
776 }
777
778 if (color != null)
779 edit.setSpan(new ForegroundColorSpan(color), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
780
781 etBody.setText(edit);
782 etBody.setSelection(select ? start : end, end);
783 }
784
785 static boolean selectFont(LifecycleOwner owner, View anchor, EditText etBody, int start, int end, boolean select) {
786 Log.breadcrumb("style", "action", "selectFont");

Callers 2

onClickMethod · 0.95
updateDrawStateMethod · 0.45

Calls 11

breadcrumbMethod · 0.95
splitSpanMethod · 0.95
setTextMethod · 0.65
getTextMethod · 0.45
getSpansMethod · 0.45
getSpanStartMethod · 0.45
getSpanEndMethod · 0.45
getSpanFlagsMethod · 0.45
removeSpanMethod · 0.45
setSpanMethod · 0.45
setSelectionMethod · 0.45

Tested by

no test coverage detected