~aleteoryx/muditaos

58c8f7b79527f74539f2b57d4d38b9fbf4fa4e4c — Maciej Gibowicz 2 years ago 98fb56a
[BH-1756] Fix "turn off" window display time

"Turn off" window should be displayed for 10 seconds triggered by
pressing the buttons "light" and "back" or 180 seconds triggered from
the menu->settings
M harmony_changelog.md => harmony_changelog.md +1 -0
@@ 22,6 22,7 @@
* Fixed issues with file uploads with low disk space.
* Fixed hard fault handling
* Fixed meditation countdown timer when a deep press is performed
* Fixed "turn off" window display time

### Added


M products/BellHybrid/apps/Application.cpp => products/BellHybrid/apps/Application.cpp +2 -1
@@ 71,7 71,8 @@ namespace app
                break;
            case ID::PowerOff:
                windowsFactory.attach(window::power_off_window, [](ApplicationCommon *app, const std::string &name) {
                    return std::make_unique<gui::BellTurnOffOptionWindow>(app, window::power_off_window);
                    return std::make_unique<gui::BellTurnOffOptionWindow>(
                        app, gui::turnOffPopupTimeout, window::power_off_window);
                });
                windowsFactory.attach(gui::BellTurnOffWindow::name,
                                      [](ApplicationCommon *app, const std::string &name) {

M products/BellHybrid/apps/common/include/common/popups/BellTurnOffOptionWindow.hpp => products/BellHybrid/apps/common/include/common/popups/BellTurnOffOptionWindow.hpp +6 -1
@@ 8,11 8,16 @@

namespace gui
{
    constexpr std::chrono::seconds turnOffPopupTimeout{10};
    constexpr std::chrono::milliseconds defaultWindowTimeout{0};

    class BellTurnOffOptionWindow : public BellShortOptionWindow
    {
      public:
        static constexpr auto defaultName = "BellTurnOffOptionWindow";
        explicit BellTurnOffOptionWindow(app::ApplicationCommon *app, const char *name = defaultName);
        explicit BellTurnOffOptionWindow(app::ApplicationCommon *app,
                                         std::chrono::milliseconds duration = defaultWindowTimeout,
                                         const char *name                   = defaultName);
        void onBeforeShow(ShowMode mode, SwitchData *data) override;
        void onClose(CloseReason reason) override;


M products/BellHybrid/apps/common/src/popups/BellTurnOffOptionWindow.cpp => products/BellHybrid/apps/common/src/popups/BellTurnOffOptionWindow.cpp +7 -4
@@ 16,20 16,23 @@

namespace
{
    using namespace std::chrono_literals;
    constexpr auto windowTimeout{10s};
    constexpr auto timerName{"BellTurnOffPopupTimer"};
} // namespace

namespace gui
{
    BellTurnOffOptionWindow::BellTurnOffOptionWindow(app::ApplicationCommon *app, const char *name)
    BellTurnOffOptionWindow::BellTurnOffOptionWindow(app::ApplicationCommon *app,
                                                     std::chrono::milliseconds duration,
                                                     const char *name)
        : BellShortOptionWindow(app, name), yesStr{utils::translate("common_yes")}, noStr{utils::translate("common_no")}
    {
        addOptions(settingsOptionsList());
        setListTitle(utils::translate("app_bell_turn_off_question"));

        popupTimer    = app::GuiTimerFactory::createSingleShotTimer(application, this, timerName, windowTimeout);
        if (duration > std::chrono::milliseconds::zero()) {
            popupTimer = app::GuiTimerFactory::createSingleShotTimer(application, this, timerName, duration);
        }

        timerCallback = [this, name](Item &, sys::Timer &timer) {
            if (application->getCurrentWindow()->getName() == name) {
                application->returnToPreviousWindow();