From 57fa3567679bd9246e8e53a1d08ed45bd7aa671e Mon Sep 17 00:00:00 2001 From: rrandomsky Date: Thu, 23 Feb 2023 15:00:50 +0100 Subject: [PATCH] [MOS-359] Fix returning to call screen from message template Fixed returning to the call screen from the message template screen from which the user can send a message during an incoming call. --- .../application-call/windows/CallWindow.cpp | 3 ++- module-apps/application-messages/data/SMSdata.hpp | 15 ++++++++++++--- .../windows/SMSTemplatesWindow.cpp | 13 ++++++++++++- .../windows/SMSTemplatesWindow.hpp | 9 ++++++--- pure_changelog.md | 1 + 5 files changed, 33 insertions(+), 8 deletions(-) diff --git a/module-apps/application-call/windows/CallWindow.cpp b/module-apps/application-call/windows/CallWindow.cpp index 5177e6c6bb41e1262175b67075aa18efd571107a..4a12a40c847da9676e770ccc2ec7e09b54815493 100644 --- a/module-apps/application-call/windows/CallWindow.cpp +++ b/module-apps/application-call/windows/CallWindow.cpp @@ -113,7 +113,8 @@ namespace gui sendSmsIcon->activatedCallback = [=](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(), preventAutoLock, application->GetName()); msg->ignoreCurrentWindowOnStack = true; return app::manager::Controller::sendAction(application, app::manager::actions::ShowSmsTemplates, diff --git a/module-apps/application-messages/data/SMSdata.hpp b/module-apps/application-messages/data/SMSdata.hpp index 02f12f0d2d9201ecf6728dd0671c8a1e3970365d..c5b0ae55b98a536f628b94ae8c54d616e4ec1592 100644 --- a/module-apps/application-messages/data/SMSdata.hpp +++ b/module-apps/application-messages/data/SMSdata.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -71,8 +72,10 @@ class SMSSendRequest : public SMSRequest class SMSSendTemplateRequest : public SMSRequest { public: - SMSSendTemplateRequest(const utils::PhoneNumber::View &phoneNumber, bool preventAutoLock = false) - : SMSRequest(phoneNumber), preventAutoLock(preventAutoLock) + explicit SMSSendTemplateRequest(const utils::PhoneNumber::View &phoneNumber, + bool preventAutoLock = false, + std::optional nameOfSenderApp = std::nullopt) + : SMSRequest(phoneNumber), preventAutoLock(preventAutoLock), nameOfSenderApp(nameOfSenderApp) {} ~SMSSendTemplateRequest() override = default; @@ -81,8 +84,14 @@ class SMSSendTemplateRequest : public SMSRequest return preventAutoLock; } + [[nodiscard]] auto getNameOfSenderApp() const -> std::optional + { + return nameOfSenderApp; + } + private: bool preventAutoLock; + std::optional nameOfSenderApp; }; class SMSTemplateSent : public gui::SwitchData diff --git a/module-apps/application-messages/windows/SMSTemplatesWindow.cpp b/module-apps/application-messages/windows/SMSTemplatesWindow.cpp index ed53a4c70991bba46277c8d4f7b07237c3ca3d6d..fec2469f9a6c29b515d9525c094bf5b3bcb0eb53 100644 --- a/module-apps/application-messages/windows/SMSTemplatesWindow.cpp +++ b/module-apps/application-messages/windows/SMSTemplatesWindow.cpp @@ -40,7 +40,6 @@ namespace gui setTitle(utils::translate("app_messages_templates")); navBar->setText(nav_bar::Side::Center, utils::translate(style::strings::common::use)); - navBar->setActive(nav_bar::Side::Center, false); navBar->setText(nav_bar::Side::Right, utils::translate(style::strings::common::back)); namespace style = style::messages::templates::list; @@ -116,8 +115,20 @@ namespace gui } if (auto switchData = dynamic_cast(data); switchData != nullptr) { + ignoreWindowsOfThisAppOnSwitchBack = data->ignoreCurrentWindowOnStack; + appNameToSwitchBack = switchData->getNameOfSenderApp(); smsSendTemplateRequestHandler(switchData); } } + bool SMSTemplatesWindow::onInput(const InputEvent &inputEvent) + { + if (!inputEvent.isShortRelease(KeyCode::KEY_RF) || !ignoreWindowsOfThisAppOnSwitchBack || + !appNameToSwitchBack.has_value()) { + return AppWindow::onInput(inputEvent); + } + + return app::manager::Controller::switchBack( + application, std::make_unique(appNameToSwitchBack.value(), nullptr, true)); + } } /* namespace gui */ diff --git a/module-apps/application-messages/windows/SMSTemplatesWindow.hpp b/module-apps/application-messages/windows/SMSTemplatesWindow.hpp index 6af30f6701c9a29dda65f57b8adef02dd0067d3b..c9f3bbede541ac78faa40cce658613854df8be09 100644 --- a/module-apps/application-messages/windows/SMSTemplatesWindow.hpp +++ b/module-apps/application-messages/windows/SMSTemplatesWindow.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -20,8 +20,10 @@ namespace gui class SMSTemplatesWindow : public AppWindow { std::shared_ptr smsTemplateModel; - gui::ListView *list = nullptr; - gui::Icon *emptyListIcon = nullptr; + gui::ListView *list = nullptr; + gui::Icon *emptyListIcon = nullptr; + bool ignoreWindowsOfThisAppOnSwitchBack = false; + std::optional appNameToSwitchBack = std::nullopt; void smsSendTemplateRequestHandler(const SMSSendTemplateRequest *const switchData); void smsTemplateRequestHandler(const SMSTemplateRequest *const switchData); @@ -32,6 +34,7 @@ namespace gui virtual ~SMSTemplatesWindow(); void onBeforeShow(ShowMode mode, SwitchData *data) override; + bool onInput(const InputEvent &inputEvent) override; void rebuild() override; void buildInterface() override; diff --git a/pure_changelog.md b/pure_changelog.md index 8d29624155b31468396cb785a922c3e05ec96ffa..6d6556599adabd85652200ec5852470177e44beb 100644 --- a/pure_changelog.md +++ b/pure_changelog.md @@ -90,6 +90,7 @@ * Fixed missing "No calls yet" text in call log * Fixed phonebook is not handling database notification about contacts action done by Center * Fixed contact deleted via Center cannot be edited by Phonebook app and saved again +* Fixed returning to call screen from message template ## [1.5.0 2022-12-20]