diff --git a/module-apps/application-messages/ApplicationMessages.cpp b/module-apps/application-messages/ApplicationMessages.cpp index 9de43c32f..246dddf2f 100644 --- a/module-apps/application-messages/ApplicationMessages.cpp +++ b/module-apps/application-messages/ApplicationMessages.cpp @@ -83,24 +83,22 @@ sys::ReturnCodes ApplicationMessages::DeinitHandler() { void ApplicationMessages::createUserInterface() { - threadOptionsWindow = gui::newOptionWindow(this, gui::name::window::thread_options, {}); - messageOptionWindow = gui::newOptionWindow(this, gui::name::window::messages_options, {}); + windowOptions = gui::newOptionWindow(this); windows.insert({gui::name::window::main_window, new gui::MessagesMainWindow(this)}); windows.insert({gui::name::window::thread_view, new gui::ThreadViewWindow(this)}); windows.insert({gui::name::window::new_sms, new gui::NewSMS_Window(this)}); - windows.insert({gui::name::window::thread_options, threadOptionsWindow}); + windows.insert({windowOptions->getName(), windowOptions}); windows.insert({gui::name::window::thread_rm_confirm, new gui::Dialog(this, gui::name::window::thread_rm_confirm, { - .title = "rm contact?", + .title = "", .icon = "phonebook_contact_delete_trashcan", - .text = "thou shall not pass", + .text = "", .action = []() -> bool { LOG_INFO("!"); return true; }, })}); - windows.insert({gui::name::window::messages_options, messageOptionWindow}); } void ApplicationMessages::destroyUserInterface() { diff --git a/module-apps/application-messages/ApplicationMessages.hpp b/module-apps/application-messages/ApplicationMessages.hpp index fdf54c7df..c8a3e12d1 100644 --- a/module-apps/application-messages/ApplicationMessages.hpp +++ b/module-apps/application-messages/ApplicationMessages.hpp @@ -34,8 +34,7 @@ public: std::string parent = "", bool startBackgound = false); virtual ~ApplicationMessages(); - gui::OptionWindow *threadOptionsWindow = nullptr; - gui::OptionWindow *messageOptionWindow = nullptr; + gui::OptionWindow *windowOptions = nullptr; sys::Message_t DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) override; diff --git a/module-apps/application-messages/windows/MessagesMainWindow.cpp b/module-apps/application-messages/windows/MessagesMainWindow.cpp index 5c55b631d..83e2fe0bd 100644 --- a/module-apps/application-messages/windows/MessagesMainWindow.cpp +++ b/module-apps/application-messages/windows/MessagesMainWindow.cpp @@ -171,14 +171,14 @@ bool MessagesMainWindow::onInput(const InputEvent &inputEvent) LOG_ERROR("Something went horribly wrong"); return false; } - if (app->threadOptionsWindow != nullptr) + if (app->windowOptions != nullptr) { - app->threadOptionsWindow->clearOptions(); + app->windowOptions->clearOptions(); auto it = dynamic_cast(list->getSelectedItem()); if (it) { - app->threadOptionsWindow->addOptions(threadWindowOptions(app, it->getThreadItem().get())); - app->switchWindow(gui::name::window::thread_options, nullptr); + app->windowOptions->addOptions(threadWindowOptions(app, it->getThreadItem().get())); + app->switchWindow(app->windowOptions->getName(), nullptr); } else { diff --git a/module-apps/application-messages/windows/OptionsMessages.cpp b/module-apps/application-messages/windows/OptionsMessages.cpp index 3fe467b7f..2258d43cb 100644 --- a/module-apps/application-messages/windows/OptionsMessages.cpp +++ b/module-apps/application-messages/windows/OptionsMessages.cpp @@ -15,6 +15,11 @@ gui::HBox *newCombo(app::ApplicationMessages *app, const ContactRecord &contact) auto box = new gui::HBox(nullptr, offset, 0, style::window_width - 2 * offset, label::big_h); box->setPenWidth(0); box->setPenFocusWidth(0); + // items cant be bound to any Alignment + // This should be fixed with: + // * Time when UX design will provide us with design guide which is in progress and should be done shortly + // * additon of alignment to elements (so that Layouts could position them properly) + // right now it's added as it is, trying to conform with window which UX was being changed while it was written auto l = new gui::Label(box, 0, 0, style::window_width - 3 * wlabel - 2 * offset - 1, label::big_h); decorate(l); l->setText(contact.primaryName); @@ -25,6 +30,7 @@ gui::HBox *newCombo(app::ApplicationMessages *app, const ContactRecord &contact) decorate(phone); // does nothing for image :| phone->setAlignement({gui::Alignment::ALIGN_HORIZONTAL_CENTER | gui::Alignment::ALIGN_VERTICAL_CENTER}); + // please read comment above - this is alignment done by hand new gui::Image(phone, 12, 12, 50, label::big_h, icon); phone->activatedCallback = foo; }; diff --git a/module-apps/application-messages/windows/OptionsMessages.hpp b/module-apps/application-messages/windows/OptionsMessages.hpp index b1b11451a..5039f560e 100644 --- a/module-apps/application-messages/windows/OptionsMessages.hpp +++ b/module-apps/application-messages/windows/OptionsMessages.hpp @@ -4,15 +4,4 @@ #include "Interface/SMSRecord.hpp" #include "OptionWindow.hpp" -namespace gui -{ - namespace name - { - namespace window - { - inline const std::string messages_options = "options_mess"; - }; - }; // namespace name -}; // namespace gui - std::list smsWindowOptions(app::ApplicationMessages *app, const SMSRecord &record); diff --git a/module-apps/application-messages/windows/OptionsWindow.hpp b/module-apps/application-messages/windows/OptionsWindow.hpp index 57f6b74b6..a9a3c67cb 100644 --- a/module-apps/application-messages/windows/OptionsWindow.hpp +++ b/module-apps/application-messages/windows/OptionsWindow.hpp @@ -4,15 +4,4 @@ #include "Interface/ThreadRecord.hpp" #include "OptionWindow.hpp" -namespace gui -{ - namespace name - { - namespace window - { - inline const std::string thread_options = "options"; - }; - }; // namespace name -}; // namespace gui - std::list threadWindowOptions(app::ApplicationMessages *appl, const ThreadRecord *record); diff --git a/module-apps/application-messages/windows/ThreadViewWindow.cpp b/module-apps/application-messages/windows/ThreadViewWindow.cpp index 3cefdea60..9a93d468a 100644 --- a/module-apps/application-messages/windows/ThreadViewWindow.cpp +++ b/module-apps/application-messages/windows/ThreadViewWindow.cpp @@ -91,10 +91,15 @@ namespace gui void ThreadViewWindow::cleanMessages() { - // hack just to fix setting pos for now + // remove items from list and and set text to no navigation (text is all the time same widget) + auto text = body->children.front(); + body->setFocusItem(text); + text->setNavigationItem(NavigationDirection::UP, nullptr); + text->setNavigationItem(NavigationDirection::DOWN, nullptr); if (body->children.size() > 1) { - std::for_each(std::next(body->children.begin(), 1), body->children.end(), [=](auto el) { body->removeWidget(el); }); + std::for_each(std::next(body->children.begin(), 1), body->children.end(), [&](auto &el) { delete el; }); + body->children.erase(std::next(body->children.begin()), body->children.end()); } } @@ -127,12 +132,12 @@ namespace gui LOG_ERROR("Something went horribly wrong"); return false; } - if (app->messageOptionWindow != nullptr) + if (app->windowOptions != nullptr) { - app->messageOptionWindow->clearOptions(); + app->windowOptions->clearOptions(); /// TODO get record properly... - app->messageOptionWindow->addOptions(smsWindowOptions(app, el)); - app->switchWindow(gui::name::window::messages_options, nullptr); + app->windowOptions->addOptions(smsWindowOptions(app, el)); + app->switchWindow(app->windowOptions->getName(), nullptr); } return true; }; @@ -176,7 +181,7 @@ namespace gui if (pdata) { LOG_INFO("We have it! %d", pdata->thread->dbID); - // cleanMessages + cleanMessages(); addMessages(pdata->thread->dbID); auto ret = DBServiceAPI::ContactGetByID(application, pdata->thread->contactID); // should be name number for now - easier to handle diff --git a/module-apps/application-settings/ApplicationSettings.cpp b/module-apps/application-settings/ApplicationSettings.cpp index 465924b24..feb5d5701 100644 --- a/module-apps/application-settings/ApplicationSettings.cpp +++ b/module-apps/application-settings/ApplicationSettings.cpp @@ -23,6 +23,7 @@ #include "service-cellular/ServiceCellular.hpp" #include "windows/SettingsMainWindow.hpp" +#include namespace app { @@ -75,7 +76,8 @@ void ApplicationSettings::createUserInterface() { gui::AppWindow* window = nullptr; window = newOptionWindow(this, gui::name::window::main_window, mainWindowOptions(this)); - windows.insert(std::pair(window->getName(), window)); + window->setTitle(utils::localize.get("app_settings_title_main")); + windows.insert(std::pair(window->getName(), window)); window = new gui::LanguageWindow(this); windows.insert(std::pair(window->getName(), window)); diff --git a/module-apps/windows/Dialog.cpp b/module-apps/windows/Dialog.cpp index 873b18068..3ad6bd2f0 100644 --- a/module-apps/windows/Dialog.cpp +++ b/module-apps/windows/Dialog.cpp @@ -6,6 +6,7 @@ using namespace gui; Dialog::Dialog(app::Application *app, const std::string &name, const Dialog::Meta &meta) : gui::AppWindow(app, name), meta(meta) { AppWindow::buildInterface(); + // TODO fix elements positioning with styles ready, right now copied from Phonebook as it is topBar->setActive(TopBar::Elements::TIME, true); bottomBar->setActive(BottomBar::Side::LEFT, false); diff --git a/module-apps/windows/OptionWindow.cpp b/module-apps/windows/OptionWindow.cpp index 786726e90..d7c97f775 100644 --- a/module-apps/windows/OptionWindow.cpp +++ b/module-apps/windows/OptionWindow.cpp @@ -22,6 +22,7 @@ namespace gui Item *newOptionLabel(const UTF8 &text, std::function activatedCallback) { + // TODO fix elements positioning with styles ready, right now moved from Settings main window as it is gui::Label *label = new gui::Label(nullptr, 20, 0, style::window_width - 2 * 20, style::window::label::big_h, text); style::window::decorateOption(label); label->activatedCallback = activatedCallback; @@ -78,8 +79,7 @@ namespace gui topBar->setActive(TopBar::Elements::SIGNAL, true); topBar->setActive(TopBar::Elements::BATTERY, true); - - setTitle(utils::localize.get("app_settings_title_main")); + setTitle(name); // magical offset on designs int32_t offset_h = 8; @@ -107,6 +107,11 @@ namespace gui OptionWindow *newOptionWindow(app::Application *app, std::string name, std::list