~aleteoryx/muditaos

9194323b085708ec7c69b8259792c1403d714987 — Przemyslaw Brudny 4 years ago 21a7855
[EGD-7120] Remove old settings application

Moved valuable assets to new settings.
Removed old settings.
49 files changed, 132 insertions(+), 2132 deletions(-)

M image/assets/lang/Deutsch.json
M image/assets/lang/English.json
M image/assets/lang/Espanol.json
M image/assets/lang/Francais.json
M image/assets/lang/Polski.json
M image/assets/lang/Svenska.json
M module-apps/CMakeLists.txt
M module-apps/application-desktop/windows/MenuWindow.cpp
M module-apps/application-settings-new/ApplicationSettings.cpp
M module-apps/application-settings-new/ApplicationSettings.hpp
M module-apps/application-settings-new/CMakeLists.txt
R module-apps/{application-settings/models => application-settings-new/models/advanced}/ColorTestModel.cpp
R module-apps/{application-settings/models => application-settings-new/models/advanced}/ColorTestModel.hpp
R module-apps/{application-settings/widgets => application-settings-new/widgets/advanced}/ColorTestListItem.cpp
R module-apps/{application-settings/widgets => application-settings-new/widgets/advanced}/ColorTestListItem.hpp
R module-apps/{application-settings/widgets => application-settings-new/widgets/advanced}/ColorTestListStyle.hpp
R module-apps/{application-settings/widgets => application-settings-new/widgets/advanced}/ColorTestListView.cpp
R module-apps/{application-settings/widgets => application-settings-new/widgets/advanced}/ColorTestListView.hpp
M module-apps/application-settings-new/windows/SettingsMainWindow.cpp
A module-apps/application-settings-new/windows/advanced/AdvancedOptionsWindow.cpp
R module-apps/{application-settings/windows/SettingsMainWindow => application-settings-new/windows/advanced/AdvancedOptionsWindow}.hpp
R module-apps/{application-settings/windows => application-settings-new/windows/advanced}/ColorTestWindow.cpp
R module-apps/{application-settings/windows => application-settings-new/windows/advanced}/ColorTestWindow.hpp
R module-apps/{application-settings/windows => application-settings-new/windows/advanced}/EinkModeWindow.cpp
R module-apps/{application-settings/windows => application-settings-new/windows/advanced}/EinkModeWindow.hpp
R module-apps/{application-settings/windows/Info => application-settings-new/windows/advanced/InformationWindow}.cpp
R module-apps/{application-settings/windows/Info => application-settings-new/windows/advanced/InformationWindow}.hpp
R module-apps/{application-settings/windows => application-settings-new/windows/advanced}/UITestWindow.cpp
R module-apps/{application-settings/windows => application-settings-new/windows/advanced}/UITestWindow.hpp
D module-apps/application-settings/ApplicationSettings.cpp
D module-apps/application-settings/ApplicationSettings.hpp
D module-apps/application-settings/CMakeLists.txt
D module-apps/application-settings/windows/BtScanWindow.cpp
D module-apps/application-settings/windows/BtScanWindow.hpp
D module-apps/application-settings/windows/BtWindow.cpp
D module-apps/application-settings/windows/BtWindow.hpp
D module-apps/application-settings/windows/CellularPassthroughWindow.cpp
D module-apps/application-settings/windows/CellularPassthroughWindow.hpp
D module-apps/application-settings/windows/Fota.cpp
D module-apps/application-settings/windows/Fota.hpp
D module-apps/application-settings/windows/FotaWindow.cpp
D module-apps/application-settings/windows/FotaWindow.hpp
D module-apps/application-settings/windows/LanguageWindow.cpp
D module-apps/application-settings/windows/LanguageWindow.hpp
D module-apps/application-settings/windows/SettingsMainWindow.cpp
D module-apps/application-settings/windows/TestMessageWindow.cpp
D module-apps/application-settings/windows/TestMessageWindow.hpp
M products/BellHybrid/BellHybridMain.cpp
M products/PurePhone/PurePhoneMain.cpp
M image/assets/lang/Deutsch.json => image/assets/lang/Deutsch.json +3 -4
@@ 260,8 260,7 @@
  "app_desktop_menu_meditation": "MEDITATION",
  "app_desktop_menu_music": "MUSIK",
  "app_desktop_menu_tools": "WERKZEUGE",
  "app_desktop_menu_settings_new": "EINSTELLUNGEN",
  "app_desktop_menu_settings": "Fortgeschritten",
  "app_desktop_menu_settings": "EINSTELLUNGEN",
  "app_desktop_menu_title": "Menü",
  "app_desktop_tools_title": "Werkzeuge",
  "app_desktop_tools_notes": "NOTIZEN",


@@ 324,8 323,8 @@
  "app_onboarding_configuration_successful": "<text>Ihr Mudita Pure<br></br>ist jetzt einsatzbereit.</text>",
  "app_onboarding_no_configuration": "<text>Ihr Mudita Pure wurde noch nicht<br></br>konfiguriert. Sie können es in den<br></br>Einstellungen einrichten.</text>",
  "app_onboarding_update_info": "<text>Die aktuelle Version von MuditaOS ist Version <br></br> <token>$VERSION</token>. Updates mit neuen <br></br> Funktionen und Fehlerbehebungen erfolgen häufig. <br></br>Um Ihr Telefon zu aktualisieren, besuchen Sie bitte <br></br>: </text><text font='gt_pressura' weight='bold' size='27'>www.mudita.com/updateos</text><br></br><text>und folgen Sie den Anweisungen.</text>",
  "app_settings_title_main": "Fortgeschritten",
  "app_settings_title_main_new": "Einstellungen",
  "app_settings_title_main": "Einstellungen",
  "app_settings_advanced": "Fortgeschritten",
  "app_settings_bt": "Bluetooth",
  "app_settings_bluetooth_add_device": "Gerät hinzufügen",
  "app_settings_bluetooth_all_devices": "Alle Geräte",

M image/assets/lang/English.json => image/assets/lang/English.json +3 -4
@@ 230,8 230,7 @@
  "app_desktop_menu_meditation": "MEDITATION",
  "app_desktop_menu_music": "MUSIC",
  "app_desktop_menu_tools": "TOOLS",
  "app_desktop_menu_settings_new": "SETTINGS",
  "app_desktop_menu_settings": "Advanced",
  "app_desktop_menu_settings": "SETTINGS",
  "app_desktop_menu_title": "Menu",
  "app_desktop_tools_title": "Tools",
  "app_desktop_tools_notes": "NOTES",


@@ 294,8 293,8 @@
  "app_onboarding_configuration_successful": "<text>Your Mudita Pure<br></br>is ready to use.</text>",
  "app_onboarding_no_configuration": "<text>Your Mudita Pure has not been<br></br>configured. You can go to<br></br>Settings to set it up.</text>",
  "app_onboarding_update_info": "<text>The current version of MuditaOS is <br></br> <token>$VERSION</token>. Updates with new <br></br> features and fixes appear often. <br></br>To update your Phone please <br></br> visit: </text><text font='gt_pressura' weight='bold' size='27'>www.mudita.com/updateos</text><br></br><text>and follow the instructions.</text>",
  "app_settings_title_main": "Advanced",
  "app_settings_title_main_new": "Settings",
  "app_settings_title_main": "Settings",
  "app_settings_advanced" : "Advanced",
  "app_settings_bt": "Bluetooth",
  "app_settings_bluetooth_add_device": "Add device",
  "app_settings_bluetooth_all_devices": "All devices",

M image/assets/lang/Espanol.json => image/assets/lang/Espanol.json +3 -4
@@ 260,8 260,7 @@
  "app_desktop_menu_meditation": "MEDITACIÓN",
  "app_desktop_menu_music": "MÚSICA",
  "app_desktop_menu_tools": "HERRAMIENTAS",
  "app_desktop_menu_settings_new": "AJUSTES",
  "app_desktop_menu_settings": "Avanzados",
  "app_desktop_menu_settings": "AJUSTES",
  "app_desktop_menu_title": "Menú",
  "app_desktop_tools_title": "Herramientas",
  "app_desktop_tools_notes": "NOTAS",


@@ 324,8 323,8 @@
  "app_onboarding_configuration_successful": "<text>Tu Mudita Pure<br></br>ya está listo.</text>",
  "app_onboarding_no_configuration": "<text>Tu Mudita Pure no está<br></br>configurado. Ve a<br></br>Ajustes para configurarlo.</text>",
  "app_onboarding_update_info": "<text>La versión actual del SO de Mudita es la <br></br> <token>$VERSION</token>. Las frecuentes actualizaciones <br></br> incluyen nuevas funciones y correcciones. <br></br>Para actualizar tu teléfono, <br></br>visita: </text><text font='gt_pressura' weight='bold' size='27'>www.mudita.com/updateos</text><br></br><text>y sigue las instrucciones.</text>",
  "app_settings_title_main": "Avanzados",
  "app_settings_title_main_new": "Ajustes",
  "app_settings_title_main": "Ajustes",
  "app_settings_advanced" : "Avanzados",
  "app_settings_bt": "Bluetooth",
  "app_settings_bluetooth_add_device": "Añadir dispositivo",
  "app_settings_bluetooth_all_devices": "Añadir dispositivos",

M image/assets/lang/Francais.json => image/assets/lang/Francais.json +0 -1
@@ 79,7 79,6 @@
  "app_desktop_menu_meditation": "MEDITATION",
  "app_desktop_menu_music": "MUSIC",
  "app_desktop_menu_tools": "TOOLS",
  "app_desktop_menu_settings": "SETTINGS",
  "app_desktop_menu_title": "Main Menu",
  "app_desktop_tools_title": "Tools",
  "app_desktop_tools_notes": "NOTES",

M image/assets/lang/Polski.json => image/assets/lang/Polski.json +3 -4
@@ 260,8 260,7 @@
  "app_desktop_menu_meditation": "MEDYTACJA",
  "app_desktop_menu_music": "MUZYKA",
  "app_desktop_menu_tools": "NARZĘDZIA",
  "app_desktop_menu_settings_new": "USTAWIENIA",
  "app_desktop_menu_settings": "Zaawansowane",
  "app_desktop_menu_settings": "USTAWIENIA",
  "app_desktop_menu_title": "Menu",
  "app_desktop_tools_title": "Narzędzia",
  "app_desktop_tools_notes": "NOTATKI",


@@ 324,8 323,8 @@
  "app_onboarding_configuration_successful": "<text>Twój telefon Mudita Pure<br></br>jest gotowy do użycia.</text>",
  "app_onboarding_no_configuration": "<text>Twój telefon Mudita Pure nie został<br></br>skonfigurowany. Możesz przejść do<br></br>Ustawień, by go skonfigurować.</text>",
  "app_onboarding_update_info": "<text>Aktualna wersja MuditaOS to <br></br> <token>$VERSION</token>. Często się pojawiają aktualizacje z nowymi <br></br> funkcjami i poprawkami. <br></br>Aby zaktualizować telefon, <br></br> odwiedź stronę: </text><text font='gt_pressura' weight='bold' size='27'>www.mudita.com/updateos</text><br></br><text>i postępuj zgodnie ze wskazówkami.</text>",
  "app_settings_title_main": "Zaawansowane",
  "app_settings_title_main_new": "Ustawienia",
  "app_settings_title_main": "Ustawienia",
  "app_settings_advanced" : "Zaawansowane",
  "app_settings_bt": "Bluetooth",
  "app_settings_bluetooth_add_device": "Dodaj urządzenie",
  "app_settings_bluetooth_all_devices": "Wszystkie urządzenia",

M image/assets/lang/Svenska.json => image/assets/lang/Svenska.json +3 -4
@@ 211,8 211,7 @@
  "app_desktop_menu_meditation": "MEDITATION",
  "app_desktop_menu_music": "MUSIK",
  "app_desktop_menu_tools": "VERKTYG",
  "app_desktop_menu_settings_new": "NYA INSTÄLLNINGAR",
  "app_desktop_menu_settings": "INSTÄLLNINGAR",
  "app_desktop_menu_settings": "NYA INSTÄLLNINGAR",
  "app_desktop_menu_title": "Meny",
  "app_desktop_tools_title": "Verktyg",
  "app_desktop_tools_notes": "ANTECKNINGAR",


@@ 258,8 257,8 @@
  "app_messages_thread_not_sent": "Ej skickat: ",
  "app_messages_thread_you": "Du: ",
  "app_onboarding_start_configuration": "<text font='gt_pressura' weight='light' size='46'><p>Välkommen!</p></text><br></br><text font='gt_pressura' weight='regular' size='27'>Vi börjar med att välja inställningar för din Mudita Pure.</text>",
  "app_settings_title_main": "Inställningar",
  "app_settings_title_main_new": "Nya Inställningar",
  "app_settings_title_main": "Nya Inställningar",
  "app_settings_advanced" : "Inställningar",
  "app_settings_bt": "Bluetooth",
  "app_settings_bluetooth_add_device": "Lägg till enhet",
  "app_settings_bluetooth_all_devices": "Alla enheter",

M module-apps/CMakeLists.txt => module-apps/CMakeLists.txt +0 -1
@@ 20,7 20,6 @@ set(APPLICATIONS
    clock
    calendar
    desktop
    settings
    settings-new
    call
    notes

M module-apps/application-desktop/windows/MenuWindow.cpp => module-apps/application-desktop/windows/MenuWindow.cpp +1 -1
@@ 234,7 234,7 @@ namespace gui
                                      app::manager::actions::Launch,
                                      std::make_unique<app::ApplicationLaunchData>("ApplicationMeditation"));
                              }},
                new gui::Tile{"menu_settings_W_G", "app_desktop_menu_settings_new", [=](gui::Item &item) {
                new gui::Tile{"menu_settings_W_G", "app_desktop_menu_settings", [=](gui::Item &item) {
                                  return app::manager::Controller::sendAction(
                                      application,
                                      app::manager::actions::Launch,

M module-apps/application-settings-new/ApplicationSettings.cpp => module-apps/application-settings-new/ApplicationSettings.cpp +23 -2
@@ 3,12 3,17 @@

#include "ApplicationSettings.hpp"

#include <application-settings-new/windows/SettingsMainWindow.hpp>
#include <application-settings-new/windows/advanced/AdvancedOptionsWindow.hpp>
#include <application-settings-new/windows/advanced/InformationWindow.hpp>
#include <application-settings-new/windows/advanced/UITestWindow.hpp>
#include <application-settings-new/windows/advanced/EinkModeWindow.hpp>
#include <application-settings-new/windows/advanced/ColorTestWindow.hpp>
#include <application-settings-new/windows/AddDeviceWindow.hpp>
#include <application-settings-new/windows/AllDevicesWindow.hpp>
#include <application-settings-new/windows/ApnSettingsWindow.hpp>
#include <application-settings-new/windows/ApnOptionsWindow.hpp>
#include <application-settings-new/windows/BluetoothWindow.hpp>
#include <application-settings-new/windows/SettingsMainWindow.hpp>
#include <application-settings-new/windows/DisplayAndKeypadWindow.hpp>
#include <application-settings-new/windows/InputLanguageWindow.hpp>
#include <application-settings-new/windows/LockedScreenWindow.hpp>


@@ 330,7 335,23 @@ namespace app
    {
        windowsFactory.attach(gui::name::window::main_window, [](Application *app, const std::string &name) {
            return std::make_unique<gui::OptionWindow>(
                app, utils::translate("app_settings_title_main_new"), mainWindowOptionsNew(app));
                app, utils::translate("app_settings_title_main"), mainWindowOptionsNew(app));
        });
        windowsFactory.attach(gui::window::name::advanced, [](Application *app, const std::string &name) {
            return std::make_unique<gui::OptionWindow>(
                app, utils::translate("app_settings_advanced"), advancedOptions(app));
        });
        windowsFactory.attach(gui::window::name::information, [](Application *app, const std::string &name) {
            return std::make_unique<gui::InformationWindow>(app);
        });
        windowsFactory.attach(gui::window::name::ui_test, [](Application *app, const std::string &name) {
            return std::make_unique<gui::UiTestWindow>(app);
        });
        windowsFactory.attach(gui::window::name::eink_mode, [](Application *app, const std::string &name) {
            return std::make_unique<gui::EinkModeWindow>(app);
        });
        windowsFactory.attach(gui::window::name::color_test_window, [](Application *app, const std::string &name) {
            return std::make_unique<gui::ColorTestWindow>(app);
        });
        windowsFactory.attach(gui::window::name::bluetooth, [](Application *app, const std::string &name) {
            return std::make_unique<gui::BluetoothWindow>(app);

M module-apps/application-settings-new/ApplicationSettings.hpp => module-apps/application-settings-new/ApplicationSettings.hpp +6 -0
@@ 12,6 12,12 @@

namespace gui::window::name
{
    inline constexpr auto advanced          = "Advanced";
    inline constexpr auto information       = "Information";
    inline constexpr auto ui_test           = "UI Test";
    inline constexpr auto eink_mode         = "Change Eink Mode";
    inline constexpr auto color_test_window = "Color Test";

    inline constexpr auto bluetooth   = "Bluetooth";
    inline constexpr auto all_devices = "AllDevices";
    inline constexpr auto phone_name  = "PhoneName";

M module-apps/application-settings-new/CMakeLists.txt => module-apps/application-settings-new/CMakeLists.txt +17 -0
@@ 15,6 15,7 @@ target_sources( ${PROJECT_NAME}

    PRIVATE
        ApplicationSettings.cpp
        models/advanced/ColorTestModel.cpp
        models/ApnSettingsModel.cpp
        models/BluetoothSettingsModel.cpp
        models/NewApnModel.cpp


@@ 28,6 29,8 @@ target_sources( ${PROJECT_NAME}
        models/SoundsModel.cpp
        presenter/SARInfoWindowPresenter.cpp
        presenter/TechnicalWindowPresenter.cpp
        widgets/advanced/ColorTestListItem.cpp
        widgets/advanced/ColorTestListView.cpp
        widgets/QuoteWidget.cpp
        widgets/CategoryWidget.cpp
        widgets/ApnInputWidget.cpp


@@ 35,6 38,11 @@ target_sources( ${PROJECT_NAME}
        widgets/SettingsTimeItem.cpp
        widgets/SettingsSoundItem.cpp
        windows/SettingsMainWindow.cpp
        windows/advanced/AdvancedOptionsWindow.cpp
        windows/advanced/InformationWindow.cpp
        windows/advanced/UITestWindow.cpp
        windows/advanced/EinkModeWindow.cpp
        windows/advanced/ColorTestWindow.cpp
        windows/AddDeviceWindow.cpp
        windows/AllDevicesWindow.cpp
        windows/ApnSettingsWindow.cpp


@@ 86,10 94,19 @@ target_sources( ${PROJECT_NAME}

    PUBLIC
        ApplicationSettings.hpp
        models/advanced/ColorTestModel.hpp
        widgets/advanced/ColorTestListItem.hpp
        widgets/advanced/ColorTestListItem.hpp
        widgets/advanced/ColorTestListStyle.hpp
        widgets/ApnInputWidget.hpp
        widgets/CategoryWidget.hpp
        windows/NewApnWindow.hpp
        windows/SettingsMainWindow.hpp
        windows/advanced/AdvancedOptionsWindow.hpp
        windows/advanced/InformationWindow.hpp
        windows/advanced/UITestWindow.hpp
        windows/advanced/EinkModeWindow.hpp
        windows/advanced/ColorTestWindow.hpp
        windows/BaseSettingsWindow.hpp
        windows/FontSizeWindow.hpp
        windows/InputLanguageWindow.hpp

R module-apps/application-settings/models/ColorTestModel.cpp => module-apps/application-settings-new/models/advanced/ColorTestModel.cpp +1 -1
@@ 1,8 1,8 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "application-settings/widgets/ColorTestListStyle.hpp"
#include "ColorTestModel.hpp"
#include <application-settings-new/widgets/advanced/ColorTestListStyle.hpp>

namespace gui
{

R module-apps/application-settings/models/ColorTestModel.hpp => module-apps/application-settings-new/models/advanced/ColorTestModel.hpp +4 -3
@@ 3,9 3,10 @@

#pragma once

#include "Application.hpp"
#include "InternalModel.hpp"
#include "module-apps/application-settings/widgets/ColorTestListItem.hpp"
#include "application-settings-new/widgets/advanced/ColorTestListItem.hpp"

#include <Application.hpp>
#include <InternalModel.hpp>
#include <ListView.hpp>
#include <ListItemProvider.hpp>


R module-apps/application-settings/widgets/ColorTestListItem.cpp => module-apps/application-settings-new/widgets/advanced/ColorTestListItem.cpp +0 -0
R module-apps/application-settings/widgets/ColorTestListItem.hpp => module-apps/application-settings-new/widgets/advanced/ColorTestListItem.hpp +1 -4
@@ 3,15 3,12 @@

#pragma once

#include <memory>

#include <Application.hpp>
#include <BoxLayout.hpp>
#include <Label.hpp>
#include <ListItem.hpp>
#include <InputEvent.hpp>

#include "Application.hpp"

namespace gui
{
    class ColorTestListItem : public ListItem

R module-apps/application-settings/widgets/ColorTestListStyle.hpp => module-apps/application-settings-new/widgets/advanced/ColorTestListStyle.hpp +0 -0
R module-apps/application-settings/widgets/ColorTestListView.cpp => module-apps/application-settings-new/widgets/advanced/ColorTestListView.cpp +1 -1
@@ 2,7 2,7 @@
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "ColorTestListView.hpp"
#include "InputEvent.hpp"
#include <InputEvent.hpp>

namespace gui
{

R module-apps/application-settings/widgets/ColorTestListView.hpp => module-apps/application-settings-new/widgets/advanced/ColorTestListView.hpp +2 -2
@@ 3,8 3,8 @@

#pragma once

#include "ListView.hpp"
#include "Application.hpp"
#include <Application.hpp>
#include <ListView.hpp>

namespace gui
{

M module-apps/application-settings-new/windows/SettingsMainWindow.cpp => module-apps/application-settings-new/windows/SettingsMainWindow.cpp +1 -17
@@ 25,24 25,8 @@ std::list<gui::Option> mainWindowOptionsNew(app::Application *app)
                                   },
                                   gui::option::Arrow::Enabled});
    };
    auto addApp = [&l, &app](UTF8 name, const std::string &window = "") {
        l.emplace_back(gui::Option{name,
                                   [=](gui::Item &item) {
                                       if (window.empty()) {
                                           return false;
                                       }
                                       LOG_INFO("switching to %s page", window.c_str());
                                       app::manager::Controller::sendAction(
                                           app,
                                           app::manager::actions::Launch,
                                           std::make_unique<app::ApplicationLaunchData>("ApplicationSettings"));
                                       app->switchWindow(window, nullptr);
                                       return true;
                                   },
                                   gui::option::Arrow::Enabled});
    };

    addApp(i18("app_desktop_menu_settings"), "Settings");
    addMenu(i18("app_settings_advanced"), gui::window::name::advanced);
    addMenu(i18("app_settings_bt"), gui::window::name::bluetooth);
    addMenu(i18("app_settings_net"), gui::window::name::network);
    addMenu(i18("app_settings_disp_key"), gui::window::name::display_and_keypad);

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

#include "AdvancedOptionsWindow.hpp"

#include <application-settings-new/ApplicationSettings.hpp>

std::list<gui::Option> advancedOptions(app::Application *app)
{
    std::list<gui::Option> l;

    auto addMenu = [&l, &app](UTF8 name, const std::string &window = "") {
        l.emplace_back(gui::Option{name,
                                   [=](gui::Item &item) {
                                       if (window.empty()) {
                                           return false;
                                       }
                                       LOG_INFO("switching to %s page", window.c_str());
                                       app->switchWindow(window, nullptr);
                                       return true;
                                   },
                                   gui::option::Arrow::Enabled});
    };

    addMenu("Information", gui::window::name::information);
    addMenu("UI Test", gui::window::name::ui_test);
    addMenu("Eink Mode", gui::window::name::eink_mode);
    addMenu("Color Test", gui::window::name::color_test_window);

    return l;
}

R module-apps/application-settings/windows/SettingsMainWindow.hpp => module-apps/application-settings-new/windows/advanced/AdvancedOptionsWindow.hpp +2 -2
@@ 1,4 1,4 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once


@@ 6,4 6,4 @@
#include "OptionWindow.hpp"
#include "Application.hpp"

std::list<gui::Option> mainWindowOptions(app::Application *app);
std::list<gui::Option> advancedOptions(app::Application *app);

R module-apps/application-settings/windows/ColorTestWindow.cpp => module-apps/application-settings-new/windows/advanced/ColorTestWindow.cpp +4 -7
@@ 1,16 1,13 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <memory>
#include "ColorTestWindow.hpp"

#include <application-settings-new/ApplicationSettings.hpp>
#include <application-settings-new/widgets/advanced/ColorTestListStyle.hpp>

#include <service-appmgr/Controller.hpp>
#include <service-gui/Common.hpp>
#include <service-gui/messages/ChangeColorScheme.hpp>
#include <Style.hpp>

#include "application-settings/ApplicationSettings.hpp"
#include "application-settings/widgets/ColorTestListStyle.hpp"
#include "ColorTestWindow.hpp"

namespace gui
{

R module-apps/application-settings/windows/ColorTestWindow.hpp => module-apps/application-settings-new/windows/advanced/ColorTestWindow.hpp +2 -14
@@ 3,25 3,13 @@

#pragma once

#include <memory>
#include <functional>

#include "module-apps/application-settings/models/ColorTestModel.hpp"
#include "AppWindow.hpp"
#include "application-settings/widgets/ColorTestListView.hpp"

#include <gui/widgets/Label.hpp>
#include <gui/widgets/Image.hpp>
#include <gui/widgets/Window.hpp>
#include <gui/widgets/BottomBar.hpp>
#include "application-settings-new/models/advanced/ColorTestModel.hpp"
#include "application-settings-new/widgets/advanced/ColorTestListView.hpp"

namespace gui
{
    namespace window::name
    {
        inline constexpr auto color_test_window = "ColorTestWindow";
    } // namespace window::name

    class ColorTestWindow : public AppWindow
    {
      private:

R module-apps/application-settings/windows/EinkModeWindow.cpp => module-apps/application-settings-new/windows/advanced/EinkModeWindow.cpp +5 -16
@@ 1,26 1,15 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <memory>
#include <functional>

#include "Common.hpp"
#include "service-eink/Common.hpp"
#include "messages/EinkModeMessage.hpp"
#include "service-appmgr/Controller.hpp"
#include "../ApplicationSettings.hpp"

#include <i18n/i18n.hpp>

#include "Label.hpp"
#include "Margins.hpp"
#include "EinkModeWindow.hpp"
#include <Style.hpp>

#include <application-settings-new/ApplicationSettings.hpp>
#include <messages/EinkModeMessage.hpp>

namespace gui
{

    EinkModeWindow::EinkModeWindow(app::Application *app) : AppWindow(app, window::name::eink)
    EinkModeWindow::EinkModeWindow(app::Application *app) : AppWindow(app, window::name::eink_mode)
    {
        AppWindow::buildInterface();
        bottomBar->setActive(BottomBar::Side::CENTER, true);


@@ 28,7 17,7 @@ namespace gui
        bottomBar->setText(BottomBar::Side::CENTER, utils::translate(style::strings::common::select));
        bottomBar->setText(BottomBar::Side::RIGHT, utils::translate(style::strings::common::back));

        setTitle("Change eink mode");
        setTitle(window::name::eink_mode);
        auto label               = new Label(this, 100, 200, 300, 50, "Change mode on click");
        label->activatedCallback = [this](Item &) -> bool {
            static auto last_mode = service::eink::EinkModeMessage::Mode::Normal;

R module-apps/application-settings/windows/EinkModeWindow.hpp => module-apps/application-settings-new/windows/advanced/EinkModeWindow.hpp +1 -12
@@ 1,22 1,11 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// 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 <functional>

#include "AppWindow.hpp"
#include "gui/widgets/Label.hpp"
#include "gui/widgets/Image.hpp"
#include "gui/widgets/Window.hpp"
#include "gui/widgets/BottomBar.hpp"

namespace gui
{
    namespace window::name
    {
        inline constexpr auto eink = "EinkModeWindow";
    } // namespace window::name

    class EinkModeWindow : public AppWindow
    {
      public:

R module-apps/application-settings/windows/Info.cpp => module-apps/application-settings-new/windows/advanced/InformationWindow.cpp +8 -31
@@ 1,43 1,29 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "Info.hpp"
#include "InformationWindow.hpp"

#include <application-settings/ApplicationSettings.hpp>
#include <application-settings-new/ApplicationSettings.hpp>
#include <service-cellular/CellularServiceAPI.hpp>

#include <source/version.hpp>
#include <log.hpp>

#include <gui/widgets/BoxLayout.hpp>
#include <gui/widgets/Label.hpp>
#include <gui/widgets/Margins.hpp>
#include <gui/widgets/Style.hpp>

#include <i18n/i18n.hpp>
#include <boot/bootconfig.hpp>

namespace gui
{

    Info::Info(app::Application *app) : AppWindow(app, gui::window::hw_info)
    {
        buildInterface();
    }

    void Info::rebuild()
    InformationWindow::InformationWindow(app::Application *app) : AppWindow(app, gui::window::name::information)
    {
        destroyInterface();
        buildInterface();
    }

    void Info::buildInterface()
    void InformationWindow::buildInterface()
    {
        AppWindow::buildInterface();
        bottomBar->setActive(BottomBar::Side::RIGHT, true);
        bottomBar->setText(BottomBar::Side::RIGHT, utils::translate(style::strings::common::back));

        setTitle("Info");
        setTitle(gui::window::name::information);

        box = new gui::VBox(this, 0, style::window::default_vertical_pos, style::window_width, style::window_height);
        box->setPenWidth(style::window::default_border_no_focus_w);


@@ 55,18 41,9 @@ namespace gui
            box, "Modem Frimware:", (firmwareVersion.empty() ? utils::translate("not available") : firmwareVersion));
    }

    void Info::destroyInterface()
    {
        erase();
        invalidate();
    }

    void Info::invalidate() noexcept
    {
        box = nullptr;
    }

    void Info::addAlignedLabelWithValue(BoxLayout *layout, const std::string &labelText, const std::string &valueText)
    void InformationWindow::addAlignedLabelWithValue(BoxLayout *layout,
                                                     const std::string &labelText,
                                                     const std::string &valueText)
    {
        auto lineBox = new gui::VBox(layout, 0, 0, style::window_width, style::window::label::small_h * 2);
        lineBox->setEdges(RectangleEdge::Bottom);

R module-apps/application-settings/windows/Info.hpp => module-apps/application-settings-new/windows/advanced/InformationWindow.hpp +3 -22
@@ 1,42 1,23 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// 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 <functional>
#include <string>

#include "AppWindow.hpp"
#include "gui/widgets/Image.hpp"
#include "gui/widgets/Label.hpp"
#include "gui/widgets/Window.hpp"
#include <BoxLayout.hpp>
#include <memory>

namespace gui
{

    namespace window
    {
        inline constexpr auto hw_info = "hw_info";
    };

    class Info : public AppWindow
    class InformationWindow : public AppWindow
    {
      protected:
        VBox *box = nullptr;

      public:
        Info(app::Application *app);

        // virtual methods
        void rebuild() override;
        explicit InformationWindow(app::Application *app);
        void buildInterface() override;
        void destroyInterface() override;

      private:
        void addAlignedLabelWithValue(BoxLayout *layout, const std::string &labelText, const std::string &valueText);

        void invalidate() noexcept;
    };
} // namespace gui

R module-apps/application-settings/windows/UITestWindow.cpp => module-apps/application-settings-new/windows/advanced/UITestWindow.cpp +2 -34
@@ 2,17 2,8 @@
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "UITestWindow.hpp"
#include "../ApplicationSettings.hpp"
#include "Label.hpp"
#include "Margins.hpp"
#include <i18n/i18n.hpp>
#include <log.hpp>
#include "messages/AppMessage.hpp"
#include <service-appmgr/model/ApplicationManager.hpp>
#include <GridLayout.hpp>
#include <Style.hpp>
#include <functional>
#include <memory>

#include <application-settings-new/ApplicationSettings.hpp>
#include <Font.hpp>

namespace gui


@@ 68,27 59,4 @@ namespace gui
        text->setPenFocusWidth(0);
        setFocusItem(text);
    }

    void UiTestWindow::rebuild()
    {
        LOG_INFO("Only if I have to!");
    }

    void UiTestWindow::buildInterface()
    {}

    void UiTestWindow::destroyInterface()
    {
        erase();
        invalidate();
    }

    void UiTestWindow::invalidate() noexcept
    {
        text = nullptr;
    }

    void UiTestWindow::onBeforeShow(ShowMode mode, SwitchData *data)
    {}

} // namespace gui

R module-apps/application-settings/windows/UITestWindow.hpp => module-apps/application-settings-new/windows/advanced/UITestWindow.hpp +2 -18
@@ 1,16 1,9 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// 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 <functional>
#include <string>

#include "AppWindow.hpp"
#include "gui/widgets/Image.hpp"
#include "gui/widgets/Label.hpp"
#include "gui/widgets/Window.hpp"
#include <memory>
#include <Text.hpp>

namespace gui


@@ 21,15 14,6 @@ namespace gui
        gui::Text *text = nullptr;

      public:
        UiTestWindow(app::Application *app);

        void onBeforeShow(ShowMode mode, SwitchData *data) override;
        void rebuild() override;
        void buildInterface() override;
        void destroyInterface() override;
        void set_navigation();

      private:
        void invalidate() noexcept;
        explicit UiTestWindow(app::Application *app);
    };
} // namespace gui

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

#include "Application.hpp"

#include "MessageType.hpp"
#include "application-settings/windows/EinkModeWindow.hpp"
#include "windows/BtScanWindow.hpp"
#include "windows/BtWindow.hpp"
#include "windows/FotaWindow.hpp"
#include "windows/Info.hpp"
#include "windows/LanguageWindow.hpp"
#include "windows/SettingsMainWindow.hpp"
#include "windows/ColorTestWindow.hpp"

#include "windows/UITestWindow.hpp"

#include "windows/TestMessageWindow.hpp"

#include "ApplicationSettings.hpp"

#include "windows/SettingsMainWindow.hpp"
#include "windows/CellularPassthroughWindow.hpp"

#include <i18n/i18n.hpp>
#include <service-evtmgr/EventManagerServiceAPI.hpp>
#include <service-bluetooth/BluetoothMessage.hpp>
#include <service-bluetooth/messages/ResponseVisibleDevices.hpp>
#include <service-db/Settings.hpp>
#include <module-services/service-db/agents/settings/SystemSettings.hpp>

namespace gui::window::name
{
    inline constexpr auto date_time = "DateTime";
}

namespace app
{
    ApplicationSettings::ApplicationSettings(std::string name,
                                             std::string parent,
                                             sys::phone_modes::PhoneMode mode,
                                             StartInBackground startInBackground)
        : Application(name, parent, mode, startInBackground)
    {}

    ApplicationSettings::~ApplicationSettings()
    {}

    // Invoked upon receiving data message
    sys::MessagePointer ApplicationSettings::DataReceivedHandler(sys::DataMessage *msgl,
                                                                 sys::ResponseMessage * /*resp*/)
    {

        auto retMsg = Application::DataReceivedHandler(msgl);
        // if message was handled by application's template there is no need to process further.
        if (reinterpret_cast<sys::ResponseMessage *>(retMsg.get())->retCode == sys::ReturnCodes::Success) {
            return retMsg;
        }
        if (auto btmsg = dynamic_cast<message::bluetooth::ResponseVisibleDevices *>(msgl); btmsg != nullptr) {
            LOG_INFO("received BT Scan message!");
            auto data = std::make_unique<gui::DeviceData>(btmsg->getDevices());
            windowsFactory.build(this, gui::name::window::name_btscan);
            switchWindow(gui::name::window::name_btscan, gui::ShowMode::GUI_SHOW_INIT, std::move(data));

            render(gui::RefreshModes::GUI_REFRESH_FAST);
        }
        if (auto btmsg = dynamic_cast<BluetoothPairResultMessage *>(msgl); btmsg != nullptr) {
            if (btmsg->isSucceed()) {
                LOG_INFO("Paired successfully");
            }
            else {
                LOG_ERROR("Pairing error!");
            }
        }
        // this variable defines whether message was processed.
        bool handled = true;

        if (handled)
            return std::make_shared<sys::ResponseMessage>();
        else
            return std::make_shared<sys::ResponseMessage>(sys::ReturnCodes::Unresolved);
    }

    // Invoked during initialization
    sys::ReturnCodes ApplicationSettings::InitHandler()
    {
        board = EventManagerServiceAPI::GetBoard(this);

        auto ret = Application::InitHandler();
        if (ret != sys::ReturnCodes::Success)
            return ret;

        createUserInterface();

        return ret;
    }

    sys::ReturnCodes ApplicationSettings::DeinitHandler()
    {
        return sys::ReturnCodes::Success;
    }

    void ApplicationSettings::createUserInterface()
    {
        windowsFactory.attach(gui::name::window::main_window, [](Application *app, const std::string &name) {
            return std::make_unique<gui::OptionWindow>(
                app, utils::translate("app_settings_title_main"), mainWindowOptions(app));
        });
        windowsFactory.attach("Languages", [](Application *app, const std::string &name) {
            return std::make_unique<gui::LanguageWindow>(app);
        });
        windowsFactory.attach("Bluetooth", [](Application *app, const std::string &name) {
            return std::make_unique<gui::BtWindow>(app);
        });
        windowsFactory.attach(gui::name::window::name_btscan, [](Application *app, const std::string &name) {
            return std::make_unique<gui::BtScanWindow>(app);
        });
        windowsFactory.attach("TEST_UI", [](Application *app, const std::string &name) {
            return std::make_unique<gui::UiTestWindow>(app);
        });
        windowsFactory.attach(gui::window::hw_info, [](Application *app, const std::string &name) {
            return std::make_unique<gui::Info>(app);
        });
        windowsFactory.attach(gui::window::name::fota_window, [](Application *app, const std::string &name) {
            return std::make_unique<gui::FotaWindow>(app);
        });
        windowsFactory.attach(gui::window::name::eink, [](Application *app, const std::string &name) {
            return std::make_unique<gui::EinkModeWindow>(app);
        });
        windowsFactory.attach(gui::window::name::color_test_window, [](Application *app, const std::string &name) {
            return std::make_unique<gui::ColorTestWindow>(app);
        });

        if (board == bsp::Board::T4) {
            windowsFactory.attach(gui::window::cellular_passthrough::window_name,
                                  [](Application *app, const std::string &name) {
                                      return std::make_unique<gui::CellularPassthroughWindow>(app);
                                  });
        }

        attachPopups(
            {gui::popup::ID::Volume, gui::popup::ID::Tethering, gui::popup::ID::PhoneModes, gui::popup::ID::PhoneLock});
    }

    void ApplicationSettings::destroyUserInterface()
    {}

    void ApplicationSettings::timeDateChanged(std::string value)
    {
        auto newTimeDateFormat = utils::getNumericValue<bool>(value);
        if (newTimeDateFormat != europeanDateTimeFormat) {
            europeanDateTimeFormat = newTimeDateFormat;
            auto currentWindow     = getCurrentWindow();
            if (gui::window::name::date_time == currentWindow->getName()) {
                currentWindow->rebuild();
            }
        }
    }

} /* namespace app */

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

#ifndef MODULE_APPS_APPLICATION_SETTINGS_APPLICATIONSETTINGS_HPP_
#define MODULE_APPS_APPLICATION_SETTINGS_APPLICATIONSETTINGS_HPP_

#include "Application.hpp"
#include "bsp/common.hpp"
#include <EventStore.hpp>

namespace app
{
    inline constexpr auto name_settings  = "ApplicationSettings";

    class ApplicationSettings : public app::Application
    {
      public:
        ApplicationSettings(std::string name                    = name_settings,
                            std::string parent                  = {},
                            sys::phone_modes::PhoneMode mode    = sys::phone_modes::PhoneMode::Connected,
                            StartInBackground startInBackground = {false});
        virtual ~ApplicationSettings();
        sys::MessagePointer DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) override;
        sys::ReturnCodes InitHandler() override;
        sys::ReturnCodes DeinitHandler() override;

        sys::ReturnCodes SwitchPowerModeHandler(const sys::ServicePowerMode mode) override final
        {
            return sys::ReturnCodes::Success;
        }

        void createUserInterface() override;
        void destroyUserInterface() override;
        bsp::Board board = bsp::Board::none;
        void timeDateChanged(std::string value);

      private:
        bool europeanDateTimeFormat = false; // true europe format, false american format
    };

    template <> struct ManifestTraits<ApplicationSettings>
    {
        static auto GetManifest() -> manager::ApplicationManifest
        {
            return {{manager::actions::Launch, manager::actions::PhoneModeChanged}};
        }
    };
} /* namespace app */

#endif /* MODULE_APPS_APPLICATION_SETTINGS_APPLICATIONSETTINGS_HPP_ */

D module-apps/application-settings/CMakeLists.txt => module-apps/application-settings/CMakeLists.txt +0 -48
@@ 1,48 0,0 @@

include_directories( ${CMAKE_PROJECT_NAME}

    PUBLIC
        "${CMAKE_CURRENT_LIST_DIR}"
)

include_directories( ${PROJECT_NAME}

    PUBLIC
        ${CMAKE_CURRENT_LIST_DIR}
)

target_sources( ${PROJECT_NAME}

    PRIVATE
        ApplicationSettings.cpp
        windows/SettingsMainWindow.cpp
        windows/LanguageWindow.cpp
        windows/BtWindow.cpp
        windows/BtScanWindow.cpp
        windows/UITestWindow.cpp
        windows/Info.cpp
        windows/CellularPassthroughWindow.cpp
        windows/FotaWindow.cpp
        windows/Fota.cpp
        windows/EinkModeWindow.cpp
        windows/ColorTestWindow.cpp
        widgets/ColorTestListItem.cpp
        widgets/ColorTestListView.cpp
        models/ColorTestModel.cpp

    PUBLIC
        ApplicationSettings.hpp
        windows/SettingsMainWindow.hpp
        windows/LanguageWindow.hpp
)

add_dependencies(${PROJECT_NAME} version)

target_link_libraries(${PROJECT_NAME}
    PRIVATE
        service-bluetooth
        service-evtmgr
        service-fota
    PUBLIC
        eventstore
)

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

#include <functional>
#include <memory>

#include <service-appmgr/model/ApplicationManager.hpp>

#include "../ApplicationSettings.hpp"

#include <i18n/i18n.hpp>

#include "BtScanWindow.hpp"
#include "Label.hpp"
#include "Margins.hpp"

#include <Style.hpp>

extern "C"
{
#include <module-bluetooth/lib/btstack/src/btstack_util.h>
}

namespace gui
{

    BtScanWindow::BtScanWindow(app::Application *app, std::vector<Devicei> devices)
        : AppWindow(app, name::window::name_btscan), devices(devices)
    {
        buildInterface();
    }

    void BtScanWindow::rebuild()
    {
        destroyInterface();
        buildInterface();
    }

    void add_box_label2(VBox *layout, UTF8 name, std::function<bool(Item &)> foo)
    {
        auto el = new gui::Label(nullptr, 0, 0, layout->getWidth(), style::window::label::default_h);
        style::window::decorateOption(el);
        el->setText(name);
        el->activatedCallback = std::move(foo);
        layout->addWidget(el);
    }

    sys::ReturnCodes message_bt2(app::Application *app, BluetoothMessage::Request req)
    {
        std::shared_ptr<BluetoothMessage> msg = std::make_shared<BluetoothMessage>(req);
        auto ret                              = app->bus.sendUnicast(msg, "ServiceBluetooth");
        if (!ret) {
            LOG_ERROR("err: %d", static_cast<int>(ret));
        }
        return ret ? sys::ReturnCodes::Success : sys::ReturnCodes::Failure;
    }

    void BtScanWindow::buildInterface()
    {
        AppWindow::buildInterface();
        bottomBar->setActive(BottomBar::Side::CENTER, true);
        bottomBar->setActive(BottomBar::Side::RIGHT, true);
        bottomBar->setText(BottomBar::Side::CENTER, utils::translate(style::strings::common::select));
        bottomBar->setText(BottomBar::Side::RIGHT, utils::translate(style::strings::common::back));

        setTitle(utils::translate("BT_scan_results"));

        box = new gui::VBox(
            this, 0, style::window::default_vertical_pos, style::window_width, 7 * style::window::label::default_h);

        for (auto device : devices) {
            add_box_label2(box, device.name, [=](Item &) {
                LOG_DEBUG("Device added to list");

                std::shared_ptr<BluetoothAddrMessage> msg =
                    std::make_shared<BluetoothAddrMessage>(bd_addr_to_str(device.address));
                application->bus.sendUnicastSync(msg, "ServiceBluetooth", 5000);

                message_bt2(application, BluetoothMessage::Request::StopScan);
                // message_bt2(application, BluetoothMessage::Request::Start);

                return true;
            });
        }
        for (auto &el : box->children) {
            el->visible = true;
        }
        box->setPenWidth(style::window::default_border_no_focus_w);
        box->setVisible(true);
        setFocusItem(box);
        application->render(gui::RefreshModes::GUI_REFRESH_FAST);
    }

    bool BtScanWindow::onInput(const InputEvent &inputEvent)
    {
        return AppWindow::onInput(inputEvent);
    }

    void BtScanWindow::destroyInterface()
    {
        erase();
        invalidate();
    }

    void BtScanWindow::invalidate() noexcept
    {
        box = nullptr;
    }

    void BtScanWindow::onBeforeShow(ShowMode mode, SwitchData *data)
    {
        auto newData = static_cast<DeviceData *>(data);
        devices      = newData->getDevices();
        rebuild();
    }

} // namespace gui

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

#pragma once

#include <functional>
#include <string>

#include "AppWindow.hpp"
#include "gui/widgets/Image.hpp"
#include "gui/widgets/Label.hpp"
#include "gui/widgets/Window.hpp"
#include <BoxLayout.hpp>
#include <memory>
#include <service-bluetooth/BluetoothMessage.hpp>

namespace gui
{
    namespace name::window
    {
        inline constexpr auto name_btscan = "BT_SCAN";
    }

    class BtScanWindow : public AppWindow
    {
      protected:
        VBox *box;

      public:
        BtScanWindow(app::Application *app, std::vector<Devicei> devices = {});

        void onBeforeShow(ShowMode mode, SwitchData *data) override;
        void rebuild() override;
        void buildInterface() override;
        auto onInput(const InputEvent &inputEvent) -> bool override;
        void destroyInterface() override;

      private:
        void invalidate() noexcept;
        std::vector<Devicei> devices;
    };

    class DeviceData : public SwitchData
    {
        std::vector<Devicei> devices;

      public:
        DeviceData(std::vector<Devicei> devices) : SwitchData(), devices(std::move(devices))
        {}
        auto getDevices() -> const std::vector<Devicei> &
        {
            return devices;
        }
    };
} // namespace gui

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

#include <functional>
#include <memory>

#include <service-appmgr/model/ApplicationManager.hpp>

#include "../ApplicationSettings.hpp"
#include "../windows/BtScanWindow.hpp"

#include <i18n/i18n.hpp>

#include "BtWindow.hpp"
#include "Label.hpp"
#include "Margins.hpp"

#include <Style.hpp>

#include <service-bluetooth/BluetoothMessage.hpp>

namespace gui
{

    BtWindow::BtWindow(app::Application *app) : AppWindow(app, "Bluetooth")
    {
        buildInterface();
    }

    void BtWindow::rebuild()
    {
        destroyInterface();
        buildInterface();
    }

    void add_box_label(VBox *layout, UTF8 name, std::function<bool(Item &)> foo)
    {
        auto el = new gui::Label(nullptr, 0, 0, layout->getWidth(), style::window::label::default_h);
        style::window::decorateOption(el);
        el->setText(name);
        el->activatedCallback = foo;
        layout->addWidget(el);
    }

    sys::ReturnCodes message_bt(app::Application *app, BluetoothMessage::Request req)
    {
        std::shared_ptr<BluetoothMessage> msg = std::make_shared<BluetoothMessage>(req);
        auto ret                              = app->bus.sendUnicast(msg, "ServiceBluetooth");
        if (!ret) {
            LOG_ERROR("err: %d", static_cast<int>(ret));
        }
        return ret ? sys::ReturnCodes::Success : sys::ReturnCodes::Failure;
    }

    void BtWindow::buildInterface()
    {
        AppWindow::buildInterface();
        bottomBar->setActive(BottomBar::Side::CENTER, true);
        bottomBar->setActive(BottomBar::Side::RIGHT, true);
        bottomBar->setText(BottomBar::Side::CENTER, utils::translate(style::strings::common::select));
        bottomBar->setText(BottomBar::Side::RIGHT, utils::translate(style::strings::common::back));

        setTitle(utils::translate("app_settings_bt"));

        LOG_INFO("Create box layout");
        box = new gui::VBox(
            this, 0, style::window::default_vertical_pos, style::window_width, 8 * style::window::label::default_h);
        box->setEdges(RectangleEdge::None);

        add_box_label(box, "Bluetooth on off", [=](Item &) {
            LOG_DEBUG("Callback Bluetooth on");

            for (auto &el : box->children) {
                el->visible = true;
            }
            box->setVisible(true);
            application->render(gui::RefreshModes::GUI_REFRESH_FAST);
            return true;
        });

        add_box_label(box, "  -> All devices", [=](Item &) {
            LOG_DEBUG("Callback all devices");
            message_bt(application, BluetoothMessage::Request::Scan);
            application->setActiveWindow(gui::name::window::name_btscan);
            return true;
        });

        add_box_label(box, "  -> PAN", [=](Item &) {
            LOG_DEBUG("Callback start PAN");
            message_bt(application, BluetoothMessage::Request::PAN);
            return true;
        });

        add_box_label(box, "  -> Switch A2DP <-> HSP", [=](Item &) {
            LOG_DEBUG("Callback switch profile");
            message_bt(application, BluetoothMessage::Request::SwitchProfile);
            return true;
        });

        add_box_label(box, "  -> Start stream", [=](Item &) {
            LOG_DEBUG("Start stream");
            message_bt(application, BluetoothMessage::Request::Play);
            return true;
        });

        add_box_label(box, "  -> Stop stream", [=](Item &) {
            LOG_DEBUG("Stop stream");
            message_bt(application, BluetoothMessage::Request::Stop);
            return true;
        });
        add_box_label(box, "  -> Disconnect audio", [=](Item &) {
            LOG_DEBUG("Disconnect");
            message_bt(application, BluetoothMessage::Request::Disconnect);
            return true;
        });

        // hide all elements except button for `bluetooth on off` - this would cause infinite loop
        std::for_each(std::next(box->children.begin()), box->children.end(), [](auto &el) { el->visible = false; });
        setFocusItem(box);
    }

    bool BtWindow::onInput(const InputEvent &inputEvent)
    {
        return AppWindow::onInput(inputEvent);
    }

    void BtWindow::destroyInterface()
    {
        erase();
        invalidate();
    }

    void BtWindow::invalidate() noexcept
    {
        box = nullptr;
    }

    void BtWindow::onBeforeShow(ShowMode mode, SwitchData *data)
    {}

} // namespace gui

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

#pragma once

#include <functional>
#include <string>

#include "AppWindow.hpp"
#include "gui/widgets/Image.hpp"
#include "gui/widgets/Label.hpp"
#include "gui/widgets/Window.hpp"
#include <memory>
#include <BoxLayout.hpp>

namespace gui
{

    class BtWindow : public AppWindow
    {
      protected:
        VBox *box;

        gui::Item *addOptionLabel(const std::string &text, std::function<bool(Item &)> activatedCallback);

      public:
        BtWindow(app::Application *app);

        void onBeforeShow(ShowMode mode, SwitchData *data) override;
        void rebuild() override;
        void buildInterface() override;
        bool onInput(const InputEvent &inputEvent) override;
        void destroyInterface() override;
        void set_navigation();

      private:
        void invalidate() noexcept;
    };
} // namespace gui

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

#include "CellularPassthroughWindow.hpp"
#include <i18n/i18n.hpp>
#include <module-bsp/bsp/cellular/bsp_cellular.hpp>
#include "Label.hpp"
#include <cassert>

using namespace bsp::cellular::USB;

namespace gui
{

    CellularPassthroughWindow::CellularPassthroughWindow(app::Application *app)
        : AppWindow(app, window::cellular_passthrough::window_name)
    {
        buildInterface();
    }

    void CellularPassthroughWindow::rebuild()
    {
        destroyInterface();
        buildInterface();
    }

    void CellularPassthroughWindow::buildInterface()
    {
        AppWindow::buildInterface();
        bottomBar->setActive(BottomBar::Side::CENTER, true);
        bottomBar->setActive(BottomBar::Side::RIGHT, true);
        bottomBar->setText(BottomBar::Side::CENTER, utils::translate(style::strings::common::select));
        bottomBar->setText(BottomBar::Side::RIGHT, utils::translate(style::strings::common::back));

        setTitle(utils::translate("app_settings_cellular_passthrough"));

        layout = new VBox(
            this, 0, style::window::default_vertical_pos, style::window_width, 8 * style::window::label::big_h);
        layout->setPenFocusWidth(style::window::default_border_no_focus_w);

        statusHbox = new gui::HBox(layout,
                                   style::window::default_left_margin,
                                   0,
                                   style::window_width -
                                       (style::window::default_left_margin + style::window::default_right_margin),
                                   style::window::label::big_h);
        statusHbox->setPenWidth(0);
        statusHbox->activeItem = false;

        currentStateConst = new Label(nullptr, 0, 0, 0, style::window::label::big_h, "State:");
        style::window::decorate(currentStateConst);
        currentStateConst->setFont(style::window::font::big);
        currentStateConst->setSize(currentStateConst->getTextNeedSpace(), currentStateConst->getHeight());

        currentStateVariable = new Label(nullptr, 0, 0, 0, style::window::label::big_h);
        style::window::decorate(currentStateVariable);
        currentStateVariable->setFont(style::window::font::bigbold);
        currentStateVariable->setAlignment(gui::Alignment::Horizontal::Right);
        currentStateVariable->setSize(statusHbox->getWidth() - currentStateConst->getTextNeedSpace(),
                                      currentStateVariable->getHeight());

        statusHbox->addWidget(currentStateConst);
        statusHbox->addWidget(currentStateVariable);

        addSeparator(layout);

        // init label buttons
        // enable buttons
        passNormal = new Label(nullptr, 0, 0, layout->getWidth(), style::window::label::big_h);
        style::window::decorateOption(passNormal);
        passNormal->setPadding(Padding(style::window::default_left_margin, 0, style::window::default_right_margin, 0));
        passNormal->setText(window::cellular_passthrough::passNormalDescription);
        passNormal->activatedCallback = [=](gui::Item &) {
            if (set(PassthroughState::ENABLED, BootPinState::NORMAL_BOOT)) {
                setWindowState(State::PASS_NORMAL);
            }
            else {
                setWindowState(State::FAIL);
            }
            return true;
        };
        layout->addWidget(passNormal);

        passDFU = new Label(nullptr, 0, 0, layout->getWidth(), style::window::label::big_h);
        style::window::decorateOption(passDFU);
        passDFU->setPadding(Padding(style::window::default_left_margin, 0, style::window::default_right_margin, 0));
        passDFU->setText(window::cellular_passthrough::passDFUDescription);
        passDFU->activatedCallback = [=](gui::Item &) {
            if (set(PassthroughState::ENABLED, BootPinState::FIRMWARE_UPGRADE)) {
                setWindowState(State::PASS_DFU);
            }
            else {
                setWindowState(State::FAIL);
            }
            return true;
        };
        layout->addWidget(passDFU);

        // disable buttons
        noPass = new Label(nullptr, 0, 0, layout->getWidth(), style::window::label::big_h);
        style::window::decorateOption(noPass);
        noPass->setPadding(Padding(style::window::default_left_margin, 0, style::window::default_right_margin, 0));
        noPass->setText(window::cellular_passthrough::noPassDescription);
        noPass->activatedCallback = [=](gui::Item &) {
            if (set(PassthroughState::DISABLED, BootPinState::NORMAL_BOOT)) {
                setWindowState(State::NO_PASS);
            }
            else {
                setWindowState(State::FAIL);
            }
            return true;
        };
        layout->addWidget(noPass);

        layout->resizeItems();

        setFocusItem(layout);

        // init note
        auto noteSeparator = new Rect(layout, 0, 0, layout->getWidth(), 50);
        noteSeparator->setPenWidth(style::window::default_border_no_focus_w);
        noteSeparator->activeItem = false;

        note = new Label(layout,
                         2 * style::window::default_left_margin,
                         0,
                         layout->getWidth() -
                             2 * (style::window::default_left_margin + style::window::default_right_margin),
                         style::window::label::default_h);
        note->setFont(style::window::font::small);
        note->setFilled(true);
        note->setTextColor(gui::ColorFullWhite);
        note->setFillColor(gui::ColorFullBlack);
        note->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
        note->activeItem = false;

        // get initial state
        setWindowState(getInitialState());
    }

    void CellularPassthroughWindow::destroyInterface()
    {
        erase();
        invalidate();
    }

    void CellularPassthroughWindow::invalidate() noexcept
    {
        layout               = nullptr;
        passNormal           = nullptr;
        passDFU              = nullptr;
        noPass               = nullptr;
        statusHbox           = nullptr;
        currentStateConst    = nullptr;
        currentStateVariable = nullptr;
        note                 = nullptr;
    }

    void CellularPassthroughWindow::addSeparator(VBox *layout)
    {
        assert(layout != nullptr);
        uint16_t height = style::window::label::small_h * 2;
        auto separatorLayout =
            new VBox(nullptr,
                     style::window::default_left_margin,
                     0,
                     (style::window_width - (style::window::default_left_margin + style::window::default_right_margin)),
                     height);
        separatorLayout->setPenWidth(0);

        auto separatorUpper = new Rect(nullptr, 0, 0, separatorLayout->getWidth(), height / 2);
        auto separatorLower = new Rect(nullptr, 0, 0, separatorLayout->getWidth(), height / 2);
        separatorUpper->setBorderColor(gui::ColorFullBlack);
        separatorLower->setBorderColor(gui::ColorFullBlack);
        separatorUpper->setPenWidth(1);
        separatorLower->setPenWidth(1);
        separatorUpper->setEdges(RectangleEdge::Bottom);
        separatorLower->setEdges(RectangleEdge::Top);

        separatorLayout->addWidget(separatorUpper);
        separatorLayout->addWidget(separatorLower);
        separatorLayout->activeItem = false;
        layout->addWidget(separatorLayout);
    }

    CellularPassthroughWindow::State CellularPassthroughWindow::getInitialState()
    {
        auto pass    = getPassthrough();
        auto bootPin = getBootPin();

        auto ret = State::UNKNOWN;

        if (pass == PassthroughState::ENABLED) {
            if (bootPin == BootPinState::FIRMWARE_UPGRADE) {
                ret = State::PASS_DFU;
            }
            else {
                ret = State::PASS_NORMAL;
            }
        }
        else if (pass == PassthroughState::DISABLED) {
            ret = State::NO_PASS;
        }
        return ret;
    }

    bool CellularPassthroughWindow::set(PassthroughState pass_to_set, BootPinState dfu_to_set)
    {
        setPassthrough(pass_to_set);
        setBootPin(dfu_to_set);
        // in order to really enter DFU mode, modem needs be restarted

        // verify if new state has been applied with "Software Input On Field" loopback function
        vTaskDelay(pdMS_TO_TICKS(wait_for_pin_change_state));
        return (getPassthrough() == pass_to_set && getBootPin() == dfu_to_set);
    }

    void CellularPassthroughWindow::setWindowState(CellularPassthroughWindow::State state)
    {
        note->setVisible(false);

        if (state == State::PASS_NORMAL) {
            currentStateVariable->setText(window::cellular_passthrough::passNormalLabel);
            passNormal->setVisible(false);
            passDFU->setVisible(false);
            noPass->setVisible(true);
            if (previousState == State::PASS_DFU) {
                note->setText(window::cellular_passthrough::noPassNote);
                note->setVisible(true);
            }
            // no additional action is needed
        }
        else if (state == State::PASS_DFU) {
            currentStateVariable->setText(window::cellular_passthrough::passDFULabel);
            passNormal->setVisible(false);
            passDFU->setVisible(false);
            noPass->setVisible(true);
            // here modem needs be reset. PWK_KEY reset (aka. nice reset) should be enough
            note->setText(window::cellular_passthrough::passDFUNote);
            note->setVisible(true);
        }
        else if (state == State::NO_PASS) {
            currentStateVariable->setText(window::cellular_passthrough::noPassLabel);
            passNormal->setVisible(true);
            passDFU->setVisible(true);
            noPass->setVisible(false);
            if (previousState == State::PASS_DFU) {
                // reset with a reset key or even Vcc reset i.e. force reset
                note->setText(window::cellular_passthrough::noPassNote);
                note->setVisible(true);
            }
        }
        else if (state == State::FAIL) {
            currentStateVariable->setText("FAIL");
        }
        statusHbox->resizeItems();
        layout->setVisible(true);

        previousState = state;
    }

} // namespace gui

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

#pragma once

#include "AppWindow.hpp"
#include "Application.hpp"
#include <module-bsp/bsp/cellular/bsp_cellular.hpp>
#include <module-gui/gui/widgets/Text.hpp>

namespace gui
{

    namespace window
    {
        namespace cellular_passthrough
        {
            inline constexpr auto window_name = "CellularPassthroughWindow";

            inline constexpr auto passNormalDescription = "Regular passthrough";
            inline constexpr auto passNormalLabel       = "ON";

            inline constexpr auto passDFUDescription = "Firmware Upgrade";
            inline constexpr auto passDFULabel       = "ON (upgrade)";
            inline constexpr auto passDFUNote        = "Reset modem with 2*PWR_KEY";

            inline constexpr auto noPassDescription = "Disable passthrough";
            inline constexpr auto noPassLabel       = "OFF";
            inline constexpr auto noPassNote        = "Reset modem hard. (battery out)";
        } // namespace cellular_passthrough
    }     // namespace window

    class CellularPassthroughWindow : public AppWindow
    {
      private:
        VBox *layout = nullptr;

        Label *passNormal = nullptr;
        Label *passDFU    = nullptr;
        Label *noPass     = nullptr;

        HBox *statusHbox            = nullptr;
        Label *currentStateConst    = nullptr;
        Label *currentStateVariable = nullptr;

        Label *note = nullptr;

      protected:
        enum class State
        {
            PASS_NORMAL,
            PASS_DFU,
            NO_PASS,
            FAIL,
            UNKNOWN,
        };

        State previousState = State::UNKNOWN;

        const time_t wait_for_pin_change_state = 10; // [ms]

      public:
        CellularPassthroughWindow(app::Application *app);

        virtual ~CellularPassthroughWindow() override = default;

        void rebuild() override;

        void buildInterface() override;

        void destroyInterface() override;

        void addSeparator(VBox *layout);

        CellularPassthroughWindow::State getInitialState();

        bool set(bsp::cellular::USB::PassthroughState pass_to_set, bsp::cellular::USB::BootPinState dfu_to_set);

        void setWindowState(State state);

      private:
        void invalidate() noexcept;
    };
} // namespace gui

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

#include "Fota.hpp"
#include "FotaWindow.hpp"

#include <service-cellular/CellularServiceAPI.hpp>
#include <service-fota/FotaServiceAPI.hpp>
#include <service-fota/FotaMessages.hpp>

#include <gui/widgets/Label.hpp>

#include <numeric>

std::string Fota::urlPrefix   = "http://mudita-pure-firmware-test.s3.eu-central-1.amazonaws.com/";
std::string Fota::versionFile = "fota.txt";

Fota::Fota(gui::FotaWindow *parent) : currentState(State::Disconnected), parent(parent)
{
    app = std::shared_ptr<app::Application>(parent->getApplication(),
                                            [](app::Application *) {}); /// with deleter that doesn't delete.
    app->bus.channels.push_back(sys::BusChannel::ServiceFotaNotifications);
    registerHandlers();

    getCurrentVersion();
    parent->statusLabel->setText(getStateString());
}

void Fota::next()
{
    switch (currentState) {
    case State::Disconnected:
        configureAPN();
        break;
    case State::Configuring:
        break;
    case State::Configured:
        connect();
        break;

    case State::Connecting:
        break;
    case State::Connected:
        downloadInfo();
        break;

    case State::DownloadingInfo:
        break;
    case State::DownloadedInfo:
        break;

    case State::ParsingInfo:
        break;
    case State::NeedUpdate:
        update();
        break;

    case State::Updating:
        break;
    case State::Finished:
        reboot();
        break;
    case State::Reboot:
        break;
    }
    parent->statusLabel->setText(getStateString());
}

std::string Fota::getStateString()
{
    switch (currentState) {
    case State::Disconnected:
        return std::string("Disconnected");
    case State::Configuring:
        return std::string("Configuring APN");
    case State::Configured:
        return std::string("Connect to APN");
    case State::Connecting:
        return std::string("Connecting...");
    case State::Connected:
        return std::string("Connected");
    case State::DownloadingInfo:
        return std::string("Downloading firmware info...");
    case State::DownloadedInfo:
        return std::string("Downloading info finished");
    case State::ParsingInfo:
        return std::string("Checking for firmware update...");
    case State::NeedUpdate:
        return std::string("Update");
    case State::Updating:
        return std::string("Updating...");
    case State::Finished:
        return std::string("Updating Finished! Reboot!");
    case State::Reboot:
        return std::string("Rebooting...");
    }
    return std::string("Unsupported state:") + std::to_string(static_cast<int>(currentState));
}

void Fota::configureAPN()
{
    FotaService::APN::Config apnConfig;
    apnConfig.contextId  = 1;
    apnConfig.apn        = "plus";
    apnConfig.authMethod = FotaService::APN::AuthMethod::NONE;
    FotaService::API::Configure(app.get(), apnConfig);
    parent->getBottomBar()->setActive(gui::BottomBar::Side::CENTER, false);
    currentState = State::Configuring;
}

void Fota::connect()
{
    currentState = State::Connecting;
    // do the connection
    parent->getBottomBar()->setActive(gui::BottomBar::Side::CENTER, false);
    FotaService::API::Connect(app.get());
}

void Fota::downloadInfo()
{
    currentState = State::DownloadingInfo;
    parent->getBottomBar()->setActive(gui::BottomBar::Side::CENTER, false);
    FotaService::API::HTTPGET(app.get(), urlPrefix + versionFile);
}

void Fota::parseInfo(std::string data)
{
    currentState = State::ParsingInfo;
    updateStatus();
    std::istringstream inputData(data);
    std::string line;
    /* version mapping file, each line is divided this way:
     * <currentVersion>:<newVersion>:<fileName>
     */
    const unsigned char noItemsInLine(3);
    const unsigned char currentVersionPos(0);
    const unsigned char newVersionPos(1);
    const unsigned char fileNamePos(2);
    while (std::getline(inputData, line, '\n')) {
        std::istringstream lineInput(line);
        std::string subItem;
        std::vector<std::string> items;
        items.reserve(noItemsInLine);
        while (std::getline(lineInput, subItem, ':')) {
            items.push_back(subItem);
        }
        if (items.size() == noItemsInLine) {
            versionMap[items[currentVersionPos]] = {items[newVersionPos], items[fileNamePos]};
        }
    }

    LOG_DEBUG("parsed Data:");
    for (auto item : versionMap) {
        LOG_DEBUG("%s %s->%s\n\t\t%s",
                  (item.first == currentFirmwareVersion ? "*" : " "),
                  item.first.c_str(),
                  item.second.newVersion.c_str(),
                  item.second.file.c_str());
        if (item.first == currentFirmwareVersion) {
            newFirmwareVersion = item.second.newVersion;
            break;
        }
    }
    // do the parsing
}

void Fota::checkIfUpdateRequired()
{
    if (newFirmwareVersion.empty()) {
        parent->getBottomBar()->setActive(gui::BottomBar::Side::RIGHT, true);
        currentState = State::Finished;
    }
    else {
        parent->newFirmwareLabelText->setVisible(true);
        parent->newFirmwareLabel->setText(newFirmwareVersion);
        parent->newFirmwareLabel->setVisible(true);
        parent->getBottomBar()->setActive(gui::BottomBar::Side::CENTER, true);
        currentState = State::NeedUpdate;
    }
    updateStatus();
}

void Fota::update()
{
    currentState = State::Updating;
    parent->getBottomBar()->setActive(gui::BottomBar::Side::RIGHT, false);
    parent->getBottomBar()->setActive(gui::BottomBar::Side::CENTER, false);
    parent->downloadProgress->setVisible(true);
    FotaService::API::FotaStart(app.get(), urlPrefix + versionMap[currentFirmwareVersion].file);
}

void Fota::reboot()
{
    currentState = State::Reboot;
    parent->statusLabel->setText(getStateString());
    auto msg = std::make_shared<sys::SystemManagerCmd>(sys::Code::Reboot);
    app->bus.sendUnicast(std::move(msg), service::name::system_manager);
}

void Fota::registerHandlers()
{
    LOG_DEBUG("Registrng handles");
    handleInternetNotification();
    handleHTTPResponse();
    handleFotaProgres();
    handleFotaFinished();
}

void Fota::handleInternetNotification()
{
    LOG_DEBUG("handle IntrntNotificationMassage");
    app->connect(FotaService::NotificationMessage(), [&](sys::Message *req) {
        LOG_DEBUG("IntrntNotificationMassage");
        if (auto msg = dynamic_cast<FotaService::NotificationMessage *>(req)) {
            LOG_DEBUG("IntrntNotificationMassage: %s", msg->c_str());
            switch (msg->type) {
            case FotaService::NotificationMessage::Type::NotReady:
                break;
            case FotaService::NotificationMessage::Type::Configured:
                currentState = State::Configured;
                parent->statusLabel->setText(getStateString());
                parent->getBottomBar()->setActive(gui::BottomBar::Side::CENTER, true);
                app->refreshWindow(gui::RefreshModes::GUI_REFRESH_FAST);
                break;
            case FotaService::NotificationMessage::Type::Connected:
                currentState = State::Connected;
                parent->statusLabel->setText(getStateString());
                parent->getBottomBar()->setActive(gui::BottomBar::Side::CENTER, true);
                app->refreshWindow(gui::RefreshModes::GUI_REFRESH_FAST);
                break;
            case FotaService::NotificationMessage::Type::Disconnected:
                currentState = State::Disconnected;
                break;
            case FotaService::NotificationMessage::Type::RequestProcessed:
                break;
            case FotaService::NotificationMessage::Type::ServiceReady:
                break;
            }
        }
        return std::make_shared<sys::ResponseMessage>();
    });
}

void Fota::handleHTTPResponse()
{
    LOG_DEBUG("Handling http response");
    app->connect(FotaService::HTTPResponseMessage(), [&](sys::Message *req) {
        if (auto msg = dynamic_cast<FotaService::HTTPResponseMessage *>(req)) {
            LOG_DEBUG("HTTP Response to: %s", msg->url.c_str());
            LOG_DEBUG("HTTP AT Error   : %s", FotaService::toString(msg->httpError).c_str());
            LOG_DEBUG(
                "response headers:\n\t%s",
                std::accumulate(msg->responseHeaders.begin(), msg->responseHeaders.end(), std::string("\n\t")).c_str());
            LOG_DEBUG("response data   :\n%s", msg->body.c_str());
            const std::string contentLength("Content-Length: ");
            std::string data;
            for (auto &header : msg->responseHeaders) {
                auto sizeBegin = header.find(contentLength);
                if (sizeBegin != std::string::npos) {
                    try {
                        unsigned long len = std::stoul(header.substr(sizeBegin + contentLength.size()));
                        data              = msg->body.substr(0, len);
                    }
                    catch (const std::exception &e) {
                        LOG_ERROR("Fota::handleHTTPResponse exception %s", e.what());
                        return std::make_shared<sys::ResponseMessage>();
                    }
                    break;
                }
            }

            currentState = State::DownloadedInfo;
            parseInfo(std::move(data));
            checkIfUpdateRequired();
        }
        return std::make_shared<sys::ResponseMessage>();
    });
}

void Fota::handleFotaProgres()
{
    app->connect(FotaService::FOTAProgres(), [&](sys::Message *req) {
        if (auto msg = dynamic_cast<FotaService::FOTAProgres *>(req)) {
            parent->downloadProgress->setValue(msg->progress);
            app->refreshWindow(gui::RefreshModes::GUI_REFRESH_FAST);
        }
        return std::make_shared<sys::ResponseMessage>();
    });
}

void Fota::handleFotaFinished()
{
    app->connect(FotaService::FOTAFinished(), [&](sys::Message *) {
        LOG_DEBUG("Done!");
        currentState = State::Finished;
        parent->statusLabel->setText(getStateString());
        parent->currentFirmwareLabel->setText(newFirmwareVersion);
        parent->newFirmwareLabelText->setVisible(false);
        parent->newFirmwareLabel->setVisible(false);
        parent->downloadProgress->setVisible(false);
        parent->getBottomBar()->setActive(gui::BottomBar::Side::CENTER, true);
        app->refreshWindow(gui::RefreshModes::GUI_REFRESH_FAST);
        return std::make_shared<sys::ResponseMessage>();
    });
}

void Fota::getCurrentVersion()
{
    CellularServiceAPI::GetFirmwareVersion(parent->getApplication(), currentFirmwareVersion);
}

void Fota::updateStatus()
{
    parent->statusLabel->setText(getStateString());
    app->refreshWindow(gui::RefreshModes::GUI_REFRESH_FAST);
}

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

#pragma once

#include <Service/Service.hpp>
#include <Application.hpp>

#include <string>

namespace gui
{
    class Label;
    class FotaWindow;
} // namespace gui

class Fota
{
    enum class State
    {
        Disconnected,
        Configuring,
        Configured,
        Connecting,
        Connected,
        DownloadingInfo,
        DownloadedInfo,
        ParsingInfo,
        NeedUpdate,
        Updating,
        Finished,
        Reboot,
    };

  public:
    struct VersionInfo
    {
        std::string newVersion;
        std::string file;
    };
    using VersionMap = std::unordered_map<std::string, VersionInfo>;
    Fota(gui::FotaWindow *parent);
    void next();
    std::string getCurrentFirmwareVersion()
    {
        return currentFirmwareVersion;
    }
    std::string getStateString();
    State getState()
    {
        return currentState;
    };

  private:
    void configureAPN();
    void connect();
    void downloadInfo();
    void parseInfo(std::string data);
    void checkIfUpdateRequired();
    void update();
    void reboot();

    void registerHandlers();
    void handleInternetNotification();
    void handleHTTPResponse();
    void handleFotaProgres();
    void handleFotaFinished();

    void getCurrentVersion();
    void updateStatus();
    State currentState;

    gui::FotaWindow *parent = nullptr;
    std::shared_ptr<app::Application> app;
    std::string currentFirmwareVersion;
    std::string newFirmwareVersion;
    VersionMap versionMap;
    static std::string urlPrefix;
    static std::string versionFile;
};

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

#include "FotaWindow.hpp"

#include "Fota.hpp"

#include <i18n/i18n.hpp>

namespace gui
{

    FotaWindow::FotaWindow(app::Application *app) : AppWindow(app, window::name::fota_window)
    {
        buildInterface();
        fotaUpdater = std::make_unique<Fota>(this);
        currentFirmwareLabel->setText(fotaUpdater->getCurrentFirmwareVersion());
    }

    FotaWindow::~FotaWindow()
    {
        destroyInterface();
    }

    void FotaWindow::onBeforeShow(ShowMode /*mode*/, SwitchData * /*data*/)
    {}

    void FotaWindow::rebuild()
    {
        destroyInterface();
        buildInterface();
    }

    void FotaWindow::buildInterface()
    {
        LOG_INFO("Build Fota Window");
        AppWindow::buildInterface();
        setTitle("Modem Firmware update (FOTA)");

        bottomBar->setActive(BottomBar::Side::CENTER, true);
        bottomBar->setActive(BottomBar::Side::RIGHT, true);
        bottomBar->setText(BottomBar::Side::CENTER, utils::translate("Go"));
        bottomBar->setText(BottomBar::Side::RIGHT, utils::translate("common_back"));

        mainBox =
            new gui::VBox(this, 0, style::window::default_vertical_pos, style::window_width, style::window_height);
        mainBox->setPenWidth(style::window::default_border_no_focus_w);

        addBoxLabel(mainBox, "FOTA Status:");
        statusLabel = new Label(mainBox, 0, 0, style::window_width, style::window::label::default_h);
        statusLabel->setFocus(true);

        addBoxLabel(mainBox, "Current Firmware:");
        currentFirmwareLabel = new Label(mainBox, 0, 0, style::window_width, style::window::label::default_h);

        setFocusItem(statusLabel);

        newFirmwareLabelText = addBoxLabel(mainBox, "New Firmware:");
        newFirmwareLabel     = new Label(mainBox, 0, 0, style::window_width, style::window::label::default_h);
        newFirmwareLabel->setText("");

        const unsigned char progressLow(0);
        const unsigned char progressMax(100);
        downloadProgress = new ProgressBar(mainBox, 0, 0, style::window_width, style::window::label::default_h);
        downloadProgress->setMaximum(progressMax);
        downloadProgress->setValue(progressLow);

        statusLabel->activatedCallback = [&](Item &) -> bool {
            if (bottomBar->isActive(gui::BottomBar::Side::CENTER)) {
                fotaUpdater->next();
            }
            return true;
        };
        newFirmwareLabelText->setVisible(false);
        newFirmwareLabel->setVisible(false);
        downloadProgress->setVisible(false);
        getApplication()->refreshWindow(gui::RefreshModes::GUI_REFRESH_FAST);
    }

    void FotaWindow::destroyInterface()
    {
        erase();
        invalidate();
    }

    void FotaWindow::invalidate() noexcept
    {
        currentFirmwareLabel = nullptr;
        statusLabel          = nullptr;
        newFirmwareLabelText = nullptr;
        newFirmwareLabel     = nullptr;
        downloadProgress     = nullptr;
        mainBox              = nullptr;
    }

    BottomBar *FotaWindow::getBottomBar()
    {
        return bottomBar;
    }

    gui::Label *FotaWindow::addBoxLabel(BoxLayout *layout, const std::string &text)
    {
        auto el = new gui::Label(layout, 0, 0, style::window_width, style::window::label::default_h);
        style::window::decorateOption(el);
        el->setText(text);
        return el;
    }

} // namespace gui

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

#pragma once

#include <Application.hpp>
#include <AppWindow.hpp>
#include <gui/widgets/BoxLayout.hpp>
#include <gui/widgets/Label.hpp>
#include <gui/widgets/Text.hpp>
#include <gui/widgets/BoxLayout.hpp>
#include <gui/widgets/ProgressBar.hpp>

#include <memory>
#include <string>

class Fota;

namespace gui
{
    namespace window
    {
        namespace name
        {
            inline constexpr auto fota_window = "fota_window";
        } // namespace name
    }     // namespace window
    /** @brief Window managing modem firmware update
     *
     */
    class FotaWindow : public AppWindow
    {
      public:
        FotaWindow(app::Application *app);
        virtual ~FotaWindow();

        void onBeforeShow(ShowMode mode, SwitchData *data) override;
        void rebuild() override;
        void buildInterface() override;
        void destroyInterface() override;

        //        Text apnName;
        //        Text apnUser;
        //        Text apnPassword;
        gui::BottomBar *getBottomBar();

      public:
        Label *addBoxLabel(BoxLayout *layout, const std::string &text);

        Label *currentFirmwareLabel   = nullptr;
        Label *statusLabel            = nullptr;
        Label *newFirmwareLabelText   = nullptr;
        Label *newFirmwareLabel       = nullptr;
        ProgressBar *downloadProgress = nullptr;
        VBox *mainBox                 = nullptr;

      private:
        void invalidate() noexcept;

        std::unique_ptr<Fota> fotaUpdater;
    };
} // namespace gui

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

#include <functional>

#include "service-appmgr/Controller.hpp"

#include "../ApplicationSettings.hpp"

#include <i18n/i18n.hpp>

#include "Label.hpp"
#include "LanguageWindow.hpp"
#include <Style.hpp>
#include <module-apps/application-settings-new/widgets/SettingsStyle.hpp>

namespace gui
{
    namespace window::name
    {
        constexpr inline auto languages = "Languages";
    }

    LanguageWindow::LanguageWindow(app::Application *app) : AppWindow(app, gui::window::name::languages)
    {
        buildInterface();
        setFocusItem(options[0]);
    }

    void LanguageWindow::rebuild()
    {
        // find which widget has focus
        uint32_t index = 0;
        for (uint32_t i = 0; i < options.size(); i++)
            if (options[i] == getFocusItem()) {
                index = i;
                break;
            }

        destroyInterface();
        buildInterface();
        setFocusItem(options[index]);
    }
    void LanguageWindow::buildInterface()
    {
        AppWindow::buildInterface();
        bottomBar->setActive(BottomBar::Side::CENTER, true);
        bottomBar->setActive(BottomBar::Side::RIGHT, true);
        bottomBar->setText(BottomBar::Side::CENTER, utils::translate(style::strings::common::select));
        bottomBar->setText(BottomBar::Side::RIGHT, utils::translate(style::strings::common::back));

        setTitle(utils::translate("app_settings_title_languages"));
        const auto &langList = loader.getAvailableDisplayLanguages();
        for (const auto &lang : langList) {
            options.push_back(addOptionLabel(lang, [=](gui::Item &item) {
                app::manager::Controller::changeDisplayLanguage(application, lang);
                return true;
            }));
        }

        // set position and navigation for labels
        uint32_t size = options.size();
        for (uint32_t i = 0; i < size; i++) {
            options[i]->setPosition(style::settings::window::languageChange::options_posX,
                                    style::settings::window::languageChange::options_posY +
                                        (i * style::settings::window::languageChange::options_distance_between));
            options[i]->setNavigationItem(NavigationDirection::DOWN, options[(i + 1) % size]);
            options[i]->setNavigationItem(NavigationDirection::UP, options[(size + i - 1) % size]);
        }
    }

    void LanguageWindow::destroyInterface()
    {
        erase();
        invalidate();
    }

    void LanguageWindow::invalidate() noexcept
    {
        options.clear();
    }

    gui::Item *LanguageWindow::addOptionLabel(const std::string &text, std::function<bool(Item &)> activatedCallback)
    {
        gui::Label *label = new gui::Label(this, 17, 0, 480 - 34, 60, text);
        label->setPadding(gui::Padding(16, 0, 0, 0));
        label->setFilled(false);
        label->setPenFocusWidth(3);
        label->setPenWidth(0);
        label->setFont(style::window::font::medium);
        label->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center));
        label->setRadius(11);
        label->activatedCallback = activatedCallback;

        return label;
    }

    void LanguageWindow::onBeforeShow(ShowMode mode, SwitchData *data)
    {
        setFocusItem(options[0]);
    }

} /* namespace gui */

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

#ifndef MODULE_APPS_APPLICATION_SETTINGS_WINDOWS_LANGUAGEWINDOW_HPP_
#define MODULE_APPS_APPLICATION_SETTINGS_WINDOWS_LANGUAGEWINDOW_HPP_

#include <string>
#include <functional>

#include "AppWindow.hpp"
#include "gui/widgets/Label.hpp"
#include "gui/widgets/Image.hpp"
#include "gui/widgets/Window.hpp"
#include "gui/widgets/BottomBar.hpp"

namespace gui
{

    class LanguageWindow : public AppWindow
    {
      protected:
        std::vector<gui::Item *> options;

        gui::Item *addOptionLabel(const std::string &text, std::function<bool(Item &)> activatedCallback);

      public:
        LanguageWindow(app::Application *app);

        void onBeforeShow(ShowMode mode, SwitchData *data) override;
        void rebuild() override;
        void buildInterface() override;
        void destroyInterface() override;

      private:
        utils::LangLoader loader;
        void invalidate() noexcept;
    };
} /* namespace gui */

#endif /* MODULE_APPS_APPLICATION_SETTINGS_WINDOWS_LANGUAGEWINDOW_HPP_ */

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

#include "SettingsMainWindow.hpp"
#include "../ApplicationSettings.hpp"
#include "Info.hpp"
#include <i18n/i18n.hpp>
#include <log.hpp>
#include "CellularPassthroughWindow.hpp"
#include "FotaWindow.hpp"
#include "EinkModeWindow.hpp"
#include "ColorTestWindow.hpp"

std::list<gui::Option> mainWindowOptions(app::Application *app)
{
    std::list<gui::Option> l;

    auto i18     = [](std::string text) { return utils::translate(text); };
    auto addMenu = [&](UTF8 name, std::string window = "") {
        l.emplace_back(gui::Option{name,
                                   [=](gui::Item &item) {
                                       if (window == "") {
                                           return false;
                                       }
                                       LOG_INFO("switching to %s page", window.c_str());
                                       app->switchWindow(window, nullptr);
                                       return true;
                                   },
                                   gui::option::Arrow::Enabled});
    };

    addMenu(i18("Information"), gui::window::hw_info);
    addMenu("UI TEST", "TEST_UI");
    addMenu(i18("app_settings_bt"), "Bluetooth");
    addMenu(i18("app_settings_language"), "Languages");
    addMenu(i18("app_settings_date_and_time"), "DateTime");
    if (dynamic_cast<app::ApplicationSettings *>(app)->board == bsp::Board::T4) {
        addMenu(i18("app_settings_cellular_passthrough"), gui::window::cellular_passthrough::window_name);
    }
    addMenu(i18("Fota update"), gui::window::name::fota_window);
    addMenu("Eink Mode", gui::window::name::eink);
    addMenu(i18("Color test"), gui::window::name::color_test_window);
    addMenu(i18("app_settings_display"));
    addMenu(i18("app_settings_phone_modes"));
    addMenu(i18("app_settings_security"));
    addMenu(i18("app_settings_about"));
    return l;
}

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

/*
 * TestMessageWindow.cpp
 *
 *  Created on: 3 gru 2019
 *      Author: kuba
 */

#include <memory>
#include <functional>

#include "module-services/service-appmgr/model/ApplicationManager.hpp"

#include "../ApplicationSettings.hpp"

#include <i18n/i18n.hpp>

#include "Label.hpp"
#include "Margins.hpp"
#include "TestMessageWindow.hpp"
#include <Style.hpp>

#include "service-cellular/api/CellularServiceAPI.hpp"

namespace gui
{

    TestMessageWindow::TestMessageWindow(app::Application *app) : AppWindow(app, "Message")
    {
        buildInterface();
    }

    void TestMessageWindow::rebuild()
    {

        destroyInterface();
        buildInterface();
    }

    void textSetInput(Text *text, bool numeric = true)
    {
        /// tu ustawiasz że coś jest edytowalne
        text->setEditMode(EditMode::EDIT);
        text->setFont(style::window::font::bigbold);
        /// tu ustawiasz tak naprawdę przez tą listę InputMode::digit etc jakie kolejne tryby wprowadzania są wybierane
        if (numeric) {
            text->setInputMode(new InputMode({InputMode::digit}));
        }
        else {
            text->setInputMode(new InputMode({InputMode::ABC, InputMode::abc, InputMode::digit}));
        }
    }

    void TestMessageWindow::buildInterface()
    {
        AppWindow::buildInterface();
        bottomBar->setActive(BottomBar::Side::CENTER, true);
        bottomBar->setActive(BottomBar::Side::RIGHT, true);
        bottomBar->setText(BottomBar::Side::CENTER, utils::translate(style::strings::common::select));
        bottomBar->setText(BottomBar::Side::RIGHT, utils::translate(style::strings::common::back));

        receivedLabel = new gui::Label(this, 10, 50, 480 - 20, 50, "Received SMS");
        receivedLabel->setAlignment(
            gui::Alignment(gui::Alignment::Vertical::Center, gui::Alignment::Horizontal::Center));
        receivedLabel->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);

        receiveNumber = new gui::Label(this, 110, 190, 480 - 120, 50);
        receiveNumber->setFont(style::window::font::small);

        RecNumberLabel = new gui::Label(this, 10, 190, 90, 50, "Number");
        RecNumberLabel->setAlignment(
            gui::Alignment(gui::Alignment::Vertical::Center, gui::Alignment::Horizontal::Center));
        RecNumberLabel->setFont(style::window::font::small);
        RecNumberLabel->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);

        receiveMessage = new gui::Text(this, 110, 120, 480 - 120, 50);
        textSetInput(receiveMessage);
        receiveMessage->setFont(style::window::font::small);

        RecMessageLabel = new gui::Label(this, 10, 120, 90, 50, "Message");
        RecMessageLabel->setAlignment(
            gui::Alignment(gui::Alignment::Vertical::Center, gui::Alignment::Horizontal::Center));
        RecMessageLabel->setFont(style::window::font::small);
        RecMessageLabel->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);

        sendLabel = new gui::Label(this, 10, 290, 480 - 20, 50, "New SMS");
        sendLabel->setAlignment(gui::Alignment(gui::Alignment::Vertical::Center, gui::Alignment::Horizontal::Center));
        sendLabel->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);

        sendMessage = new gui::Text(this, 110, 360, 480 - 120, 50);
        textSetInput(sendMessage, false);
        sendMessage->setText("Siema tu PurePhone :)");
        sendMessage->setFont(style::window::font::small);

        sendNumber = new gui::Text(this, 110, 430, 480 - 120, 50);
        textSetInput(sendNumber);
        sendNumber->setFont(style::window::font::small);

        SendNumberLabel = new gui::Label(this, 10, 430, 90, 50, "Number");
        SendNumberLabel->setAlignment(
            gui::Alignment(gui::Alignment::Vertical::Center, gui::Alignment::Horizontal::Center));
        SendNumberLabel->setFont(style::window::font::small);
        SendNumberLabel->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);

        SendMessageLabel = new gui::Label(this, 10, 360, 90, 50, "Message");
        SendMessageLabel->setAlignment(
            gui::Alignment(gui::Alignment::Vertical::Center, gui::Alignment::Horizontal::Center));
        SendMessageLabel->setFont(style::window::font::small);
        SendMessageLabel->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);

        sendButton = new gui::Label(this, 10, 500, 480 - 20, 50, "Send SMS");
        sendButton->setAlignment(gui::Alignment(gui::Alignment::Vertical::Center, gui::Alignment::Horizontal::Center));
        sendButton->setPenWidth(1);
        sendButton->setPenFocusWidth(3);
        sendButton->activatedCallback = [=](gui::Item &item) {
            LOG_INFO("Send SMS callback");
            CellularServiceAPI::SendSMS(application, sendNumber->getText(), sendMessage->getText());
            return true;
        };

        sendButton->setNavigationItem(gui::NavigationDirection::UP, sendNumber);
        sendNumber->setNavigationItem(gui::NavigationDirection::UP, sendMessage);

        sendMessage->setNavigationItem(gui::NavigationDirection::DOWN, sendNumber);
        sendNumber->setNavigationItem(gui::NavigationDirection::DOWN, sendButton);
    }
    void TestMessageWindow::destroyInterface()
    {
        erase();
    }

    void TestMessageWindow::onBeforeShow(ShowMode mode, SwitchData *data)
    {
        setFocusItem(sendButton);
    }

    void TestMessageWindow::cellularMessageCallback(UTF8 &number, UTF8 &message)
    {
        receiveNumber->setText(number);
        receiveMessage->setText(message);
        application->refreshWindow(RefreshModes::GUI_REFRESH_FAST);
    }
} /* namespace gui */

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

/*
 * TestMessageWindow.hpp
 *
 *  Created on: 3 gru 2019
 *      Author: kuba
 */

#ifndef MODULE_APPS_APPLICATION_SETTINGS_WINDOWS_TESTMESSAGEWINDOW_HPP_
#define MODULE_APPS_APPLICATION_SETTINGS_WINDOWS_TESTMESSAGEWINDOW_HPP_

#include <string>
#include <functional>

#include "AppWindow.hpp"
#include "gui/widgets/Label.hpp"
#include "gui/widgets/Text.hpp"
#include "gui/widgets/Image.hpp"
#include "gui/widgets/Window.hpp"
#include "gui/widgets/BottomBar.hpp"

namespace gui
{

    /*
     *
     */
    class TestMessageWindow : public AppWindow
    {
      protected:
        gui::Label *sendLabel;
        gui::Label *sendButton;

        gui::Label *receivedLabel;

        gui::Label *SendNumberLabel;
        gui::Label *SendMessageLabel;
        gui::Text *sendNumber;
        gui::Text *sendMessage;

        gui::Label *RecNumberLabel;
        gui::Label *RecMessageLabel;
        gui::Label *receiveNumber;
        gui::Text *receiveMessage;

      public:
        TestMessageWindow(app::Application *app);

        void onBeforeShow(ShowMode mode, SwitchData *data) override;
        void rebuild() override;
        void buildInterface() override;
        void destroyInterface() override;
        void cellularMessageCallback(UTF8 &number, UTF8 &message);
    };
} /* namespace gui */

#endif /* MODULE_APPS_APPLICATION_SETTINGS_WINDOWS_TESTMESSAGEWINDOW_HPP_ */

M products/BellHybrid/BellHybridMain.cpp => products/BellHybrid/BellHybridMain.cpp +0 -1
@@ 7,7 7,6 @@
#include <application-call/ApplicationCall.hpp>
#include <application-calllog/ApplicationCallLog.hpp>
#include <application-desktop/ApplicationDesktop.hpp>
#include <application-settings/ApplicationSettings.hpp>
#include <application-settings-new/ApplicationSettings.hpp>
#include <application-special-input/ApplicationSpecialInput.hpp>
#include <application-calendar/ApplicationCalendar.hpp>

M products/PurePhone/PurePhoneMain.cpp => products/PurePhone/PurePhoneMain.cpp +0 -4
@@ 11,7 11,6 @@
#include <application-messages/ApplicationMessages.hpp>
#include <application-notes/ApplicationNotes.hpp>
#include <application-phonebook/ApplicationPhonebook.hpp>
#include <application-settings/ApplicationSettings.hpp>
#include <application-settings-new/ApplicationSettings.hpp>
#include <application-special-input/ApplicationSpecialInput.hpp>
#include <application-calendar/ApplicationCalendar.hpp>


@@ 127,9 126,6 @@ int main()
#ifdef ENABLE_APP_CALL
            applications.push_back(app::CreateLauncher<app::ApplicationCall>(app::name_call));
#endif
#ifdef ENABLE_APP_SETTINGS
            applications.push_back(app::CreateLauncher<app::ApplicationSettings>(app::name_settings));
#endif
#ifdef ENABLE_APP_SETTINGS_NEW
            applications.push_back(app::CreateLauncher<app::ApplicationSettingsNew>(app::name_settings_new));
#endif