From d43a200e8f0769ed909dacc9eeeca17038f14112 Mon Sep 17 00:00:00 2001 From: Tobias Preuss Date: Wed, 10 Jan 2024 14:30:43 +0100 Subject: [PATCH] Display session subtitle as title if the latter is empty. + Improves the rendering of Engelsystem shifts where the "title" property is empty while the "name" (locationName) property has been set. --- .../dataconverters/SessionExtensions.kt | 4 ++++ .../dataconverters/SessionExtensionsTest.kt | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/app/src/main/java/nerd/tuxmobil/fahrplan/congress/dataconverters/SessionExtensions.kt b/app/src/main/java/nerd/tuxmobil/fahrplan/congress/dataconverters/SessionExtensions.kt index a15ab9ebde..e8f40469cf 100644 --- a/app/src/main/java/nerd/tuxmobil/fahrplan/congress/dataconverters/SessionExtensions.kt +++ b/app/src/main/java/nerd/tuxmobil/fahrplan/congress/dataconverters/SessionExtensions.kt @@ -164,6 +164,10 @@ fun SessionNetworkModel.toSessionAppModel(): Session { } fun Session.sanitize(): Session { + if (title.isEmpty() && subtitle.isNotEmpty()) { + title = subtitle + subtitle = "" + } if (title == subtitle) { subtitle = "" } diff --git a/app/src/test/java/nerd/tuxmobil/fahrplan/congress/dataconverters/SessionExtensionsTest.kt b/app/src/test/java/nerd/tuxmobil/fahrplan/congress/dataconverters/SessionExtensionsTest.kt index b5620f5a4f..993ac1bf30 100644 --- a/app/src/test/java/nerd/tuxmobil/fahrplan/congress/dataconverters/SessionExtensionsTest.kt +++ b/app/src/test/java/nerd/tuxmobil/fahrplan/congress/dataconverters/SessionExtensionsTest.kt @@ -196,6 +196,19 @@ class SessionExtensionsTest { assertThat(session.toHighlightDatabaseModel()).isEqualTo(highlight) } + @Test + fun sanitizeWithEmptyTitleAndSubtitle() { + val session = Session("").apply { + subtitle = "Lorem ipsum" + title = "" + }.sanitize() + val expected = Session("").apply { + subtitle = "" + title = "Lorem ipsum" + } + assertThat(session).isEqualTo(expected) + } + @Test fun sanitizeWithSameTitleAndSubtitle() { val session = Session("").apply { @@ -271,10 +284,12 @@ class SessionExtensionsTest { val session = Session("").apply { speakers = listOf("Luke Skywalker") subtitle = "Luke Skywalker" + title = "Some title" }.sanitize() val expected = Session("").apply { speakers = listOf("Luke Skywalker") subtitle = "" + title = "Some title" } assertThat(session).isEqualTo(expected) } @@ -284,10 +299,12 @@ class SessionExtensionsTest { val session = Session("").apply { speakers = listOf("Darth Vader") subtitle = "Lorem ipsum" + title = "Some title" }.sanitize() val expected = Session("").apply { speakers = listOf("Darth Vader") subtitle = "Lorem ipsum" + title = "Some title" } assertThat(session).isEqualTo(expected) }