~aleteoryx/muditaos

e2a1f82f910c195ca3ab6229f1364a1cce73ecca — Lukasz Skrzypczak 4 years ago a4a5a09
[BH-757] Reworked settings and GUI model

Using new settings model & simplified GUI layout - no 1-element list
21 files changed, 555 insertions(+), 18 deletions(-)

M image/assets/lang/English.json
M products/BellHybrid/apps/application-bell-settings/ApplicationBellSettings.cpp
M products/BellHybrid/apps/application-bell-settings/CMakeLists.txt
M products/BellHybrid/apps/application-bell-settings/data/BellSettingsStyle.hpp
A products/BellHybrid/apps/application-bell-settings/data/FinishedWindowMessageData.hpp
M products/BellHybrid/apps/application-bell-settings/include/application-bell-settings/ApplicationBellSettings.hpp
A products/BellHybrid/apps/application-bell-settings/models/FrontlightModel.cpp
A products/BellHybrid/apps/application-bell-settings/models/FrontlightModel.hpp
A products/BellHybrid/apps/application-bell-settings/presenter/FrontlightPresenter.cpp
A products/BellHybrid/apps/application-bell-settings/presenter/FrontlightPresenter.hpp
M products/BellHybrid/apps/application-bell-settings/windows/BellSettingsAdvancedWindow.cpp
M products/BellHybrid/apps/application-bell-settings/windows/BellSettingsFinishedWindow.cpp
M products/BellHybrid/apps/application-bell-settings/windows/BellSettingsFinishedWindow.hpp
A products/BellHybrid/apps/application-bell-settings/windows/BellSettingsFrontlight.cpp
A products/BellHybrid/apps/application-bell-settings/windows/BellSettingsFrontlight.hpp
M products/BellHybrid/apps/application-bell-settings/windows/BellSettingsTimeUnitsWindow.cpp
M products/BellHybrid/services/evtmgr/CMakeLists.txt
M products/BellHybrid/services/evtmgr/EventManager.cpp
A products/BellHybrid/services/evtmgr/WorkerEvent.cpp
A products/BellHybrid/services/evtmgr/WorkerEvent.hpp
M products/BellHybrid/services/evtmgr/include/evtmgr/EventManager.hpp
M image/assets/lang/English.json => image/assets/lang/English.json +4 -1
@@ 571,5 571,8 @@
  "app_bellmain_home_screen_bottom_desc": "Next alarm will ring in",
  "app_bellmain_home_screen_bottom_desc_dp": "Deep press to activate",
  "app_bell_alarm_deactivated": "Alarm deactivated",
  "app_bell_alarm_ringing_deactivated": "Good morning!\nRise and shine"
  "app_bell_alarm_ringing_deactivated": "Good morning!\nRise and shine",
  "app_bell_settings_advanced_frontlight": "Frontlight",
  "app_bell_settings_frontlight_top_message": "Frontlight intensity",
  "app_bell_settings_frontlight_finished_message": "Frontlight is set"
}

M products/BellHybrid/apps/application-bell-settings/ApplicationBellSettings.cpp => products/BellHybrid/apps/application-bell-settings/ApplicationBellSettings.cpp +45 -0
@@ 3,13 3,20 @@

#include "ApplicationBellSettings.hpp"
#include "TimeUnitsPresenter.hpp"
#include "FrontlightPresenter.hpp"
#include "models/TemperatureUnitModel.hpp"
#include "models/FrontlightModel.hpp"
#include "windows/BellSettingsAdvancedWindow.hpp"
#include "windows/BellSettingsFinishedWindow.hpp"
#include "windows/BellSettingsTimeUnitsWindow.hpp"
#include "windows/BellSettingsWindow.hpp"
#include "windows/BellSettingsFrontlight.hpp"

#include <apps-common/windows/Dialog.hpp>
#include <apps-common/AsyncTask.hpp>
#include <service-evtmgr/Constants.hpp>
#include <service-evtmgr/EventManagerServiceAPI.hpp>
#include <service-evtmgr/ScreenLightControlMessage.hpp>

namespace app
{


@@ 28,6 35,7 @@ namespace app
            return ret;
        }
        createUserInterface();

        return sys::ReturnCodes::Success;
    }



@@ 49,6 57,13 @@ namespace app
            return std::make_unique<gui::BellSettingsTimeUnitsWindow>(app, std::move(presenter));
        });

        windowsFactory.attach(gui::window::name::bellSettingsFrontlight, [](Application *app, const std::string &name) {
            auto model =
                std::make_shared<bell_settings::FrontlightModel>(app, static_cast<ApplicationBellSettings *>(app));
            auto presenter = std::make_unique<bell_settings::FrontlightWindowPresenter>(std::move(model));
            return std::make_unique<gui::BellSettingsFrontlightWindow>(app, std::move(presenter));
        });

        windowsFactory.attach(gui::window::name::bellSettingsFinished, [](Application *app, const std::string &name) {
            return std::make_unique<gui::BellSettingsFinishedWindow>(app);
        });


@@ 60,6 75,36 @@ namespace app
        if (dynamic_cast<sys::ResponseMessage *>(retMsg.get())->retCode == sys::ReturnCodes::Success) {
            return retMsg;
        }

        // handle database response
        if (resp != nullptr) {
            if (auto command = callbackStorage->getCallback(resp); command->execute()) {
                refreshWindow(gui::RefreshModes::GUI_REFRESH_FAST);
            }
            return sys::msgHandled();
        }
        return std::make_shared<sys::ResponseMessage>();
    }

    void ApplicationBellSettings::setBrightness(bsp::eink_frontlight::BrightnessPercentage value)
    {
        screen_light_control::ManualModeParameters parameters{value};
        bus.sendUnicast(std::make_shared<sevm::ScreenLightSetManualModeParams>(parameters), service::name::evt_manager);
    }

    void ApplicationBellSettings::setMode(bool isAutoLightSwitchOn)
    {
        bus.sendUnicast(std::make_shared<sevm::ScreenLightControlMessage>(
                            isAutoLightSwitchOn ? screen_light_control::Action::enableAutomaticMode
                                                : screen_light_control::Action::disableAutomaticMode),
                        service::name::evt_manager);
    }

    void ApplicationBellSettings::setStatus(bool isDisplayLightSwitchOn)
    {
        bus.sendUnicast(std::make_shared<sevm::ScreenLightControlMessage>(isDisplayLightSwitchOn
                                                                              ? screen_light_control::Action::turnOn
                                                                              : screen_light_control::Action::turnOff),
                        service::name::evt_manager);
    }
} // namespace app

M products/BellHybrid/apps/application-bell-settings/CMakeLists.txt => products/BellHybrid/apps/application-bell-settings/CMakeLists.txt +7 -0
@@ 23,7 23,9 @@ target_sources(application-bell-settings
        ApplicationBellSettings.cpp
        models/TimeUnitsModel.cpp
        models/TemperatureUnitModel.cpp
        models/FrontlightModel.cpp
        presenter/TimeUnitsPresenter.cpp
        presenter/FrontlightPresenter.cpp
        widgets/TimeSetListItem.cpp
        widgets/TimeFormatSetListItem.cpp
        widgets/TemperatureUnitListItem.cpp


@@ 31,19 33,24 @@ target_sources(application-bell-settings
        windows/BellSettingsAdvancedWindow.cpp
        windows/BellSettingsTimeUnitsWindow.cpp
        windows/BellSettingsFinishedWindow.cpp
        windows/BellSettingsFrontlight.cpp

        models/TimeUnitsModel.hpp
        models/TemperatureUnitModel.hpp
        models/FrontlightModel.hpp
        presenter/TimeUnitsPresenter.hpp
        presenter/FrontlightPresenter.hpp
        widgets/TimeSetListItem.hpp
        widgets/TimeFormatSetListItem.hpp
        widgets/TemperatureUnitListItem.hpp
        windows/BellSettingsWindow.hpp
        windows/BellSettingsAdvancedWindow.hpp
        windows/BellSettingsTimeUnitsWindow.hpp
        windows/BellSettingsFrontlight.hpp

    PRIVATE
        windows/BellSettingsFinishedWindow.hpp
        data/FinishedWindowMessageData.hpp

    PUBLIC
        include/application-bell-settings/ApplicationBellSettings.hpp

M products/BellHybrid/apps/application-bell-settings/data/BellSettingsStyle.hpp => products/BellHybrid/apps/application-bell-settings/data/BellSettingsStyle.hpp +5 -0
@@ 21,5 21,10 @@ namespace gui
        {
            inline constexpr auto font = style::window::font::supersizemelight;
        } // namespace time_fmt_set_list_item

        namespace top_text
        {
            inline constexpr auto font = "gt_pressura_light_46";
        }
    }     // namespace bell_settings_style
} // namespace gui

A products/BellHybrid/apps/application-bell-settings/data/FinishedWindowMessageData.hpp => products/BellHybrid/apps/application-bell-settings/data/FinishedWindowMessageData.hpp +24 -0
@@ 0,0 1,24 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <gui/SwitchData.hpp>

namespace gui
{
    class FinishedWindowMessageData : public gui::SwitchData
    {
      public:
        explicit FinishedWindowMessageData(std::string message) : _message(std::move(message))
        {}

        [[nodiscard]] std::string getMessage() const
        {
            return _message;
        }

      private:
        std::string _message{};
    };
}; // namespace gui

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 +31 -6
@@ 4,14 4,16 @@
#pragma once

#include <apps-common/Application.hpp>
#include <service-evtmgr/screen-light-control/ScreenLightControl.hpp>

namespace gui::window::name
{
    inline constexpr auto bellSettings          = "BellSettings";
    inline constexpr auto bellSettingsAdvanced  = "BellSettingsAdvanced";
    inline constexpr auto bellSettingsTimeUnits = "BellSettingsTimeUnits";
    inline constexpr auto bellSettingsDialog    = "BellSettingsDialog";
    inline constexpr auto bellSettingsFinished  = "BellSettingsFinished";
    inline constexpr auto bellSettings           = "BellSettings";
    inline constexpr auto bellSettingsAdvanced   = "BellSettingsAdvanced";
    inline constexpr auto bellSettingsTimeUnits  = "BellSettingsTimeUnits";
    inline constexpr auto bellSettingsDialog     = "BellSettingsDialog";
    inline constexpr auto bellSettingsFinished   = "BellSettingsFinished";
    inline constexpr auto bellSettingsFrontlight = "BellSettingsFrontlight";

} // namespace gui::window::name



@@ 19,7 21,26 @@ namespace app
{
    inline constexpr auto applicationBellSettingsName = "ApplicationBellSettings";

    class ApplicationBellSettings : public Application
    namespace settingsInterface
    {
        class BellScreenLightSettings
        {
          public:
            struct Values
            {
                bool lightOn;
                screen_light_control::ScreenLightMode mode;
                screen_light_control::ManualModeParameters parameters;
            };

            virtual ~BellScreenLightSettings()                  = default;
            virtual void setBrightness(float brightnessValue)   = 0;
            virtual void setMode(bool isAutoLightSwitchOn)      = 0;
            virtual void setStatus(bool isDisplayLightSwitchOn) = 0;
        };
    }; // namespace settingsInterface

    class ApplicationBellSettings : public Application, public settingsInterface::BellScreenLightSettings
    {
      public:
        ApplicationBellSettings(std::string name                            = applicationBellSettingsName,


@@ 40,6 61,10 @@ namespace app
        {
            return sys::ReturnCodes::Success;
        }

        void setBrightness(float brightnessValue) override;
        void setMode(bool isAutoLightSwitchOn) override;
        void setStatus(bool isDisplayLightSwitchOn) override;
    };

    template <> struct ManifestTraits<ApplicationBellSettings>

A products/BellHybrid/apps/application-bell-settings/models/FrontlightModel.cpp => products/BellHybrid/apps/application-bell-settings/models/FrontlightModel.cpp +76 -0
@@ 0,0 1,76 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "FrontlightModel.hpp"
#include "BellSettingsStyle.hpp"

#include <gui/widgets/ListViewEngine.hpp>
#include <gui/widgets/Style.hpp>
#include <gui/widgets/Text.hpp>
#include <service-time/Constants.hpp>
#include <widgets/BellBaseLayout.hpp>
#include <service-db/Settings.hpp>
#include <service-db/agents/settings/SystemSettings.hpp>

namespace
{
    constexpr auto fmtSpinnerMin   = 1U;
    constexpr auto fmtSpinnerMax   = 10U;
    constexpr auto fmtSpinnerStep  = 1U;
    constexpr auto brightnessLevel = settings::Brightness::brightnessLevel;
} // namespace

namespace app::bell_settings
{
    FrontlightModel::FrontlightModel(app::Application *app, app::settingsInterface::BellScreenLightSettings *slSettings)
        : application(app), screenLightSettings(slSettings)
    {
        settings.init(service::ServiceProxy{application->weak_from_this()});
    }

    FrontlightModel::~FrontlightModel()
    {}

    auto FrontlightModel::getSpinner() -> gui::Spinner *
    {
        if (frontlightSetSpinner != nullptr) {
            return frontlightSetSpinner;
        }
        else {
            LOG_ERROR("Spinner not initialized !");
            return nullptr;
        }
    }

    void FrontlightModel::createData()
    {
        frontlightSetSpinner =
            new gui::Spinner(fmtSpinnerMin, fmtSpinnerMax, fmtSpinnerStep, gui::Boundaries::Continuous);
        frontlightSetSpinner->setMaximumSize(style::bell_base_layout::w, style::bell_base_layout::h);
        frontlightSetSpinner->setFont(gui::bell_settings_style::time_fmt_set_list_item::font);

        frontlightSetSpinner->setAlignment(
            gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
        frontlightSetSpinner->setFixedFieldWidth(2);
        frontlightSetSpinner->setEdges(gui::RectangleEdge::None);
        frontlightSetSpinner->setCurrentValue(fmtSpinnerMin);
        frontlightSetSpinner->setFocusEdges(gui::RectangleEdge::None);
    }

    void FrontlightModel::saveData()
    {
        const int value = frontlightSetSpinner->getCurrentValue() * 10;
        LOG_DEBUG("Storing frontlight value %i", value);
        screenLightSettings->setBrightness(static_cast<float>(value));
        settings.setValue(
            brightnessLevel, std::to_string(static_cast<std::int32_t>(value)), settings::SettingsScope::Global);
    }

    void FrontlightModel::loadData()
    {
        bsp::eink_frontlight::BrightnessPercentage brightnessValue =
            utils::getNumericValue<float>(settings.getValue(brightnessLevel, settings::SettingsScope::Global));
        LOG_DEBUG("Reading frontlight value %0.1f", brightnessValue);
        frontlightSetSpinner->setCurrentValue(static_cast<int>(brightnessValue / 10));
    }
} // namespace app::bell_settings

A products/BellHybrid/apps/application-bell-settings/models/FrontlightModel.hpp => products/BellHybrid/apps/application-bell-settings/models/FrontlightModel.hpp +33 -0
@@ 0,0 1,33 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <apps-common/InternalModel.hpp>
#include <ApplicationBellSettings.hpp>
#include <widgets/Spinner.hpp>
#include <service-db/Settings.hpp>

class Application;

namespace app::bell_settings
{
    class FrontlightModel
    {
      public:
        explicit FrontlightModel(app::Application *app, app::settingsInterface::BellScreenLightSettings *slSettings);
        ~FrontlightModel();

        auto saveData() -> void;
        auto loadData() -> void;
        auto createData() -> void;

        [[nodiscard]] auto getSpinner() -> gui::Spinner *;

      private:
        app::Application *application                                        = nullptr;
        app::settingsInterface::BellScreenLightSettings *screenLightSettings = nullptr;
        gui::Spinner *frontlightSetSpinner                                   = nullptr;
        mutable settings::Settings settings;
    };
} // namespace app::bell_settings

A products/BellHybrid/apps/application-bell-settings/presenter/FrontlightPresenter.cpp => products/BellHybrid/apps/application-bell-settings/presenter/FrontlightPresenter.cpp +31 -0
@@ 0,0 1,31 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "FrontlightPresenter.hpp"

namespace app::bell_settings
{
    FrontlightWindowPresenter::FrontlightWindowPresenter(std::shared_ptr<FrontlightModel> pagesProvider)
        : pagesProvider(std::move(pagesProvider))
    {}

    auto FrontlightWindowPresenter::saveData() -> void
    {
        pagesProvider->saveData();
    }

    auto FrontlightWindowPresenter::loadData() -> void
    {
        pagesProvider->loadData();
    }

    auto FrontlightWindowPresenter::createData() -> void
    {
        pagesProvider->createData();
    }

    auto FrontlightWindowPresenter::getPagesProvider() const -> std::shared_ptr<FrontlightModel>
    {
        return pagesProvider;
    }
} // namespace app::bell_settings

A products/BellHybrid/apps/application-bell-settings/presenter/FrontlightPresenter.hpp => products/BellHybrid/apps/application-bell-settings/presenter/FrontlightPresenter.hpp +46 -0
@@ 0,0 1,46 @@

// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include "models/FrontlightModel.hpp"
#include <apps-common/BasePresenter.hpp>
#include <memory>

namespace app::bell_settings
{
    class FrontlightWindowContract
    {
      public:
        class View
        {
          public:
            virtual ~View() noexcept = default;
        };

        class Presenter : public BasePresenter<FrontlightWindowContract::View>
        {
          public:
            virtual ~Presenter() noexcept                                             = default;
            virtual auto getPagesProvider() const -> std::shared_ptr<FrontlightModel> = 0;
            virtual auto saveData() -> void                                           = 0;
            virtual auto loadData() -> void                                           = 0;
            virtual auto createData() -> void                                         = 0;
        };
    };

    class FrontlightWindowPresenter : public FrontlightWindowContract::Presenter
    {
      public:
        explicit FrontlightWindowPresenter(std::shared_ptr<FrontlightModel> pagesProvider);

        auto saveData() -> void;
        auto loadData() -> void;
        auto createData() -> void;
        auto getPagesProvider() const -> std::shared_ptr<FrontlightModel> override;

      private:
        std::shared_ptr<FrontlightModel> pagesProvider;
    };
} // namespace app::bell_settings

M products/BellHybrid/apps/application-bell-settings/windows/BellSettingsAdvancedWindow.cpp => products/BellHybrid/apps/application-bell-settings/windows/BellSettingsAdvancedWindow.cpp +2 -0
@@ 57,6 57,8 @@ namespace gui

        addWinSettings(utils::translate("app_bell_settings_advanced_time_units"),
                       gui::window::name::bellSettingsTimeUnits);
        addWinSettings(utils::translate("app_bell_settings_advanced_frontlight"),
                       gui::window::name::bellSettingsFrontlight);

        return settingsOptionList;
    }

M products/BellHybrid/apps/application-bell-settings/windows/BellSettingsFinishedWindow.cpp => products/BellHybrid/apps/application-bell-settings/windows/BellSettingsFinishedWindow.cpp +16 -7
@@ 2,9 2,11 @@
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "BellSettingsFinishedWindow.hpp"
#include "data/FinishedWindowMessageData.hpp"

#include <gui/input/InputEvent.hpp>
#include <gui/widgets/Icon.hpp>
#include <log.hpp>

namespace
{


@@ 32,13 34,7 @@ namespace gui
        header->setTitleVisibility(false);
        bottomBar->setVisible(false);

        icon = new Icon(this,
                        0,
                        0,
                        style::window_width,
                        style::window_height,
                        "circle_success",
                        utils::translate("app_bell_settings_time_units_finished_message"));
        icon = new Icon(this, 0, 0, style::window_width, style::window_height, "circle_success", message);
    }
    bool BellSettingsFinishedWindow::onInput(const InputEvent &inputEvent)
    {


@@ 58,4 54,17 @@ namespace gui
        buildInterface();
    }

    void BellSettingsFinishedWindow::onBeforeShow(ShowMode mode, SwitchData *data)
    {
        WindowWithTimer::onBeforeShow(mode, data);
        auto messageData = dynamic_cast<FinishedWindowMessageData *>(data);
        if (messageData != nullptr) {
            message = messageData->getMessage();
            icon->text->setRichText(message);
        }
        else {
            LOG_ERROR("Received empty icon label message !");
        }
    }

} // namespace gui

M products/BellHybrid/apps/application-bell-settings/windows/BellSettingsFinishedWindow.hpp => products/BellHybrid/apps/application-bell-settings/windows/BellSettingsFinishedWindow.hpp +3 -0
@@ 20,8 20,11 @@ namespace gui
        void buildInterface() override;
        bool onInput(const InputEvent &inputEvent) override;
        void rebuild() override;
        void onBeforeShow(ShowMode mode, SwitchData *data) override;

        Icon *icon{};

        std::string message;
    };

} // namespace gui

A products/BellHybrid/apps/application-bell-settings/windows/BellSettingsFrontlight.cpp => products/BellHybrid/apps/application-bell-settings/windows/BellSettingsFrontlight.cpp +79 -0
@@ 0,0 1,79 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "application-bell-settings/ApplicationBellSettings.hpp"
#include "BellSettingsStyle.hpp"
#include "BellSettingsFrontlight.hpp"
#include "data/FinishedWindowMessageData.hpp"

#include <gui/input/InputEvent.hpp>
#include <apps-common/options/OptionStyle.hpp>
#include <widgets/SideListView.hpp>
#include <widgets/BellBaseLayout.hpp>

namespace gui
{
    BellSettingsFrontlightWindow::BellSettingsFrontlightWindow(
        app::Application *app,
        std::unique_ptr<app::bell_settings::FrontlightWindowContract::Presenter> &&windowPresenter,
        std::string name)
        : AppWindow(app, std::move(name)), presenter{std::move(windowPresenter)}
    {
        presenter->attach(this);
        buildInterface();
    }

    void BellSettingsFrontlightWindow::rebuild()
    {
        erase();
        buildInterface();
    }

    void BellSettingsFrontlightWindow::buildInterface()
    {
        AppWindow::buildInterface();
        statusBar->setVisible(false);
        header->setTitleVisibility(true);
        bottomBar->setVisible(false);

        presenter->createData();

        body = new BellBaseLayout(this, 0, 0, style::window_width, style::window_height);

        topText = new Label(body->firstBox);
        topText->setMinimumSize(style::bell_base_layout::w, style::bell_base_layout::outer_layouts_h);
        topText->setText(utils::translate("app_bell_settings_frontlight_top_message"));
        topText->setFont(bell_settings_style::top_text::font);
        topText->setEdges(RectangleEdge::None);
        topText->activeItem = false;
        topText->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center));

        auto centerBox = dynamic_cast<HBox *>(body->getCenterBox());
        centerBox->addWidget(presenter->getPagesProvider()->getSpinner());
        body->resizeItems();
        body->firstBox->resizeItems();
        centerBox->resizeItems();
        body->lastBox->resizeItems();

        presenter->loadData();

        setFocusItem(body);
    }

    bool BellSettingsFrontlightWindow::onInput(const gui::InputEvent &inputEvent)
    {
        if (body->onInput(inputEvent)) {
            return true;
        }
        if (inputEvent.isShortRelease(KeyCode::KEY_ENTER)) {
            presenter->saveData();

            auto finishedMessageData = std::make_unique<FinishedWindowMessageData>(
                utils::translate("app_bell_settings_frontlight_finished_message"));
            application->switchWindow(window::name::bellSettingsFinished, std::move(finishedMessageData));
            return true;
        }

        return AppWindow::onInput(inputEvent);
    }
} /* namespace gui */

A products/BellHybrid/apps/application-bell-settings/windows/BellSettingsFrontlight.hpp => products/BellHybrid/apps/application-bell-settings/windows/BellSettingsFrontlight.hpp +31 -0
@@ 0,0 1,31 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include "application-bell-settings/ApplicationBellSettings.hpp"
#include "presenter/FrontlightPresenter.hpp"
#include <apps-common/windows/AppWindow.hpp>

namespace gui
{
    class BellBaseLayout;

    class BellSettingsFrontlightWindow : public AppWindow, public app::bell_settings::FrontlightWindowContract::View
    {
      public:
        explicit BellSettingsFrontlightWindow(
            app::Application *app,
            std::unique_ptr<app::bell_settings::FrontlightWindowContract::Presenter> &&windowPresenter,
            std::string name = window::name::bellSettingsFrontlight);

        void buildInterface() override;
        bool onInput(const InputEvent &inputEvent) override;
        void rebuild() override;

      private:
        BellBaseLayout *body{nullptr};
        Label *topText{nullptr};
        std::unique_ptr<app::bell_settings::FrontlightWindowContract::Presenter> presenter;
    };
} /* namespace gui */

M products/BellHybrid/apps/application-bell-settings/windows/BellSettingsTimeUnitsWindow.cpp => products/BellHybrid/apps/application-bell-settings/windows/BellSettingsTimeUnitsWindow.cpp +4 -1
@@ 4,6 4,7 @@
#include "application-bell-settings/ApplicationBellSettings.hpp"
#include "BellSettingsStyle.hpp"
#include "BellSettingsTimeUnitsWindow.hpp"
#include "data/FinishedWindowMessageData.hpp"

#include <gui/input/InputEvent.hpp>
#include <apps-common/options/OptionStyle.hpp>


@@ 53,7 54,9 @@ namespace gui
        }
        if (inputEvent.isShortRelease(KeyCode::KEY_ENTER)) {
            presenter->saveData();
            application->switchWindow(window::name::bellSettingsFinished);
            auto finishedMessageData = std::make_unique<FinishedWindowMessageData>(
                utils::translate("app_bell_settings_time_units_finished_message"));
            application->switchWindow(window::name::bellSettingsFinished, std::move(finishedMessageData));
            return true;
        }
        if (AppWindow::onInput(inputEvent)) {

M products/BellHybrid/services/evtmgr/CMakeLists.txt => products/BellHybrid/services/evtmgr/CMakeLists.txt +2 -0
@@ 4,6 4,8 @@ add_library(bell::evtmgr ALIAS evtmgr)
target_sources(evtmgr
    PRIVATE
        EventManager.cpp
        WorkerEvent.cpp
        WorkerEvent.hpp
        internal/StaticData.cpp
        internal/TemperatureApi.cpp


M products/BellHybrid/services/evtmgr/EventManager.cpp => products/BellHybrid/services/evtmgr/EventManager.cpp +55 -1
@@ 3,11 3,16 @@

#include "internal/StaticData.hpp"

#include "WorkerEvent.hpp"
#include <evtmgr/EventManager.hpp>
#include <evtmgr/messages/AlarmMessage.hpp>
#include <keymap/KeyMap.hpp>
#include <module-bsp/hal/temperature_source/TemperatureSource.hpp>
#include <service-evtmgr/KbdMessage.hpp>
#include <screen-light-control/ScreenLightControl.hpp>
#include <service-evtmgr/EVMessages.hpp>
#include <service-evtmgr/ScreenLightControlMessage.hpp>
#include <service-evtmgr/WorkerEventCommon.hpp>

namespace
{


@@ 23,7 28,8 @@ namespace
}

EventManager::EventManager(const std::string &name)
    : EventManagerCommon(name), temperatureSource{hal::temperature::AbstractTemperatureSource::Factory::create()}
    : EventManagerCommon(name), temperatureSource{hal::temperature::AbstractTemperatureSource::Factory::create()},
      backlightHandler(settings, this)
{
    updateTemperature(*temperatureSource);



@@ 45,3 51,51 @@ void EventManager::handleKeyEvent(sys::Message *msg)
        bus.sendMulticast(std::make_unique<AlarmActivated>(), sys::BusChannel::AlarmChanges);
    }
}

auto EventManager::createEventWorker() -> std::unique_ptr<WorkerEventCommon>
{
    return std::make_unique<bell::WorkerEvent>(this);
}

void EventManager::initProductEvents()
{
    backlightHandler.init();

    connect(typeid(sevm::ScreenLightControlMessage), [&](sys::Message *msgl) {
        auto *m = static_cast<sevm::ScreenLightControlMessage *>(msgl);
        backlightHandler.processScreenRequest(m->getAction(), screen_light_control::Parameters());
        return sys::msgHandled();
    });

    connect(typeid(sevm::ScreenLightSetAutoModeParams), [&](sys::Message *msgl) {
        auto *m = static_cast<sevm::ScreenLightSetAutoModeParams *>(msgl);
        backlightHandler.processScreenRequest(m->getAction(), screen_light_control::Parameters(m->getParams()));
        return sys::msgHandled();
    });

    connect(typeid(sevm::ScreenLightSetManualModeParams), [&](sys::Message *msgl) {
        auto *m = static_cast<sevm::ScreenLightSetManualModeParams *>(msgl);
        backlightHandler.processScreenRequest(m->getAction(), screen_light_control::Parameters(m->getParams()));
        return sys::msgHandled();
    });

    connect(sevm::ScreenLightControlRequestParameters(), [&](sys::Message *msgl) {
        screen_light_control::ManualModeParameters params = {backlightHandler.getScreenBrightnessValue()};
        auto msg = std::make_shared<sevm::ScreenLightControlParametersResponse>(
            backlightHandler.getScreenLightState(), backlightHandler.getScreenAutoModeState(), params);
        return msg;
    });
}

sys::MessagePointer EventManager::DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp)
{

    auto responseMessage =
        std::static_pointer_cast<sys::ResponseMessage>(EventManagerCommon::DataReceivedHandler(msgl, resp));

    if (responseMessage->retCode != sys::ReturnCodes::Unresolved) {
        return responseMessage;
    }

    return std::make_shared<sys::ResponseMessage>(sys::ReturnCodes::Unresolved);
}

A products/BellHybrid/services/evtmgr/WorkerEvent.cpp => products/BellHybrid/services/evtmgr/WorkerEvent.cpp +34 -0
@@ 0,0 1,34 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "WorkerEvent.hpp"

#include <bsp/eink_frontlight/eink_frontlight.hpp>
#include <service-audio/AudioMessage.hpp>
#include <service-evtmgr/EVMessages.hpp>

namespace bell
{

    WorkerEvent::WorkerEvent(sys::Service *service) : WorkerEventCommon(service)
    {}

    void WorkerEvent::addProductQueues(std::list<sys::WorkerQueueInfo> &queuesList)
    {}

    void WorkerEvent::initProductHardware()
    {
        bsp::eink_frontlight::init();
    }

    bool WorkerEvent::handleMessage(std::uint32_t queueID)
    {

        return WorkerEventCommon::handleMessage(queueID);
    }

    void WorkerEvent::deinitProductHardware()
    {
        bsp::eink_frontlight::deinit();
    }
} // namespace bell

A products/BellHybrid/services/evtmgr/WorkerEvent.hpp => products/BellHybrid/services/evtmgr/WorkerEvent.hpp +21 -0
@@ 0,0 1,21 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <service-evtmgr/WorkerEventCommon.hpp>

namespace bell
{
    class WorkerEvent : public WorkerEventCommon
    {
      public:
        explicit WorkerEvent(sys::Service *service);

      private:
        void addProductQueues(std::list<sys::WorkerQueueInfo> &queuesList) final;
        void initProductHardware() final;
        void deinitProductHardware() final;
        bool handleMessage(std::uint32_t queueID) override;
    };
} // namespace bell

M products/BellHybrid/services/evtmgr/include/evtmgr/EventManager.hpp => products/BellHybrid/services/evtmgr/include/evtmgr/EventManager.hpp +6 -2
@@ 5,6 5,8 @@

#include <service-evtmgr/EventManagerCommon.hpp>

#include <backlight-handler/BacklightHandler.hpp>

namespace hal::temperature
{
    class AbstractTemperatureSource;


@@ 17,9 19,11 @@ class EventManager : public EventManagerCommon

  private:
    void handleKeyEvent(sys::Message *msg) override;

  private:
    sys::MessagePointer DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) override;
    void initProductEvents() final;
    auto createEventWorker() -> std::unique_ptr<WorkerEventCommon> final;
    std::shared_ptr<hal::temperature::AbstractTemperatureSource> temperatureSource;
    backlight::Handler backlightHandler;
};

namespace sys