[UI] Add highlighting user mentions in changelog.

This commit is contained in:
Kuba Szczodrzyński 2021-04-05 21:02:49 +02:00
parent 02d60754b6
commit cd6951dcbb
No known key found for this signature in database
GPG Key ID: 70CB8A85BA1633CB

View File

@ -44,9 +44,14 @@ class ChangelogDialog(
val textView = TextView(activity)
textView.setPadding(24.dp, 24.dp, 24.dp, 0)
val text = app.assets.open("pl-changelog.html").bufferedReader().use {
var text = app.assets.open("pl-changelog.html").bufferedReader().use {
it.readText()
}
val commitsUrlPrefix = "https://github.com/szkolny-eu/szkolny-android/commits?author="
text = text.replace("""\[(.+?)]\(@([A-z0-9-]+)\)""".toRegex(), "<a href=\"$commitsUrlPrefix$2\">$1</a>")
text = text.replace("""\s@([A-z0-9-]+)""".toRegex(), " <a href=\"$commitsUrlPrefix$1\">@$1</a>")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
textView.text = Html.fromHtml(text)
}