~aleteoryx/muditaos

5da31450b5930cf68bca6f1767299b329ff71d79 — Pawel Olejniczak 5 years ago 40bf381
[EGD-4739] Add empty APN settings window

APN settings window without APN list.
Icon widget now accepts rich text.
M changelog.md => changelog.md +2 -0
@@ 7,12 7,14 @@
* VoLTE ON/OFF switch in Settings Network window
* Add PLL2 clock switching
* Support for asynchronous callbacks on application side.
* APN settings window - empty

### Changed

* Input keyboard language files parser from KBD to JSON.
* Input language files are now loaded based on files in "profiles" folder.
* Minimum CPU frequency is now 132 MHz
* Icon widget now accepts rich text

### Fixed


M image/assets/lang/English.json => image/assets/lang/English.json +6 -4
@@ 81,7 81,7 @@
  "app_alarm_clock_repeat_everyday" : "Everyday",
  "app_alarm_clock_repeat_week_days" : "Week Days",
  "app_alarm_clock_repeat_custom" : "Custom",
  "app_alarm_clock_no_alarms_information" : "No alarms yet.\nPress left arrow to add new.",
  "app_alarm_clock_no_alarms_information" : "<text align='center' color='9'>No alarms yet.<p>Press <b>left arrow</b> to add new.</p></text>",
  "app_alarm_clock_options_title": "Options",
  "app_alarm_clock_options_edit": "Edit",
  "app_alarm_clock_options_delete": "Delete",


@@ 154,7 154,7 @@
  "app_notes_edited": "Edited",
  "app_notes_delete_note": "Delete",
  "app_notes_note_delete_confirmation": "Do you really want to delete this note?",
  "app_notes_no_notes": "There are no notes yet.\nPress Left arrow to add new.",
  "app_notes_no_notes": "<text align='center' color='9'>No notes yet.<p>Press <b>left arrow</b> to add new.</p></text>",
  "app_notes_search_no_results": "No notes found.",

  "app_calllog_title_main": "Calls",


@@ 263,7 263,7 @@
  "app_call_offline": "You're offline.\n\nTo make a call\n switch to the Connected mode.",
  "app_messages_title_main": "Messages",
  "app_messages_new_message": "New Message",
  "app_messages_no_messages": "There are no messages yet.\nPress Left arrow to add new.",
  "app_messages_no_messages": "<text align='center' color='9'>No messages yet.<p>Press <b>left arrow</b> to add new.</p></text>",
  "app_messages_thread_delete_confirmation": "Delete this conversation?",
  "app_messages_message_delete_confirmation": "<text align='center'><p>Do you really want to <text weight='bold'>delete</text></p>this message?</text>",
  "app_messages_thread_no_result": "There are no results",


@@ 342,7 342,9 @@
  "app_settings_network_sim1": "Sim1",
  "app_settings_network_sim2": "Sim2",
  "app_settings_network_sim_none": "No Sim",
  "app_settings_network_voice_over_lte" :"VoLTE (experimental)",
  "app_settings_network_voice_over_lte" : "VoLTE (experimental)",
  "app_settings_network_apn_settings" : "APN settings",
  "app_settings_network_apn_settings_no_apns" : "<text align='center' color='9'>No APNs yet.<p>Press <b>left arrow</b> to add new.</p></text>",
  "app_settings_toggle_on": "ON",
  "app_settings_toggle_off": "OFF",
  "app_settings_security_lock_screen_passcode": "Lock screen passcode",

M module-apps/application-settings-new/ApplicationSettings.cpp => module-apps/application-settings-new/ApplicationSettings.cpp +4 -0
@@ 5,6 5,7 @@

#include "windows/AddDeviceWindow.hpp"
#include "windows/AllDevicesWindow.hpp"
#include "windows/APNSettingsWindow.hpp"
#include "windows/BluetoothWindow.hpp"
#include "windows/SettingsMainWindow.hpp"
#include "windows/DisplayAndKeypadWindow.hpp"


@@ 170,6 171,9 @@ namespace app
            return std::make_unique<gui::NetworkWindow>(
                app, static_cast<ApplicationSettingsNew *>(app), static_cast<ApplicationSettingsNew *>(app));
        });
        windowsFactory.attach(gui::window::name::apn_settings, [](Application *app, const std::string &name) {
            return std::make_unique<gui::APNSettingsWindow>(app);
        });
        windowsFactory.attach(gui::window::name::messages, [](Application *app, const std::string &name) {
            return std::make_unique<gui::MessagesWindow>(app);
        });

M module-apps/application-settings-new/ApplicationSettings.hpp => module-apps/application-settings-new/ApplicationSettings.hpp +1 -0
@@ 15,6 15,7 @@ namespace gui::window::name
    inline constexpr auto add_device  = "AddDevice";

    inline constexpr auto network        = "Network";
    inline constexpr auto apn_settings   = "APNSettings";
    inline constexpr auto phone_modes    = "PhoneModes";
    inline constexpr auto apps_and_tools = "AppsAndTools";
    inline constexpr auto security       = "Security";

M module-apps/application-settings-new/CMakeLists.txt => module-apps/application-settings-new/CMakeLists.txt +1 -0
@@ 19,6 19,7 @@ target_sources( ${PROJECT_NAME}
        windows/SettingsMainWindow.cpp
        windows/AddDeviceWindow.cpp
        windows/AllDevicesWindow.cpp
        windows/APNSettingsWindow.cpp
        windows/BaseSettingsWindow.cpp
        windows/BluetoothWindow.cpp
        windows/FontSizeWindow.cpp

A module-apps/application-settings-new/windows/APNSettingsWindow.cpp => module-apps/application-settings-new/windows/APNSettingsWindow.cpp +61 -0
@@ 0,0 1,61 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "APNSettingsWindow.hpp"
#include "application-settings-new/ApplicationSettings.hpp"
#include "application-settings-new/widgets/SettingsStyle.hpp"
#include "OptionSetting.hpp"

#include <InputEvent.hpp>

namespace gui
{

    APNSettingsWindow::APNSettingsWindow(app::Application *app) : OptionWindow(app, gui::window::name::apn_settings)
    {
        buildInterface();
    }

    auto APNSettingsWindow::onInput(const InputEvent &inputEvent) -> bool
    {

        if (inputEvent.isShortPress()) {
            if (inputEvent.is(KeyCode::KEY_LEFT)) {
                // switch to new/edit APN window
            }
        }

        return AppWindow::onInput(inputEvent);
    }
    void APNSettingsWindow::buildInterface()
    {
        setTitle(utils::localize.get("app_settings_network_apn_settings"));

        topBar->setActive(TopBar::Elements::SIGNAL, false);
        topBar->setActive(TopBar::Elements::BATTERY, false);
        topBar->setActive(TopBar::Elements::SIM, false);

        leftArrowImage = new gui::Image(this,
                                        style::settings::window::leftArrowImage::x,
                                        style::settings::window::leftArrowImage::y,
                                        style::settings::window::leftArrowImage::w,
                                        style::settings::window::leftArrowImage::h,
                                        "arrow_left");
        crossImage     = new gui::Image(this,
                                    style::settings::window::crossImage::x,
                                    style::settings::window::crossImage::y,
                                    style::settings::window::crossImage::w,
                                    style::settings::window::crossImage::h,
                                    "cross");
        emptyListIcon  = new Icon(this,
                                 0,
                                 style::header::height,
                                 style::window_width,
                                 style::window_height - style::header::height - style::footer::height,
                                 "phonebook_empty_grey_circle_W_G",
                                 utils::localize.get("app_settings_network_apn_settings_no_apns"));

        bottomBar->setActive(gui::BottomBar::Side::CENTER, false);
    }

} // namespace gui

A module-apps/application-settings-new/windows/APNSettingsWindow.hpp => module-apps/application-settings-new/windows/APNSettingsWindow.hpp +24 -0
@@ 0,0 1,24 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include "OptionWindow.hpp"
#include <Icon.hpp>

namespace gui
{
    class APNSettingsWindow : public OptionWindow
    {
      public:
        APNSettingsWindow(app::Application *app);

      private:
        void buildInterface() override;
        auto onInput(const InputEvent &inputEvent) -> bool override;

        Image *leftArrowImage = nullptr;
        Image *crossImage     = nullptr;
        Icon *emptyListIcon   = nullptr;
    };
}; // namespace gui

M module-apps/application-settings-new/windows/NetworkWindow.cpp => module-apps/application-settings-new/windows/NetworkWindow.cpp +13 -2
@@ 14,8 14,7 @@ namespace gui
                                 app::settingsInterface::SimParams *simParams,
                                 app::settingsInterface::OperatorsSettings *operatorsSettings)
        : OptionWindow(app, gui::window::name::network), simParams(simParams), operatorsSettings(operatorsSettings)
    {
    }
    {}
    void NetworkWindow::onBeforeShow(ShowMode m, SwitchData *d)
    {
        rebuild();


@@ 78,6 77,7 @@ namespace gui
            nullptr,
            nullptr,
            operatorsOn ? RightItem::On : RightItem::Off));

        if (!operatorsOn) {
            optList.emplace_back(std::make_unique<gui::OptionSettings>(
                utils::translateI18("app_settings_network_all_operators"),


@@ 110,6 110,17 @@ namespace gui
            nullptr,
            voLteOn ? RightItem::On : RightItem::Off));

        optList.emplace_back(std::make_unique<gui::OptionSettings>(
            utils::translateI18("app_settings_network_apn_settings"),
            [=](gui::Item &item) {
                this->application->switchWindow(gui::window::name::apn_settings, nullptr);
                return true;
            },
            nullptr,
            nullptr,
            RightItem::ArrowWhite,
            true));

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

        topBar->setActive(TopBar::Elements::SIGNAL, false);

M module-gui/gui/widgets/Icon.cpp => module-gui/gui/widgets/Icon.cpp +5 -10
@@ 18,11 18,10 @@ namespace style
    } // namespace img
    namespace text
    {
        constexpr uint32_t x  = 40;
        constexpr uint32_t y  = 247;
        constexpr uint32_t w  = 400;
        constexpr uint32_t h  = 66;
        constexpr Color color = {7, 0};
        constexpr uint32_t x = 40;
        constexpr uint32_t y = 247;
        constexpr uint32_t w = 400;
        constexpr uint32_t h = 80;
    } // namespace text
} // namespace style



@@ 41,13 40,9 @@ Icon::Icon(Item *parent,

    new Image(this, style::img::x, style::img::y, imageName);
    text = new Text(this, style::text::x, style::text::y, style::text::w, style::text::h);
    text->setRichText(str);
    text->setTextType(TextType::MultiLine);
    text->setEditMode(EditMode::Browse);
    text->setEdges(RectangleEdge::None);
    text->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));

    auto format = TextFormat(Font(27).raw(), Color(7, 0));
    for (auto &el : textToTextBlocks(str, format)) {
        text->addText(el);
    }
}