M image/system_a/data/lang/Deutsch.json => image/system_a/data/lang/Deutsch.json +2 -0
@@ 140,6 140,8 @@
"app_bell_settings_alarm_settings_sounds": "T\u00f6ne",
"app_bell_settings_alarm_settings_title": "Alarmeinstellungen",
"app_bell_settings_alarm_settings_volume": "Alarmlautst\u00e4rke",
+ "app_bell_settings_relaxation_fade": "Entspannung",
+ "app_bell_settings_relaxation_fade_message": "Erh\u00f6ht allm\u00e4hlich Erholungslautst\u00e4rke",
"app_bell_settings_bedtime_chime": "Schlafenszeit",
"app_bell_settings_bedtime_settings_tone": "Schlafenszeitton",
"app_bell_settings_bedtime_settings_volume": "Schlafenszeit Lautst\u00e4rke",
M image/system_a/data/lang/English.json => image/system_a/data/lang/English.json +2 -0
@@ 142,6 142,8 @@
"app_bell_settings_alarm_settings_sounds": "Sounds",
"app_bell_settings_alarm_settings_title": "Alarm settings",
"app_bell_settings_alarm_settings_volume": "Main alarm volume",
+ "app_bell_settings_relaxation_fade": "Relaxation",
+ "app_bell_settings_relaxation_fade_message": "Gradually raise the relaxation volume",
"app_bell_settings_bedtime_chime": "Bedtime",
"app_bell_settings_bedtime_settings_tone": "Bedtime chime",
"app_bell_settings_bedtime_settings_volume": "Bedtime volume",
M image/system_a/data/lang/Espanol.json => image/system_a/data/lang/Espanol.json +2 -0
@@ 139,6 139,8 @@
"app_bell_settings_alarm_settings_sounds": "Sonidos",
"app_bell_settings_alarm_settings_title": "Ajustes de alarma",
"app_bell_settings_alarm_settings_volume": "Volumen de alarma",
+ "app_bell_settings_relaxation_fade": "Relajaci\u00f3n",
+ "app_bell_settings_relaxation_fade_message": "Aumentar la relajaci\u00f3n gradualmente",
"app_bell_settings_bedtime_chime": "Hora de dormir",
"app_bell_settings_bedtime_settings_tone": "Alarma de dormir",
"app_bell_settings_bedtime_settings_volume": "Volumen para la hora de dormir",
M image/system_a/data/lang/Francais.json => image/system_a/data/lang/Francais.json +2 -0
@@ 141,6 141,8 @@
"app_bell_settings_alarm_settings_sounds": "Sons",
"app_bell_settings_alarm_settings_title": "Alarme",
"app_bell_settings_alarm_settings_volume": "Volume",
+ "app_bell_settings_relaxation_fade": "Bruits de fond",
+ "app_bell_settings_relaxation_fade_message": "Hausse graduelle du vol. de d\u00e9tente",
"app_bell_settings_bedtime_chime": "Heure du coucher",
"app_bell_settings_bedtime_settings_tone": "Son pr\u00e9-sommeil",
"app_bell_settings_bedtime_settings_volume": "Volume de l'heure du coucher",
M image/system_a/data/lang/Polski.json => image/system_a/data/lang/Polski.json +2 -0
@@ 140,6 140,8 @@
"app_bell_settings_alarm_settings_sounds": "D\u017awi\u0119ki",
"app_bell_settings_alarm_settings_title": "Ustawienia alarmu",
"app_bell_settings_alarm_settings_volume": "G\u0142o\u015bno\u015b\u0107 alarmu",
+ "app_bell_settings_relaxation_fade": "Relaks",
+ "app_bell_settings_relaxation_fade_message": "Powoli podno\u015b g\u0142o\u015bno\u015b\u0107 relaksacji",
"app_bell_settings_bedtime_chime": "Pora snu",
"app_bell_settings_bedtime_settings_tone": "D\u017awi\u0119k pory snu",
"app_bell_settings_bedtime_settings_volume": "G\u0142o\u015bno\u015b\u0107 pory snu",
M products/BellHybrid/apps/application-bell-relaxation/ApplicationBellRelaxation.cpp => products/BellHybrid/apps/application-bell-relaxation/ApplicationBellRelaxation.cpp +3 -1
@@ 25,6 25,7 @@
#include <common/models/BatteryModel.hpp>
#include <common/models/AudioModel.hpp>
#include <common/models/SongsModel.hpp>
+#include <common/models/RelaxationFadeModel.hpp>
#include <common/windows/AppsBatteryStatusWindow.hpp>
#include <common/AudioErrorPresenter.hpp>
#include <common/windows/AudioErrorWindow.hpp>
@@ 71,7 72,8 @@ namespace app
batteryModel = std::make_unique<app::BatteryModel>(this);
lowBatteryInfoModel = std::make_unique<app::LowBatteryInfoModel>();
- player = std::make_unique<relaxation::RelaxationPlayer>(*audioModel);
+ fadeModel = std::make_unique<app::RelaxationFadeModel>(this);
+ player = std::make_unique<relaxation::RelaxationPlayer>(*fadeModel, *audioModel);
relaxationRebuildTimerHandle = sys::TimerFactory::createSingleShotTimer(
this, relaxationRebuildTimer, relaxationRebuildTimerInterval, [this](sys::Timer &) {
const auto mainWindow = getWindow(gui::name::window::main_window);
M products/BellHybrid/apps/application-bell-relaxation/include/application-bell-relaxation/ApplicationBellRelaxation.hpp => products/BellHybrid/apps/application-bell-relaxation/include/application-bell-relaxation/ApplicationBellRelaxation.hpp +2 -0
@@ 5,6 5,7 @@
#include <Application.hpp>
#include <common/models/AbstractAudioModel.hpp>
+#include <common/models/AbstractRelaxationFadeModel.hpp>
#include <common/models/BatteryModel.hpp>
#include <common/models/LowBatteryInfoModel.hpp>
#include <purefs/filesystem_paths.hpp>
@@ 52,6 53,7 @@ namespace app
private:
std::unique_ptr<AbstractAudioModel> audioModel;
+ std::unique_ptr<AbstractRelaxationFadeModel> fadeModel;
std::unique_ptr<AbstractBatteryModel> batteryModel;
std::unique_ptr<AbstractLowBatteryInfoModel> lowBatteryInfoModel;
std::unique_ptr<relaxation::RelaxationPlayer> player;
M products/BellHybrid/apps/application-bell-relaxation/widgets/RelaxationPlayer.cpp => products/BellHybrid/apps/application-bell-relaxation/widgets/RelaxationPlayer.cpp +8 -2
@@ 11,7 11,8 @@ namespace app::relaxation
return playbackMode;
}
- RelaxationPlayer::RelaxationPlayer(AbstractAudioModel &audioModel) : audioModel{audioModel}
+ RelaxationPlayer::RelaxationPlayer(AbstractRelaxationFadeModel &fadeModel, AbstractAudioModel &audioModel)
+ : fadeModel{fadeModel}, audioModel{audioModel}
{}
void RelaxationPlayer::start(const std::string &filePath,
@@ 42,11 43,16 @@ namespace app::relaxation
}
};
- auto fadeParams = audio::FadeParams{.mode = audio::Fade::InOut, .playbackDuration = playbackDuration};
+ auto fadeParams = audio::FadeParams{.mode = getFadeMode(), .playbackDuration = playbackDuration};
audioModel.setPlaybackFinishedCb(std::move(onPlayerFinished));
audioModel.play(filePath, Type::Multimedia, std::move(stateChangeCallback), std::move(fadeParams));
}
+ audio::Fade RelaxationPlayer::getFadeMode() const
+ {
+ return fadeModel.getFade().getValue() ? audio::Fade::InOut : audio::Fade::Disable;
+ }
+
void RelaxationPlayer::stop(AbstractAudioModel::OnStateChangeCallback &&callback)
{
paused = false;
M products/BellHybrid/apps/application-bell-relaxation/widgets/RelaxationPlayer.hpp => products/BellHybrid/apps/application-bell-relaxation/widgets/RelaxationPlayer.hpp +5 -1
@@ 4,6 4,7 @@
#pragma once
#include <common/models/AbstractAudioModel.hpp>
+#include <common/models/AbstractRelaxationFadeModel.hpp>
namespace app
{
@@ 36,13 37,14 @@ namespace app::relaxation
virtual void pause(AbstractAudioModel::OnStateChangeCallback &&callback) = 0;
virtual void resume(AbstractAudioModel::OnStateChangeCallback &&callback) = 0;
virtual PlaybackMode getCurrentMode() const noexcept = 0;
+ virtual audio::Fade getFadeMode() const = 0;
virtual bool isPaused() = 0;
};
class RelaxationPlayer : public AbstractRelaxationPlayer
{
public:
- explicit RelaxationPlayer(AbstractAudioModel &audioModel);
+ RelaxationPlayer(AbstractRelaxationFadeModel &fadeModel, AbstractAudioModel &audioModel);
private:
void start(const std::string &filePath,
@@ 54,8 56,10 @@ namespace app::relaxation
void pause(AbstractAudioModel::OnStateChangeCallback &&callback) override;
void resume(AbstractAudioModel::OnStateChangeCallback &&callback) override;
PlaybackMode getCurrentMode() const noexcept override;
+ audio::Fade getFadeMode() const override;
bool isPaused() override;
+ AbstractRelaxationFadeModel &fadeModel;
AbstractAudioModel &audioModel;
std::string recentFilePath;
PlaybackMode playbackMode = PlaybackMode::SingleShot;
M products/BellHybrid/apps/application-bell-settings/ApplicationBellSettings.cpp => products/BellHybrid/apps/application-bell-settings/ApplicationBellSettings.cpp +12 -0
@@ 7,6 7,7 @@
#include "models/TemperatureUnitModel.hpp"
#include "models/AboutYourBellModel.hpp"
#include "models/AudioErrorModel.hpp"
+#include "models/RelaxationListItemProvider.hpp"
#include "models/alarm_settings/AlarmSettingsListItemProvider.hpp"
#include "models/alarm_settings/PrewakeUpListItemProvider.hpp"
#include "models/alarm_settings/BedtimeSettingsListItemProvider.hpp"
@@ 30,6 31,7 @@
#include "windows/alarm_settings/BellSettingsAlarmSettingsWindow.hpp"
#include "windows/alarm_settings/BellSettingsPrewakeUpWindow.hpp"
#include "windows/BellSettingsBedtimeToneWindow.hpp"
+#include "windows/BellSettingsRelaxationWindow.hpp"
#include "windows/BellSettingsHomeViewWindow.hpp"
#include "windows/BellSettingsTimeUnitsWindow.hpp"
#include "windows/BellSettingsWindow.hpp"
@@ 39,6 41,7 @@
#include <common/BellPowerOffPresenter.hpp>
#include <common/models/BedtimeModel.hpp>
#include <common/models/LayoutModel.hpp>
+#include <common/models/RelaxationFadeModel.hpp>
#include <common/windows/BellFinishedWindow.hpp>
#include <common/windows/BellTurnOffWindow.hpp>
#include <common/windows/ShortcutsWindow.hpp>
@@ 105,6 108,15 @@ namespace app
return std::make_unique<gui::BellSettingsLayoutWindow>(app, std::move(presenter), name);
});
+ windowsFactory.attach(gui::window::name::bellSettingsRelaxation,
+ [](ApplicationCommon *app, [[maybe_unused]] const std::string &name) {
+ auto fadeModel = std::make_unique<RelaxationFadeModel>(app);
+ auto provider =
+ std::make_shared<bell_settings::RelaxationListItemProvider>(std::move(fadeModel));
+ auto presenter = std::make_unique<bell_settings::RelaxationWindowPresenter>(provider);
+ return std::make_unique<gui::BellSettingsRelaxationWindow>(app, std::move(presenter));
+ });
+
windowsFactory.attach(
gui::BellSettingsFrontlightWindow::name, [](ApplicationCommon *app, const std::string &name) {
auto model = std::make_unique<bell_settings::FrontlightModel>(app);
M products/BellHybrid/apps/application-bell-settings/CMakeLists.txt => products/BellHybrid/apps/application-bell-settings/CMakeLists.txt +3 -0
@@ 28,6 28,7 @@ target_sources(application-bell-settings
models/FrontlightListItemProvider.cpp
models/FrontlightModel.cpp
models/AudioErrorModel.cpp
+ models/RelaxationListItemProvider.cpp
models/alarm_settings/AlarmSettingsListItemProvider.cpp
models/alarm_settings/AlarmSettingsModel.cpp
models/alarm_settings/BedtimeSettingsListItemProvider.cpp
@@ 46,6 47,7 @@ target_sources(application-bell-settings
presenter/LayoutWindowPresenter.cpp
presenter/ShortcutsWindowPresenter.cpp
presenter/UpdateInstructionWindowPresenter.cpp
+ presenter/RelaxationWindowPresenter.cpp
presenter/alarm_settings/AlarmSettingsPresenter.cpp
presenter/alarm_settings/PrewakeUpPresenter.cpp
presenter/alarm_settings/SnoozePresenter.cpp
@@ 67,6 69,7 @@ target_sources(application-bell-settings
windows/BellSettingsLayoutWindow.cpp
windows/BellSettingsFrontlightWindow.cpp
windows/BellSettingsFactoryResetWindow.cpp
+ windows/BellSettingsRelaxationWindow.cpp
windows/alarm_settings/BellSettingsAlarmSettingsSnoozeWindow.cpp
windows/alarm_settings/BellSettingsAlarmSettingsMenuWindow.cpp
windows/alarm_settings/BellSettingsAlarmSettingsWindow.cpp
M products/BellHybrid/apps/application-bell-settings/data/BellSettingsStyle.hpp => products/BellHybrid/apps/application-bell-settings/data/BellSettingsStyle.hpp +3 -1
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 54,12 54,14 @@ namespace gui
inline constexpr auto value_height = 33;
} // namespace list_item
} // namespace about_your_bell_window
+
namespace bedtime_settings_window
{
inline constexpr auto options_list_margin_x = 100U;
inline constexpr auto options_list_margin_y = 110U;
inline constexpr auto default_body_width = 400U;
} // namespace bedtime_settings_window
+
namespace bedtime_settings_chime_tone
{
inline constexpr auto font_center = style::window::font::largelight;
M products/BellHybrid/apps/application-bell-settings/include/application-bell-settings/ApplicationBellSettings.hpp => products/BellHybrid/apps/application-bell-settings/include/application-bell-settings/ApplicationBellSettings.hpp +1 -0
@@ 16,6 16,7 @@ namespace gui::window::name
inline constexpr auto bellSettingsLanguage = "BellSettingsLanguage";
inline constexpr auto bellSettingsLayout = "BellSettingsLayout";
inline constexpr auto bellSettingsBedtimeTone = "BellSettingsBedtimeTone";
+ inline constexpr auto bellSettingsRelaxation = "BellSettingsRelaxation";
inline constexpr auto bellSettingsShortcuts = "BellSettingsShortcuts";
inline constexpr auto bellSettingsUpdateInstruction = "BellSettingsUpdateInstruction";
} // namespace gui::window::name
A products/BellHybrid/apps/application-bell-settings/models/RelaxationListItemProvider.cpp => products/BellHybrid/apps/application-bell-settings/models/RelaxationListItemProvider.cpp +65 -0
@@ 0,0 1,65 @@
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "RelaxationListItemProvider.hpp"
+#include "common/widgets/ListItems.hpp"
+#include "data/BellSettingsStyle.hpp"
+
+#include <gui/widgets/ListViewEngine.hpp>
+
+namespace app::bell_settings
+{
+ using namespace gui;
+
+ RelaxationListItemProvider::RelaxationListItemProvider(std::unique_ptr<AbstractRelaxationFadeModel> &&model)
+ : model{std::move(model)}
+ {
+ buildListItems();
+ }
+
+ void RelaxationListItemProvider::buildListItems()
+ {
+ constexpr auto itemCount = 1U;
+ internalData.reserve(itemCount);
+
+ auto onOff = new OnOffListItem(model->getFade(), utils::translate("app_bell_settings_relaxation_fade_message"));
+ onOff->onProceed = [onOff, this]() {
+ if (not onOff->isActive()) {
+ this->onExit();
+ return true;
+ }
+ return false;
+ };
+ internalData.emplace_back(onOff);
+
+ for (auto item : internalData) {
+ item->deleteByList = false;
+ }
+ }
+
+ auto RelaxationListItemProvider::requestRecords(std::uint32_t offset, std::uint32_t limit) -> void
+ {
+ setupModel(offset, limit);
+ list->onProviderDataUpdate();
+ }
+
+ auto RelaxationListItemProvider::getItem(Order order) -> ListItem *
+ {
+ return getRecord(order);
+ }
+
+ auto RelaxationListItemProvider::requestRecordsCount() -> unsigned int
+ {
+ return internalData.size();
+ }
+
+ auto RelaxationListItemProvider::getMinimalItemSpaceRequired() const -> unsigned int
+ {
+ return style::sidelistview::list_item::w;
+ }
+
+ auto RelaxationListItemProvider::getListItems() -> std::vector<BellSideListItemWithCallbacks *>
+ {
+ return internalData;
+ }
+} // namespace app::bell_settings
A products/BellHybrid/apps/application-bell-settings/models/RelaxationListItemProvider.hpp => products/BellHybrid/apps/application-bell-settings/models/RelaxationListItemProvider.hpp +30 -0
@@ 0,0 1,30 @@
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <common/models/AbstractRelaxationFadeModel.hpp>
+#include <common/widgets/BellSideListItemWithCallbacks.hpp>
+#include <apps-common/InternalModel.hpp>
+
+namespace app::bell_settings
+{
+ class RelaxationListItemProvider : public app::InternalModel<gui::BellSideListItemWithCallbacks *>,
+ public gui::ListItemProvider
+ {
+ public:
+ explicit RelaxationListItemProvider(std::unique_ptr<AbstractRelaxationFadeModel> &&model);
+ auto getListItems() -> std::vector<gui::BellSideListItemWithCallbacks *>;
+ auto requestRecords(std::uint32_t offset, std::uint32_t limit) -> void override;
+ [[nodiscard]] auto getItem(gui::Order order) -> gui::ListItem * override;
+ [[nodiscard]] auto requestRecordsCount() -> unsigned int override;
+ [[nodiscard]] auto getMinimalItemSpaceRequired() const -> unsigned int override;
+
+ std::function<void()> onExit;
+
+ private:
+ auto buildListItems() -> void;
+
+ std::unique_ptr<AbstractRelaxationFadeModel> model;
+ };
+} // namespace app::bell_settings
A products/BellHybrid/apps/application-bell-settings/presenter/RelaxationWindowPresenter.cpp => products/BellHybrid/apps/application-bell-settings/presenter/RelaxationWindowPresenter.cpp +33 -0
@@ 0,0 1,33 @@
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "RelaxationWindowPresenter.hpp"
+#include "models/RelaxationListItemProvider.hpp"
+
+namespace app::bell_settings
+{
+ RelaxationWindowPresenter::RelaxationWindowPresenter(std::shared_ptr<RelaxationListItemProvider> provider)
+ : provider{provider}
+ {
+ provider->onExit = [this]() { getView()->exit(); };
+ }
+
+ void RelaxationWindowPresenter::saveData()
+ {
+ for (const auto &item : provider->getListItems()) {
+ item->getValue();
+ }
+ }
+
+ void RelaxationWindowPresenter::loadData()
+ {
+ for (const auto &item : provider->getListItems()) {
+ item->setValue();
+ }
+ }
+
+ auto RelaxationWindowPresenter::getPagesProvider() const -> std::shared_ptr<gui::ListItemProvider>
+ {
+ return provider;
+ }
+} // namespace app::bell_settings
A products/BellHybrid/apps/application-bell-settings/presenter/RelaxationWindowPresenter.hpp => products/BellHybrid/apps/application-bell-settings/presenter/RelaxationWindowPresenter.hpp +46 -0
@@ 0,0 1,46 @@
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <memory>
+#include <apps-common/BasePresenter.hpp>
+#include <common/models/AbstractRelaxationFadeModel.hpp>
+
+namespace gui
+{
+ class ListItemProvider;
+} // namespace gui
+
+namespace app::bell_settings
+{
+ class RelaxationListItemProvider;
+
+ class View
+ {
+ public:
+ virtual ~View() noexcept = default;
+ virtual void exit() = 0;
+ };
+
+ class AbstractRelaxationPresenter : public BasePresenter<View>
+ {
+ public:
+ virtual ~AbstractRelaxationPresenter() noexcept = default;
+ virtual auto getPagesProvider() const -> std::shared_ptr<gui::ListItemProvider> = 0;
+ virtual void saveData() = 0;
+ virtual void loadData() = 0;
+ };
+
+ class RelaxationWindowPresenter : public AbstractRelaxationPresenter
+ {
+ private:
+ std::shared_ptr<RelaxationListItemProvider> provider;
+
+ public:
+ explicit RelaxationWindowPresenter(std::shared_ptr<RelaxationListItemProvider> provider);
+ auto getPagesProvider() const -> std::shared_ptr<gui::ListItemProvider> override;
+ void saveData() override;
+ void loadData() override;
+ };
+} // namespace app::bell_settings
M products/BellHybrid/apps/application-bell-settings/presenter/alarm_settings/SnoozePresenter.hpp => products/BellHybrid/apps/application-bell-settings/presenter/alarm_settings/SnoozePresenter.hpp +21 -17
@@ 19,28 19,32 @@ namespace app::bell_settings
{
class SnoozeListItemProvider;
- class View
+ class SnoozeWindowContract
{
public:
- virtual ~View() noexcept = default;
- virtual auto exit() -> void = 0;
- virtual auto deepRefresh() -> void = 0;
- virtual auto handleError() -> void = 0;
- virtual auto handleDeletedFile() -> void = 0;
- };
+ class View
+ {
+ public:
+ virtual ~View() noexcept = default;
+ virtual auto exit() -> void = 0;
+ virtual auto deepRefresh() -> void = 0;
+ virtual auto handleError() -> void = 0;
+ virtual auto handleDeletedFile() -> void = 0;
+ };
- class AbstractSnoozePresenter : public BasePresenter<View>
- {
- public:
- virtual ~AbstractSnoozePresenter() = default;
- virtual auto getPagesProvider() const -> std::shared_ptr<gui::ListItemProvider> = 0;
- virtual auto saveData() -> void = 0;
- virtual auto loadData() -> void = 0;
- virtual auto eraseProviderData() -> void = 0;
- virtual auto exitWithoutSave() -> void = 0;
+ class AbstractSnoozePresenter : public BasePresenter<View>
+ {
+ public:
+ virtual ~AbstractSnoozePresenter() = default;
+ virtual auto getPagesProvider() const -> std::shared_ptr<gui::ListItemProvider> = 0;
+ virtual auto saveData() -> void = 0;
+ virtual auto loadData() -> void = 0;
+ virtual auto eraseProviderData() -> void = 0;
+ virtual auto exitWithoutSave() -> void = 0;
+ };
};
- class SnoozePresenter : public AbstractSnoozePresenter
+ class SnoozePresenter : public SnoozeWindowContract::AbstractSnoozePresenter
{
public:
SnoozePresenter(ApplicationCommon *app,
A products/BellHybrid/apps/application-bell-settings/windows/BellSettingsRelaxationWindow.cpp => products/BellHybrid/apps/application-bell-settings/windows/BellSettingsRelaxationWindow.cpp +66 -0
@@ 0,0 1,66 @@
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "BellSettingsRelaxationWindow.hpp"
+
+#include <module-gui/gui/input/InputEvent.hpp>
+#include <widgets/SideListView.hpp>
+#include <common/windows/BellFinishedWindow.hpp>
+
+namespace gui
+{
+ BellSettingsRelaxationWindow::BellSettingsRelaxationWindow(
+ app::ApplicationCommon *app,
+ std::unique_ptr<app::bell_settings::RelaxationWindowPresenter> &&windowPresenter,
+ std::string name)
+ : AppWindow(app, std::move(name)), presenter{std::move(windowPresenter)}
+ {
+ presenter->attach(this);
+ buildInterface();
+ }
+
+ void BellSettingsRelaxationWindow::buildInterface()
+ {
+ AppWindow::buildInterface();
+
+ statusBar->setVisible(false);
+ header->setTitleVisibility(true);
+ navBar->setVisible(false);
+
+ listView = new SideListView(
+ this, 0U, 0U, this->getWidth(), this->getHeight(), presenter->getPagesProvider(), PageBarType::None);
+ listView->setEdges(RectangleEdge::None);
+
+ listView->rebuildList(listview::RebuildType::Full);
+
+ presenter->loadData();
+
+ setFocusItem(listView);
+ }
+
+ bool BellSettingsRelaxationWindow::onInput(const InputEvent &inputEvent)
+ {
+ if (listView->onInput(inputEvent)) {
+ return true;
+ }
+ if (inputEvent.isShortRelease(KeyCode::KEY_ENTER)) {
+ exit();
+ return true;
+ }
+ return AppWindow::onInput(inputEvent);
+ }
+
+ void BellSettingsRelaxationWindow::rebuild()
+ {
+ erase();
+ buildInterface();
+ }
+
+ void BellSettingsRelaxationWindow::exit()
+ {
+ presenter->saveData();
+ application->switchWindow(
+ window::bell_finished::defaultName,
+ BellFinishedWindowData::Factory::create("circle_success_big", name::window::main_window));
+ }
+} /* namespace gui */
A products/BellHybrid/apps/application-bell-settings/windows/BellSettingsRelaxationWindow.hpp => products/BellHybrid/apps/application-bell-settings/windows/BellSettingsRelaxationWindow.hpp +31 -0
@@ 0,0 1,31 @@
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include "ApplicationBellSettings.hpp"
+#include "presenter/RelaxationWindowPresenter.hpp"
+
+#include <apps-common/windows/AppWindow.hpp>
+
+namespace gui
+{
+ class SideListView;
+
+ class BellSettingsRelaxationWindow : public AppWindow, public app::bell_settings::View
+ {
+ public:
+ BellSettingsRelaxationWindow(app::ApplicationCommon *app,
+ std::unique_ptr<app::bell_settings::RelaxationWindowPresenter> &&windowPresenter,
+ std::string name = window::name::bellSettingsRelaxation);
+
+ void buildInterface() override;
+ auto onInput(const InputEvent &inputEvent) -> bool override;
+ void rebuild() override;
+ void exit() override;
+
+ private:
+ SideListView *listView{};
+ std::unique_ptr<app::bell_settings::RelaxationWindowPresenter> presenter;
+ };
+} /* namespace gui */
M products/BellHybrid/apps/application-bell-settings/windows/BellSettingsWindow.cpp => products/BellHybrid/apps/application-bell-settings/windows/BellSettingsWindow.cpp +3 -0
@@ 58,6 58,9 @@ namespace gui
addWinSettings(utils::translate("app_bell_settings_alarm_settings"),
BellSettingsAlarmSettingsMenuWindow::name,
defaultCallback);
+ addWinSettings(utils::translate("app_bell_settings_relaxation_fade"),
+ window::name::bellSettingsRelaxation,
+ defaultCallback);
addWinSettings(utils::translate("app_bell_settings_bedtime_chime"),
window::name::bellSettingsBedtimeTone,
defaultCallback);
M products/BellHybrid/apps/application-bell-settings/windows/alarm_settings/BellSettingsAlarmSettingsSnoozeWindow.hpp => products/BellHybrid/apps/application-bell-settings/windows/alarm_settings/BellSettingsAlarmSettingsSnoozeWindow.hpp +1 -1
@@ 12,7 12,7 @@ namespace gui
{
class SideListView;
- class BellSettingsAlarmSettingsSnoozeWindow : public AppWindow, app::bell_settings::View
+ class BellSettingsAlarmSettingsSnoozeWindow : public AppWindow, app::bell_settings::SnoozeWindowContract::View
{
public:
static constexpr auto name = "BellSettingsAlarmSettingsSnooze";
M products/BellHybrid/apps/common/CMakeLists.txt => products/BellHybrid/apps/common/CMakeLists.txt +3 -0
@@ 43,6 43,7 @@ target_sources(application-bell-common
src/models/LowBatteryInfoModel.cpp
src/models/SongsModel.cpp
src/models/PreWakeUpModel.cpp
+ src/models/RelaxationFadeModel.cpp
src/popups/AlarmActivatedWindow.cpp
src/popups/AlarmActivatedWindow.cpp
@@ 115,6 116,7 @@ target_sources(application-bell-common
include/common/data/BatteryStatusSwitchData.hpp
include/common/models/AbstractAlarmModel.hpp
+ include/common/models/AbstractRelaxationFadeModel.hpp
include/common/models/AbstractBedtimeModel.hpp
include/common/models/AbstractSettingsModel.hpp
include/common/models/AbstractAudioModel.hpp
@@ 122,6 124,7 @@ target_sources(application-bell-common
include/common/models/SettingsModel.hpp
include/common/models/BedtimeModel.hpp
include/common/models/BatteryModel.hpp
+ include/common/models/RelaxationFadeModel.hpp
include/common/models/BatteryLevelNotificationModel.hpp
include/common/models/TimeModel.hpp
include/common/models/UserSessionModel.hpp
A products/BellHybrid/apps/common/include/common/models/AbstractRelaxationFadeModel.hpp => products/BellHybrid/apps/common/include/common/models/AbstractRelaxationFadeModel.hpp +16 -0
@@ 0,0 1,16 @@
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include "common/models/AbstractSettingsModel.hpp"
+
+namespace app
+{
+ class AbstractRelaxationFadeModel
+ {
+ public:
+ virtual ~AbstractRelaxationFadeModel() = default;
+ virtual auto getFade() -> gui::AbstractSettingsModel<bool> & = 0;
+ };
+} // namespace app
A products/BellHybrid/apps/common/include/common/models/RelaxationFadeModel.hpp => products/BellHybrid/apps/common/include/common/models/RelaxationFadeModel.hpp +39 -0
@@ 0,0 1,39 @@
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include "AbstractRelaxationFadeModel.hpp"
+#include "SettingsModel.hpp"
+#include <ApplicationCommon.hpp>
+
+namespace app
+{
+ class RelaxationFadeSettings : public gui::SettingsModel<bool>
+ {
+ public:
+ using SettingsModel::SettingsModel;
+
+ auto setValue(bool value) -> void override;
+ auto getValue() const -> bool override;
+ };
+
+ class RelaxationFadeModel : public AbstractRelaxationFadeModel
+ {
+ public:
+ RelaxationFadeModel() = delete;
+
+ RelaxationFadeModel(ApplicationCommon *app)
+ {
+ fade = std::make_unique<RelaxationFadeSettings>(app);
+ }
+
+ gui::AbstractSettingsModel<bool> &getFade() override
+ {
+ return *fade;
+ }
+
+ private:
+ std::unique_ptr<gui::AbstractSettingsModel<bool>> fade;
+ };
+} // namespace app
A products/BellHybrid/apps/common/src/models/RelaxationFadeModel.cpp => products/BellHybrid/apps/common/src/models/RelaxationFadeModel.cpp +21 -0
@@ 0,0 1,21 @@
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "models/RelaxationFadeModel.hpp"
+#include <apps-common/ApplicationCommon.hpp>
+#include <db/SystemSettings.hpp>
+
+namespace app
+{
+ auto RelaxationFadeSettings::setValue(bool value) -> void
+ {
+ const auto valStr = std::to_string(value);
+ settings.setValue(bell::settings::Relaxation::fadeActive, valStr, settings::SettingsScope::Global);
+ }
+
+ auto RelaxationFadeSettings::getValue() const -> bool
+ {
+ const auto str = settings.getValue(bell::settings::Relaxation::fadeActive, settings::SettingsScope::Global);
+ return utils::toNumeric(str);
+ }
+} // namespace app
M products/BellHybrid/services/db/include/db/SystemSettings.hpp => products/BellHybrid/services/db/include/db/SystemSettings.hpp +5 -0
@@ 47,6 47,11 @@ namespace bell::settings
inline constexpr auto duration = "bedtime_duration";
} // namespace Bedtime
+ namespace Relaxation
+ {
+ inline constexpr auto fadeActive = "relaxation_fade_active";
+ }
+
namespace Layout
{
inline constexpr auto layout = "layout";