~aleteoryx/muditaos

1eaf2e35bf41a1b69ce14b256e52a87a50fba791 — Maciej Gibowicz 1 year, 6 months ago 7b20578
[BH-1946] Add update instructions in settings

User will see instructions on how to update Harmony operating system at
any time in settings.
M harmony_changelog.md => harmony_changelog.md +1 -0
@@ 8,6 8,7 @@
### Added
* Added custom alarms functionality
* Added update instruction screen at end of onboarding
* Added update instruction screen in Settings

### Changed / Improved
* Changed the refresh rate of the progress bar screen

M products/BellHybrid/apps/application-bell-settings/ApplicationBellSettings.cpp => products/BellHybrid/apps/application-bell-settings/ApplicationBellSettings.cpp +8 -0
@@ 19,6 19,7 @@
#include "presenter/alarm_settings/SnoozePresenter.hpp"
#include "presenter/FrontlightPresenter.hpp"
#include "presenter/ShortcutsWindowPresenter.hpp"
#include "presenter/UpdateInstructionWindowPresenter.hpp"
#include "windows/AboutYourBellWindow.hpp"
#include "windows/BellSettingsLanguageWindow.hpp"
#include "windows/BellSettingsLayoutWindow.hpp"


@@ 41,6 42,7 @@
#include <common/windows/BellFinishedWindow.hpp>
#include <common/windows/BellTurnOffWindow.hpp>
#include <common/windows/ShortcutsWindow.hpp>
#include <common/windows/UpdateInstructionWindow.hpp>
#include <common/popups/BellTurnOffOptionWindow.hpp>
#include <common/models/AudioModel.hpp>
#include <common/models/TimeModel.hpp>


@@ 287,6 289,12 @@ namespace app
                                  return std::make_unique<gui::ShortcutsWindow>(app, std::move(presenter), name);
                              });

        windowsFactory.attach(
            gui::window::name::bellSettingsUpdateInstruction, [&](ApplicationCommon *app, const std::string &name) {
                auto presenter = std::make_unique<bell_settings::UpdateInstructionWindowPresenter>(this);
                return std::make_unique<gui::UpdateInstructionWindow>(app, std::move(presenter), name);
            });

        attachPopups({gui::popup::ID::AlarmActivated,
                      gui::popup::ID::AlarmDeactivated,
                      gui::popup::ID::PowerOff,

M products/BellHybrid/apps/application-bell-settings/CMakeLists.txt => products/BellHybrid/apps/application-bell-settings/CMakeLists.txt +2 -0
@@ 45,6 45,7 @@ target_sources(application-bell-settings
        presenter/LanguageWindowPresenter.cpp
        presenter/LayoutWindowPresenter.cpp
        presenter/ShortcutsWindowPresenter.cpp
        presenter/UpdateInstructionWindowPresenter.cpp
        presenter/alarm_settings/AlarmSettingsPresenter.cpp
        presenter/alarm_settings/PrewakeUpPresenter.cpp
        presenter/alarm_settings/SnoozePresenter.cpp


@@ 91,6 92,7 @@ target_sources(application-bell-settings
        presenter/LanguageWindowPresenter.hpp
        presenter/LayoutWindowPresenter.hpp
        presenter/ShortcutsWindowPresenter.hpp
        presenter/UpdateInstructionWindowPresenter.hpp
        presenter/alarm_settings/AlarmSettingsPresenter.hpp
        presenter/alarm_settings/PrewakeUpPresenter.hpp
        presenter/alarm_settings/SnoozePresenter.hpp

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 +8 -7
@@ 10,13 10,14 @@

namespace gui::window::name
{
    inline constexpr auto bellSettings             = gui::name::window::main_window;
    inline constexpr auto bellSettingsTimeUnits    = "BellSettingsTimeUnits";
    inline constexpr auto bellSettingsHomeView     = "BellSettingsHomeView";
    inline constexpr auto bellSettingsLanguage     = "BellSettingsLanguage";
    inline constexpr auto bellSettingsLayout       = "BellSettingsLayout";
    inline constexpr auto bellSettingsBedtimeTone  = "BellSettingsBedtimeTone";
    inline constexpr auto bellSettingsShortcuts    = "BellSettingsShortcuts";
    inline constexpr auto bellSettings                  = gui::name::window::main_window;
    inline constexpr auto bellSettingsTimeUnits         = "BellSettingsTimeUnits";
    inline constexpr auto bellSettingsHomeView          = "BellSettingsHomeView";
    inline constexpr auto bellSettingsLanguage          = "BellSettingsLanguage";
    inline constexpr auto bellSettingsLayout            = "BellSettingsLayout";
    inline constexpr auto bellSettingsBedtimeTone       = "BellSettingsBedtimeTone";
    inline constexpr auto bellSettingsShortcuts         = "BellSettingsShortcuts";
    inline constexpr auto bellSettingsUpdateInstruction = "BellSettingsUpdateInstruction";
} // namespace gui::window::name

namespace app

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

#include "UpdateInstructionWindowPresenter.hpp"
#include <common/layouts/UpdateInstructionLayoutProvider.hpp>
#include <common/layouts/UpdateInstructionLayouts.hpp>

namespace app::bell_settings
{
    UpdateInstructionWindowPresenter::UpdateInstructionWindowPresenter(app::ApplicationCommon *app) : app(app)
    {
        initLayoutOptions();
    }

    std::vector<gui::Item *> UpdateInstructionWindowPresenter::getLayouts() const
    {
        return layoutOptions;
    }

    gui::Item *UpdateInstructionWindowPresenter::getFirstLayout() const
    {
        return layoutOptions.empty() ? nullptr : layoutOptions.front();
    }

    bool UpdateInstructionWindowPresenter::isLastLayout(const gui::Item *layout) const
    {
        return !layoutOptions.empty() && layoutOptions.back() == layout;
    }

    void UpdateInstructionWindowPresenter::initLayoutOptions()
    {
        const auto layoutsList = gui::factory::getUpdateInstructionLayouts();

        for (auto &layoutEntry : layoutsList) {
            layoutOptions.push_back(layoutEntry()->getLayout());
        }
    }

    bool UpdateInstructionWindowPresenter::onInput(const gui::InputEvent &inputEvent, const gui::Item *currentLayout)
    {
        return false;
    }
} // namespace app::bell_settings

A products/BellHybrid/apps/application-bell-settings/presenter/UpdateInstructionWindowPresenter.hpp => products/BellHybrid/apps/application-bell-settings/presenter/UpdateInstructionWindowPresenter.hpp +29 -0
@@ 0,0 1,29 @@
// 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/windows/UpdateInstructionWindowContract.hpp>
#include <apps-common/ApplicationCommon.hpp>

#include <vector>
#include <Item.hpp>

namespace app::bell_settings
{
    class UpdateInstructionWindowPresenter : public gui::UpdateInstructionWindowContract::Presenter
    {
      private:
        app::ApplicationCommon *app;
        std::vector<gui::Item *> layoutOptions;
        void initLayoutOptions();

      public:
        explicit UpdateInstructionWindowPresenter(app::ApplicationCommon *app);

        std::vector<gui::Item *> getLayouts() const override;
        bool isLastLayout(const gui::Item *layout) const override;
        gui::Item *getFirstLayout() const override;
        bool onInput(const gui::InputEvent &inputEvent, const gui::Item *currentLayout) override;
    };
} // namespace app::bell_settings

M products/BellHybrid/apps/application-bell-settings/windows/BellSettingsWindow.cpp => products/BellHybrid/apps/application-bell-settings/windows/BellSettingsWindow.cpp +3 -0
@@ 66,6 66,9 @@ namespace gui
            utils::translate("app_bell_settings_language"), gui::window::name::bellSettingsLanguage, defaultCallback);
        addWinSettings(
            utils::translate("app_bell_settings_shortcuts"), window::name::bellSettingsShortcuts, defaultCallback);
        addWinSettings(utils::translate("app_bell_update_instruction_title"),
                       window::name::bellSettingsUpdateInstruction,
                       defaultCallback);
        addWinSettings(
            utils::translate("app_bell_settings_frontlight"), gui::BellSettingsFrontlightWindow::name, defaultCallback);
        addWinSettings(utils::translate("app_bell_settings_about"), gui::AboutYourBellWindow::name, defaultCallback);