~aleteoryx/muditaos

5ca8e9e5cf96ed95f7e62b2d42194dcc50ec8ad8 — Lefucjusz 2 years ago a2ab8f4
[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.
M module-apps/application-call/windows/CallWindow.cpp => module-apps/application-call/windows/CallWindow.cpp +3 -3
@@ 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<SMSSendTemplateRequest>(presenter.getPhoneNumber().getView(), preventAutoLock);
            auto msg = std::make_unique<SMSSendTemplateRequest>(presenter.getPhoneNumber().getView(),
                                                                SMSSendTemplateRequest::AutolockBehavior::Prevent);
            msg->ignoreCurrentWindowOnStack = true;
            msg->nameOfSenderApplication    = application->GetName();
            return app::manager::Controller::sendAction(application,

M module-apps/application-messages/ApplicationMessages.cpp => module-apps/application-messages/ApplicationMessages.cpp +2 -2
@@ 157,11 157,11 @@ namespace app
            gui::name::window::thread_sms_search,
            [](ApplicationCommon *app, const std::string &name) { return std::make_unique<gui::SMSSearch>(app); });
        windowsFactory.attach(gui::name::window::sms_templates, [](ApplicationCommon *app, const std::string &name) {
            return std::make_unique<gui::SMSTemplatesWindow>(app);
            return std::make_unique<gui::SMSTemplatesWindow>(app, name);
        });
        windowsFactory.attach(gui::name::window::call_sms_templates,
                              [](ApplicationCommon *app, const std::string &name) {
                                  return std::make_unique<gui::SMSTemplatesWindow>(app);
                                  return std::make_unique<gui::SMSTemplatesWindow>(app, name);
                              });
        windowsFactory.attach(gui::name::window::search_results, [](ApplicationCommon *app, const std::string &name) {
            return std::make_unique<gui::SearchResults>(app);

M module-apps/application-messages/data/SMSdata.hpp => module-apps/application-messages/data/SMSdata.hpp +12 -5
@@ 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

M module-apps/application-messages/windows/SMSTemplatesWindow.cpp => module-apps/application-messages/windows/SMSTemplatesWindow.cpp +4 -6
@@ 91,8 91,7 @@ namespace gui
        auto requestingWindow  = switchData->requestingWindow;
        app->templatesCallback = [=](std::shared_ptr<SMSTemplateRecord> templ) {
            LOG_DEBUG("SMS template id = %" PRIu32 "chosen", templ->ID);
            std::unique_ptr<gui::SwitchData> data =
                std::make_unique<SMSTextData>(templ->text, SMSTextData::Concatenate::True);
            auto data = std::make_unique<SMSTextData>(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<app::ApplicationMessages *>(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<SMSTemplateRequest *>(data)) {
            smsTemplateRequestHandler(switchData);
        }

M pure_changelog.md => pure_changelog.md +1 -0
@@ 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