From 4b8735610b5e5f4116b906c9d9583b9eaee3d1a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zieli=C5=84ski?= Date: Tue, 21 Feb 2023 18:33:14 +0100 Subject: [PATCH] [MOS-357] Fixed regression described in MOS-916 Ditto --- .../windows/PhonebookNewContact.cpp | 11 +++++++++++ .../service-appmgr/messages/SwitchBackRequest.hpp | 10 ++++++---- .../service-appmgr/messages/SwitchBackRequest.cpp | 7 +++++-- .../service-appmgr/model/ApplicationManagerCommon.cpp | 6 ++++++ pure_changelog.md | 1 + 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/module-apps/application-phonebook/windows/PhonebookNewContact.cpp b/module-apps/application-phonebook/windows/PhonebookNewContact.cpp index 441ceb7428e3b85fffb4e88d13dd6555e3eac029..1981741920274a890f6185abea078d36523ba4aa 100644 --- a/module-apps/application-phonebook/windows/PhonebookNewContact.cpp +++ b/module-apps/application-phonebook/windows/PhonebookNewContact.cpp @@ -9,6 +9,7 @@ #include #include #include +#include namespace gui { @@ -119,6 +120,16 @@ namespace gui auto PhonebookNewContact::onInput(const InputEvent &inputEvent) -> bool { + auto backToCallLogIfCameFromThere = [this]() { + // MOS-357: conditionally (@see ApplicationManagerCommon::handleSwitchBack) return to call log + return app::manager::Controller::switchBack( + application, std::make_unique("ApplicationCallLog", nullptr, true)); + }; + + if (inputEvent.isShortRelease(gui::KeyCode::KEY_RF)) { + return backToCallLogIfCameFromThere(); + } + auto ret = AppWindow::onInput(inputEvent); setSaveButtonVisible(!newContactModel->emptyData()); diff --git a/module-services/service-appmgr/include/service-appmgr/messages/SwitchBackRequest.hpp b/module-services/service-appmgr/include/service-appmgr/messages/SwitchBackRequest.hpp index bb95b9225ff804d226738c85178fdba77aaf8676..577d6f8e6cb2b604d5e34f878534ce74652d8470 100644 --- a/module-services/service-appmgr/include/service-appmgr/messages/SwitchBackRequest.hpp +++ b/module-services/service-appmgr/include/service-appmgr/messages/SwitchBackRequest.hpp @@ -11,12 +11,14 @@ namespace app::manager { class SwitchBackRequest : public BaseMessage { + std::unique_ptr data; + public: - SwitchBackRequest(const ApplicationName &name, std::unique_ptr data = nullptr); + SwitchBackRequest(const ApplicationName &name, + std::unique_ptr data = nullptr, + bool dontSwitchBackWhenRequestedAppNameDoesntMatch = false); [[nodiscard]] auto getData() noexcept -> std::unique_ptr &; - - private: - std::unique_ptr data; + bool dontSwitchBackWhenRequestedAppNameDoesntMatch; }; } // namespace app::manager diff --git a/module-services/service-appmgr/messages/SwitchBackRequest.cpp b/module-services/service-appmgr/messages/SwitchBackRequest.cpp index 1fcf1ef67e67bf106914e0f60ece8f6aeab311ca..9ad81ab2a6ff2b693715aa1862f2c53e79095065 100644 --- a/module-services/service-appmgr/messages/SwitchBackRequest.cpp +++ b/module-services/service-appmgr/messages/SwitchBackRequest.cpp @@ -5,8 +5,11 @@ namespace app::manager { - SwitchBackRequest::SwitchBackRequest(const ApplicationName &name, std::unique_ptr data) - : BaseMessage(MessageType::APMSwitchPrevApp, name), data{std::move(data)} + SwitchBackRequest::SwitchBackRequest(const ApplicationName &name, + std::unique_ptr data, + bool dontSwitchBackWhenRequestedAppNameDoesntMatch) + : BaseMessage(MessageType::APMSwitchPrevApp, name), data{std::move(data)}, + dontSwitchBackWhenRequestedAppNameDoesntMatch{dontSwitchBackWhenRequestedAppNameDoesntMatch} {} [[nodiscard]] auto SwitchBackRequest::getData() noexcept -> std::unique_ptr & diff --git a/module-services/service-appmgr/model/ApplicationManagerCommon.cpp b/module-services/service-appmgr/model/ApplicationManagerCommon.cpp index f21cf68efe56ce318575c67332c4661476ff2ebe..1ec0d2519f7536435b71b6adb636975944a58e8f 100644 --- a/module-services/service-appmgr/model/ApplicationManagerCommon.cpp +++ b/module-services/service-appmgr/model/ApplicationManagerCommon.cpp @@ -590,6 +590,12 @@ namespace app::manager return false; } + if (msg->dontSwitchBackWhenRequestedAppNameDoesntMatch && previousApp->name() != msg->getSenderName()) { + LOG_INFO("Requested to switch back only if to [%s] - discarding as doesn't match", + previousApp->name().c_str()); + return false; + } + auto currentlyFocusedApp = getFocusedApplication(); if (currentlyFocusedApp == nullptr) { LOG_INFO("No focused application at the moment. Starting previous application..."); diff --git a/pure_changelog.md b/pure_changelog.md index 0a091fea70c226bca79b4356f3540109d1c94187..e6f7121dfdbf31ccff787eb07d5b203d2fccd98a 100644 --- a/pure_changelog.md +++ b/pure_changelog.md @@ -85,6 +85,7 @@ * Fixed missing translation for words "show" and "replace" * Fixed music playback disablement after currently played audio file gets deleted * Fixed incorrectly displayed Swedish translations in Onboarding +* Fixed going back to wrong window after confirming or cancelling creation of new contact from call log ## [1.5.0 2022-12-20]