~aleteoryx/muditaos

1e9cf7d5572eb2dcbef812b79f1c52fa68e05162 — Paweł Joński 4 years ago 3bca468
[BH-1036] Fix confirmation & welcome screens after factory reset

Fix confifmation & welcome screens after factory reset
A image/assets/images/circle_success_big.vpi => image/assets/images/circle_success_big.vpi +0 -0
M module-apps/apps-common/popups/presenter/PowerOffPresenter.cpp => module-apps/apps-common/popups/presenter/PowerOffPresenter.cpp +1 -1
@@ 10,7 10,7 @@ namespace gui
    PowerOffPresenter::PowerOffPresenter(app::ApplicationCommon *app) : application(app)
    {}

    void PowerOffPresenter::powerOff()
    void PowerOffPresenter::powerOff(sys::CloseReason reason)
    {
        auto msg = std::make_shared<app::UserPowerDownRequest>();
        application->bus.sendUnicast(std::move(msg), service::name::system_manager);

M module-apps/apps-common/popups/presenter/PowerOffPresenter.hpp => module-apps/apps-common/popups/presenter/PowerOffPresenter.hpp +4 -2
@@ 3,6 3,8 @@

#pragma once

#include <system/Common.hpp>

namespace app
{
    class ApplicationCommon;


@@ 14,7 16,7 @@ namespace gui
    {
      public:
        virtual ~AbstractPowerOffPresenter() = default;
        virtual void powerOff()              = 0;
        virtual void powerOff(sys::CloseReason reason = sys::CloseReason::RegularPowerDown) = 0;
        virtual void reboot()                = 0;
    };



@@ 22,7 24,7 @@ namespace gui
    {
      public:
        PowerOffPresenter(app::ApplicationCommon *app);
        void powerOff() override;
        void powerOff(sys::CloseReason reason = sys::CloseReason::RegularPowerDown) override;
        void reboot() override;

      private:

M products/BellHybrid/apps/application-bell-main/ApplicationBellMain.cpp => products/BellHybrid/apps/application-bell-main/ApplicationBellMain.cpp +5 -0
@@ 11,9 11,11 @@
#include "windows/BellMainMenuWindow.hpp"

#include <apps-common/messages/AppMessage.hpp>
#include <common/BellPowerOffPresenter.hpp>
#include <common/models/AlarmModel.hpp>
#include <common/models/TimeModel.hpp>
#include <common/windows/BellWelcomeWindow.hpp>
#include <common/windows/BellFactoryReset.hpp>
#include <service-db/DBNotificationMessage.hpp>
#include <windows/Dialog.hpp>
#include <service-audio/AudioMessage.hpp>


@@ 72,6 74,9 @@ namespace app
                              [](ApplicationCommon *app, const std::string &name) {
                                  return std::make_unique<gui::BellBatteryShutdownWindow>(app);
                              });
        windowsFactory.attach(gui::BellFactoryReset::name, [](ApplicationCommon *app, const std::string &name) {
            return std::make_unique<gui::BellFactoryReset>(app, std::make_unique<gui::BellPowerOffPresenter>(app));
        });

        // for demo only - to be removed
        windowsFactory.attach(

M products/BellHybrid/apps/application-bell-settings/ApplicationBellSettings.cpp => products/BellHybrid/apps/application-bell-settings/ApplicationBellSettings.cpp +8 -1
@@ 32,8 32,10 @@

#include <AlarmSoundPaths.hpp>
#include <apps-common/windows/Dialog.hpp>
#include <common/BellPowerOffPresenter.hpp>
#include <common/models/BedtimeModel.hpp>
#include <common/windows/BellFinishedWindow.hpp>
#include <common/windows/BellFinishedCallbackWindow.hpp>
#include <common/windows/BellTurnOffWindow.hpp>
#include <common/popups/BellTurnOffOptionWindow.hpp>
#include <common/models/AudioModel.hpp>


@@ 115,6 117,11 @@ namespace app
                                  return std::make_unique<gui::BellFinishedWindow>(app);
                              });

        windowsFactory.attach(gui::BellFinishedCallbackWindow::defaultName,
                              [](ApplicationCommon *app, const std::string &name) {
                                  return std::make_unique<gui::BellFinishedCallbackWindow>(app);
                              });

        windowsFactory.attach(gui::window::name::bellSettingsHomeView,
                              [](ApplicationCommon *app, const std::string &name) {
                                  return std::make_unique<gui::BellSettingsHomeViewWindow>(app);


@@ 139,7 146,7 @@ namespace app
                              });

        windowsFactory.attach(gui::BellTurnOffWindow::name, [](ApplicationCommon *app, const std::string &name) {
            return std::make_unique<gui::BellTurnOffWindow>(app, std::make_unique<gui::PowerOffPresenter>(app));
            return std::make_unique<gui::BellTurnOffWindow>(app, std::make_unique<gui::BellPowerOffPresenter>(app));
        });

        windowsFactory.attach(

M products/BellHybrid/apps/application-bell-settings/CMakeLists.txt => products/BellHybrid/apps/application-bell-settings/CMakeLists.txt +1 -0
@@ 123,6 123,7 @@ target_link_libraries(application-bell-settings
        bellgui
        bell::db
        bell::alarms
        bell::app-main
        service-appmgr
        apps-common
    PUBLIC

M products/BellHybrid/apps/application-bell-settings/windows/advanced/BellSettingsAdvancedWindow.cpp => products/BellHybrid/apps/application-bell-settings/windows/advanced/BellSettingsAdvancedWindow.cpp +12 -8
@@ 6,10 6,17 @@
#include "BellSettingsStyle.hpp"
#include "BellSettingsFrontlightWindow.hpp"

#include <common/options/OptionBellMenu.hpp>
#include <application-bell-main/ApplicationBellMain.hpp>
#include <apps-common/messages/DialogMetadataMessage.hpp>
#include <apps-common/windows/Dialog.hpp>
#include <common/options/OptionBellMenu.hpp>
#include <service-appmgr/Constants.hpp>
#include <service-appmgr/messages/UserPowerDownRequest.hpp>
#include <service-appmgr/messages/SwitchRequest.hpp>
#include <windows/advanced/AboutYourBellWindow.hpp>
#include <common/windows/BellFinishedWindow.hpp>
#include <common/windows/BellFactoryReset.hpp>
#include <common/windows/BellFinishedCallbackWindow.hpp>
#include <common/windows/BellTurnOffWindow.hpp>

namespace gui
{


@@ 40,12 47,9 @@ namespace gui

        auto factoryResetCallback = [this](const std::string &window) {
            auto actionCallback = [this]() {
                if (sys::SystemManagerCommon::FactoryReset(application)) {
                    application->switchWindow(
                        window::bell_finished::defaultName,
                        BellFinishedWindowData::Factory::create(
                            "big_check_W_M", utils::translate("app_bell_settings_factory_reset_finished"), ""));
                }
                auto switchRequest = std::make_unique<app::manager::SwitchRequest>(
                    service::name::appmgr, app::applicationBellName, gui::BellFactoryReset::name, nullptr);
                application->bus.sendUnicast(std::move(switchRequest), service::name::appmgr);
                return true;
            };


M products/BellHybrid/apps/common/CMakeLists.txt => products/BellHybrid/apps/common/CMakeLists.txt +2 -0
@@ 16,6 16,7 @@ target_sources(application-bell-common
        src/TimeModel.cpp
        src/SoundsRepository.cpp
        src/BellListItemProvider.cpp
        src/windows/BellFactoryReset.cpp
        src/windows/BellFinishedWindow.cpp
        src/windows/BellFinishedCallbackWindow.cpp
        src/windows/BellTurnOffWindow.cpp


@@ 42,6 43,7 @@ target_sources(application-bell-common
        include/common/BellListItemProvider.hpp
        include/common/SoundsRepository.hpp
        include/common/BellPowerOffPresenter.hpp
        include/common/windows/BellFactoryReset.hpp
        include/common/windows/BellFinishedWindow.hpp
        include/common/windows/BellFinishedCallbackWindow.hpp
        include/common/windows/BellTurnOffWindow.hpp

M products/BellHybrid/apps/common/include/common/BellPowerOffPresenter.hpp => products/BellHybrid/apps/common/include/common/BellPowerOffPresenter.hpp +1 -1
@@ 11,7 11,7 @@ namespace gui
    {
      public:
        explicit BellPowerOffPresenter(app::ApplicationCommon *app);
        void powerOff() override;
        void powerOff(sys::CloseReason reason = sys::CloseReason::RegularPowerDown) override;
        void reboot() override;

      private:

A products/BellHybrid/apps/common/include/common/windows/BellFactoryReset.hpp => products/BellHybrid/apps/common/include/common/windows/BellFactoryReset.hpp +28 -0
@@ 0,0 1,28 @@
// 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/popups/presenter/PowerOffPresenter.hpp>
#include <apps-common/popups/WindowWithTimer.hpp>

namespace gui
{
    class Icon;

    class BellFactoryReset : public WindowWithTimer
    {
      public:
        static constexpr auto name = "BellFactoryResetWindow";

        BellFactoryReset(app::ApplicationCommon *app, std::unique_ptr<AbstractPowerOffPresenter> presenter);

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

        Icon *icon{};
        std::unique_ptr<AbstractPowerOffPresenter> presenter;
    };

} // namespace gui

M products/BellHybrid/apps/common/include/common/windows/BellTurnOffWindow.hpp => products/BellHybrid/apps/common/include/common/windows/BellTurnOffWindow.hpp +1 -1
@@ 3,7 3,7 @@

#pragma once

#include <apps-common/popups/presenter/PowerOffPresenter.hpp>
#include <common/BellPowerOffPresenter.hpp>
#include <apps-common/popups/WindowWithTimer.hpp>

namespace gui

M products/BellHybrid/apps/common/src/BellPowerOffPresenter.cpp => products/BellHybrid/apps/common/src/BellPowerOffPresenter.cpp +10 -3
@@ 13,10 13,17 @@ namespace gui
    BellPowerOffPresenter::BellPowerOffPresenter(app::ApplicationCommon *app) : application(app)
    {}

    void BellPowerOffPresenter::powerOff()
    void BellPowerOffPresenter::powerOff(sys::CloseReason reason)
    {
        auto msg = std::make_shared<app::UserPowerDownRequest>();
        application->bus.sendUnicast(std::move(msg), service::name::system_manager);
        switch (reason) {
        case sys::CloseReason::FactoryReset:
            sys::SystemManagerCommon::FactoryReset(application);
            break;
        default:
            auto msg = std::make_shared<app::UserPowerDownRequest>();
            application->bus.sendUnicast(std::move(msg), service::name::system_manager);
            break;
        }
    }
    void BellPowerOffPresenter::reboot()
    {

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

#include "windows/BellFactoryReset.hpp"
#include <gui/input/InputEvent.hpp>
#include <gui/widgets/Icon.hpp>
#include <i18n/i18n.hpp>
#include <Application.hpp>

namespace gui
{
    BellFactoryReset::BellFactoryReset(app::ApplicationCommon *app,
                                       std::unique_ptr<AbstractPowerOffPresenter> presenter)
        : WindowWithTimer(app, name), presenter(std::move(presenter))
    {
        buildInterface();

        timerCallback = [this](Item &, sys::Timer &) {
            this->presenter->powerOff(sys::CloseReason::FactoryReset);
            return true;
        };
    }

    void BellFactoryReset::buildInterface()
    {
        WindowWithTimer::buildInterface();

        statusBar->setVisible(false);
        header->setTitleVisibility(false);
        bottomBar->setVisible(false);

        if (icon == nullptr) {
            icon = new Icon(this, 0, 0, style::window_width, style::window_height, "circle_success_big", {});
            icon->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center));
        }
    }
    bool BellFactoryReset::onInput(const InputEvent &)
    {
        return false;
    }

} // namespace gui

M products/BellHybrid/apps/common/src/windows/BellTurnOffWindow.cpp => products/BellHybrid/apps/common/src/windows/BellTurnOffWindow.cpp +2 -0
@@ 7,6 7,8 @@
#include <i18n/i18n.hpp>
#include <Application.hpp>

#include <system/Common.hpp>

namespace gui
{
    BellTurnOffWindow::BellTurnOffWindow(app::ApplicationCommon *app,