M image/assets/lang/English.json => image/assets/lang/English.json +10 -1
@@ 374,9 374,18 @@
"app_settings_display_wallpaper_quotes_custom": "Custom",
"app_settings_display_wallpaper_quotes_categories": "Categories",
"app_settings_system": "System",
- "app_settings_apps_tools": "Apps and tools",
+ "app_settings_apps": "Apps",
+ "app_settings_apps_phone": "Phone",
"app_settings_apps_messages": "Messages",
"app_settings_show_unread_first": "Show unread first",
+ "app_settings_apps_calendar": "Calendar",
+ "app_settings_apps_alarm_clock": "Alarm clock",
+ "app_settings_vibration": "Vibration",
+ "app_settings_sound": "Sound",
+ "app_settings_volume": "Volume",
+ "app_settings_call_ringtome": "Call ringtone",
+ "app_settings_message_sound": "Message sound",
+ "app_settings_notification_sound": "Notification sound",
"app_settings_Templates": "Templates",
"app_settings_apps_torch": "Torch",
"app_settings_title_torch": "Torch",
M module-apps/application-settings-new/ApplicationSettings.cpp => module-apps/application-settings-new/ApplicationSettings.cpp +25 -1
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "ApplicationSettings.hpp"
@@ 18,7 18,13 @@
#include "windows/AppsAndToolsWindow.hpp"
#include "windows/NightshiftWindow.hpp"
#include "windows/NetworkWindow.hpp"
+#include "windows/PhoneWindow.hpp"
+#include "windows/CallRingtoneWindow.hpp"
#include "windows/MessagesWindow.hpp"
+#include "windows/MessageSoundWindow.hpp"
+#include "windows/CalendarWindow.hpp"
+#include "windows/NotificationSoundWindow.hpp"
+#include "windows/AlarmClockWindow.hpp"
#include "windows/PhoneNameWindow.hpp"
#include "windows/AutolockWindow.hpp"
#include "windows/TorchWindow.hpp"
@@ 414,9 420,27 @@ namespace app
windowsFactory.attach(gui::window::name::apn_options, [](Application *app, const std::string &name) {
return std::make_unique<gui::ApnOptionsWindow>(app);
});
+ windowsFactory.attach(gui::window::name::phone, [](Application *app, const std::string &name) {
+ return std::make_unique<gui::PhoneWindow>(app);
+ });
+ windowsFactory.attach(gui::window::name::call_ringtone, [](Application *app, const std::string &name) {
+ return std::make_unique<gui::CallRingtoneWindow>(app);
+ });
windowsFactory.attach(gui::window::name::messages, [](Application *app, const std::string &name) {
return std::make_unique<gui::MessagesWindow>(app);
});
+ windowsFactory.attach(gui::window::name::message_sound, [](Application *app, const std::string &name) {
+ return std::make_unique<gui::MessageSoundWindow>(app);
+ });
+ windowsFactory.attach(gui::window::name::calendar, [](Application *app, const std::string &name) {
+ return std::make_unique<gui::CalendarWindow>(app);
+ });
+ windowsFactory.attach(gui::window::name::notification_sound, [](Application *app, const std::string &name) {
+ return std::make_unique<gui::NotificationSoundWindow>(app);
+ });
+ windowsFactory.attach(gui::window::name::alarm_clock, [](Application *app, const std::string &name) {
+ return std::make_unique<gui::AlarmClockWindow>(app);
+ });
windowsFactory.attach(gui::window::name::phone_name, [](Application *app, const std::string &name) {
return std::make_unique<gui::PhoneNameWindow>(app);
});
M module-apps/application-settings-new/ApplicationSettings.hpp => module-apps/application-settings-new/ApplicationSettings.hpp +10 -4
@@ 30,10 30,16 @@ namespace gui::window::name
inline constexpr auto input_language = "InputLanguage";
inline constexpr auto locked_screen = "LockedScreen";
- inline constexpr auto messages = "Messages";
- inline constexpr auto torch = "Torch";
- inline constexpr auto nightshift = "Nightshift";
- inline constexpr auto templates = "Templates";
+ inline constexpr auto phone = "Phone";
+ inline constexpr auto call_ringtone = "CallRingtone";
+ inline constexpr auto messages = "Messages";
+ inline constexpr auto message_sound = "MessageSound";
+ inline constexpr auto message_templates = "MessageTemplates";
+ inline constexpr auto calendar = "Calendar";
+ inline constexpr auto notification_sound = "NotificationSound";
+ inline constexpr auto alarm_clock = "AlarmClock";
+ inline constexpr auto torch = "Torch";
+ inline constexpr auto nightshift = "Nightshift";
inline constexpr auto autolock = "Autolock";
inline constexpr auto wallpaper = "Wallpaper";
M module-apps/application-settings-new/CMakeLists.txt => module-apps/application-settings-new/CMakeLists.txt +8 -1
@@ 46,7 46,14 @@ target_sources( ${PROJECT_NAME}
windows/AppsAndToolsWindow.cpp
windows/NetworkWindow.cpp
windows/NightshiftWindow.cpp
+ windows/OptionsWidgetMaker.cpp
+ windows/PhoneWindow.cpp
+ windows/CallRingtoneWindow.cpp
windows/MessagesWindow.cpp
+ windows/MessageSoundWindow.cpp
+ windows/CalendarWindow.cpp
+ windows/NotificationSoundWindow.cpp
+ windows/AlarmClockWindow.cpp
windows/PhoneNameWindow.cpp
windows/AutolockWindow.cpp
windows/TorchWindow.cpp
@@ 59,7 66,7 @@ target_sources( ${PROJECT_NAME}
windows/ChangePasscodeWindow.cpp
windows/NewApnWindow.cpp
widgets/SpinBox.cpp
- widgets/SpinBoxOptionSetting.cpp
+ widgets/SpinBoxOptionSettings.cpp
windows/SystemMainWindow.cpp
windows/LanguagesWindow.cpp
windows/DateAndTimeMainWindow.cpp
R module-apps/application-settings-new/widgets/SpinBoxOptionSetting.cpp => module-apps/application-settings-new/widgets/SpinBoxOptionSettings.cpp +2 -2
@@ 1,7 1,7 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#include "OptionSetting.hpp"
+#include "SpinBoxOptionSettings.hpp"
#include <utility>
#include "SpinBox.hpp"
@@ 23,7 23,7 @@ namespace gui
auto optionItem = new gui::ListItem();
optionItem->setMinimumSize(style::window::default_body_width, style::window::label::big_h);
- optionItem->inputCallback = spinBox->inputCallback;
+ optionItem->inputCallback = spinBox->inputCallback;
optionItem->focusChangedCallback = [spinBox](Item &item) { return spinBox->focusChangedCallback(item); };
optionItem->dimensionChangedCallback = [spinBox](gui::Item &, const BoundingBox &newDim) -> bool {
spinBox->setPosition(0, 0);
R module-apps/application-settings-new/widgets/OptionSetting.hpp => module-apps/application-settings-new/widgets/SpinBoxOptionSettings.hpp +0 -0
A module-apps/application-settings-new/windows/AlarmClockWindow.cpp => module-apps/application-settings-new/windows/AlarmClockWindow.cpp +60 -0
@@ 0,0 1,60 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "AlarmClockWindow.hpp"
+
+#include <application-settings-new/ApplicationSettings.hpp>
+#include <i18n/i18n.hpp>
+#include "BaseSettingsWindow.hpp"
+#include "application-settings-new/widgets/SpinBoxOptionSettings.hpp"
+
+namespace gui
+{
+ AlarmClockWindow::AlarmClockWindow(app::Application *app)
+ : BaseSettingsWindow(app, gui::window::name::alarm_clock), mWidgetMaker(this)
+ {
+ mVibrationsEnabled = true;
+ setTitle(utils::localize.get("app_settings_apps_alarm_clock"));
+ }
+
+ std::list<Option> AlarmClockWindow::buildOptionsList()
+ {
+ std::list<gui::Option> optionList;
+ mWidgetMaker.addSwitchOption(optionList,
+ utils::translateI18("app_settings_vibration"),
+ mVibrationsEnabled,
+ [&]() { switchVibrationState(); });
+
+ auto focusCallback = [&](gui::Item &item) {
+ if (item.focus) {
+ setBottomBarText(UTF8(), BottomBar::Side::CENTER);
+ }
+ return true;
+ };
+
+ optionList.emplace_back(std::make_unique<gui::SpinBoxOptionSettings>(
+ utils::translateI18("app_settings_volume"),
+ std::ceil(1.2),
+ std::ceil(10.0),
+ [&](uint8_t value) {
+ setVolume(value);
+ return true;
+ },
+ focusCallback));
+
+ return optionList;
+ }
+
+ void AlarmClockWindow::switchVibrationState()
+ {
+ mVibrationsEnabled = !mVibrationsEnabled;
+ LOG_INFO("switchVibrationState %d", static_cast<int>(mVibrationsEnabled));
+ refreshOptionsList();
+ }
+
+ void AlarmClockWindow::setVolume(uint8_t vol)
+ {
+ LOG_INFO("setVolume %d", static_cast<int>(vol));
+ }
+
+} // namespace gui
A module-apps/application-settings-new/windows/AlarmClockWindow.hpp => module-apps/application-settings-new/windows/AlarmClockWindow.hpp +38 -0
@@ 0,0 1,38 @@
+// 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 "BaseSettingsWindow.hpp"
+#include "OptionsWidgetMaker.hpp"
+
+namespace gui
+{
+ /// @brief AlarmClock vibration and volume settings
+ ///
+ class AlarmClockWindow : public BaseSettingsWindow
+ {
+ public:
+ /// Constructor
+ /// @app parent application pointer
+ explicit AlarmClockWindow(app::Application *app);
+
+ private:
+ /// Switches alarm vibration state
+ void switchVibrationState();
+
+ /// Sets the volume
+ /// @param vol volume value
+ void setVolume(uint8_t vol);
+
+ /// Build the list of options to be drawn
+ /// @return list of options
+ std::list<Option> buildOptionsList() override;
+
+ /// Widget maker object
+ OptionsWidgetMaker mWidgetMaker;
+
+ /// Flag describing if phone vibration is enabled
+ bool mVibrationsEnabled = false;
+ };
+} // namespace gui
M module-apps/application-settings-new/windows/AppsAndToolsWindow.cpp => module-apps/application-settings-new/windows/AppsAndToolsWindow.cpp +5 -3
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "AppsAndToolsWindow.hpp"
@@ 12,7 12,7 @@ namespace gui
AppsAndToolsWindow::AppsAndToolsWindow(app::Application *app) : OptionWindow(app, gui::window::name::apps_and_tools)
{
addOptions(appsAndToolsOptionsList());
- setTitle(utils::localize.get("app_settings_apps_tools"));
+ setTitle(utils::localize.get("app_settings_apps"));
}
std::list<Option> AppsAndToolsWindow::appsAndToolsOptionsList()
@@ 33,8 33,10 @@ namespace gui
gui::option::Arrow::Enabled});
};
+ addMenu(i18("app_settings_apps_phone"), gui::window::name::phone);
addMenu(i18("app_settings_apps_messages"), gui::window::name::messages);
- addMenu(i18("app_settings_apps_torch"), gui::window::name::torch);
+ addMenu(i18("app_settings_apps_calendar"), gui::window::name::calendar);
+ addMenu(i18("app_settings_apps_alarm_clock"), gui::window::name::alarm_clock);
return optionList;
}
A module-apps/application-settings-new/windows/CalendarWindow.cpp => module-apps/application-settings-new/windows/CalendarWindow.cpp +62 -0
@@ 0,0 1,62 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "CalendarWindow.hpp"
+
+#include <application-settings-new/ApplicationSettings.hpp>
+#include <i18n/i18n.hpp>
+#include "BaseSettingsWindow.hpp"
+#include <OptionSetting.hpp>
+
+namespace gui
+{
+ CalendarWindow::CalendarWindow(app::Application *app)
+ : BaseSettingsWindow(app, gui::window::name::calendar), mWidgetMaker(this)
+ {
+ mVibrationsEnabled = true;
+ mSoundEnabled = true;
+ setTitle(utils::localize.get("app_settings_apps_calendar"));
+ }
+
+ std::list<Option> CalendarWindow::buildOptionsList()
+ {
+ std::list<gui::Option> optionList;
+ mWidgetMaker.addSwitchOption(optionList,
+ utils::translateI18("app_settings_vibration"),
+ mVibrationsEnabled,
+ [&]() { switchVibrationState(); });
+
+ mWidgetMaker.addSwitchOption(
+ optionList, utils::translateI18("app_settings_sound"), mSoundEnabled, [&]() { switchSoundState(); });
+
+ if (mSoundEnabled) {
+ mWidgetMaker.addSelectOption(
+ optionList,
+ utils::translateI18("app_settings_notification_sound"),
+ [&]() { openNoticicationSoundWindow(); },
+ true);
+ }
+
+ return optionList;
+ }
+
+ void CalendarWindow::switchVibrationState()
+ {
+ mVibrationsEnabled = !mVibrationsEnabled;
+ LOG_INFO("switchVibrationState %d", static_cast<int>(mVibrationsEnabled));
+ refreshOptionsList();
+ }
+
+ void CalendarWindow::switchSoundState()
+ {
+ mSoundEnabled = !mSoundEnabled;
+ LOG_INFO("switchSoundState %d", static_cast<int>(mSoundEnabled));
+ refreshOptionsList();
+ }
+
+ void CalendarWindow::openNoticicationSoundWindow()
+ {
+ application->switchWindow(gui::window::name::notification_sound);
+ }
+
+} // namespace gui
A module-apps/application-settings-new/windows/CalendarWindow.hpp => module-apps/application-settings-new/windows/CalendarWindow.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 "BaseSettingsWindow.hpp"
+#include "OptionsWidgetMaker.hpp"
+
+namespace gui
+{
+ /// @brief Calendar vibration and sound settings window
+ ///
+ class CalendarWindow : public BaseSettingsWindow
+ {
+ public:
+ /// Constructor
+ /// @app parent application pointer
+ explicit CalendarWindow(app::Application *app);
+
+ private:
+ /// Switches calendar vibration state
+ void switchVibrationState();
+
+ /// Switches calendar sound state
+ void switchSoundState();
+
+ /// Opens notification sound selection window
+ void openNoticicationSoundWindow();
+
+ /// Build the list of options to be drawn
+ /// @return list of options
+ std::list<Option> buildOptionsList() override;
+
+ /// Widget maker object
+ OptionsWidgetMaker mWidgetMaker;
+
+ /// Flag describing if calendar vibration is enabled
+ bool mVibrationsEnabled = false;
+
+ /// Flag describing if calendar sound is enabled
+ bool mSoundEnabled = true;
+ };
+} // namespace gui
A module-apps/application-settings-new/windows/CallRingtoneWindow.cpp => module-apps/application-settings-new/windows/CallRingtoneWindow.cpp +14 -0
@@ 0,0 1,14 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "CallRingtoneWindow.hpp"
+#include "application-settings-new/ApplicationSettings.hpp"
+#include <i18n/i18n.hpp>
+
+namespace gui
+{
+ CallRingtoneWindow::CallRingtoneWindow(app::Application *app) : BaseSettingsWindow(app, window::name::call_ringtone)
+ {
+ setTitle(utils::localize.get("app_settings_call_ringtome"));
+ }
+} // namespace gui
A module-apps/application-settings-new/windows/CallRingtoneWindow.hpp => module-apps/application-settings-new/windows/CallRingtoneWindow.hpp +26 -0
@@ 0,0 1,26 @@
+// 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 "BaseSettingsWindow.hpp"
+
+namespace gui
+{
+ /// @brief Ring tone selection window
+ class CallRingtoneWindow : public BaseSettingsWindow
+ {
+ public:
+ /// Constructor
+ /// @param app pointer to application
+ CallRingtoneWindow(app::Application *app);
+
+ /// Build the list of options to be drawn
+ /// @return list of options
+ std::list<Option> buildOptionsList() override
+ {
+ std::list<Option> lst;
+ return lst;
+ }
+ };
+} // namespace gui
M module-apps/application-settings-new/windows/DisplayLightWindow.cpp => module-apps/application-settings-new/windows/DisplayLightWindow.cpp +1 -1
@@ 2,7 2,7 @@
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "DisplayLightWindow.hpp"
-#include "application-settings-new/widgets/OptionSetting.hpp"
+#include "application-settings-new/widgets/SpinBoxOptionSettings.hpp"
#include "OptionSetting.hpp"
#include "application-settings-new/ApplicationSettings.hpp"
#include "OptionSetting.hpp"
M module-apps/application-settings-new/windows/DisplayLightWindow.hpp => module-apps/application-settings-new/windows/DisplayLightWindow.hpp +1 -1
@@ 7,7 7,7 @@
#include <module-services/service-evtmgr/screen-light-control/ScreenLightControl.hpp>
#include <module-apps/application-settings-new/widgets/SpinBox.hpp>
#include <module-apps/application-settings-new/ApplicationSettings.hpp>
-#include <module-apps/application-settings-new/widgets/OptionSetting.hpp>
+#include <module-apps/application-settings-new/widgets/SpinBoxOptionSettings.hpp>
#include "BaseSettingsWindow.hpp"
namespace gui
A module-apps/application-settings-new/windows/MessageSoundWindow.cpp => module-apps/application-settings-new/windows/MessageSoundWindow.cpp +14 -0
@@ 0,0 1,14 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "MessageSoundWindow.hpp"
+#include "application-settings-new/ApplicationSettings.hpp"
+#include <i18n/i18n.hpp>
+
+namespace gui
+{
+ MessageSoundWindow::MessageSoundWindow(app::Application *app) : BaseSettingsWindow(app, window::name::message_sound)
+ {
+ setTitle(utils::localize.get("app_settings_message_sound"));
+ }
+} // namespace gui
A module-apps/application-settings-new/windows/MessageSoundWindow.hpp => module-apps/application-settings-new/windows/MessageSoundWindow.hpp +26 -0
@@ 0,0 1,26 @@
+// 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 "BaseSettingsWindow.hpp"
+
+namespace gui
+{
+ /// @brief Message sound selection window
+ class MessageSoundWindow : public BaseSettingsWindow
+ {
+ public:
+ /// Constructor
+ /// @param app pointer to application
+ MessageSoundWindow(app::Application *app);
+
+ /// Build the list of options to be drawn
+ /// @return list of options
+ std::list<Option> buildOptionsList() override
+ {
+ std::list<Option> lst;
+ return lst;
+ }
+ };
+} // namespace gui
M module-apps/application-settings-new/windows/MessagesWindow.cpp => module-apps/application-settings-new/windows/MessagesWindow.cpp +51 -53
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "MessagesWindow.hpp"
@@ 10,76 10,74 @@
namespace gui
{
- MessagesWindow::MessagesWindow(app::Application *app) : OptionWindow(app, gui::window::name::messages)
+ MessagesWindow::MessagesWindow(app::Application *app)
+ : BaseSettingsWindow(app, gui::window::name::messages), mWidgetMaker(this)
{
- addOptions(messagesOptList());
+ mVibrationsEnabled = false;
+ mSoundEnabled = true;
+ mShowUnreadMessagesFirst = true;
setTitle(utils::localize.get("app_settings_apps_messages"));
}
- std::list<Option> MessagesWindow::messagesOptList()
+ std::list<Option> MessagesWindow::buildOptionsList()
{
std::list<gui::Option> optionList;
- auto addMenuSwitch = [&](UTF8 name, std::string window) {
- optionList.emplace_back(std::make_unique<gui::option::OptionSettings>(
- name,
- [=](gui::Item &item) {
- showUnreadMessagesFirst = !showUnreadMessagesFirst;
- if (showUnreadMessagesFirst)
- LOG_INFO("showUnreadMessagesFirst =true ");
- else
- LOG_INFO("showUnreadMessagesFirst =false ");
- rebuildOptList();
- return true;
- },
- [&](gui::Item &item) {
- if (item.focus) {
- this->setBottomBarText(utils::localize.get(style::strings::common::Switch),
- BottomBar::Side::CENTER);
- }
- else {
- this->setBottomBarText(utils::localize.get(style::strings::common::select),
- BottomBar::Side::CENTER);
- }
- return true;
- },
- nullptr,
- showUnreadMessagesFirst ? gui::option::SettingRightItem::On : gui::option::SettingRightItem::Off));
- };
+ mWidgetMaker.addSwitchOption(optionList,
+ utils::translateI18("app_settings_vibration"),
+ mVibrationsEnabled,
+ [&]() { switchVibrationState(); });
- auto addMenu = [&](UTF8 name, std::string window) {
- optionList.emplace_back(std::make_unique<gui::option::OptionSettings>(
- name,
- [=](gui::Item &item) {
- if (window.empty()) {
- return false;
- }
- LOG_INFO("switching to %s page", window.c_str());
- application->switchWindow(window, nullptr);
- return true;
- },
- nullptr,
- nullptr,
- gui::option::SettingRightItem::ArrowWhite));
- };
+ mWidgetMaker.addSwitchOption(
+ optionList, utils::translateI18("app_settings_sound"), mSoundEnabled, [&]() { switchSoundState(); });
- bottomBar->setText(BottomBar::Side::CENTER, utils::localize.get(style::strings::common::select));
+ if (mSoundEnabled) {
+ mWidgetMaker.addSelectOption(
+ optionList,
+ utils::translateI18("app_settings_message_sound"),
+ [&]() { openMessageSoundWindow(); },
+ true);
+ }
- addMenuSwitch(utils::translateI18("app_settings_show_unread_first"), "");
- addMenu(utils::translateI18("app_settings_Templates"), gui::window::name::templates);
+ mWidgetMaker.addSwitchOption(optionList,
+ utils::translateI18("app_settings_show_unread_first"),
+ mShowUnreadMessagesFirst,
+ [&]() { switchShowUnreadFirst(); });
+ mWidgetMaker.addSelectOption(
+ optionList, utils::translateI18("app_settings_Templates"), [&]() { openMessageTemplates(); });
return optionList;
}
- void MessagesWindow::rebuildOptList()
+ void MessagesWindow::switchVibrationState()
{
- clearOptions();
- addOptions(messagesOptList());
+ mVibrationsEnabled = !mVibrationsEnabled;
+ LOG_INFO("switchVibrationState %d", static_cast<int>(mVibrationsEnabled));
+ refreshOptionsList();
}
- void MessagesWindow::onBeforeShow(ShowMode m, SwitchData *d)
+ void MessagesWindow::switchSoundState()
{
- rebuildOptList();
+ mSoundEnabled = !mSoundEnabled;
+ LOG_INFO("switchSoundState %d", static_cast<int>(mSoundEnabled));
+ refreshOptionsList();
+ }
+
+ void MessagesWindow::switchShowUnreadFirst()
+ {
+ mShowUnreadMessagesFirst = !mShowUnreadMessagesFirst;
+ LOG_INFO("switchSoundState %d", static_cast<int>(mSoundEnabled));
+ refreshOptionsList();
+ }
+
+ void MessagesWindow::openMessageSoundWindow()
+ {
+ this->application->switchWindow(gui::window::name::message_sound);
+ }
+
+ void MessagesWindow::openMessageTemplates()
+ {
+ this->application->switchWindow(gui::window::name::message_templates);
}
} // namespace gui
M module-apps/application-settings-new/windows/MessagesWindow.hpp => module-apps/application-settings-new/windows/MessagesWindow.hpp +40 -9
@@ 1,22 1,53 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// 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 <OptionWindow.hpp>
+#include "BaseSettingsWindow.hpp"
+#include "OptionsWidgetMaker.hpp"
namespace gui
{
- class MessagesWindow : public OptionWindow
+ /// @brief Messages vibration, sound, and other settings window
+ ///
+ class MessagesWindow : public BaseSettingsWindow
{
public:
- MessagesWindow(app::Application *app);
- ~MessagesWindow() override = default;
- void onBeforeShow(ShowMode m, SwitchData *d) override;
- void rebuildOptList();
+ /// Constructor
+ /// @app parent application pointer
+ explicit MessagesWindow(app::Application *app);
private:
- std::list<Option> messagesOptList();
- bool showUnreadMessagesFirst = false;
+ /// Switches messages vibration state
+ /// @return new state
+ void switchVibrationState();
+
+ /// Switches messages sound state
+ void switchSoundState();
+
+ /// Opens message sound selection window
+ void openMessageSoundWindow();
+
+ /// Switches option to show unread messages first
+ void switchShowUnreadFirst();
+
+ /// Opens message templates window
+ void openMessageTemplates();
+
+ /// Build the list of options to be drawn
+ /// @return list of options
+ std::list<Option> buildOptionsList() override;
+
+ /// Widget maker object
+ OptionsWidgetMaker mWidgetMaker;
+
+ /// Flag describing if messages vibration is enabled
+ bool mVibrationsEnabled = false;
+
+ /// Flag describing if messages sound is enabled
+ bool mSoundEnabled = true;
+
+ /// Flag describing if unread messages are shown first
+ bool mShowUnreadMessagesFirst = true;
};
} // namespace gui
A module-apps/application-settings-new/windows/NotificationSoundWindow.cpp => module-apps/application-settings-new/windows/NotificationSoundWindow.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 "NotificationSoundWindow.hpp"
+#include "application-settings-new/ApplicationSettings.hpp"
+#include <i18n/i18n.hpp>
+
+namespace gui
+{
+ NotificationSoundWindow::NotificationSoundWindow(app::Application *app)
+ : BaseSettingsWindow(app, window::name::notification_sound)
+ {
+ setTitle(utils::localize.get("app_settings_notification_sound"));
+ }
+} // namespace gui
A module-apps/application-settings-new/windows/NotificationSoundWindow.hpp => module-apps/application-settings-new/windows/NotificationSoundWindow.hpp +26 -0
@@ 0,0 1,26 @@
+// 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 "BaseSettingsWindow.hpp"
+
+namespace gui
+{
+ /// @brief Notification sound selection window
+ class NotificationSoundWindow : public BaseSettingsWindow
+ {
+ public:
+ /// Constructor
+ /// @param app pointer to application
+ explicit NotificationSoundWindow(app::Application *app);
+
+ /// Build the list of options to be drawn
+ /// @return list of options
+ std::list<Option> buildOptionsList() override
+ {
+ std::list<Option> lst;
+ return lst;
+ }
+ };
+} // namespace gui
A module-apps/application-settings-new/windows/OptionsWidgetMaker.cpp => module-apps/application-settings-new/windows/OptionsWidgetMaker.cpp +54 -0
@@ 0,0 1,54 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "OptionsWidgetMaker.hpp"
+#include <OptionSetting.hpp>
+
+namespace gui
+{
+ OptionsWidgetMaker::OptionsWidgetMaker(OptionWindow *window) : mWindow(window)
+ {}
+
+ void OptionsWidgetMaker::addSwitchOption(
+ std::list<gui::Option> &list, const UTF8 &text, bool &option, std::function<void()> callback, bool indent)
+ {
+ list.emplace_back(std::make_unique<option::OptionSettings>(
+ std::move(text),
+ [=](Item &item) {
+ callback();
+ return true;
+ },
+ [=](Item &item) {
+ if (item.focus) {
+ mWindow->setBottomBarText(utils::localize.get(style::strings::common::Switch),
+ BottomBar::Side::CENTER);
+ }
+ else {
+ mWindow->setBottomBarText(utils::localize.get(style::strings::common::select),
+ BottomBar::Side::CENTER);
+ }
+ return true;
+ },
+ nullptr,
+ option ? option::SettingRightItem::On : option::SettingRightItem::Off,
+ indent));
+ }
+
+ void OptionsWidgetMaker::addSelectOption(std::list<gui::Option> &list,
+ const UTF8 &text,
+ std::function<void(void)> callback,
+ bool indent)
+ {
+ list.emplace_back(std::make_unique<option::OptionSettings>(
+ std::move(text),
+ [=](Item &item) {
+ callback();
+ return true;
+ },
+ nullptr,
+ nullptr,
+ option::SettingRightItem::ArrowWhite,
+ indent));
+ }
+
+} // namespace gui
A module-apps/application-settings-new/windows/OptionsWidgetMaker.hpp => module-apps/application-settings-new/windows/OptionsWidgetMaker.hpp +45 -0
@@ 0,0 1,45 @@
+// 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 "Option.hpp"
+#include "OptionWindow.hpp"
+
+namespace gui
+{
+ /// @brief Helping class for easy options creation/manipulation
+ class OptionsWidgetMaker
+ {
+ public:
+ /// Constructor
+ /// @param window pointer to parent option window
+ explicit OptionsWidgetMaker(OptionWindow *window);
+
+ /// Adds switch option to the given options list
+ /// @param list list to be updated
+ /// @param text option description text
+ /// @param option state of option
+ /// @param callback called whenever option is changed
+ /// @param indent should the option be indent
+ void addSwitchOption(std::list<gui::Option> &list,
+ const UTF8 &text,
+ bool &option,
+ std::function<void()> callback,
+ bool indent = false);
+
+ /// Adds select option to the given options list
+ /// @param list list to be updated
+ /// @param text option description text
+ /// @param callback called whenever option is clicked
+ /// @param indent should the option be indent
+ void addSelectOption(std::list<gui::Option> &list,
+ const UTF8 &text,
+ std::function<void(void)> callback,
+ bool indent = false);
+
+ private:
+ /// Pointer to the window containing the options
+ OptionWindow *mWindow = nullptr;
+ };
+} // namespace gui
A module-apps/application-settings-new/windows/PhoneWindow.cpp => module-apps/application-settings-new/windows/PhoneWindow.cpp +60 -0
@@ 0,0 1,60 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "PhoneWindow.hpp"
+
+#include <application-settings-new/ApplicationSettings.hpp>
+#include <i18n/i18n.hpp>
+#include <OptionWindow.hpp>
+#include <OptionSetting.hpp>
+
+namespace gui
+{
+ PhoneWindow::PhoneWindow(app::Application *app)
+ : BaseSettingsWindow(app, gui::window::name::phone), mWidgetMaker(this)
+ {
+ mVibrationsEnabled = true;
+ mSoundEnabled = true;
+ setTitle(utils::localize.get("app_settings_apps_phone"));
+ }
+
+ std::list<Option> PhoneWindow::buildOptionsList()
+ {
+ std::list<gui::Option> optionList;
+ mWidgetMaker.addSwitchOption(optionList,
+ utils::translateI18("app_settings_vibration"),
+ mVibrationsEnabled,
+ [&]() { switchVibrationState(); });
+
+ mWidgetMaker.addSwitchOption(
+ optionList, utils::translateI18("app_settings_sound"), mSoundEnabled, [&]() { switchSoundState(); });
+
+ if (mSoundEnabled) {
+ mWidgetMaker.addSelectOption(
+ optionList, utils::translateI18("app_settings_call_ringtome"), [&]() { openRingtoneWindow(); }, true);
+ }
+
+ return optionList;
+ }
+
+ void PhoneWindow::switchVibrationState()
+ {
+ LOG_INFO("switchVibrationState before %d", static_cast<int>(mVibrationsEnabled));
+ mVibrationsEnabled = !mVibrationsEnabled;
+ LOG_INFO("switchVibrationState after %d", static_cast<int>(mVibrationsEnabled));
+ refreshOptionsList();
+ }
+
+ void PhoneWindow::switchSoundState()
+ {
+ mSoundEnabled = !mSoundEnabled;
+ LOG_INFO("switchSoundState %d", static_cast<int>(mSoundEnabled));
+ refreshOptionsList();
+ }
+
+ void PhoneWindow::openRingtoneWindow()
+ {
+ application->switchWindow(gui::window::name::call_ringtone);
+ }
+
+} // namespace gui
A module-apps/application-settings-new/windows/PhoneWindow.hpp => module-apps/application-settings-new/windows/PhoneWindow.hpp +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
+
+#pragma once
+
+#include "BaseSettingsWindow.hpp"
+#include "OptionsWidgetMaker.hpp"
+
+namespace gui
+{
+ /// @brief Phone (call) vibration and sound settings window
+ class PhoneWindow : public BaseSettingsWindow
+ {
+ public:
+ /// Constructor
+ /// @app parent application pointer
+ explicit PhoneWindow(app::Application *app);
+
+ private:
+ /// Switches phone vibration state
+ void switchVibrationState();
+
+ /// Switches phone sound state
+ void switchSoundState();
+
+ /// Opens call ringtone selection window
+ void openRingtoneWindow();
+
+ /// Build the list of options to be drawn
+ /// @return list of options
+ std::list<Option> buildOptionsList() override;
+
+ /// Widget maker object
+ OptionsWidgetMaker mWidgetMaker;
+
+ /// Flag describing if phone vibration is enabled
+ bool mVibrationsEnabled = false;
+
+ /// Flag describing if phone sound is enabled
+ bool mSoundEnabled = true;
+ };
+} // namespace gui
M module-apps/application-settings-new/windows/SettingsMainWindow.cpp => module-apps/application-settings-new/windows/SettingsMainWindow.cpp +1 -1
@@ 47,7 47,7 @@ std::list<gui::Option> mainWindowOptionsNew(app::Application *app)
addMenu(i18("app_settings_net"), gui::window::name::network);
addMenu(i18("app_settings_disp_key"), gui::window::name::display_and_keypad);
addMenu(i18("app_settings_phone_modes"), gui::window::name::phone_modes);
- addMenu(i18("app_settings_apps_tools"), gui::window::name::apps_and_tools);
+ addMenu(i18("app_settings_apps"), gui::window::name::apps_and_tools);
addMenu(i18("app_settings_security"), gui::window::name::security);
addMenu(i18("app_settings_system"), gui::window::name::system);
return l;