From 0063ab02e664114fdb2e6b37aa6fea6810cfc1be Mon Sep 17 00:00:00 2001 From: denizk0461 Date: Fri, 12 Jan 2024 17:06:53 +0100 Subject: [PATCH] Edited opening hours retriever to display links --- .../main/java/com/denizk0461/weserplaner/data/StwParser.kt | 5 +++-- .../main/java/com/denizk0461/weserplaner/sheet/TextSheet.kt | 5 +++-- build.gradle.kts | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/denizk0461/weserplaner/data/StwParser.kt b/app/src/main/java/com/denizk0461/weserplaner/data/StwParser.kt index 65f31fa..b7a3147 100644 --- a/app/src/main/java/com/denizk0461/weserplaner/data/StwParser.kt +++ b/app/src/main/java/com/denizk0461/weserplaner/data/StwParser.kt @@ -452,7 +452,8 @@ class StwParser(application: Application) { result = result.replace("

", "\n") // Remove all other characters - return result.replace(Regex(""), "") + // 'a' is excluded to avoid removing the tags + return result.replace(Regex(""), "") } /** @@ -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}
" } } } diff --git a/app/src/main/java/com/denizk0461/weserplaner/sheet/TextSheet.kt b/app/src/main/java/com/denizk0461/weserplaner/sheet/TextSheet.kt index f95648d..9f2fbe9 100644 --- a/app/src/main/java/com/denizk0461/weserplaner/sheet/TextSheet.kt +++ b/app/src/main/java/com/denizk0461/weserplaner/sheet/TextSheet.kt @@ -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( diff --git a/build.gradle.kts b/build.gradle.kts index 4cb48c3..99ce78a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id("com.android.application") version "8.1.0" apply false - id("com.android.library") version "8.1.0" apply false + id("com.android.application") version "8.1.2" apply false + id("com.android.library") version "8.1.2" apply false id("org.jetbrains.kotlin.android") version "1.8.21" apply false } \ No newline at end of file