M changelog.md => changelog.md +2 -0
@@ 8,6 8,8 @@
* `[audio]` Added A2DP playback backend
* `[audio]` Added SendEvent audio API
* `[calculator]` Add calculator application.
+* `[settings]` Create Messages window for apps and tools branch.
+
### Fixed
M image/assets/lang/lang_en.json => image/assets/lang/lang_en.json +2 -0
@@ 241,6 241,8 @@
"app_settings_system" : "System",
"app_settings_apps_tools" : "Apps and tools",
"app_settings_apps_messages" : "Messages",
+ "app_settings_show_unread_first" : "Show unread first",
+ "app_settings_Templates" : "Templates",
"app_settings_apps_torch" : "Torch",
"app_settings_date_and_time": "Date and Time",
"app_settings_title_day": "Day",
M module-apps/application-settings-new/ApplicationSettings.cpp => module-apps/application-settings-new/ApplicationSettings.cpp +4 -0
@@ 11,6 11,7 @@
#include "windows/KeypadLightWindow.hpp"
#include "windows/AppsAndToolsWindow.hpp"
#include "windows/NetworkWindow.hpp"
+#include "windows/MessagesWindow.hpp"
#include "ApplicationSettings.hpp"
@@ 91,6 92,9 @@ namespace app
windowsFactory.attach(gui::window::name::network, [](Application *app, const std::string &name) {
return std::make_unique<gui::NetworkWindow>(app);
});
+ windowsFactory.attach(gui::window::name::messages, [](Application *app, const std::string &name) {
+ return std::make_unique<gui::MessagesWindow>(app);
+ });
}
void ApplicationSettingsNew::destroyUserInterface()
M module-apps/application-settings-new/ApplicationSettings.hpp => module-apps/application-settings-new/ApplicationSettings.hpp +1 -0
@@ 25,6 25,7 @@ namespace gui::window::name
inline const std::string messages = "Messages";
inline const std::string torch = "Torch";
+ inline const std::string templates = "Templates";
inline const std::string display_and_keypad = "DisplayAndKeypad";
M module-apps/application-settings-new/CMakeLists.txt => module-apps/application-settings-new/CMakeLists.txt +2 -0
@@ 26,6 26,7 @@ target_sources( ${PROJECT_NAME}
windows/DisplayAndKeypadWindow.cpp
windows/AppsAndToolsWindow.cpp
windows/NetworkWindow.cpp
+ windows/MessagesWindow.cpp
PUBLIC
ApplicationSettings.hpp
@@ 38,6 39,7 @@ target_sources( ${PROJECT_NAME}
windows/LockedScreenWindow.hpp
windows/DisplayAndKeypadWindow.hpp
windows/AppsAndToolsWindow.hpp
+ windows/MessagesWindow.hpp
)
add_dependencies(${PROJECT_NAME} version)
M module-apps/application-settings-new/windows/AppsAndToolsWindow.cpp => module-apps/application-settings-new/windows/AppsAndToolsWindow.cpp +2 -2
@@ 17,10 17,10 @@ namespace gui
std::list<gui::Option> optionList;
auto i18 = [](std::string text) { return utils::localize.get(text); };
- auto addMenu = [&](UTF8 name, std::string window = "") {
+ auto addMenu = [&](UTF8 name, std::string window) {
optionList.emplace_back(gui::Option{name,
[=](gui::Item &item) {
- if (window == "") {
+ if (window.empty()) {
return false;
}
LOG_INFO("switching to %s page", window.c_str());
A module-apps/application-settings-new/windows/MessagesWindow.cpp => module-apps/application-settings-new/windows/MessagesWindow.cpp +85 -0
@@ 0,0 1,85 @@
+#include "MessagesWindow.hpp"
+
+#include <application-settings-new/ApplicationSettings.hpp>
+#include <i18/i18.hpp>
+#include <OptionWindow.hpp>
+#include <OptionSetting.hpp>
+
+namespace gui
+{
+ MessagesWindow::MessagesWindow(app::Application *app) : OptionWindow(app, gui::window::name::messages)
+ {
+ addOptions(messagesOptList());
+ setTitle(utils::localize.get("app_settings_apps_messages"));
+ }
+
+ std::list<Option> MessagesWindow::messagesOptList()
+ {
+ std::list<gui::Option> optionList;
+
+ auto addMenuSwitch = [&](UTF8 name, std::string window) {
+ optionList.emplace_back(std::make_unique<gui::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 ? RightIcon::On : RightIcon::Off));
+ };
+
+ auto addMenu = [&](UTF8 name, std::string window) {
+ optionList.emplace_back(std::make_unique<gui::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,
+ RightIcon::Border));
+ };
+
+ bottomBar->setText(BottomBar::Side::CENTER, utils::localize.get(style::strings::common::select));
+ topBar->setActive(TopBar::Elements::SIGNAL, false);
+ topBar->setActive(TopBar::Elements::BATTERY, false);
+ topBar->setActive(TopBar::Elements::SIM, false);
+
+ addMenuSwitch(utils::translateI18("app_settings_show_unread_first"), "");
+ addMenu(utils::translateI18("app_settings_Templates"), gui::window::name::templates);
+
+ return optionList;
+ }
+
+ void MessagesWindow::rebuildOptList()
+ {
+ clearOptions();
+ addOptions(messagesOptList());
+ }
+
+ void MessagesWindow::onBeforeShow(ShowMode m, SwitchData *d)
+ {
+ rebuildOptList();
+ }
+
+} // namespace gui
A module-apps/application-settings-new/windows/MessagesWindow.hpp => module-apps/application-settings-new/windows/MessagesWindow.hpp +19 -0
@@ 0,0 1,19 @@
+#pragma once
+
+#include <OptionWindow.hpp>
+
+namespace gui
+{
+ class MessagesWindow : public OptionWindow
+ {
+ public:
+ MessagesWindow(app::Application *app);
+ ~MessagesWindow() override = default;
+ void onBeforeShow(ShowMode m, SwitchData *d) override;
+ void rebuildOptList();
+
+ private:
+ std::list<Option> messagesOptList();
+ bool showUnreadMessagesFirst = false;
+ };
+} // namespace gui