M image/assets/lang/English.json => image/assets/lang/English.json +4 -1
@@ 691,5 691,8 @@
"<text>Rise up, start fresh!<br />It's going to be GREAT day!</text>",
"<text>Hejsan!<br />Have a wonderful day!</text>",
"<text>It's a new Day!<br />Spread kindness everywhere you go</text>"
- ]
+ ],
+ "app_bell_settings_advanced_factory_reset": "Factory reset",
+ "app_bell_settings_display_factory_reset_confirmation": "<text>Reset to factory<br></br>settings ?</text>",
+ "app_bell_settings_factory_reset_finished": "Factory settings\nrestored"
}
M image/assets/lang/Polski.json => image/assets/lang/Polski.json +4 -1
@@ 632,5 632,8 @@
"app_bell_settings_alarm_settings_tone": "Dźwięk alarmu",
"app_bell_settings_alarm_settings_volume": "Głośność alarmu",
"app_bell_settings_alarm_settings_light": "Światło alarmu",
-"app_bell_settings_alarm_settings_alarm_tone_and_light_finished": "Ustawiono dźwięk i światło alarmu"
+"app_bell_settings_alarm_settings_alarm_tone_and_light_finished": "Ustawiono dźwięk i światło alarmu",
+"app_bell_settings_advanced_factory_reset": "Ustawienia fabryczne",
+"app_bell_settings_display_factory_reset_confirmation": "<text>Przywrócić ustawienia<br></br>fabryczne ?</text>",
+"app_bell_settings_factory_reset_finished": "Ustawienia fabryczne\nprzywrócone"
}
M products/BellHybrid/apps/application-bell-settings/ApplicationBellSettings.cpp => products/BellHybrid/apps/application-bell-settings/ApplicationBellSettings.cpp +6 -0
@@ 27,6 27,7 @@
#include "windows/BellSettingsFrontlight.hpp"
#include "windows/BellSettingsHomeViewWindow.hpp"
#include "windows/BellSettingsWindow.hpp"
+#include "widgets/DialogYesNo.hpp"
#include <AlarmSoundPaths.hpp>
#include <apps-common/windows/Dialog.hpp>
@@ 207,6 208,11 @@ namespace app
gui::popup::ID::PowerOff,
gui::popup::ID::Reboot,
gui::popup::ID::BedtimeNotification});
+
+ windowsFactory.attach(gui::window::name::bellSettingsFactoryReset,
+ [](ApplicationCommon *app, const std::string &name) {
+ return std::make_unique<gui::BellDialogYesNo>(app, name);
+ });
}
sys::MessagePointer ApplicationBellSettings::DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp)
M products/BellHybrid/apps/application-bell-settings/CMakeLists.txt => products/BellHybrid/apps/application-bell-settings/CMakeLists.txt +2 -0
@@ 46,6 46,7 @@ target_sources(application-bell-settings
widgets/TimeFormatSetListItem.cpp
widgets/TimeSetListItem.cpp
widgets/advanced/AboutYourBellListItem.cpp
+ widgets/DialogYesNo.cpp
windows/BellSettingsBedtimeToneWindow.cpp
windows/BellSettingsFrontlight.cpp
@@ 83,6 84,7 @@ target_sources(application-bell-settings
widgets/TimeFormatSetListItem.hpp
widgets/TimeSetListItem.hpp
widgets/advanced/AboutYourBellListItem.hpp
+ widgets/DialogYesNo.hpp
windows/alarm_settings/BellSettingsAlarmSettingsSnoozeWindow.hpp
windows/alarm_settings/BellSettingsAlarmSettingsWindow.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 +1 -0
@@ 17,6 17,7 @@ namespace gui::window::name
inline constexpr auto bellSettingsHomeView = "BellSettingsHomeView";
inline constexpr auto bellSettingsLanguage = "BellSettingsLanguage";
inline constexpr auto bellSettingsBedtimeTone = "BellSettingsBedtimeTone";
+ inline constexpr auto bellSettingsFactoryReset = "BellSettingsFactoryReset";
} // namespace gui::window::name
namespace app
A products/BellHybrid/apps/application-bell-settings/widgets/DialogYesNo.cpp => products/BellHybrid/apps/application-bell-settings/widgets/DialogYesNo.cpp +58 -0
@@ 0,0 1,58 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "DialogYesNo.hpp"
+
+#include <data/BellSettingsStyle.hpp>
+
+#include <apps-common/messages/DialogMetadataMessage.hpp>
+#include <common/options/OptionBellMenu.hpp>
+#include <apps-common/windows/Dialog.hpp>
+#include <TextFixedSize.hpp>
+
+using namespace gui;
+
+BellDialogYesNo::BellDialogYesNo(app::ApplicationCommon *app, const std::string &name)
+ : BellShortOptionWindow(app, name)
+{
+ optionsList->setBoundaries(Boundaries::Continuous);
+
+ statusBar->setVisible(false);
+ header->setTitleVisibility(true);
+}
+
+std::list<gui::Option> BellDialogYesNo::dialogOptionsList(std::function<bool()> yesAction)
+{
+ std::list<gui::Option> dialogOptionList;
+ auto addDialogSettings = [&](const UTF8 &name, const gui::bell_dialog::Options &optionName) {
+ dialogOptionList.emplace_back(std::make_unique<gui::option::OptionBellMenu>(
+ name,
+ [=](gui::Item &item) {
+ if (optionName == bell_dialog::Options::YES) {
+ return yesAction();
+ }
+ else if (optionName == bell_dialog::Options::NO) {
+ application->returnToPreviousWindow();
+ }
+ return true;
+ },
+ [=](gui::Item &item) {
+ // put focus change callback here
+ return true;
+ },
+ this));
+ };
+
+ addDialogSettings(utils::translate(style::strings::common::no), bell_dialog::Options::NO);
+ addDialogSettings(utils::translate(style::strings::common::yes), bell_dialog::Options::YES);
+
+ return dialogOptionList;
+}
+
+void BellDialogYesNo::onBeforeShow(ShowMode, SwitchData *data)
+{
+ if (auto metadata = dynamic_cast<DialogMetadataMessage *>(data); metadata) {
+ setListTitle(metadata->get().text);
+ addOptions(dialogOptionsList(metadata->get().action));
+ }
+}
A products/BellHybrid/apps/application-bell-settings/widgets/DialogYesNo.hpp => products/BellHybrid/apps/application-bell-settings/widgets/DialogYesNo.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 <Text.hpp>
+#include <common/options/BellShortOptionWindow.hpp>
+
+namespace gui
+{
+ namespace bell_dialog
+ {
+ enum Options
+ {
+ YES,
+ NO
+ };
+ } // namespace bell_dialog
+
+ /// @brief Yes/No Dialog class
+ ///
+ /// Contain same items as Dialog and additionally Yes and No selectable options
+ class BellDialogYesNo : public BellShortOptionWindow
+ {
+ public:
+ BellDialogYesNo(app::ApplicationCommon *app, const std::string &name);
+
+ void onBeforeShow(ShowMode mode, SwitchData *data) override;
+
+ private:
+ std::list<gui::Option> dialogOptionsList(std::function<bool()> yesAction);
+ };
+}; // namespace gui
M products/BellHybrid/apps/application-bell-settings/windows/advanced/BellSettingsAdvancedWindow.cpp => products/BellHybrid/apps/application-bell-settings/windows/advanced/BellSettingsAdvancedWindow.cpp +54 -24
@@ 9,6 9,7 @@
#include <apps-common/messages/DialogMetadataMessage.hpp>
#include <apps-common/windows/Dialog.hpp>
#include <windows/advanced/AboutYourBellWindow.hpp>
+#include <common/windows/BellFinishedWindow.hpp>
namespace gui
{
@@ 22,34 23,63 @@ namespace gui
std::list<Option> BellSettingsAdvancedWindow::settingsOptionsList()
{
+ using ActivatedCallback = std::function<bool(gui::Item &)>;
+ using Callback = std::function<ActivatedCallback(const std::string &window)>;
+
std::list<gui::Option> settingsOptionList;
- auto addWinSettings = [&](const UTF8 &name, const std::string &window) {
- settingsOptionList.emplace_back(std::make_unique<gui::option::OptionBellMenu>(
- name,
- [=](gui::Item &item) {
- if (window.empty()) {
- return false;
- }
+
+ auto defaultCallback = [this](const std::string &window) {
+ return [window, this](gui::Item &) {
+ if (window.empty()) {
+ return false;
+ }
+ application->switchWindow(window);
+ return true;
+ };
+ };
+
+ auto factoryResetCallback = [this](const std::string &window) {
+ auto actionCallback = [this]() {
+ if (sys::SystemManagerCommon::FactoryReset(application)) {
application->switchWindow(
- window,
- gui::ShowMode::GUI_SHOW_INIT,
- std::make_unique<gui::DialogMetadataMessage>(gui::DialogMetadata{name, "search_big", " "}));
- return true;
- },
- [=](gui::Item &item) {
- // put focus change callback here
- return true;
- },
- this));
+ window::bell_finished::defaultName,
+ BellFinishedWindowData::Factory::create(
+ "big_check_W_M", utils::translate("app_bell_settings_factory_reset_finished"), ""));
+ }
+ return true;
+ };
+
+ return [this, actionCallback, window](gui::Item &) {
+ auto metaData = std::make_unique<gui::DialogMetadataMessage>(
+ gui::DialogMetadata{utils::translate("app_bell_settings_advanced_factory_reset"),
+ "",
+ utils::translate("app_bell_settings_display_factory_reset_confirmation"),
+ "",
+ actionCallback});
+ application->switchWindow(window, gui::ShowMode::GUI_SHOW_INIT, std::move(metaData));
+ return true;
+ };
+ };
+
+ auto addOption = [&settingsOptionList, this](const UTF8 &name, const std::string &window, Callback &&callback) {
+ settingsOptionList.emplace_back(
+ std::make_unique<gui::option::OptionBellMenu>(name, callback(window), nullptr, this));
};
- addWinSettings(utils::translate("app_bell_settings_advanced_time_units"),
- gui::window::name::bellSettingsTimeUnits);
- addWinSettings(utils::translate("app_bell_settings_advanced_language"),
- gui::window::name::bellSettingsLanguage);
- addWinSettings(utils::translate("app_bell_settings_advanced_frontlight"),
- gui::window::name::bellSettingsFrontlight);
- addWinSettings(utils::translate("app_bell_settings_advanced_about"), gui::AboutYourBellWindow::name);
+ addOption(utils::translate("app_bell_settings_advanced_time_units"),
+ gui::window::name::bellSettingsTimeUnits,
+ defaultCallback);
+ addOption(utils::translate("app_bell_settings_advanced_language"),
+ gui::window::name::bellSettingsLanguage,
+ defaultCallback);
+ addOption(utils::translate("app_bell_settings_advanced_frontlight"),
+ gui::window::name::bellSettingsFrontlight,
+ defaultCallback);
+ addOption(
+ utils::translate("app_bell_settings_advanced_about"), gui::AboutYourBellWindow::name, defaultCallback);
+ addOption(utils::translate("app_bell_settings_advanced_factory_reset"),
+ gui::window::name::bellSettingsFactoryReset,
+ factoryResetCallback);
return settingsOptionList;
}