ClickableLinkSpan extends ClickableSpan implements HighlightedClickableSpan { @Override public void updateDrawState(TextPaint ds) { if (colored) { ds.setColor(linkColor); } else { ds.setColor(ds.linkColor); } if (selected) { ds.bgColor = selectedColor; } else { ds.bgColor = Color.TRANSPARENT; } if (underlined) { ds.setUnderlineText(true); } } ClickableLinkSpan(int selectedColor, int linkColor, boolean underlined);   ClickableLinkSpan(int selectedColor, int linkColor, boolean colored, boolean underlined); @Override void updateDrawState(TextPaint ds); @Override void select(boolean selected); @Override boolean isSelected(); final int linkColor; }
@Test public void testUpdateDrawState_shouldSetTextPaintDefaultColor() { clickableLinkSpan = new TestClickableLinkSpan(SELECTED_COLOR); clickableLinkSpan.updateDrawState(textPaint); verify(textPaint).setColor(textPaint.linkColor); assertEquals(Color.TRANSPARENT, textPaint.bgColor); }
@Test public void testUpdateDrawState_shouldSetTextPaintProvidedColor() { clickableLinkSpan = new TestClickableLinkSpan(SELECTED_COLOR, LINK_COLOR, false); clickableLinkSpan.updateDrawState(textPaint); verify(textPaint).setColor(LINK_COLOR); assertEquals(Color.TRANSPARENT, textPaint.bgColor); }
@Test public void testUpdateDrawState_shouldSetTextPaintUnderlined() { clickableLinkSpan = new TestClickableLinkSpan(SELECTED_COLOR, LINK_COLOR, true); clickableLinkSpan.updateDrawState(textPaint); verify(textPaint).setUnderlineText(true); assertEquals(Color.TRANSPARENT, textPaint.bgColor); }