From 476235d9de3e91b584d8b4bef8e894e98a60f468 Mon Sep 17 00:00:00 2001 From: Lukasz Mastalerz Date: Fri, 14 Apr 2023 08:41:51 +0200 Subject: [PATCH] [CP-1939] Difference in displaying file name for list and for loop play function Fixed problem with displaying end of title when playing song in loop was selected. --- harmony_changelog.md | 1 + .../windows/RelaxationRunningLoopWindow.cpp | 22 ++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/harmony_changelog.md b/harmony_changelog.md index 453a9b6a2f829f65148f49eec2d532856782ef50..465e39c72991a854fc01ba127f9c96844474ca3e 100644 --- a/harmony_changelog.md +++ b/harmony_changelog.md @@ -14,6 +14,7 @@ * Fixed backlight behavior after returning to the main window * Fixed settings frontlight intensity in on demand mode * Fixed problem that UI could be occasionally broken +* Fixed problem with displaying end of title when playing song in loop was selected. ### Added diff --git a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningLoopWindow.cpp b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningLoopWindow.cpp index ffd10d1973c0f949dfe78770a41aa96de0379475..993ea15bc5ac2a982595bdfb977a9e599d8b73e0 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningLoopWindow.cpp +++ b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningLoopWindow.cpp @@ -17,6 +17,7 @@ namespace inline constexpr std::chrono::seconds timerTick{1}; inline constexpr units::SOC dischargingLevelShowTop = 20; inline constexpr units::SOC dischargingLowBattery = 10; + inline constexpr auto maxPossibleCharsToDisplay = 25U; bool isBatteryCharging(const Store::Battery::State state) { @@ -69,6 +70,17 @@ namespace battery->setVisible(false); return battery; } + + std::string adjustDisplayedTitle(const std::string &title) + { + if (title.length() <= maxPossibleCharsToDisplay) { + return title; + } + std::string newTittle = title.substr(0, maxPossibleCharsToDisplay - 2); + newTittle.append("..."); + + return newTittle; + } } // namespace namespace gui @@ -94,11 +106,11 @@ namespace gui } if (data && typeid(*data) == typeid(RelaxationSwitchData)) { - const auto battery = presenter->handleBatteryStatus(); - auto *audioSwitchData = static_cast(data); - audioContext = audioSwitchData->getAudioContext(); - title->setText(audioContext->getSound().tags.title); - if (battery.level > dischargingLowBattery) { + const auto batteryStatus = presenter->handleBatteryStatus(); + auto *audioSwitchData = static_cast(data); + audioContext = audioSwitchData->getAudioContext(); + title->setText(adjustDisplayedTitle(audioContext->getSound().tags.title)); + if (batteryStatus.level > dischargingLowBattery) { presenter->activate(audioContext->getSound()); } }