From f90e5131b0ac0d299a716a55d31b00ffebfe9c5f Mon Sep 17 00:00:00 2001 From: Lukasz Mastalerz Date: Tue, 28 Feb 2023 17:05:31 +0100 Subject: [PATCH] [CP-1836] Lack of error handling for audio playback Added error handling for incorrect audio formats and corrupted files inside Relaxation app --- harmony_changelog.md | 43 +++++++++++- image/system_a/data/lang/Deutsch.json | 1 + image/system_a/data/lang/English.json | 1 + image/system_a/data/lang/Espanol.json | 1 + image/system_a/data/lang/Francais.json | 1 + image/system_a/data/lang/Polski.json | 1 + .../service-audio/AudioServiceAPI.cpp | 1 - products/BellHybrid/CMakeLists.txt | 4 +- .../ApplicationBellRelaxation.cpp | 9 ++- .../CMakeLists.txt | 24 ++++--- .../data/RelaxationStyle.hpp | 8 ++- .../ApplicationBellRelaxation.hpp | 3 +- .../presenter/RelaxationErrorPresenter.cpp | 23 +++++++ .../presenter/RelaxationErrorPresenter.hpp | 38 +++++++++++ .../RelaxationRunningLoopPresenter.cpp | 19 +++++- .../RelaxationRunningLoopPresenter.hpp | 3 +- .../RelaxationRunningProgressPresenter.cpp | 18 ++++- .../RelaxationRunningProgressPresenter.hpp | 3 +- .../windows/RelaxationErrorWindow.cpp | 68 +++++++++++++++++++ .../windows/RelaxationErrorWindow.hpp | 28 ++++++++ .../windows/RelaxationMainWindow.cpp | 2 +- .../windows/RelaxationRunningLoopWindow.cpp | 6 +- .../windows/RelaxationRunningLoopWindow.hpp | 3 +- .../RelaxationRunningProgressWindow.cpp | 7 +- .../RelaxationRunningProgressWindow.hpp | 3 +- products/BellHybrid/assets/assets_common.json | 4 +- 26 files changed, 291 insertions(+), 31 deletions(-) create mode 100644 products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationErrorPresenter.cpp create mode 100644 products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationErrorPresenter.hpp create mode 100644 products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationErrorWindow.cpp create mode 100644 products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationErrorWindow.hpp diff --git a/harmony_changelog.md b/harmony_changelog.md index 14ade3e08b3292e72b0d0ca3a0d07a89d52d198c..10a5d5df4888664a09794f586215f30876c0ba6b 100644 --- a/harmony_changelog.md +++ b/harmony_changelog.md @@ -3,6 +3,7 @@ ## Unreleased ### Fixed + * Fixed displayed device name when connected to Windows * Fixed the wrong front light on back action in alarms * Fixed the pause deactivation by a deep press in relaxation @@ -12,7 +13,10 @@ ### Added +* Added error handling for incorrect audio formats and corrupted files inside Relaxation app + ### Changed + * Added serial number and timestamp to crashdump filename ## [1.8.0 2022-12-14] @@ -20,37 +24,47 @@ ### Added #### Home Screen: + * Font size increased. * Clock faces with dates. #### General: + * Bedside lamp mode. #### UI/UX: + * Improve refreshing of the display. #### Onboarding + * Shortcuts instruction. #### Alarm + * Front light intensity during the main alarm and pre-wake up ### Changed #### Home Screen: + * Placement of battery and time format indicators. #### Relaxation: + * New circular progress bar * Add loop mode ### Fixed + * Brightness calculation for alarms #### Home Screen: + * Centering of battery indicator. #### Settings: + * Incorrect time format of the alarm in clock face settings. ## [1.7.0 2022-11-14] @@ -58,52 +72,65 @@ ### Added #### Home Screen: + * Battery status icon. #### Meditation: -* Option to see Meditation statistics from the last 7, 30, and 365 days. + +* Option to see Meditation statistics from the last 7, 30, and 365 days. * Preview a countdown before the Meditation starts. * New meditation progress layout. * Additional start delay interval - up to 90s. #### PowerNap: + * New circular progress bar * Ringing bell image at the end of the Power Nap #### Settings: + * Option to set date. ### Fixed #### Mudita Center: + * Fixed problem with errors while connecting the device to Mudita Center. #### Snooze: + * Fixed the problem with the alarm light flashing during snooze time. #### Bedtime reminder: + * Fixed an issue with not pausing music notifications at bedtime. #### Alarm: + * Fixed problem with wrong alarm status message when setting alarm from the menu. * Fixed the spelling of the titles of two soundtracks in the alarms application. * Fixed the issue with the welcome message not being displayed when the alarm is turned off. #### Meditation: + * Fixed view of diacritic signs. * Fixed resetting meditation settings with deep press. * Fixed an issue with saving meditation settings before going through the entire setup process. #### Relaxation: + * Fixed the navigation of the back button during relaxation. #### General: + * Fixed inconsistencies in welcome messages. #### UX/UI: + * Updated screens according to design. #### Translations: + * Fixed gaps in translations. ## [1.6.0 2022-06-14] @@ -111,18 +138,23 @@ ### Added #### Home Screen: + * Possibility to choose Clock Face from 8 options (3 for 24h format, 5 for 12h format). #### Meditation: + * Possibility to set a Meditation Timer start delay. #### UI/UX: + * UI update (Home Screen settings). #### Translations: + * Completed missing translations. ### Fixed + * Fixed problem with confirmation of language change action. * Fixed problem with mixed translations appearing after language change. * Fixed missing texts. @@ -136,6 +168,7 @@ ## [1.5.1 2022-04-07] ### Fixed + * Fixed issue with the device appearing in service mode when connected via USB. * Fixed problems with clock desynchronization. @@ -144,15 +177,18 @@ ### Added #### Settings: + * Ability to scroll between Harmony settings. * The order of alarm sounds has been defined. ### Changed / Improved + * The default alarm volume has been changed. * Updated alarm sounds. * The welcome screen has been updated. ### Fixed + * Fixed problem with Pre wake-up light. * Fixed problems with turning on the device despite high battery level. * Fixed problems with incorrect display of battery charge status. @@ -167,13 +203,17 @@ ## [1.4.0 2022-02-01] ### Added + #### General: + * Transportation mode. #### PowerNap: + * Add front light functionality to PowerNap app. ### Changed/Improved + #### UI/UX: * Changed exit screen with instruction to turn on. @@ -196,6 +236,7 @@ * Corrected mistakes in translations. ### Fixed + * Fixed errors in the translation of the incoming alarm message. * Fixed the operation of the alarm when using other alarm clock functions. * Fixed problem with the truncated relaxation screen. diff --git a/image/system_a/data/lang/Deutsch.json b/image/system_a/data/lang/Deutsch.json index dd31ae1b6b69fd4880536e45d85f18e65071865f..935b88c4e528914c4e3286dba63a5fa5c6b7577e 100644 --- a/image/system_a/data/lang/Deutsch.json +++ b/image/system_a/data/lang/Deutsch.json @@ -665,6 +665,7 @@ "app_bell_relaxation_loop": "endlos", "app_bell_relaxation_looped": "geschlungen", "app_bell_relaxation_loop_description": "der Titel wird abgespielt, bis Sie ihn ausschalten", + "app_bell_relaxation_error_message": "Nicht unterstütztes Dateiformat", "app_bell_onboarding_welcome_message": "Mudita Harmony
ist ausgeschaltet
", "app_bell_onboarding_info_rotate": "Drehen um auszuwählen", "app_bell_onboarding_info_light_click": "Leichter Klick um fortzufahren", diff --git a/image/system_a/data/lang/English.json b/image/system_a/data/lang/English.json index 9b930ff4a914a08aede2ba3ce9eb2c1f86eda3e3..3e6f0d4e2adb1aabef49a55051f670361636daa3 100644 --- a/image/system_a/data/lang/English.json +++ b/image/system_a/data/lang/English.json @@ -715,6 +715,7 @@ "app_bell_relaxation_loop": "loop", "app_bell_relaxation_looped": "looped", "app_bell_relaxation_loop_description": "the song will play until you turn it off", + "app_bell_relaxation_error_message": "Unsupported media type", "app_bell_turn_off_question": "Turn off Mudita Harmony?", "app_bell_goodbye": "Goodbye", "app_bell_reset_message": "Resetting Mudita
Harmony
", diff --git a/image/system_a/data/lang/Espanol.json b/image/system_a/data/lang/Espanol.json index 8c0dc7dbfe4c607ad9e5cfd6c3b0f2c5a2abfb4d..7c8c48881575640fe352c7159dc2f288791b94d5 100644 --- a/image/system_a/data/lang/Espanol.json +++ b/image/system_a/data/lang/Espanol.json @@ -682,6 +682,7 @@ "app_bell_relaxation_loop": "bucle", "app_bell_relaxation_looped": "en bucle", "app_bell_relaxation_loop_description": "la canción se reproducirá hasta que la apagues", + "app_bell_relaxation_error_message": "Formato de archivo no admitido", "app_bell_settings_home_view": "Vista de inicio", "app_bell_settings_alarm_settings": "Ajustes de alarma", "app_bell_settings_alarm_settings_title": "Ajustes de alarma", diff --git a/image/system_a/data/lang/Francais.json b/image/system_a/data/lang/Francais.json index 22efc4e7ed69b76fcf972c98e0efa744acd2a28b..f2f1a1f4c2c5899e96151ffb533420f07ceb2de2 100644 --- a/image/system_a/data/lang/Francais.json +++ b/image/system_a/data/lang/Francais.json @@ -653,6 +653,7 @@ "app_bell_relaxation_loop": "en boucle", "app_bell_relaxation_looped": "en boucle", "app_bell_relaxation_loop_description": "le morceau sera lu jusqu'à ce que vous l'éteigniez", + "app_bell_relaxation_error_message": "Format de fichier non pris en

charge
", "app_bell_settings_home_view": "Écran d'accueil", "app_bell_settings_alarm_settings": "Alarme", "app_bell_settings_alarm_settings_title": "Alarme", diff --git a/image/system_a/data/lang/Polski.json b/image/system_a/data/lang/Polski.json index 48056a353a62eaa18c646230f532a23f0501e3f8..c84641dcd34bf50577697f524432ba9904d0e865 100644 --- a/image/system_a/data/lang/Polski.json +++ b/image/system_a/data/lang/Polski.json @@ -705,6 +705,7 @@ "app_bell_relaxation_loop": "w pętli", "app_bell_relaxation_looped": "zapętlony", "app_bell_relaxation_loop_description": "utwór będzie odtwarzany do momentu wyłączenia go", + "app_bell_relaxation_error_message": "Nieobsługiwany format pliku", "app_bell_settings_alarm_settings_prewake_up": "Wstępne budzenie", "app_bell_settings_alarm_settings_prewake_up_chime_top_description": "Wstępne budzenie", "app_bell_settings_alarm_settings_prewake_up_chime_bottom_description": "przed alarmem", diff --git a/module-services/service-audio/AudioServiceAPI.cpp b/module-services/service-audio/AudioServiceAPI.cpp index 72920af49e1848fbba68378b3bf8300ff1e6cc7b..31391e4d1bbcd5c8877e9b0392d189adfcd4e902 100644 --- a/module-services/service-audio/AudioServiceAPI.cpp +++ b/module-services/service-audio/AudioServiceAPI.cpp @@ -249,5 +249,4 @@ namespace AudioServiceAPI { return serv->bus.sendUnicast(std::make_shared(volume), service::name::audio); } - } // namespace AudioServiceAPI diff --git a/products/BellHybrid/CMakeLists.txt b/products/BellHybrid/CMakeLists.txt index 69c3fd4a35c27fa5400cf71f44c659f4ac9f9af4..f5f7f3d51b64a67940b1d262f41aa4f51d81e474 100644 --- a/products/BellHybrid/CMakeLists.txt +++ b/products/BellHybrid/CMakeLists.txt @@ -142,14 +142,14 @@ download_asset_release_json(json-common-target ${CMAKE_CURRENT_SOURCE_DIR}/assets/assets_common.json ${SYSROOT_PATH}/system_a/ MuditaOSPublicAssets - 0.0.15 + 0.0.17 ${MUDITA_CACHE_DIR} ) download_asset_release_json(json-community-target ${CMAKE_CURRENT_SOURCE_DIR}/assets/assets_community.json ${SYSROOT_PATH}/system_a/ MuditaOSPublicAssets - 0.0.15 + 0.0.17 ${MUDITA_CACHE_DIR} ) download_asset_json(json-rt1051-target diff --git a/products/BellHybrid/apps/application-bell-relaxation/ApplicationBellRelaxation.cpp b/products/BellHybrid/apps/application-bell-relaxation/ApplicationBellRelaxation.cpp index c9c6132ea77cee06a5dcd7bfc64cf37e0af45f9a..677b6c7a34acb3323686e6d34668818ffd6494c2 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/ApplicationBellRelaxation.cpp +++ b/products/BellHybrid/apps/application-bell-relaxation/ApplicationBellRelaxation.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "ApplicationBellRelaxation.hpp" @@ -10,6 +10,7 @@ #include "presenter/RelaxationPausedPresenter.hpp" #include "presenter/RelaxationEndedPresenter.hpp" #include "presenter/RelaxationLowBatteryPresenter.hpp" +#include "presenter/RelaxationErrorPresenter.hpp" #include "windows/RelaxationMainWindow.hpp" #include "windows/RelaxationPausedWindow.hpp" #include "windows/RelaxationRunningProgressWindow.hpp" @@ -18,6 +19,7 @@ #include "windows/RelaxationVolumeWindow.hpp" #include "windows/RelaxationEndedWindow.hpp" #include "windows/RelaxationLowBatteryWindow.hpp" +#include "windows/RelaxationErrorWindow.hpp" #include "widgets/RelaxationPlayer.hpp" #include #include @@ -114,6 +116,11 @@ namespace app return std::make_unique(app, std::move(presenter)); }); + windowsFactory.attach(gui::window::name::relaxationError, [](ApplicationCommon *app, const std::string &name) { + auto presenter = std::make_unique(app); + return std::make_unique(app, std::move(presenter)); + }); + attachPopups({gui::popup::ID::AlarmActivated, gui::popup::ID::AlarmDeactivated, gui::popup::ID::PowerOff, diff --git a/products/BellHybrid/apps/application-bell-relaxation/CMakeLists.txt b/products/BellHybrid/apps/application-bell-relaxation/CMakeLists.txt index 63ac98b4b0332635b77a6c0db2df45cb89a78dac..36e2f434b74f753de8d0d1b6e01eb194e7f6f5c1 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/CMakeLists.txt +++ b/products/BellHybrid/apps/application-bell-relaxation/CMakeLists.txt @@ -2,16 +2,16 @@ add_library(application-bell-relaxation STATIC) add_library(bell::app-relaxation ALIAS application-bell-relaxation) target_include_directories(application-bell-relaxation - PRIVATE + PRIVATE $ - PUBLIC + PUBLIC $ -) + ) target_sources(application-bell-relaxation - PRIVATE + PRIVATE ApplicationBellRelaxation.cpp presenter/RelaxationMainWindowPresenter.cpp presenter/RelaxationRunningProgressPresenter.cpp @@ -21,6 +21,7 @@ target_sources(application-bell-relaxation presenter/RelaxationPausedPresenter.cpp presenter/RelaxationEndedPresenter.cpp presenter/RelaxationLowBatteryPresenter.cpp + presenter/RelaxationErrorPresenter.cpp widgets/RelaxationPlayer.cpp windows/RelaxationMainWindow.cpp windows/RelaxationPausedWindow.cpp @@ -30,6 +31,7 @@ target_sources(application-bell-relaxation windows/RelaxationVolumeWindow.cpp windows/RelaxationEndedWindow.cpp windows/RelaxationLowBatteryWindow.cpp + windows/RelaxationErrorWindow.cpp data/RelaxationCommon.hpp data/RelaxationStyle.hpp @@ -45,6 +47,7 @@ target_sources(application-bell-relaxation presenter/RelaxationPausedPresenter.hpp presenter/RelaxationEndedPresenter.hpp presenter/RelaxationLowBatteryPresenter.hpp + presenter/RelaxationErrorPresenter.cpp windows/RelaxationMainWindow.hpp windows/RelaxationPausedWindow.hpp windows/RelaxationRunningProgressWindow.hpp @@ -53,13 +56,14 @@ target_sources(application-bell-relaxation windows/RelaxationVolumeWindow.hpp windows/RelaxationEndedWindow.hpp windows/RelaxationLowBatteryWindow.hpp + windows/RelaxationErrorWindow.hpp - PUBLIC + PUBLIC include/application-bell-relaxation/ApplicationBellRelaxation.hpp -) + ) target_link_libraries(application-bell-relaxation - PRIVATE + PRIVATE apps-common bell::app-main bell::audio @@ -67,7 +71,7 @@ target_link_libraries(application-bell-relaxation bell::paths Microsoft.GSL::GSL - PUBLIC + PUBLIC module-gui bell::app-common -) + ) diff --git a/products/BellHybrid/apps/application-bell-relaxation/data/RelaxationStyle.hpp b/products/BellHybrid/apps/application-bell-relaxation/data/RelaxationStyle.hpp index 6550705cd85c12e5a2de442dae483cfe39fc9523..1912fb6fdf891f4fc0a6c30aa1a73e16164a9ef0 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/data/RelaxationStyle.hpp +++ b/products/BellHybrid/apps/application-bell-relaxation/data/RelaxationStyle.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -72,4 +72,10 @@ namespace gui::relaxationStyle } // namespace clock } // namespace relStyle + namespace error + { + constexpr inline auto imageMarginTop = 122U; + constexpr inline auto textPaddingTop = 30U; + } // namespace error + } // namespace gui::relaxationStyle diff --git a/products/BellHybrid/apps/application-bell-relaxation/include/application-bell-relaxation/ApplicationBellRelaxation.hpp b/products/BellHybrid/apps/application-bell-relaxation/include/application-bell-relaxation/ApplicationBellRelaxation.hpp index e62cb545ea4e76159849b427dc834a1cccfad280..37042895912e67bd8dfabe5342e578ba0dc46b34 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/include/application-bell-relaxation/ApplicationBellRelaxation.hpp +++ b/products/BellHybrid/apps/application-bell-relaxation/include/application-bell-relaxation/ApplicationBellRelaxation.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -16,6 +16,7 @@ namespace gui::window::name inline constexpr auto relaxationTimerSelect = "RelaxationTimerSelectWindow"; inline constexpr auto relaxationEnded = "RelaxationEndedWindow"; inline constexpr auto relaxationLowBattery = "RelaxationLowBatteryWindow"; + inline constexpr auto relaxationError = "RelaxationError"; } // namespace gui::window::name namespace app diff --git a/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationErrorPresenter.cpp b/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationErrorPresenter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c2126ee6a4aae7cb870f643e58382966ffa1ead9 --- /dev/null +++ b/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationErrorPresenter.cpp @@ -0,0 +1,23 @@ +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#include "presenter/RelaxationErrorPresenter.hpp" +#include "ApplicationBellRelaxation.hpp" + +#include +#include +#include + +namespace app::relaxation +{ + RelaxationErrorPresenter::RelaxationErrorPresenter(app::ApplicationCommon *app) : app{app} + {} + + void RelaxationErrorPresenter::activate() + { + app::manager::Controller::sendAction( + app, + app::manager::actions::Launch, + std::make_unique(app::applicationBellRelaxationName)); + } +} // namespace app::relaxation diff --git a/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationErrorPresenter.hpp b/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationErrorPresenter.hpp new file mode 100644 index 0000000000000000000000000000000000000000..3e7a6d6a6ed87841fe7f18a17e5a40cd9179f2dd --- /dev/null +++ b/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationErrorPresenter.hpp @@ -0,0 +1,38 @@ +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include + +namespace app +{ + class ApplicationCommon; +} + +namespace app::relaxation +{ + class RelaxationErrorContract + { + public: + class View + { + public: + virtual ~View() = default; + }; + class Presenter : public BasePresenter + { + public: + virtual void activate() = 0; + }; + }; + + class RelaxationErrorPresenter : public RelaxationErrorContract::Presenter + { + app::ApplicationCommon *app{}; + void activate() override; + + public: + explicit RelaxationErrorPresenter(app::ApplicationCommon *app); + }; +} // namespace app::relaxation diff --git a/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationRunningLoopPresenter.cpp b/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationRunningLoopPresenter.cpp index bf77e014267688bf552a4adac7e9da7513ebb6de..32b0de6cf0ae41a8757668401a662e648bddf970 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationRunningLoopPresenter.cpp +++ b/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationRunningLoopPresenter.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "RelaxationRunningLoopPresenter.hpp" @@ -36,13 +36,26 @@ namespace app::relaxation mode = AbstractRelaxationPlayer::PlaybackMode::Looped; } else { - timer->reset(std::chrono::seconds{song.audioProperties.songLength}); - mode = AbstractRelaxationPlayer::PlaybackMode::SingleShot; + const auto songLength = std::chrono::seconds{song.audioProperties.songLength}; + mode = AbstractRelaxationPlayer::PlaybackMode::SingleShot; + + if (songLength > std::chrono::seconds::zero()) { + timer->reset(songLength); + } + else { + getView()->handleError(); + return; + } } + auto onStartCallback = [this](audio::RetCode retCode) { if (retCode == audio::RetCode::Success) { timer->start(); } + else { + getView()->handleError(); + return; + } }; player.start(song.fileInfo.path, mode, std::move(onStartCallback)); } diff --git a/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationRunningLoopPresenter.hpp b/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationRunningLoopPresenter.hpp index b98c59c579798c9f3c42e90d430db97888432c78..d4e593a7110d9fad9f905d26eb2ef7edce31bf86 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationRunningLoopPresenter.hpp +++ b/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationRunningLoopPresenter.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -40,6 +40,7 @@ namespace app::relaxation virtual void resume() = 0; virtual void setTime(std::time_t newTime) = 0; virtual void setTimeFormat(utils::time::Locale::TimeFormat fmt) = 0; + virtual void handleError() = 0; }; class Presenter : public BasePresenter diff --git a/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationRunningProgressPresenter.cpp b/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationRunningProgressPresenter.cpp index 4bbd1645f369fcca59e2a2e5840c760de05f9405..2fd791298e3e58f9588762758b7a7a672ffd3636 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationRunningProgressPresenter.cpp +++ b/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationRunningProgressPresenter.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "RelaxationRunningProgressPresenter.hpp" @@ -37,13 +37,25 @@ namespace app::relaxation mode = AbstractRelaxationPlayer::PlaybackMode::Looped; } else { - timer->reset(std::chrono::seconds{song.audioProperties.songLength}); - mode = AbstractRelaxationPlayer::PlaybackMode::SingleShot; + const auto songLength = std::chrono::seconds{song.audioProperties.songLength}; + mode = AbstractRelaxationPlayer::PlaybackMode::SingleShot; + + if (songLength > std::chrono::seconds::zero()) { + timer->reset(songLength); + } + else { + getView()->handleError(); + return; + } } auto onStartCallback = [this](audio::RetCode retCode) { if (retCode == audio::RetCode::Success) { timer->start(); } + else { + getView()->handleError(); + return; + } }; player.start(song.fileInfo.path, mode, std::move(onStartCallback)); } diff --git a/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationRunningProgressPresenter.hpp b/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationRunningProgressPresenter.hpp index 67e70e155cd3343309af536e4df99acfca9b19b4..460b7ba34ed4f7a38540d358834803256e63d974 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationRunningProgressPresenter.hpp +++ b/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationRunningProgressPresenter.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -39,6 +39,7 @@ namespace app::relaxation virtual void resume() = 0; virtual void setTime(std::time_t newTime) = 0; virtual void setTimeFormat(utils::time::Locale::TimeFormat fmt) = 0; + virtual void handleError() = 0; }; class Presenter : public BasePresenter diff --git a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationErrorWindow.cpp b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationErrorWindow.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f3eb9cd0a6e0313edf2589a524cb0f6120746c93 --- /dev/null +++ b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationErrorWindow.cpp @@ -0,0 +1,68 @@ +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#include "RelaxationErrorWindow.hpp" +#include +#include +#include +#include + +#include + +namespace gui +{ + RelaxationErrorWindow::RelaxationErrorWindow( + app::ApplicationCommon *app, std::unique_ptr &&presenter) + : WindowWithTimer(app, gui::window::name::relaxationError, std::chrono::seconds{6}), presenter{ + std::move(presenter)} + { + buildInterface(); + } + + void RelaxationErrorWindow::buildInterface() + { + AppWindow::buildInterface(); + buildLayout(); + registerCallbacks(); + } + + void RelaxationErrorWindow::buildLayout() + { + statusBar->setVisible(false); + + auto icon = new Icon(this, + 0, + 0, + style::window_width, + style::window_height, + "big_information", + utils::translate("app_bell_relaxation_error_message"), + ImageTypeSpecifier::W_G); + icon->image->setMargins({0, gui::relaxationStyle::error::imageMarginTop, 0, 0}); + icon->text->setFont(style::window::font::verybiglight); + const auto textPadding = icon->text->getPadding(); + icon->text->setPadding( + {textPadding.left, gui::relaxationStyle::error::textPaddingTop, textPadding.right, textPadding.bottom}); + icon->text->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center)); + icon->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Top)); + + icon->resizeItems(); + } + + void RelaxationErrorWindow::registerCallbacks() + { + timerCallback = [this](Item &, sys::Timer &timer) { + application->switchWindow(gui::name::window::main_window); + return true; + }; + } + + bool RelaxationErrorWindow::onInput(const InputEvent &inputEvent) + { + if (inputEvent.isShortRelease(KeyCode::KEY_ENTER) || inputEvent.isShortRelease(KeyCode::KEY_RF)) { + application->switchWindow(gui::name::window::main_window); + return true; + } + return true; + } +} // namespace gui diff --git a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationErrorWindow.hpp b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationErrorWindow.hpp new file mode 100644 index 0000000000000000000000000000000000000000..37198f7a7595197d7f04bd9ce98e98d36ec1eff7 --- /dev/null +++ b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationErrorWindow.hpp @@ -0,0 +1,28 @@ +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include "presenter/RelaxationErrorPresenter.hpp" +#include +#include + +namespace gui +{ + class BellBaseLayout; + class RelaxationErrorWindow : public WindowWithTimer + { + public: + explicit RelaxationErrorWindow( + app::ApplicationCommon *app, + std::unique_ptr &&presenter); + + private: + std::unique_ptr presenter; + + void buildInterface() override; + bool onInput(const gui::InputEvent &inputEvent) override; + void registerCallbacks(); + void buildLayout(); + }; +} // namespace gui diff --git a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationMainWindow.cpp b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationMainWindow.cpp index 7999543cbea8c9341cc229469281f52e0a4d3c65..7bb7e3e7703124a352d38de7cb79ec7ea2ecbd78 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationMainWindow.cpp +++ b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationMainWindow.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "RelaxationMainWindow.hpp" diff --git a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningLoopWindow.cpp b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningLoopWindow.cpp index e2798dff39c24a6c715052de33af4e02fcd361dc..5b0acf721ffc0c4502608b8eabe2c3af9446cdab 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningLoopWindow.cpp +++ b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningLoopWindow.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "RelaxationRunningLoopWindow.hpp" @@ -222,4 +222,8 @@ namespace gui std::make_unique(soc)); } } + void RelaxationRunningLoopWindow::handleError() + { + application->switchWindow(gui::window::name::relaxationError); + } } // namespace gui diff --git a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningLoopWindow.hpp b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningLoopWindow.hpp index fba6f111e4fbc12e77b26177ae7b0f5c6c2b5825..6172822e7517d116cb81269bb477c988164c1b9e 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningLoopWindow.hpp +++ b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningLoopWindow.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -40,6 +40,7 @@ namespace gui void onPaused() override; void resume() override; bool updateBatteryStatus() override; + void handleError() override; void buildLayout(); void configureTimer(); diff --git a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningProgressWindow.cpp b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningProgressWindow.cpp index 5a8fcb5f00e654e578531d41bb89a98177badad7..222dc4265aae3848564b0d2a15150623ac57c908 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningProgressWindow.cpp +++ b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningProgressWindow.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "RelaxationRunningProgressWindow.hpp" @@ -172,4 +172,9 @@ namespace gui return RefreshModes::GUI_REFRESH_FAST; } + void RelaxationRunningProgressWindow::handleError() + { + application->switchWindow(gui::window::name::relaxationError); + } + } // namespace gui diff --git a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningProgressWindow.hpp b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningProgressWindow.hpp index 9d74509d2da6092447ed150156be807a32e80d6b..67e755eaf1c47bf2dd7b420a930f0f707ed4e0a3 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningProgressWindow.hpp +++ b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningProgressWindow.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -41,6 +41,7 @@ namespace gui void onPaused() override; void resume() override; RefreshModes updateTime() override; + void handleError() override; void buildLayout(); void configureTimer(); diff --git a/products/BellHybrid/assets/assets_common.json b/products/BellHybrid/assets/assets_common.json index 7af0a1a0a13e573ffdebadde8d52cdf5c1bb0a1e..5b3b1607be0e958e475d6a2ce2dfcae2b0afcda6 100644 --- a/products/BellHybrid/assets/assets_common.json +++ b/products/BellHybrid/assets/assets_common.json @@ -60,7 +60,9 @@ {"name": "release.tgz", "tarfile" :"image/assets/images/bell/shortcuts_step_turn_off_W_G.vpi", "output": "assets/images/shortcuts_step_turn_off_W_G.vpi"}, {"name": "release.tgz", "tarfile" :"image/assets/images/bell/shortcuts_step_restart_W_G.vpi", "output": "assets/images/shortcuts_step_restart_W_G.vpi"}, {"name": "release.tgz", "tarfile" :"image/assets/images/bell/shortcuts_step_bedside_lamp_W_G.vpi", "output": "assets/images/shortcuts_step_bedside_lamp_W_G.vpi"}, - + {"name": "release.tgz", "tarfile" :"image/assets/images/bell/big_information_W_G.vpi", "output": "assets/images/big_information_W_G.vpi"}, + + {"name": "release_audio.tgz", "tarfile" :"./image/assets/audio/bell/chimes/Blissful_Dream.mp3", "output": "assets/audio/chimes/Blissful_Dream.mp3"}, {"name": "release_audio.tgz", "tarfile" :"./image/assets/audio/bell/chimes/Gentle_Chime.mp3", "output": "assets/audio/chimes/Gentle_Chime.mp3"}, {"name": "release_audio.tgz", "tarfile" :"./image/assets/audio/bell/chimes/Rise_&_Shine.mp3", "output": "assets/audio/chimes/Rise_&_Shine.mp3"},