Edited opening hours retriever to display links

This commit is contained in:
denizk0461
2024-01-12 17:06:53 +01:00
parent c78e18b03c
commit 0063ab02e6
3 changed files with 8 additions and 6 deletions
@@ -452,7 +452,8 @@ class StwParser(application: Application) {
result = result.replace("</p>", "\n")
// Remove all other characters
return result.replace(Regex("</?[a-zA-Z0-9]+>"), "")
// 'a' is excluded to avoid removing the <a> tags
return result.replace(Regex("</?[c-zA-Z0-9]+>"), "")
}
/**
@@ -492,7 +493,7 @@ class StwParser(application: Application) {
// Confirm that this line only contains information for the opening hours
if (!line.contains("Catering")) {
// Add the line to the opening hours
openingHours += "${line}\n"
openingHours += "${line}<br>"
}
}
}
@@ -55,9 +55,10 @@ class TextSheet : AppSheet(R.layout.sheet_text) {
binding.textHeader.text = getString(
R.string.text_sheet_opening_hours_title, canteen.canteen
)
binding.textContent.text = canteen.openingHours.ifBlank {
binding.textContent.text = Html.fromHtml(canteen.openingHours.ifBlank {
getString(R.string.text_sheet_opening_hours_empty)
}
}, HtmlCompat.FROM_HTML_MODE_LEGACY)
binding.textContent.movementMethod = LinkMovementMethod.getInstance()
}
TextSheetContentId.NEWS -> {
binding.textHeader.text = getString(