respecting the underline parameter by only applying an underline when it's set

- updates the default value to true and that was the existing intentional behaviour
This commit is contained in:
Adam Brown 2022-01-10 11:57:05 +00:00
parent b6ff6aa4cc
commit 00bbede802

View file

@ -82,7 +82,7 @@ fun TextView.setTextWithColoredPart(@StringRes fullTextRes: Int,
fun TextView.setTextWithColoredPart(fullText: String, fun TextView.setTextWithColoredPart(fullText: String,
coloredPart: String, coloredPart: String,
@AttrRes colorAttribute: Int = R.attr.colorPrimary, @AttrRes colorAttribute: Int = R.attr.colorPrimary,
underline: Boolean = false, underline: Boolean = true,
onClick: (() -> Unit)? = null) { onClick: (() -> Unit)? = null) {
val color = ThemeUtils.getColor(context, colorAttribute) val color = ThemeUtils.getColor(context, colorAttribute)
@ -101,7 +101,6 @@ fun TextView.setTextWithColoredPart(fullText: String,
override fun updateDrawState(ds: TextPaint) { override fun updateDrawState(ds: TextPaint) {
ds.color = color ds.color = color
ds.isUnderlineText = !underline
} }
} }
setSpan(clickableSpan, index, index + coloredPart.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) setSpan(clickableSpan, index, index + coloredPart.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)