fix link's too large hitbox (#916)

* fix link's too large hitbox (tuskyapp#846)

* Use zero width space instead of normal space.

* Add comment.

* Remove unnecessary Html.fromHtml
This commit is contained in:
kyori19 2018-11-13 07:07:47 +09:00 committed by Konrad Pozniak
parent 7a06ebffad
commit ecd4680696

View file

@ -113,6 +113,18 @@ public class LinkHelper {
} }
builder.removeSpan(span); builder.removeSpan(span);
builder.setSpan(customSpan, start, end, flags); builder.setSpan(customSpan, start, end, flags);
/* Add zero-width space after links in end of line to fix its too large hitbox.
* See also : https://github.com/tuskyapp/Tusky/issues/846
* https://github.com/tuskyapp/Tusky/pull/916 */
if(end >= builder.length()){
builder.insert(end, "\u200B");
} else {
if(builder.subSequence(end, end + 1).toString().equals("\n")){
builder.insert(end, "\u200B");
}
}
} }
view.setText(builder); view.setText(builder);
view.setLinksClickable(true); view.setLinksClickable(true);