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") result = result.replace("</p>", "\n")
// Remove all other characters // 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 // Confirm that this line only contains information for the opening hours
if (!line.contains("Catering")) { if (!line.contains("Catering")) {
// Add the line to the opening hours // 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( binding.textHeader.text = getString(
R.string.text_sheet_opening_hours_title, canteen.canteen 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) getString(R.string.text_sheet_opening_hours_empty)
} }, HtmlCompat.FROM_HTML_MODE_LEGACY)
binding.textContent.movementMethod = LinkMovementMethod.getInstance()
} }
TextSheetContentId.NEWS -> { TextSheetContentId.NEWS -> {
binding.textHeader.text = getString( binding.textHeader.text = getString(
+2 -2
View File
@@ -1,6 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins { plugins {
id("com.android.application") version "8.1.0" apply false id("com.android.application") version "8.1.2" apply false
id("com.android.library") version "8.1.0" apply false id("com.android.library") version "8.1.2" apply false
id("org.jetbrains.kotlin.android") version "1.8.21" apply false id("org.jetbrains.kotlin.android") version "1.8.21" apply false
} }