From 16eaab6b50e000786e078a70a5ccbb211f6021e9 Mon Sep 17 00:00:00 2001 From: Alek Rudnik <54846206+alekrudnik@users.noreply.github.com> Date: Thu, 30 Apr 2020 13:48:23 +0200 Subject: [PATCH] Egd 3169 sms templates (#336) * [EGD-3169] added sms templates model and item fixed common class name convention * [EGD-3169] added templates window Passing template to new sms window is already working * [EGD-3169] PR fixes from DB PR * [EGD-3169] add universal callback for templates items * [EGD-3169] requesting templates from more 2 windows * [EGD-3169] missign change - display template in threads window * [EGD-3169] minor fixes * [EGD-3169] minimal clean up * [EGD-3169] fixed some layout constatnt * [EGD-3169] rem minor comments and logs * [EGD-3089] rem redundant vector include * [EGD-3169] PR fixes * [EGD-3169] fixes afeter rebase * [EGD-3169] workaround for list view issue - added 2 dump entries * [EGD-3169] PR fixes * [EGD-3169] style fixes * [EGD-3169] fix for 0x0D char on enter in text widget * [EGD-3169] PR fixes * [EGD-3169] compilation issue --- image/assets/lang/lang_en.json | 4 + image/assets/profiles/lang_de_lower.kprof | 2 +- image/assets/profiles/lang_de_upper.kprof | 2 +- image/assets/profiles/lang_eng_lower.kprof | 2 +- image/assets/profiles/lang_eng_upper.kprof | 2 +- image/assets/profiles/lang_pl_lower.kprof | 2 +- image/assets/profiles/lang_pl_upper.kprof | 2 +- image/assets/profiles/lang_sp_lower.kprof | 2 +- image/assets/profiles/lang_sp_upper.kprof | 2 +- image/assets/profiles/numeric.kprof | 2 +- image/sms.db | Bin 24576 -> 24576 bytes .../windows/CallLogOptionsWindow.cpp | 7 +- .../ApplicationMessages.cpp | 9 +- .../ApplicationMessages.hpp | 36 ++++--- .../application-messages/CMakeLists.txt | 49 ++++----- .../application-messages/MessagesStyle.hpp | 13 +++ .../application-messages/data/SMSdata.hpp | 26 ++++- .../widgets/SMSTemplateItem.cpp | 40 ++++++++ .../widgets/SMSTemplateItem.hpp | 25 +++++ .../widgets/SMSTemplateModel.cpp | 65 ++++++++++++ .../widgets/SMSTemplateModel.hpp | 29 ++++++ .../widgets/ThreadModel.cpp | 14 +-- .../windows/NewMessage.cpp | 9 +- .../windows/NewMessage.hpp | 9 -- .../windows/OptionsMessages.cpp | 18 ++-- .../windows/OptionsMessages.hpp | 7 +- .../windows/SMSTemplatesWindow.cpp | 94 ++++++++++++++++++ .../windows/SMSTemplatesWindow.hpp | 33 ++++++ .../windows/SearchStart.hpp | 6 -- .../windows/ThreadViewWindow.cpp | 7 +- .../windows/ThreadViewWindow.hpp | 9 -- module-db/CMakeLists.txt | 2 +- module-db/Databases/SmsDB.hpp | 4 +- module-db/Interface/SMSTemplateRecord.cpp | 37 +++---- module-db/Interface/SMSTemplateRecord.hpp | 32 +++--- ...emplatesTable.cpp => SMSTemplateTable.cpp} | 44 ++++---- module-db/Tables/SMSTemplateTable.hpp | 47 +++++++++ module-db/Tables/SMSTemplatesTable.hpp | 47 --------- module-db/tests/CMakeLists.txt | 2 +- module-db/tests/SMSTemplateRecord_tests.cpp | 42 ++++---- ...e_tests.cpp => SMSTemplateTable_tests.cpp} | 4 +- module-gui/gui/widgets/ListItem.cpp | 18 ++-- module-gui/gui/widgets/Style.hpp | 1 + module-gui/gui/widgets/Text.cpp | 6 ++ module-services/service-db/ServiceDB.cpp | 57 +++++++++-- module-services/service-db/ServiceDB.hpp | 16 +-- .../service-db/api/DBServiceAPI.cpp | 62 ++++++++++++ .../service-db/api/DBServiceAPI.hpp | 22 ++-- .../service-db/messages/DBMessage.hpp | 36 +++++++ source/MessageType.hpp | 6 ++ 50 files changed, 726 insertions(+), 286 deletions(-) create mode 100644 module-apps/application-messages/widgets/SMSTemplateItem.cpp create mode 100644 module-apps/application-messages/widgets/SMSTemplateItem.hpp create mode 100644 module-apps/application-messages/widgets/SMSTemplateModel.cpp create mode 100644 module-apps/application-messages/widgets/SMSTemplateModel.hpp create mode 100644 module-apps/application-messages/windows/SMSTemplatesWindow.cpp create mode 100644 module-apps/application-messages/windows/SMSTemplatesWindow.hpp rename module-db/Tables/{SMSTemplatesTable.cpp => SMSTemplateTable.cpp} (67%) create mode 100644 module-db/Tables/SMSTemplateTable.hpp delete mode 100644 module-db/Tables/SMSTemplatesTable.hpp rename module-db/tests/{SMSTemplatesTable_tests.cpp => SMSTemplateTable_tests.cpp} (95%) diff --git a/image/assets/lang/lang_en.json b/image/assets/lang/lang_en.json index c6c52685e..574fa9001 100644 --- a/image/assets/lang/lang_en.json +++ b/image/assets/lang/lang_en.json @@ -9,6 +9,7 @@ "common_send": "SEND", "common_confirm": "CONFIRM", "common_select": "SELECT", + "common_use": "USE", "common_ok": "OK", "common_back": "BACK", "common_set": "SET", @@ -132,6 +133,7 @@ "app_messages_thread_delete_confirmation": "Do you really want to delete\nthis conversation?", "app_messages_thread_no_result" : "There are no results", "app_messages_message": "Message", + "app_messages_templates": "Templates", "app_settings_title_main": "Settings", "app_settings_bt" : "Bluetooth", @@ -201,6 +203,8 @@ "sms_copy" : "Copy", "sms_delete_message" : "Delete", "sms_from_this_sms" : "From this message", + "sms_use_template" : "Use Template", + "sms_paste" : "Paste", "settings_lang_PL": "PL", "settings_lang_ENG": "ENG", diff --git a/image/assets/profiles/lang_de_lower.kprof b/image/assets/profiles/lang_de_lower.kprof index b00c03b55..9e35b8302 100644 --- a/image/assets/profiles/lang_de_lower.kprof +++ b/image/assets/profiles/lang_de_lower.kprof @@ -83,7 +83,7 @@ false #JoystickEnter = 12, 12 false -0x0D +'' 0 #FnLeft = 21,//1, #FnRight = 23,//3, diff --git a/image/assets/profiles/lang_de_upper.kprof b/image/assets/profiles/lang_de_upper.kprof index f8fef099c..5d9df2226 100644 --- a/image/assets/profiles/lang_de_upper.kprof +++ b/image/assets/profiles/lang_de_upper.kprof @@ -83,7 +83,7 @@ false #JoystickEnter = 12, 12 false -0x0D +'' 0 #FnLeft = 21,//1, #FnRight = 23,//3, diff --git a/image/assets/profiles/lang_eng_lower.kprof b/image/assets/profiles/lang_eng_lower.kprof index 2b45c1623..ef7179711 100644 --- a/image/assets/profiles/lang_eng_lower.kprof +++ b/image/assets/profiles/lang_eng_lower.kprof @@ -83,7 +83,7 @@ false #JoystickEnter = 12, 12 false -0x0D +'' 0 #FnLeft = 21,//1, #FnRight = 23,//3, diff --git a/image/assets/profiles/lang_eng_upper.kprof b/image/assets/profiles/lang_eng_upper.kprof index 027fd9c84..818555c49 100644 --- a/image/assets/profiles/lang_eng_upper.kprof +++ b/image/assets/profiles/lang_eng_upper.kprof @@ -83,7 +83,7 @@ false #JoystickEnter = 12, 12 false -0x0D +'' 0 #FnLeft = 21,//1, #FnRight = 23,//3, diff --git a/image/assets/profiles/lang_pl_lower.kprof b/image/assets/profiles/lang_pl_lower.kprof index 844d4f9c7..3b1fd1bf7 100644 --- a/image/assets/profiles/lang_pl_lower.kprof +++ b/image/assets/profiles/lang_pl_lower.kprof @@ -83,7 +83,7 @@ false #JoystickEnter = 12, 12 false -0x0D +'' 0 #FnLeft = 21,//1, #FnRight = 23,//3, diff --git a/image/assets/profiles/lang_pl_upper.kprof b/image/assets/profiles/lang_pl_upper.kprof index b018636b4..b7b086acb 100644 --- a/image/assets/profiles/lang_pl_upper.kprof +++ b/image/assets/profiles/lang_pl_upper.kprof @@ -83,7 +83,7 @@ false #JoystickEnter = 12, 12 false -0x0D +'' 0 #FnLeft = 21,//1, #FnRight = 23,//3, diff --git a/image/assets/profiles/lang_sp_lower.kprof b/image/assets/profiles/lang_sp_lower.kprof index 405e25fd9..87c437900 100644 --- a/image/assets/profiles/lang_sp_lower.kprof +++ b/image/assets/profiles/lang_sp_lower.kprof @@ -83,7 +83,7 @@ false #JoystickEnter = 12, 12 false -0x0D +'' 0 #FnLeft = 21,//1, #FnRight = 23,//3, diff --git a/image/assets/profiles/lang_sp_upper.kprof b/image/assets/profiles/lang_sp_upper.kprof index f166f5e42..833846b78 100644 --- a/image/assets/profiles/lang_sp_upper.kprof +++ b/image/assets/profiles/lang_sp_upper.kprof @@ -83,7 +83,7 @@ false #JoystickEnter = 12, 12 false -0x0D +'' 0 #FnLeft = 21,//1, #FnRight = 23,//3, diff --git a/image/assets/profiles/numeric.kprof b/image/assets/profiles/numeric.kprof index d1730000a..e740e0f76 100644 --- a/image/assets/profiles/numeric.kprof +++ b/image/assets/profiles/numeric.kprof @@ -83,7 +83,7 @@ false #JoystickEnter = 12, 12 false -0x0D +'' 0 #FnLeft = 21,//1, #FnRight = 23,//3, diff --git a/image/sms.db b/image/sms.db index c204b83819d16f25ea93a11cff1d429d44cb1ad6..57216ef125f275ef6dda29e1087aea62a43397dd 100644 GIT binary patch delta 235 zcmZoTz}Rqrae_3X) calllogWindowOptions(app::ApplicationCallLog *app, const // add option delete call option options.push_back(gui::Option( utils::localize.get("app_calllog_options_delete_call"), - [=](gui::Item &item) { - auto application = dynamic_cast(app); - if (application != nullptr) - return application->removeCalllogEntry(record); - return false; - }, + [=](gui::Item &item) { return app->removeCalllogEntry(record); }, gui::Arrow::Disabled)); return options; diff --git a/module-apps/application-messages/ApplicationMessages.cpp b/module-apps/application-messages/ApplicationMessages.cpp index 5643be88f..f680c91dc 100644 --- a/module-apps/application-messages/ApplicationMessages.cpp +++ b/module-apps/application-messages/ApplicationMessages.cpp @@ -6,6 +6,7 @@ #include "windows/OptionsWindow.hpp" #include "windows/ThreadViewWindow.hpp" #include "windows/SearchStart.hpp" +#include "windows/SMSTemplatesWindow.hpp" #include #include @@ -57,7 +58,8 @@ namespace app if (resp != nullptr) { handled = true; switch (resp->responseTo) { - case MessageType::DBThreadGetLimitOffset: { + case MessageType::DBThreadGetLimitOffset: + case MessageType::DBSMSTemplateGetLimitOffset: { if (getCurrentWindow()->onDatabaseMessage(resp)) refreshWindow(gui::RefreshModes::GUI_REFRESH_FAST); } break; @@ -117,6 +119,7 @@ namespace app gui::name::window::thread_search_none, gui::Dialog::Meta{.icon = "search_big", .have_choice = false})}); windows.insert({gui::name::window::thread_sms_search, new gui::SMSSearch(this)}); + windows.insert({gui::name::window::sms_templates, new gui::SMSTemplatesWindow(this)}); } void ApplicationMessages::destroyUserInterface() @@ -180,12 +183,12 @@ namespace app return DBServiceAPI::SMSAdd(this, record) != DB_ID_NONE; } - bool ApplicationMessages::newMessageOptions() + bool ApplicationMessages::newMessageOptions(const std::string &requestingWindow) { LOG_INFO("New message options"); if (windowOptions != nullptr) { windowOptions->clearOptions(); - windowOptions->addOptions(newMessageWindowOptions(this)); + windowOptions->addOptions(newMessageWindowOptions(this, requestingWindow)); switchWindow(windowOptions->getName(), nullptr); } return true; diff --git a/module-apps/application-messages/ApplicationMessages.hpp b/module-apps/application-messages/ApplicationMessages.hpp index 7ab341ff8..ca9cc10e7 100644 --- a/module-apps/application-messages/ApplicationMessages.hpp +++ b/module-apps/application-messages/ApplicationMessages.hpp @@ -1,16 +1,8 @@ -/* - * @file ApplicationMessages.hpp - * @author Robert Borzecki (robert.borzecki@mudita.com) - * @date 25 wrz 2019 - * @brief - * @copyright Copyright (C) 2019 mudita.com - * @details - */ -#ifndef MODULE_APPS_APPLICATION_MESSAGES_APPLICATIONMESSAGES_HPP_ -#define MODULE_APPS_APPLICATION_MESSAGES_APPLICATIONMESSAGES_HPP_ +#pragma once -#include "Application.hpp" -#include "Interface/ThreadRecord.hpp" +#include +#include +#include namespace gui { @@ -19,11 +11,16 @@ namespace gui { namespace window { - inline const std::string thread_rm_confirm = "ConfirmRM"; + inline const std::string thread_rm_confirm = "ConfirmRM"; inline const std::string thread_search_none = "SearchNone"; - }; - }; // namespace name -}; // namespace gui + inline const std::string new_sms = "NewSMS"; + inline const std::string thread_sms_search = "SMSSearch"; + inline const std::string sms_templates = "SMSTemplates"; + inline const std::string thread_view = "ThreadViewWindow"; + + }; // namespace window + }; // namespace name +}; // namespace gui namespace app { @@ -54,8 +51,9 @@ namespace app /// show dialog with big search icon and text which was used for query bool searchEmpty(const std::string &query = ""); bool sendSms(const UTF8 &number, const UTF8 &body); - bool newMessageOptions(); + bool newMessageOptions(const std::string &requestingWindow); + + // used by sms template items + std::function templ)> templatesCallback; }; } /* namespace app */ - -#endif /* MODULE_APPS_APPLICATION_MESSAGES_APPLICATIONMESSAGES_HPP_ */ diff --git a/module-apps/application-messages/CMakeLists.txt b/module-apps/application-messages/CMakeLists.txt index 49502712a..445d5de26 100644 --- a/module-apps/application-messages/CMakeLists.txt +++ b/module-apps/application-messages/CMakeLists.txt @@ -1,44 +1,47 @@ include_directories( ${CMAKE_PROJECT_NAME} - PUBLIC - "${CMAKE_CURRENT_LIST_DIR}" + PUBLIC + "${CMAKE_CURRENT_LIST_DIR}" ) include_directories( ${PROJECT_NAME} - PUBLIC - "${CMAKE_CURRENT_LIST_DIR}" + PUBLIC + "${CMAKE_CURRENT_LIST_DIR}" ) target_sources( ${PROJECT_NAME} - PRIVATE - "${CMAKE_CURRENT_LIST_DIR}/ApplicationMessages.cpp" - #"${CMAKE_CURRENT_LIST_DIR}/MessagesModel.cpp" - - #"${CMAKE_CURRENT_LIST_DIR}/widgets/MessagesItem.cpp" - #"${CMAKE_CURRENT_LIST_DIR}/widgets/MessagesListView.cpp" - "${CMAKE_CURRENT_LIST_DIR}/widgets/ThreadModel.cpp" - "${CMAKE_CURRENT_LIST_DIR}/widgets/ThreadItem.cpp" - "${CMAKE_CURRENT_LIST_DIR}/widgets/Icon.cpp" + PRIVATE + "${CMAKE_CURRENT_LIST_DIR}/ApplicationMessages.cpp" + #"${CMAKE_CURRENT_LIST_DIR}/MessagesModel.cpp" - "${CMAKE_CURRENT_LIST_DIR}/windows/MessagesMainWindow.cpp" + #"${CMAKE_CURRENT_LIST_DIR}/widgets/MessagesItem.cpp" + #"${CMAKE_CURRENT_LIST_DIR}/widgets/MessagesListView.cpp" + "${CMAKE_CURRENT_LIST_DIR}/widgets/ThreadModel.cpp" + "${CMAKE_CURRENT_LIST_DIR}/widgets/ThreadItem.cpp" + "${CMAKE_CURRENT_LIST_DIR}/widgets/SMSTemplateModel.cpp" + "${CMAKE_CURRENT_LIST_DIR}/widgets/SMSTemplateItem.cpp" + "${CMAKE_CURRENT_LIST_DIR}/widgets/Icon.cpp" + + "${CMAKE_CURRENT_LIST_DIR}/windows/MessagesMainWindow.cpp" "${CMAKE_CURRENT_LIST_DIR}/windows/ThreadViewWindow.cpp" "${CMAKE_CURRENT_LIST_DIR}/windows/NewMessage.cpp" "${CMAKE_CURRENT_LIST_DIR}/windows/OptionsWindow.cpp" "${CMAKE_CURRENT_LIST_DIR}/windows/OptionsMessages.cpp" "${CMAKE_CURRENT_LIST_DIR}/windows/SearchStart.cpp" + "${CMAKE_CURRENT_LIST_DIR}/windows/SMSTemplatesWindow.cpp" - PUBLIC - #"${CMAKE_CURRENT_LIST_DIR}/MessagesModel.hpp" - "${CMAKE_CURRENT_LIST_DIR}/ApplicationMessages.hpp" - "${CMAKE_CURRENT_LIST_DIR}/MessagesStyle.hpp" - - "${CMAKE_CURRENT_LIST_DIR}/widgets/ThreadModel.hpp" + PUBLIC + #"${CMAKE_CURRENT_LIST_DIR}/MessagesModel.hpp" + "${CMAKE_CURRENT_LIST_DIR}/ApplicationMessages.hpp" + "${CMAKE_CURRENT_LIST_DIR}/MessagesStyle.hpp" + + "${CMAKE_CURRENT_LIST_DIR}/widgets/ThreadModel.hpp" "${CMAKE_CURRENT_LIST_DIR}/widgets/ThreadItem.hpp" - #"${CMAKE_CURRENT_LIST_DIR}/widgets/MessagesListView.hpp" - #"${CMAKE_CURRENT_LIST_DIR}/widgets/MessagesItem.hpp" - + #"${CMAKE_CURRENT_LIST_DIR}/widgets/MessagesListView.hpp" + #"${CMAKE_CURRENT_LIST_DIR}/widgets/MessagesItem.hpp" + #"${CMAKE_CURRENT_LIST_DIR}/windows/MessagesNewContact.hpp" ) diff --git a/module-apps/application-messages/MessagesStyle.hpp b/module-apps/application-messages/MessagesStyle.hpp index 96da0033a..b71b885ff 100644 --- a/module-apps/application-messages/MessagesStyle.hpp +++ b/module-apps/application-messages/MessagesStyle.hpp @@ -51,4 +51,17 @@ namespace messages constexpr uint32_t h = 44; } } // namespace newMessage + + namespace templates + { + namespace list + { + constexpr auto pageSize = 7; + + constexpr auto h = 445; + constexpr auto w = 458; + constexpr auto x = 11; + constexpr auto y = 105; + } // namespace list + } // namespace templates } // namespace messages diff --git a/module-apps/application-messages/data/SMSdata.hpp b/module-apps/application-messages/data/SMSdata.hpp index d2fb40c2b..472b016af 100644 --- a/module-apps/application-messages/data/SMSdata.hpp +++ b/module-apps/application-messages/data/SMSdata.hpp @@ -1,8 +1,9 @@ #pragma once -#include "ContactRecord.hpp" -#include "SwitchData.hpp" -#include "ThreadRecord.hpp" +#include +#include +#include +#include #include #include #include @@ -24,3 +25,22 @@ class SMSSendRequest : public gui::SwitchData {} virtual ~SMSSendRequest() = default; }; + +class SMSTemplateData : public gui::SwitchData +{ + public: + SMSTemplateData(std::shared_ptr templ) : templ(templ) + {} + virtual ~SMSTemplateData() = default; + std::shared_ptr templ = nullptr; +}; + +class SMSTemplateRequest : public gui::SwitchData +{ + public: + SMSTemplateRequest(const std::string &requestingWindow) : requestingWindow(requestingWindow) + {} + virtual ~SMSTemplateRequest() = default; + + std::string requestingWindow; +}; \ No newline at end of file diff --git a/module-apps/application-messages/widgets/SMSTemplateItem.cpp b/module-apps/application-messages/widgets/SMSTemplateItem.cpp new file mode 100644 index 000000000..7fc5b6dea --- /dev/null +++ b/module-apps/application-messages/widgets/SMSTemplateItem.cpp @@ -0,0 +1,40 @@ +#include "SMSTemplateItem.hpp" + +#include