~aleteoryx/muditaos

4cefb5f114ea60de5e6ae30c404cef065f7d4b1d — Marcin Zieliński 3 years ago 6e901d0
[MOS-640] Change windows flow in SIM settings

Made SIM cards settings windows switching more robust
M module-apps/application-settings/ApplicationSettings.cpp => module-apps/application-settings/ApplicationSettings.cpp +35 -0
@@ 84,6 84,7 @@
#include <service-appmgr/model/ApplicationManagerCommon.hpp>
#include <apps-common/messages/DialogMetadataMessage.hpp>
#include <apps-common/windows/Dialog.hpp>
#include <apps-common/popups/lock-popups/SimInfoWindow.hpp>

#include <i18n/i18n.hpp>
#include <service-bluetooth/messages/SyncDevices.hpp>


@@ 570,6 571,40 @@ namespace app
        return selectedSimNumber;
    }

    void ApplicationSettings::returnToPreviousWindow()
    {
        using namespace gui::popup::window;
        using namespace gui::window::name;

        auto previousWindowName = getPreviousWindow();
        if (!previousWindowName.has_value()) {
            ApplicationCommon::returnToPreviousWindow();
            return;
        }

        bool previousWindowBackingToSimCards =
            (previousWindowName == sim_pin_settings || previousWindowName == import_contacts ||
             previousWindowName == sim_unlock_window);
        auto currentWindowName = getCurrentWindow()->getName();

        // despite "import_contacts" has auto-lock prevented, it's included here in previousWindowBackingToSimCards for
        // simplicity
        if (currentWindowName == phone_lock_window && previousWindowBackingToSimCards) {
            switchWindow(sim_cards);
            return;
        }

        if (currentWindowName == sim_info_window) {
            auto simInfoWindowAction = static_cast<gui::SimInfoWindow *>(getCurrentWindow())->getAction();
            if (simInfoWindowAction == locks::SimInputTypeAction::Error && previousWindowBackingToSimCards) {
                switchWindow(sim_cards);
                return;
            }
        }

        ApplicationCommon::returnToPreviousWindow();
    }

    void ApplicationSettings::setSim(Store::GSM::SIM sim)
    {
        auto arg = (sim == Store::GSM::SIM::SIM2) ? cellular::api::SimSlot::SIM2 : cellular::api::SimSlot::SIM1;

M module-apps/application-settings/include/application-settings/ApplicationSettings.hpp => module-apps/application-settings/include/application-settings/ApplicationSettings.hpp +2 -0
@@ 144,6 144,8 @@ namespace app

        void createUserInterface() override;
        void destroyUserInterface() override;
        void returnToPreviousWindow() override;

        void setSim(Store::GSM::SIM sim) override;
        void updateSim() override;
        Store::GSM::SIM getSim() override;

M module-apps/apps-common/ApplicationCommon.cpp => module-apps/apps-common/ApplicationCommon.cpp +11 -1
@@ 921,7 921,7 @@ namespace app
            return;
        }
        if (windowsStack().pop(newWindow)) {
            LOG_INFO("Get back to window!");
            LOG_INFO("Requested window %s is previous one - get back to it", newWindow.c_str());
            return;
        }
        LOG_INFO("Create window for stack: %s", newWindow.c_str());


@@ 956,6 956,16 @@ namespace app
        return false;
    }

    bool ApplicationCommon::isPreviousWindow(const std::string &windowName) const noexcept
    {
        if (const auto &previousWindowName = getPreviousWindow(); previousWindowName != std::nullopt) {
            return previousWindowName == windowName;
        }

        LOG_WARN("no previous window");
        return false;
    }

    gui::AppWindow *ApplicationCommon::getWindow(const std::string &name)
    {
        return windowsStack().get(name);

M module-apps/apps-common/ApplicationCommon.hpp => module-apps/apps-common/ApplicationCommon.hpp +2 -3
@@ 266,9 266,7 @@ namespace app
            switchWindow(windowName, gui::ShowMode::GUI_SHOW_INIT, std::move(data));
        };

        /// Method used to go back to desired window by using the index difference on stack value
        /// @param ignoredWindowsNumber: defines how many windows will be skipped while going back on stack
        [[deprecated]] void returnToPreviousWindow();
        [[deprecated]] virtual void returnToPreviousWindow();

        /// Find and pop window from stack by window name
        void popWindow(const std::string &window);


@@ 387,6 385,7 @@ namespace app
        gui::AppWindow *getCurrentWindow();
        /// @ingrup AppWindowStack
        bool isCurrentWindow(const std::string &windowName) const noexcept;
        bool isPreviousWindow(const std::string &windowName) const noexcept;

        /// @ingrup AppWindowStack
        gui::AppWindow *getWindow(const std::string &name);

M module-apps/apps-common/popups/lock-popups/SimInfoWindow.cpp => module-apps/apps-common/popups/lock-popups/SimInfoWindow.cpp +4 -2
@@ 6,6 6,8 @@
#include <locks/data/LockData.hpp>
#include <i18n/i18n.hpp>

#include <application-settings/ApplicationSettings.hpp>

using namespace gui;

SimInfoWindow::SimInfoWindow(app::ApplicationCommon *app, const std::string &name) : WindowWithTimer(app, name)


@@ 31,8 33,8 @@ void SimInfoWindow::onBeforeShow(ShowMode mode, SwitchData *data)
    WindowWithTimer::onBeforeShow(mode, data);

    if (auto infoData = dynamic_cast<locks::SimLockData *>(data)) {

        switch (infoData->getSimInputTypeAction()) {
        action_ = infoData->getSimInputTypeAction();
        switch (action_.value()) {
        case locks::SimInputTypeAction::UnlockWithPuk:
        case locks::SimInputTypeAction::ChangePin:
            setTitle(utils::translate("sim_change_pin"));

M module-apps/apps-common/popups/lock-popups/SimInfoWindow.hpp => module-apps/apps-common/popups/lock-popups/SimInfoWindow.hpp +9 -0
@@ 6,6 6,7 @@
#include <popups/WindowWithTimer.hpp>
#include <Text.hpp>
#include <gui/widgets/Icon.hpp>
#include <locks/data/LockData.hpp>

namespace gui
{


@@ 19,5 20,13 @@ namespace gui
        void buildInterface() override;
        void onBeforeShow(ShowMode mode, SwitchData *data) override;
        status_bar::Configuration configureStatusBar(status_bar::Configuration appConfiguration) override;

        locks::SimInputTypeAction getAction() const
        {
            return action_.value();
        }

      private:
        std::optional<locks::SimInputTypeAction> action_;
    };
} /* namespace gui */

M module-apps/apps-common/popups/lock-popups/SimLockInputWindow.cpp => module-apps/apps-common/popups/lock-popups/SimLockInputWindow.cpp +9 -1
@@ 7,6 7,8 @@
#include <locks/widgets/SimLockBox.hpp>
#include <locks/widgets/LockHash.hpp>

#include <application-settings/ApplicationSettings.hpp>

#include <service-appmgr/Controller.hpp>
#include <popups/data/PopupRequestParams.hpp>



@@ 88,7 90,13 @@ namespace gui
                lock->consumeState();
            }
            application->getSimLockSubject().resetSimLockState();
            application->returnToPreviousWindow();
            if (auto *settingsApp = dynamic_cast<app::ApplicationSettings *>(application);
                settingsApp && settingsApp->isPreviousWindow(gui::window::name::sim_pin_settings)) {
                settingsApp->switchWindow(gui::window::name::sim_cards);
            }
            else {
                application->returnToPreviousWindow();
            }
            return true;
        }
        else if (inputEvent.is(KeyCode::KEY_PND)) {

M pure_changelog.md => pure_changelog.md +1 -0
@@ 6,6 6,7 @@
* Added Polish translation to a calendar title
* Changed USB logging
* Separated system volume from Bluetooth device volume for A2DP
* Made windows flow in SIM cards settings more robust

### Fixed
* Fixed receiving an empty SMS message