~aleteoryx/muditaos

491e4fb795ab85ccf26283aa194d830579df8210 — RobertPiet 5 years ago 3a78f8c
[EGD-3789] main network window
[EGD-3789] OptionSetting intoduced as a base to handle settings windows
[EGD-3789] added icons on/off/bt/right arrow
[EGD-3789] btn_ok icon used
A art/phone/common/png/btn_off.png => art/phone/common/png/btn_off.png +0 -0
A art/phone/common/png/btn_on.png => art/phone/common/png/btn_on.png +0 -0
A art/phone/common/png/right_label_arrow_border.png => art/phone/common/png/right_label_arrow_border.png +0 -0
A image/assets/images/bt.vpi => image/assets/images/bt.vpi +0 -0
A image/assets/images/btn_off.vpi => image/assets/images/btn_off.vpi +0 -0
A image/assets/images/btn_on.vpi => image/assets/images/btn_on.vpi +0 -0
A image/assets/images/right_label_arrow_border.vpi => image/assets/images/right_label_arrow_border.vpi +0 -0
M image/assets/lang/lang_en.json => image/assets/lang/lang_en.json +6 -0
@@ 253,6 253,12 @@
    "app_settings_language_polish": "Polish",
    "app_settings_language_german": "German",
    "app_settings_language_spanish": "Spanish",
    "app_settings_network_active_card": "Active card",
    "app_settings_network_operator_auto_select": "Operator auto-select",
    "app_settings_network_all_operators": "All Operators",
    "app_settings_network_import_contacts_from_sim_card": "Import contacts from SIM card",
    "app_settings_network_sim1": "Sim1",
    "app_settings_network_sim2": "Sim2",

    "app_phonebook_title_main": "Contacts",
    "app_phonebook_search_win_contacts": "Contacts",

A image/bt.vpi => image/bt.vpi +0 -0
A image/btn_off.vpi => image/btn_off.vpi +0 -0
A image/btn_on.vpi => image/btn_on.vpi +0 -0
A image/right_label_arrow_border.vpi => image/right_label_arrow_border.vpi +0 -0
M module-apps/CMakeLists.txt => module-apps/CMakeLists.txt +1 -0
@@ 21,6 21,7 @@ set( SOURCES
    "windows/Dialog.cpp" 
    "windows/NoEvents.cpp"
    "widgets/SearchBox.cpp"
    "windows/OptionSetting.cpp"
    )

add_library(${PROJECT_NAME} STATIC ${SOURCES} ${BOARD_SOURCES})

M module-apps/application-settings-new/ApplicationSettings.cpp => module-apps/application-settings-new/ApplicationSettings.cpp +2 -0
@@ 10,6 10,7 @@
#include "windows/DisplayLightWindow.hpp"
#include "windows/KeypadLightWindow.hpp"
#include "windows/AppsAndToolsWindow.hpp"
#include "windows/NetworkWindow.hpp"

#include "ApplicationSettings.hpp"



@@ 73,6 74,7 @@ namespace app
        attachWindow(new gui::FontSizeWindow(this));
        attachWindow(new gui::DisplayLightWindow(this));
        attachWindow(new gui::AppsAndToolsWindow(this));
        attachWindow(new gui::NetworkWindow(this));
    }

    void ApplicationSettingsNew::destroyUserInterface()

M module-apps/application-settings-new/ApplicationSettings.hpp => module-apps/application-settings-new/ApplicationSettings.hpp +4 -0
@@ 28,6 28,10 @@ namespace gui::window::name

    inline const std::string display_and_keypad = "DisplayAndKeypad";

    inline const std::string change_settings = "ChangeSettings";
    inline const std::string all_operators   = "AllOperators";
    inline const std::string import_contacts = "ImportContacts";

} // namespace gui::window::name

namespace app

M module-apps/application-settings-new/CMakeLists.txt => module-apps/application-settings-new/CMakeLists.txt +1 -0
@@ 25,6 25,7 @@ target_sources( ${PROJECT_NAME}
        windows/LockedScreenWindow.cpp
        windows/DisplayAndKeypadWindow.cpp
        windows/AppsAndToolsWindow.cpp
        windows/NetworkWindow.cpp

    PUBLIC
        ApplicationSettings.hpp

A module-apps/application-settings-new/windows/NetworkWindow.cpp => module-apps/application-settings-new/windows/NetworkWindow.cpp +86 -0
@@ 0,0 1,86 @@
#include "NetworkWindow.hpp"

#include <i18/i18.hpp>
#include "OptionsStyle.hpp"
#include "OptionSetting.hpp"
#include <application-settings-new/ApplicationSettings.hpp>

namespace gui
{
    NetworkWindow::NetworkWindow(app::Application *app) : OptionWindow(app, gui::window::name::network)
    {
        operatorsOn = false;
    }
    void NetworkWindow::onBeforeShow(ShowMode m, SwitchData *d)
    {
        rebuildOptList();
    }
    auto NetworkWindow::netOptList() -> std::list<gui::Option>
    {
        std::list<gui::Option> optList;
        auto sim    = Store::GSM::get()->selected;
        auto simStr = utils::translateI18("app_settings_network_sim1");
        if (sim == Store::GSM::SIM::SIM2) {
            simStr = utils::translateI18("app_settings_network_sim2");
        }
        optList.emplace_back(std::make_unique<gui::OptionSettings>(
            utils::translateI18("app_settings_network_active_card") + ":" + simStr,
            [=](gui::Item &item) {
                this->application->switchWindow(gui::window::name::change_settings, nullptr);
                return true;
            },
            [=](gui::Item &item) {
                auto nlb = dynamic_cast<gui::Label *>(&item);
                if (nullptr != nlb) {
                    if (item.focus) {
                        this->setBottomBarText(utils::localize.get(style::strings::common::Switch),
                                               BottomBar::Side::CENTER);
                    }
                    else {
                        this->setBottomBarText(utils::localize.get(style::strings::common::select),
                                               BottomBar::Side::CENTER);
                    }
                }
                return true;
            },
            this));
        optList.emplace_back(std::make_unique<gui::OptionSettings>(
            utils::translateI18("app_settings_network_operator_auto_select"),
            [=](gui::Item &item) {
                operatorsOn = !operatorsOn;
                rebuildOptList();
                return true;
            },
            nullptr,
            nullptr,
            operatorsOn ? RightIcon::On : RightIcon::Off));
        if (operatorsOn) {
            optList.emplace_back(std::make_unique<gui::OptionSettings>(
                utils::translateI18("app_settings_network_all_operators"),
                [=](gui::Item &item) {
                    this->application->switchWindow(gui::window::name::all_operators, nullptr);
                    return true;
                },
                nullptr,
                nullptr,
                RightIcon::Border));
        }
        optList.emplace_back(gui::Option{
            utils::translateI18("app_settings_network_import_contacts_from_sim_card"), [=](gui::Item &item) {
                this->application->switchWindow(gui::window::name::import_contacts, nullptr);
                return true;
            }});

        bottomBar->setText(BottomBar::Side::CENTER, utils::localize.get(style::strings::common::select));

        topBar->setActive(TopBar::Elements::SIGNAL, false);
        topBar->setActive(TopBar::Elements::BATTERY, false);
        topBar->setActive(TopBar::Elements::SIM, false);
        return optList;
    }
    void NetworkWindow::rebuildOptList()
    {
        clearOptions();
        addOptions(netOptList());
    }
} // namespace gui

A module-apps/application-settings-new/windows/NetworkWindow.hpp => module-apps/application-settings-new/windows/NetworkWindow.hpp +25 -0
@@ 0,0 1,25 @@
#pragma once

#include "OptionWindow.hpp"
#include "Application.hpp"

namespace gui
{

    namespace window
    {
        inline const std::string network_window = "Network";
    };

    class NetworkWindow : public OptionWindow
    {
      private:
        bool operatorsOn;
        auto netOptList() -> std::list<gui::Option>;
        void rebuildOptList();

      public:
        NetworkWindow(app::Application *app);
        void onBeforeShow(ShowMode m, SwitchData *d) override;
    };
} // namespace gui

A module-apps/windows/OptionSetting.cpp => module-apps/windows/OptionSetting.cpp +43 -0
@@ 0,0 1,43 @@
#include "OptionSetting.hpp"
#include "OptionsStyle.hpp"

namespace gui
{
    auto OptionSettings::build() const -> Item *
    {
        auto *label = new gui::Label(nullptr,
                                     style::window::default_left_margin,
                                     0,
                                     style::window_width - 2 * style::window::default_left_margin,
                                     style::window::label::big_h,
                                     text);
        style::window::decorateOption(label);
        label->activatedCallback = activatedCallback;
        std::string img;
        switch (rIcon) {
        case RightIcon::Enabled:
            img = "right_label_arrow";
            break;
        case RightIcon::Border:
            img = "right_label_arrow_border";
            break;
        case RightIcon::On:
            img = "btn_on";
            break;
        case RightIcon::Off:
            img = "btn_off";
            break;
        case RightIcon::Bt:
            img = "bt";
            break;
        default:
            break;
        }

        if (!img.empty()) {
            new gui::Image(label, style::option::arrow_position_x, style::option::arrow_positon_y, 0, 0, img);
        }
        label->focusChangedCallback = focusCb;
        return label;
    }
} // namespace gui

A module-apps/windows/OptionSetting.hpp => module-apps/windows/OptionSetting.hpp +37 -0
@@ 0,0 1,37 @@
#pragma once

#include "OptionWindow.hpp"
#include "Application.hpp"

namespace gui
{
    enum class RightIcon : uint8_t
    {
        Disabled,
        Enabled,
        Border,
        On,
        Off,
        Bt
    };

    class OptionSettings : public option::Base
    {
      private:
        UTF8 text;
        std::function<bool(Item &)> activatedCallback = nullptr;
        std::function<bool(Item &)> focusCb           = nullptr;
        AppWindow *app                                = nullptr;
        RightIcon rIcon                               = RightIcon::Disabled;

      public:
        OptionSettings(const UTF8 text,
                       std::function<bool(Item &)> cb,
                       std::function<bool(Item &)> cbFocus,
                       AppWindow *app,
                       RightIcon rIcon = RightIcon::Disabled)
            : text(text), activatedCallback(std::move(cb)), focusCb(std::move(cbFocus)), app(app), rIcon(rIcon)
        {}
        [[nodiscard]] auto build() const -> Item * override;
    };
} // namespace gui

M module-apps/windows/OptionWindow.cpp => module-apps/windows/OptionWindow.cpp +1 -6
@@ 7,12 7,7 @@
#include <cassert>
#include <functional>
#include <memory>

namespace style::option
{
    const gui::Position arrow_position_x = 408;
    const gui::Position arrow_positon_y  = 24;
} // namespace style::option
#include "OptionsStyle.hpp"

namespace gui
{

A module-apps/windows/OptionsStyle.hpp => module-apps/windows/OptionsStyle.hpp +7 -0
@@ 0,0 1,7 @@
#pragma once

namespace style::option
{
    const gui::Position arrow_position_x = 408;
    const gui::Position arrow_positon_y  = 24;
} // namespace style::option

M module-utils/i18/i18.hpp => module-utils/i18/i18.hpp +1 -0
@@ 165,6 165,7 @@ namespace utils

    // Global instance of i18 class
    extern i18 localize;
    auto translateI18 = [](const std::string &text) { return utils::localize.get(text); };
} // namespace utils

#endif // UNTITLED_I18_HPP