~aleteoryx/muditaos

fe54fbe61c3be79e9c6331bee45e137d0d3314fc — mkamonMdt 4 years ago 8c5ca7e
[EGD-878] Add Background Sounds basic app structure

The following commit provides an implementation of basic
Background Sounds application structure that will serve
as base for futher developement
M products/BellHybrid/BellHybridMain.cpp => products/BellHybrid/BellHybridMain.cpp +3 -0
@@ 6,6 6,7 @@
// applications
#include <application-bell-alarm/ApplicationBellAlarm.hpp>
#include <application-bell-onboarding/ApplicationBellOnBoarding.hpp>
#include <application-bell-background-sounds/ApplicationBellBackgroundSounds.hpp>
#include <application-bell-main/ApplicationBellMain.hpp>
#include <application-bell-settings/ApplicationBellSettings.hpp>
#include <application-bell-powernap/ApplicationBellPowerNap.hpp>


@@ 99,6 100,8 @@ int main()
            applications.push_back(app::CreateLauncher<app::ApplicationBellPowerNap>(app::applicationBellPowerNapName));
            applications.push_back(
                app::CreateLauncher<app::ApplicationBellOnBoarding>(app::applicationBellOnBoardingName));
            applications.push_back(
                app::CreateLauncher<app::ApplicationBellBackgroundSounds>(app::applicationBellBackgroundSoundsName));
            // start application manager
            return sysmgr->RunSystemService(
                std::make_shared<app::manager::ApplicationManager>(

M products/BellHybrid/CMakeLists.txt => products/BellHybrid/CMakeLists.txt +1 -0
@@ 40,6 40,7 @@ target_link_libraries(BellHybrid
        appmgr
        bell::app-alarm
        bell::app-onboarding
        bell::app-background-sounds
        bell::app-common
        bell::app-main
        bell::app-powernap

M products/BellHybrid/apps/CMakeLists.txt => products/BellHybrid/apps/CMakeLists.txt +1 -0
@@ 20,6 20,7 @@ target_link_libraries(app

add_subdirectory(application-bell-main)
add_subdirectory(application-bell-onboarding)
add_subdirectory(application-bell-background-sounds)
add_subdirectory(application-bell-alarm)
add_subdirectory(application-bell-settings)
add_subdirectory(application-bell-powernap)

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

#include "ApplicationBellBackgroundSounds.hpp"
#include "presenter/BGSoundsMainWindowPresenter.hpp"
#include "windows/BGSoundsMainWindow.hpp"

namespace app
{
    ApplicationBellBackgroundSounds::ApplicationBellBackgroundSounds(std::string name,
                                                                     std::string parent,
                                                                     sys::phone_modes::PhoneMode mode,
                                                                     sys::bluetooth::BluetoothMode bluetoothMode,
                                                                     StartInBackground startInBackground)
        : Application(std::move(name), std::move(parent), mode, bluetoothMode, startInBackground)
    {}

    sys::ReturnCodes ApplicationBellBackgroundSounds::InitHandler()
    {
        auto ret = Application::InitHandler();
        if (ret != sys::ReturnCodes::Success) {
            return ret;
        }
        createUserInterface();

        return sys::ReturnCodes::Success;
    }

    void ApplicationBellBackgroundSounds::createUserInterface()
    {
        windowsFactory.attach(gui::name::window::main_window, [](ApplicationCommon *app, const std::string &name) {
            auto presenter = std::make_unique<bgSounds::BGSoundsMainWindowPresenter>();
            return std::make_unique<gui::BGSoundsMainWindow>(app, std::move(presenter));
        });
    }

    sys::MessagePointer ApplicationBellBackgroundSounds::DataReceivedHandler(sys::DataMessage *msgl,
                                                                             sys::ResponseMessage *resp)
    {
        auto retMsg = Application::DataReceivedHandler(msgl);
        if (auto response = dynamic_cast<sys::ResponseMessage *>(retMsg.get());
            response != nullptr && response->retCode == sys::ReturnCodes::Success) {
            return retMsg;
        }
        return handleAsyncResponse(resp);
    }
} // namespace app

A products/BellHybrid/apps/application-bell-background-sounds/CMakeLists.txt => products/BellHybrid/apps/application-bell-background-sounds/CMakeLists.txt +32 -0
@@ 0,0 1,32 @@
add_library(application-bell-background-sounds STATIC)
add_library(bell::app-background-sounds ALIAS application-bell-background-sounds)

target_include_directories(application-bell-background-sounds
    PRIVATE
        $<BUILD_INTERFACE:
            include/application-bell-background-sounds
        >
    PUBLIC
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)

target_sources(application-bell-background-sounds
    PRIVATE
        ApplicationBellBackgroundSounds.cpp
        windows/BGSoundsMainWindow.cpp

        presenter/BGSoundsMainWindowPresenter.hpp
        windows/BGSoundsMainWindow.hpp

    PUBLIC
        include/application-bell-background-sounds/ApplicationBellBackgroundSounds.hpp
)

target_link_libraries(application-bell-background-sounds
    PRIVATE
        app
        apps-common

    PUBLIC
        module-gui
)

A products/BellHybrid/apps/application-bell-background-sounds/include/application-bell-background-sounds/ApplicationBellBackgroundSounds.hpp => products/BellHybrid/apps/application-bell-background-sounds/include/application-bell-background-sounds/ApplicationBellBackgroundSounds.hpp +43 -0
@@ 0,0 1,43 @@
// 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.hpp>

namespace app
{
    inline constexpr auto applicationBellBackgroundSoundsName = "ApplicationBellBackgroundSounds";

    class ApplicationBellBackgroundSounds : public Application
    {
      public:
        ApplicationBellBackgroundSounds(
            std::string name                            = applicationBellBackgroundSoundsName,
            std::string parent                          = "",
            sys::phone_modes::PhoneMode mode            = sys::phone_modes::PhoneMode::Offline,
            sys::bluetooth::BluetoothMode bluetoothMode = sys::bluetooth::BluetoothMode::Disabled,
            StartInBackground startInBackground         = {false});

        sys::ReturnCodes InitHandler() override;

        void createUserInterface() override;
        void destroyUserInterface() override
        {}

        sys::MessagePointer DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) override;

        sys::ReturnCodes SwitchPowerModeHandler(const sys::ServicePowerMode mode) override final
        {
            return sys::ReturnCodes::Success;
        }
    };

    template <> struct ManifestTraits<ApplicationBellBackgroundSounds>
    {
        static auto GetManifest() -> manager::ApplicationManifest
        {
            return {{manager::actions::Launch}};
        }
    };
} // namespace app

A products/BellHybrid/apps/application-bell-background-sounds/presenter/BGSoundsMainWindowPresenter.hpp => products/BellHybrid/apps/application-bell-background-sounds/presenter/BGSoundsMainWindowPresenter.hpp +25 -0
@@ 0,0 1,25 @@
// 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/BasePresenter.hpp>

namespace app::bgSounds
{
    class BGSoundsMainWindowContract
    {
      public:
        class View
        {
          public:
            ~View() = default;
        };

        class Presenter : public BasePresenter<BGSoundsMainWindowContract::View>
        {};
    };

    class BGSoundsMainWindowPresenter : public BGSoundsMainWindowContract::Presenter
    {};
} // namespace app::bgSounds

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

#include "BGSoundsMainWindow.hpp"

namespace gui
{
    BGSoundsMainWindow::BGSoundsMainWindow(
        app::ApplicationCommon *app, std::unique_ptr<app::bgSounds::BGSoundsMainWindowContract::Presenter> &&presenter)
        : AppWindow(app, gui::name::window::main_window), presenter{std::move(presenter)}
    {
        this->presenter->attach(this);
        buildInterface();
    }
} // namespace gui

A products/BellHybrid/apps/application-bell-background-sounds/windows/BGSoundsMainWindow.hpp => products/BellHybrid/apps/application-bell-background-sounds/windows/BGSoundsMainWindow.hpp +18 -0
@@ 0,0 1,18 @@
// 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 "presenter/BGSoundsMainWindowPresenter.hpp"
#include <AppWindow.hpp>
namespace gui
{
    class BGSoundsMainWindow : public AppWindow, public app::bgSounds::BGSoundsMainWindowContract::View
    {
        std::unique_ptr<app::bgSounds::BGSoundsMainWindowContract::Presenter> presenter;

      public:
        BGSoundsMainWindow(app::ApplicationCommon *app,
                           std::unique_ptr<app::bgSounds::BGSoundsMainWindowContract::Presenter> &&presenter);
    };
} // namespace gui

M products/BellHybrid/apps/application-bell-main/CMakeLists.txt => products/BellHybrid/apps/application-bell-main/CMakeLists.txt +1 -0
@@ 45,6 45,7 @@ target_link_libraries(application-bell-main
        bell::evtmgr
        bell::app-alarm
        bell::app-onboarding
        bell::app-background-sounds
        bell::app-settings
        bell::app-powernap
        bell::keymap

M products/BellHybrid/apps/application-bell-main/windows/BellMainMenuWindow.cpp => products/BellHybrid/apps/application-bell-main/windows/BellMainMenuWindow.cpp +2 -1
@@ 4,6 4,7 @@
#include "BellMainMenuWindow.hpp"

#include <application-bell-alarm/ApplicationBellAlarm.hpp>
#include <application-bell-background-sounds/ApplicationBellBackgroundSounds.hpp>
#include <application-bell-main/ApplicationBellMain.hpp>
#include <application-bell-settings/ApplicationBellSettings.hpp>
#include <application-bell-powernap/ApplicationBellPowerNap.hpp>


@@ 66,9 67,9 @@ namespace gui

        addAppMenu(utils::translate("app_bellmain_alarm"), app::applicationBellAlarmName);
        addAppMenu(utils::translate("app_bellmain_power_nap"), app::applicationBellPowerNapName);
        addAppMenu(utils::translate("app_bellmain_background_sounds"), app::applicationBellBackgroundSoundsName);
        // for demo only - to be replaced by call o final window
        addWinMenu(utils::translate("app_bellmain_meditation_timer"), gui::window::name::bell_main_menu_dialog);
        addWinMenu(utils::translate("app_bellmain_background_sounds"), gui::window::name::bell_main_menu_dialog);
        addWinMenu(utils::translate("app_bellmain_bedtime"), gui::window::name::bell_main_menu_dialog);

        addAppMenu(utils::translate("app_bellmain_settings"), app::applicationBellSettingsName);