From 5ca8e9e5cf96ed95f7e62b2d42194dcc50ec8ad8 Mon Sep 17 00:00:00 2001 From: Lefucjusz Date: Mon, 10 Jul 2023 10:19:19 +0200 Subject: [PATCH] [MOS-1004] Fix autolock on SMS template call rejection Fix of the issue that unlocked phone would automatically lock after user tried to reject incoming call via SMS and stayed on the templates window. --- .../application-call/windows/CallWindow.cpp | 6 +++--- .../ApplicationMessages.cpp | 4 ++-- .../application-messages/data/SMSdata.hpp | 17 ++++++++++++----- .../windows/SMSTemplatesWindow.cpp | 10 ++++------ pure_changelog.md | 1 + 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/module-apps/application-call/windows/CallWindow.cpp b/module-apps/application-call/windows/CallWindow.cpp index 11b415effa3c49db575f8a5945db887eed56e178..3b0efb367cc030f4835051d4cc5388b157b0296f 100644 --- a/module-apps/application-call/windows/CallWindow.cpp +++ b/module-apps/application-call/windows/CallWindow.cpp @@ -110,10 +110,10 @@ namespace gui }; sendSmsIcon = new gui::SendSmsIcon(iconsBox); - sendSmsIcon->activatedCallback = [=](gui::Item &item) { + sendSmsIcon->activatedCallback = [=]([[maybe_unused]] gui::Item &item) { LOG_INFO("Send message template and reject the call"); - constexpr auto preventAutoLock = true; - auto msg = std::make_unique(presenter.getPhoneNumber().getView(), preventAutoLock); + auto msg = std::make_unique(presenter.getPhoneNumber().getView(), + SMSSendTemplateRequest::AutolockBehavior::Prevent); msg->ignoreCurrentWindowOnStack = true; msg->nameOfSenderApplication = application->GetName(); return app::manager::Controller::sendAction(application, diff --git a/module-apps/application-messages/ApplicationMessages.cpp b/module-apps/application-messages/ApplicationMessages.cpp index 247c42f72d39870f0c766fa1ea2efd606e0fbb04..df77ada81a08f56f6c7d0943884c1a3ff4c7a436 100644 --- a/module-apps/application-messages/ApplicationMessages.cpp +++ b/module-apps/application-messages/ApplicationMessages.cpp @@ -157,11 +157,11 @@ namespace app gui::name::window::thread_sms_search, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); windowsFactory.attach(gui::name::window::sms_templates, [](ApplicationCommon *app, const std::string &name) { - return std::make_unique(app); + return std::make_unique(app, name); }); windowsFactory.attach(gui::name::window::call_sms_templates, [](ApplicationCommon *app, const std::string &name) { - return std::make_unique(app); + return std::make_unique(app, name); }); windowsFactory.attach(gui::name::window::search_results, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); diff --git a/module-apps/application-messages/data/SMSdata.hpp b/module-apps/application-messages/data/SMSdata.hpp index a20d74c141320289707b24e0d9a87c1384f1c5ed..7c30b9816a735e607d715add4d5b0832f10ca1fc 100644 --- a/module-apps/application-messages/data/SMSdata.hpp +++ b/module-apps/application-messages/data/SMSdata.hpp @@ -72,18 +72,25 @@ class SMSSendRequest : public SMSRequest class SMSSendTemplateRequest : public SMSRequest { public: - explicit SMSSendTemplateRequest(const utils::PhoneNumber::View &phoneNumber, bool preventAutoLock = false) - : SMSRequest(phoneNumber), preventAutoLock(preventAutoLock) + enum class AutolockBehavior + { + Allow, + Prevent + }; + + explicit SMSSendTemplateRequest(const utils::PhoneNumber::View &phoneNumber, + AutolockBehavior autolockBehavior = AutolockBehavior::Allow) + : SMSRequest(phoneNumber), autolockBehavior(autolockBehavior) {} ~SMSSendTemplateRequest() override = default; - [[nodiscard]] bool isAutoLockPrevented() const + [[nodiscard]] AutolockBehavior getAutolockBehavior() const noexcept { - return preventAutoLock; + return autolockBehavior; } private: - bool preventAutoLock; + AutolockBehavior autolockBehavior; }; class SMSTemplateSent : public gui::SwitchData diff --git a/module-apps/application-messages/windows/SMSTemplatesWindow.cpp b/module-apps/application-messages/windows/SMSTemplatesWindow.cpp index a3f765a877e53ee687369982a7dda9aa6ef66be7..8b7515b7867287d7cadac8b17aaa0dc38de1df98 100644 --- a/module-apps/application-messages/windows/SMSTemplatesWindow.cpp +++ b/module-apps/application-messages/windows/SMSTemplatesWindow.cpp @@ -91,8 +91,7 @@ namespace gui auto requestingWindow = switchData->requestingWindow; app->templatesCallback = [=](std::shared_ptr templ) { LOG_DEBUG("SMS template id = %" PRIu32 "chosen", templ->ID); - std::unique_ptr data = - std::make_unique(templ->text, SMSTextData::Concatenate::True); + auto data = std::make_unique(templ->text, SMSTextData::Concatenate::True); application->switchWindow(requestingWindow, std::move(data)); return true; }; @@ -100,7 +99,8 @@ namespace gui void SMSTemplatesWindow::smsSendTemplateRequestHandler(const SMSSendTemplateRequest *const switchData) { - preventsAutoLock = switchData->isAutoLockPrevented(); + preventsAutoLock = (switchData->getAutolockBehavior() == SMSSendTemplateRequest::AutolockBehavior::Prevent); + auto app = dynamic_cast(application); assert(app != nullptr); @@ -115,10 +115,8 @@ namespace gui }; } - void SMSTemplatesWindow::onBeforeShow(ShowMode mode, SwitchData *data) + void SMSTemplatesWindow::onBeforeShow([[maybe_unused]] ShowMode mode, SwitchData *data) { - preventsAutoLock = false; - if (auto switchData = dynamic_cast(data)) { smsTemplateRequestHandler(switchData); } diff --git a/pure_changelog.md b/pure_changelog.md index 2e7686448d02046ef2a5be908e9e055d319fa571..920e7975000686fd509cbbded8d940fc3f985694 100644 --- a/pure_changelog.md +++ b/pure_changelog.md @@ -51,6 +51,7 @@ * Fixed occasional USB crash when USB cable was disconnected during files upload * Fixed unsupported character in several quotes * Fixed marking new message as read in Messages app main window +* Fixed unwanted autolock on template selection window while rejecting call ## [1.7.0 2023-03-23] ### Changed / Improved