From 49f432cc622ba6b24d369384a3f700269477cf99 Mon Sep 17 00:00:00 2001 From: Maciej Gibowicz Date: Tue, 21 May 2024 13:04:55 +0200 Subject: [PATCH] [BH-1945] Add update instructions at the end of onboarding User will see instructions on updating Harmony's OS at the end of onboarding. --- harmony_changelog.md | 1 + image/system_a/data/lang/Deutsch.json | 5 + image/system_a/data/lang/English.json | 5 + image/system_a/data/lang/Espanol.json | 5 + image/system_a/data/lang/Francais.json | 5 + image/system_a/data/lang/Polski.json | 5 + module-gui/gui/widgets/ThreeBox.cpp | 3 +- .../ApplicationBellOnBoarding.cpp | 21 +- .../CMakeLists.txt | 2 + .../BellOnBoardingNames.hpp | 17 +- ...ardingUpdateInstructionWindowPresenter.cpp | 57 ++++++ ...ardingUpdateInstructionWindowPresenter.hpp | 29 +++ .../windows/OnBoardingSettingsWindow.cpp | 4 +- .../BellHybrid/apps/common/CMakeLists.txt | 8 + .../common/include/common/BellCommonNames.hpp | 5 +- .../UpdateInstructionLayoutClassic.hpp | 45 +++++ .../UpdateInstructionLayoutProvider.hpp | 30 +++ .../layouts/UpdateInstructionLayouts.hpp | 19 ++ .../windows/UpdateInstructionWindow.hpp | 32 +++ .../UpdateInstructionWindowContract.hpp | 30 +++ .../UpdateInstructionLayoutClassic.cpp | 187 ++++++++++++++++++ .../src/layouts/UpdateInstructionLayouts.cpp | 24 +++ .../src/windows/UpdateInstructionWindow.cpp | 64 ++++++ 23 files changed, 589 insertions(+), 14 deletions(-) create mode 100644 products/BellHybrid/apps/application-bell-onboarding/presenter/OnBoardingUpdateInstructionWindowPresenter.cpp create mode 100644 products/BellHybrid/apps/application-bell-onboarding/presenter/OnBoardingUpdateInstructionWindowPresenter.hpp create mode 100644 products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayoutClassic.hpp create mode 100644 products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayoutProvider.hpp create mode 100644 products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayouts.hpp create mode 100644 products/BellHybrid/apps/common/include/common/windows/UpdateInstructionWindow.hpp create mode 100644 products/BellHybrid/apps/common/include/common/windows/UpdateInstructionWindowContract.hpp create mode 100644 products/BellHybrid/apps/common/src/layouts/UpdateInstructionLayoutClassic.cpp create mode 100644 products/BellHybrid/apps/common/src/layouts/UpdateInstructionLayouts.cpp create mode 100644 products/BellHybrid/apps/common/src/windows/UpdateInstructionWindow.cpp diff --git a/harmony_changelog.md b/harmony_changelog.md index 096dba68316f30c53753bb3949060ceebfa4d75a..8a709bf170cdd88af94e1b223c4e4076dfeef9fa 100644 --- a/harmony_changelog.md +++ b/harmony_changelog.md @@ -7,6 +7,7 @@ ### Added * Added custom alarms functionality +* Added update instruction screen at end of onboarding ### Changed / Improved * Changed the refresh rate of the progress bar screen diff --git a/image/system_a/data/lang/Deutsch.json b/image/system_a/data/lang/Deutsch.json index 1480dac1479ba98329932d7d2295e75e540ce8b8..f4449f5962362650e0593918a2c49f20cc609cc9 100644 --- a/image/system_a/data/lang/Deutsch.json +++ b/image/system_a/data/lang/Deutsch.json @@ -130,6 +130,11 @@ "app_bell_settings_time_units_time_message": "Zeit", "app_bell_settings_turn_off": "Ausschalten", "app_bell_turn_off_question": "Schalten Sie das Ger\u00e4t aus?", + "app_bell_update_instruction_title": "Update-Leitfaden", + "app_bell_update_instruction_1st_point": "Lade Mudita Center über
mudita.com/center
", + "app_bell_update_instruction_2nd_point": "Verbinde Harmony per USB-C mit dem PC", + "app_bell_update_instruction_3rd_point": "Öffne Mudita Center", + "app_bell_update_instruction_4th_point": "Klicke in Overview auf Update", "app_bell_welcome_charge_message": "Charge Harmony
und leicht dr\u00fccken
", "app_bell_welcome_message": "Mudita Harmony
ist ausgeschaltet
", "app_bellmain_alarm": "Alarm", diff --git a/image/system_a/data/lang/English.json b/image/system_a/data/lang/English.json index f3f5782ad4d8e96b30bc00eb04b0d7b2a31b0783..06c8f9d1de8188708a2b7e0809796bf3ba5cb24d 100644 --- a/image/system_a/data/lang/English.json +++ b/image/system_a/data/lang/English.json @@ -164,6 +164,11 @@ "app_bell_settings_time_units_time_message": "Time", "app_bell_settings_turn_off": "Turn off", "app_bell_turn_off_question": "Turn off Mudita Harmony?", + "app_bell_update_instruction_title": "Update Guide", + "app_bell_update_instruction_1st_point": "Download Mudita Center from
mudita.com/center
", + "app_bell_update_instruction_2nd_point": "Connect Harmony to computer via USB-C", + "app_bell_update_instruction_3rd_point": "Open Mudita Center", + "app_bell_update_instruction_4th_point": "On Overview click
Update
", "app_bell_welcome_charge_message": "Charge Harmony
and press light click
", "app_bell_welcome_message": "Mudita Harmony
is switched OFF
", "app_bellmain_alarm": "Alarm", diff --git a/image/system_a/data/lang/Espanol.json b/image/system_a/data/lang/Espanol.json index 5e7932b8179b3afc936ea85e0134f9cf92cc862e..5e7d5c9e2b54b1f2aa23d960da8cc1f568071d09 100644 --- a/image/system_a/data/lang/Espanol.json +++ b/image/system_a/data/lang/Espanol.json @@ -129,6 +129,11 @@ "app_bell_settings_time_units_time_message": "Hora", "app_bell_settings_turn_off": "Apagar", "app_bell_turn_off_question": "\u00bfApagar Mudita Harmony?", + "app_bell_update_instruction_title": "Cómo actualizar", + "app_bell_update_instruction_1st_point": "Descarga Mudita Center en
mudita.com/center
", + "app_bell_update_instruction_2nd_point": "Conecta Harmony a un PC con un USB-C", + "app_bell_update_instruction_3rd_point": "Abre Mudita Center", + "app_bell_update_instruction_4th_point": "Haz clic en Update en
Overview
", "app_bell_welcome_charge_message": "Carga tu Harmony
y pulsa levemente
", "app_bell_welcome_message": "Mudita Harmony
est\u00e1 apagado
", "app_bellmain_alarm": "Alarma", diff --git a/image/system_a/data/lang/Francais.json b/image/system_a/data/lang/Francais.json index 0bbdbfbb8d17bb17cf12d35f79e9448a44b11147..dc04e1cd68ed3354681b72beace87561eeb1f5ad 100644 --- a/image/system_a/data/lang/Francais.json +++ b/image/system_a/data/lang/Francais.json @@ -131,6 +131,11 @@ "app_bell_settings_time_units_time_message": "Heure", "app_bell_settings_turn_off": "\u00c9teindre", "app_bell_turn_off_question": "\u00c9teindre l'appareil ?", + "app_bell_update_instruction_title": "Guide des MaJ", + "app_bell_update_instruction_1st_point": "Téléchargez Mudita Center sur
mudita.com/center
", + "app_bell_update_instruction_2nd_point": "Branchez Harmony à votre PC via USB-C", + "app_bell_update_instruction_3rd_point": "Ouvrez Mudita Center", + "app_bell_update_instruction_4th_point": "Dans Overview >
Update
", "app_bell_welcome_charge_message": "Rechargez Harmony
et appuyez l\u00e9g\u00e8rement
", "app_bell_welcome_message": "Mudita Harmony
est d\u00e9sactiv\u00e9
", "app_bellmain_alarm": "Alarme", diff --git a/image/system_a/data/lang/Polski.json b/image/system_a/data/lang/Polski.json index 354cd202d0bacbf7ed804dff76e53ccfd8476a3d..915d675a8c5f8d1ad6e418000bc68b8433882a45 100644 --- a/image/system_a/data/lang/Polski.json +++ b/image/system_a/data/lang/Polski.json @@ -130,6 +130,11 @@ "app_bell_settings_time_units_time_message": "Czas", "app_bell_settings_turn_off": "Wy\u0142\u0105cz", "app_bell_turn_off_question": "Wy\u0142\u0105czy\u0107 Mudita Harmony?", + "app_bell_update_instruction_title": "Jak aktualizować", + "app_bell_update_instruction_1st_point": "Pobierz Mudita Center
z mudita.com/center
", + "app_bell_update_instruction_2nd_point": "Podłącz Harmony do PC za pomocą USB-C", + "app_bell_update_instruction_3rd_point": "Otwórz Mudita Center", + "app_bell_update_instruction_4th_point": "Kliknij Update
w Overview
", "app_bell_welcome_charge_message": "Na\u0142aduj Harmony
i kliknij lekko
", "app_bell_welcome_message": "Mudita Harmony
jest wy\u0142\u0105czony
", "app_bellmain_alarm": "Alarm", diff --git a/module-gui/gui/widgets/ThreeBox.cpp b/module-gui/gui/widgets/ThreeBox.cpp index ba65af24513238357c2e8dbbf484b5184d1044e5..a39a84d34e965753a91747f7d469a0f528ee801a 100644 --- a/module-gui/gui/widgets/ThreeBox.cpp +++ b/module-gui/gui/widgets/ThreeBox.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "ThreeBox.hpp" @@ -21,6 +21,7 @@ namespace gui {} template class HThreeBox; + template class HThreeBox; template class VThreeBox; } // namespace gui diff --git a/products/BellHybrid/apps/application-bell-onboarding/ApplicationBellOnBoarding.cpp b/products/BellHybrid/apps/application-bell-onboarding/ApplicationBellOnBoarding.cpp index a380145ebb241cafcee6e760f98fc36115bb3dec..70088dad118e6a0e2177bf42582989b767042a51 100644 --- a/products/BellHybrid/apps/application-bell-onboarding/ApplicationBellOnBoarding.cpp +++ b/products/BellHybrid/apps/application-bell-onboarding/ApplicationBellOnBoarding.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -21,6 +22,7 @@ #include #include #include +#include #include #include @@ -118,6 +120,13 @@ namespace app return std::make_unique(app, std::move(presenter), name); }); + windowsFactory.attach( + gui::window::name::onBoardingUpdateInstructionWindow, + [this](ApplicationCommon *app, const std::string &name) { + auto presenter = std::make_unique(this); + return std::make_unique(app, std::move(presenter), name); + }); + windowsFactory.attach( gui::window::name::onBoardingSettingsWindow, [this](ApplicationCommon *app, const std::string &name) { auto layoutModel = std::make_unique(this); @@ -290,11 +299,21 @@ namespace app else informationState = OnBoarding::InformationStates::RotateInfo; } + else if (window->getName() == gui::window::name::onBoardingUpdateInstructionWindow) { + const auto updateInstructionWindow = dynamic_cast(window); + if (updateInstructionWindow != nullptr && updateInstructionWindow->isLastLayout()) { + informationState = OnBoarding::InformationStates::RotateInfo; + } + else { + informationState = OnBoarding::InformationStates::LightClickInfo; + } + } else { informationState = OnBoarding::InformationStates::LightClickInfo; } } - else if (getCurrentWindow()->getName() != gui::window::name::onBoardingShortcutsWindow) { + else if (getCurrentWindow()->getName() != gui::window::name::onBoardingShortcutsWindow && + getCurrentWindow()->getName() != gui::window::name::onBoardingUpdateInstructionWindow) { if (inputEvent.isKeyRelease(gui::KeyCode::KEY_RIGHT) || inputEvent.isKeyRelease(gui::KeyCode::KEY_LEFT)) { informationState = OnBoarding::InformationStates::DeepClickWarningInfo; diff --git a/products/BellHybrid/apps/application-bell-onboarding/CMakeLists.txt b/products/BellHybrid/apps/application-bell-onboarding/CMakeLists.txt index 28ddc57610a48a6c97c7f5baf6d937cda575bdcf..a888cda8109e29c639b8dfc536075bd5d8c7035e 100644 --- a/products/BellHybrid/apps/application-bell-onboarding/CMakeLists.txt +++ b/products/BellHybrid/apps/application-bell-onboarding/CMakeLists.txt @@ -23,10 +23,12 @@ target_sources(application-bell-onboarding presenter/OnBoardingLanguageWindowPresenter.cpp presenter/OnBoardingFinalizeWindowPresenter.cpp presenter/OnBoardingShortcutsWindowPresenter.cpp + presenter/OnBoardingUpdateInstructionWindowPresenter.cpp presenter/OnBoardingLanguageWindowPresenter.hpp presenter/OnBoardingFinalizeWindowPresenter.hpp presenter/OnBoardingShortcutsWindowPresenter.hpp + presenter/OnBoardingUpdateInstructionWindowPresenter.hpp windows/OnBoardingLanguageWindow.hpp windows/OnBoardingOnOffWindow.hpp windows/OnBoardingSettingsWindow.hpp diff --git a/products/BellHybrid/apps/application-bell-onboarding/include/application-bell-onboarding/BellOnBoardingNames.hpp b/products/BellHybrid/apps/application-bell-onboarding/include/application-bell-onboarding/BellOnBoardingNames.hpp index 6db99f29325637ce1ea5813c40d3ce22f4554364..1e8d34cc9da82829e5d40bb37ecae695160f0c31 100644 --- a/products/BellHybrid/apps/application-bell-onboarding/include/application-bell-onboarding/BellOnBoardingNames.hpp +++ b/products/BellHybrid/apps/application-bell-onboarding/include/application-bell-onboarding/BellOnBoardingNames.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -12,12 +12,13 @@ namespace app namespace gui::window::name { - inline constexpr auto onBoardingOnOffWindow = "BellOnBoardingOnOff"; - inline constexpr auto onBoardingLanguageWindow = "BellOnBoardingLanguage"; - inline constexpr auto onBoardingShortcutsOptionWindow = "BellOnBoardingShortcutsOption"; - inline constexpr auto onBoardingShortcutsWindow = gui::window::name::shortcutsWindow; - inline constexpr auto onBoardingSettingsWindow = "BellOnBoardingSettings"; - inline constexpr auto finalizeOnBoardingWindow = "BellOnBoardingFinalize"; - inline constexpr auto informationOnBoardingWindow = "BellOnBoardingInformation"; + inline constexpr auto onBoardingOnOffWindow = "BellOnBoardingOnOff"; + inline constexpr auto onBoardingLanguageWindow = "BellOnBoardingLanguage"; + inline constexpr auto onBoardingShortcutsOptionWindow = "BellOnBoardingShortcutsOption"; + inline constexpr auto onBoardingShortcutsWindow = gui::window::name::shortcutsWindow; + inline constexpr auto onBoardingUpdateInstructionWindow = gui::window::name::updateInstructionWindow; + inline constexpr auto onBoardingSettingsWindow = "BellOnBoardingSettings"; + inline constexpr auto finalizeOnBoardingWindow = "BellOnBoardingFinalize"; + inline constexpr auto informationOnBoardingWindow = "BellOnBoardingInformation"; } // namespace gui::window::name diff --git a/products/BellHybrid/apps/application-bell-onboarding/presenter/OnBoardingUpdateInstructionWindowPresenter.cpp b/products/BellHybrid/apps/application-bell-onboarding/presenter/OnBoardingUpdateInstructionWindowPresenter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6826618608e6b35a7693e1aa57b3c73dec791665 --- /dev/null +++ b/products/BellHybrid/apps/application-bell-onboarding/presenter/OnBoardingUpdateInstructionWindowPresenter.cpp @@ -0,0 +1,57 @@ +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#include "OnBoardingUpdateInstructionWindowPresenter.hpp" +#include +#include +#include +#include +#include + +namespace app::OnBoarding +{ + OnBoardingUpdateInstructionWindowPresenter::OnBoardingUpdateInstructionWindowPresenter(app::ApplicationCommon *app) + : app(app) + { + initLayoutOptions(); + } + + std::vector OnBoardingUpdateInstructionWindowPresenter::getLayouts() const + { + return layoutOptions; + } + + gui::Item *OnBoardingUpdateInstructionWindowPresenter::getFirstLayout() const + { + return layoutOptions.empty() ? nullptr : layoutOptions.front(); + } + + bool OnBoardingUpdateInstructionWindowPresenter::isLastLayout(const gui::Item *layout) const + { + return !layoutOptions.empty() && layoutOptions.back() == layout; + } + + void OnBoardingUpdateInstructionWindowPresenter::initLayoutOptions() + { + const auto layoutsList = gui::factory::getUpdateInstructionLayouts(); + + for (auto &layoutEntry : layoutsList) { + layoutOptions.push_back(layoutEntry()->getLayout()); + } + } + + bool OnBoardingUpdateInstructionWindowPresenter::onInput(const gui::InputEvent &inputEvent, + const gui::Item *currentLayout) + { + if (inputEvent.isShortRelease()) { + const auto key = mapKey(inputEvent.getKeyCode()); + if (key == KeyMap::LightPress) { + if (isLastLayout(currentLayout)) { + app->switchWindow(gui::window::name::finalizeOnBoardingWindow); + } + return true; + } + } + return false; + } +} // namespace app::OnBoarding diff --git a/products/BellHybrid/apps/application-bell-onboarding/presenter/OnBoardingUpdateInstructionWindowPresenter.hpp b/products/BellHybrid/apps/application-bell-onboarding/presenter/OnBoardingUpdateInstructionWindowPresenter.hpp new file mode 100644 index 0000000000000000000000000000000000000000..4cd1bee6d6131c0d9995bdb2b3854e4ca1ef91bb --- /dev/null +++ b/products/BellHybrid/apps/application-bell-onboarding/presenter/OnBoardingUpdateInstructionWindowPresenter.hpp @@ -0,0 +1,29 @@ +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include +#include + +#include +#include + +namespace app::OnBoarding +{ + class OnBoardingUpdateInstructionWindowPresenter : public gui::UpdateInstructionWindowContract::Presenter + { + private: + app::ApplicationCommon *app; + std::vector layoutOptions; + void initLayoutOptions(); + + public: + explicit OnBoardingUpdateInstructionWindowPresenter(app::ApplicationCommon *app); + + std::vector getLayouts() const override; + bool isLastLayout(const gui::Item *layout) const override; + gui::Item *getFirstLayout() const override; + bool onInput(const gui::InputEvent &inputEvent, const gui::Item *currentLayout) override; + }; +} // namespace app::OnBoarding diff --git a/products/BellHybrid/apps/application-bell-onboarding/windows/OnBoardingSettingsWindow.cpp b/products/BellHybrid/apps/application-bell-onboarding/windows/OnBoardingSettingsWindow.cpp index 5f26a17788c42d9d50c6db0c8793c19b5151a28b..0e17abbf419b7366cdcd5629329023b90d6e561c 100644 --- a/products/BellHybrid/apps/application-bell-onboarding/windows/OnBoardingSettingsWindow.cpp +++ b/products/BellHybrid/apps/application-bell-onboarding/windows/OnBoardingSettingsWindow.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "OnBoardingSettingsWindow.hpp" @@ -12,7 +12,7 @@ namespace gui std::string name) : BellSettingsTimeUnitsWindow(app, std::move(windowPresenter), name) { - finishedCallback = [this]() { application->switchWindow(window::name::finalizeOnBoardingWindow); }; + finishedCallback = [this]() { application->switchWindow(window::name::onBoardingUpdateInstructionWindow); }; returnCallback = [this]() { application->switchWindow(window::name::onBoardingShortcutsOptionWindow); }; } } // namespace gui diff --git a/products/BellHybrid/apps/common/CMakeLists.txt b/products/BellHybrid/apps/common/CMakeLists.txt index da0435179c70184b3066f6e0a14e5f0ca350b35a..b8eb195387971579563573357ff89d6d222799f0 100644 --- a/products/BellHybrid/apps/common/CMakeLists.txt +++ b/products/BellHybrid/apps/common/CMakeLists.txt @@ -37,6 +37,7 @@ target_sources(application-bell-common src/windows/BellBatteryStatusWindow.cpp src/windows/AppsBatteryStatusWindow.cpp src/windows/AudioErrorWindow.cpp + src/windows/UpdateInstructionWindow.cpp src/models/SettingsModel.cpp src/models/BedtimeModel.cpp @@ -87,6 +88,8 @@ target_sources(application-bell-common src/layouts/HomeScreenLayoutVerticalWithDate.cpp src/layouts/ShortcutsLayouts.cpp src/layouts/ShortcutsLayoutClassic.cpp + src/layouts/UpdateInstructionLayouts.cpp + src/layouts/UpdateInstructionLayoutClassic.cpp PUBLIC include/common/BellListItemProvider.hpp @@ -104,6 +107,8 @@ target_sources(application-bell-common include/common/windows/BellBatteryStatusWindow.hpp include/common/windows/AppsBatteryStatusWindow.hpp include/common/windows/AudioErrorWindow.hpp + include/common/windows/UpdateInstructionWindowContract.hpp + include/common/windows/UpdateInstructionWindow.hpp include/common/TimeUtils.hpp include/common/data/BatteryUtils.hpp @@ -173,6 +178,9 @@ target_sources(application-bell-common include/common/layouts/ShortcutsLayouts.hpp include/common/layouts/ShortcutsLayoutProvider.hpp include/common/layouts/ShortcutsLayoutClassic.hpp + include/common/layouts/UpdateInstructionLayouts.hpp + include/common/layouts/UpdateInstructionLayoutProvider.hpp + include/common/layouts/UpdateInstructionLayoutClassic.hpp ) target_link_libraries(application-bell-common diff --git a/products/BellHybrid/apps/common/include/common/BellCommonNames.hpp b/products/BellHybrid/apps/common/include/common/BellCommonNames.hpp index 84c25a06a1f1a4fb3d0f76ad9105490044d0511b..a6eef75d444a428d6294b55177eac4bb4833ceac 100644 --- a/products/BellHybrid/apps/common/include/common/BellCommonNames.hpp +++ b/products/BellHybrid/apps/common/include/common/BellCommonNames.hpp @@ -5,6 +5,7 @@ namespace gui::window::name { - inline constexpr auto shortcutsWindow = "BellShortcuts"; - inline constexpr auto audioErrorWindow = "AudioError"; + inline constexpr auto shortcutsWindow = "BellShortcuts"; + inline constexpr auto updateInstructionWindow = "BellUpdateInstruction"; + inline constexpr auto audioErrorWindow = "AudioError"; } // namespace gui::window::name diff --git a/products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayoutClassic.hpp b/products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayoutClassic.hpp new file mode 100644 index 0000000000000000000000000000000000000000..c8c2a420b717c36adcea4eca365667d4e4a5f580 --- /dev/null +++ b/products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayoutClassic.hpp @@ -0,0 +1,45 @@ +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include "UpdateInstructionLayoutProvider.hpp" + +#include +#include + +namespace gui +{ + class BellBaseLayout; + + using Instruction = std::vector>; + + class UpdateInstructionLayoutClassic : public UpdateInstructionLayoutProvider, VBox + { + public: + UpdateInstructionLayoutClassic(const UTF8 &image, + const UTF8 &title, + const Instruction &instruction, + bool leftArrowVisible = true, + bool rightArrowVisible = true); + + auto getLayout() -> Item * override; + + private: + struct InstructionPoint + { + HBox *container; + Text *textBox; + Text *numberBox; + }; + std::vector instructionPoints; + + ImageBox *leftArrowBox; + ImageBox *rightArrowBox; + + Text *titleBox; + ImageBox *imageBox; + + void buildInterface(const Instruction &instruction); + }; +}; // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayoutProvider.hpp b/products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayoutProvider.hpp new file mode 100644 index 0000000000000000000000000000000000000000..393d315757cbc26622f7ef5941dbe5b837013461 --- /dev/null +++ b/products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayoutProvider.hpp @@ -0,0 +1,30 @@ +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include + +namespace gui +{ + class Item; + + class UpdateInstructionLayoutProvider + { + protected: + const UTF8 image; + const UTF8 title; + const bool leftArrowVisible; + const bool rightArrowVisible; + + public: + UpdateInstructionLayoutProvider(const UTF8 &image, + const UTF8 &title, + bool leftArrow = true, + bool rightArrow = true) + : image{image}, title{title}, leftArrowVisible{leftArrow}, rightArrowVisible{rightArrow} {}; + virtual ~UpdateInstructionLayoutProvider() noexcept = default; + + virtual Item *getLayout() = 0; + }; +}; // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayouts.hpp b/products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayouts.hpp new file mode 100644 index 0000000000000000000000000000000000000000..3d4e3f63829890ec95eba76d6d29196198fb1f27 --- /dev/null +++ b/products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayouts.hpp @@ -0,0 +1,19 @@ +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include +#include +#include + +namespace gui +{ + class UpdateInstructionLayoutProvider; + using LayoutGenerator = std::function; + + namespace factory + { + std::vector getUpdateInstructionLayouts(); + } // namespace factory +}; // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/windows/UpdateInstructionWindow.hpp b/products/BellHybrid/apps/common/include/common/windows/UpdateInstructionWindow.hpp new file mode 100644 index 0000000000000000000000000000000000000000..03a1c5a30b47acf6f522235cc8b665ae40000eee --- /dev/null +++ b/products/BellHybrid/apps/common/include/common/windows/UpdateInstructionWindow.hpp @@ -0,0 +1,32 @@ +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include "UpdateInstructionWindowContract.hpp" +#include +#include +#include + +namespace gui +{ + class SideListView; + class UpdateInstructionWindow : public AppWindow, public UpdateInstructionWindowContract::View + { + std::unique_ptr presenter; + SideListView *sideListView = nullptr; + WidgetSpinner *spinner = nullptr; + + bool onInput(const gui::InputEvent &inputEvent) override; + void buildInterface() override; + + void onValueChanged(const std::uint32_t currentValue); + + public: + UpdateInstructionWindow(app::ApplicationCommon *app, + std::unique_ptr &&presenter, + const std::string &name); + + bool isLastLayout() const; + }; +} // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/windows/UpdateInstructionWindowContract.hpp b/products/BellHybrid/apps/common/include/common/windows/UpdateInstructionWindowContract.hpp new file mode 100644 index 0000000000000000000000000000000000000000..82940557253162efa98b21902660c8a61d5585ea --- /dev/null +++ b/products/BellHybrid/apps/common/include/common/windows/UpdateInstructionWindowContract.hpp @@ -0,0 +1,30 @@ +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include +#include +#include + +namespace gui +{ + class UpdateInstructionWindowContract + { + public: + class View + { + public: + virtual ~View() = default; + }; + + class Presenter : public app::BasePresenter + { + public: + virtual std::vector getLayouts() const = 0; + virtual bool isLastLayout(const gui::Item *layout) const = 0; + virtual gui::Item *getFirstLayout() const = 0; + virtual bool onInput(const gui::InputEvent &inputEvent, const gui::Item *currentLayout) = 0; + }; + }; +} // namespace gui diff --git a/products/BellHybrid/apps/common/src/layouts/UpdateInstructionLayoutClassic.cpp b/products/BellHybrid/apps/common/src/layouts/UpdateInstructionLayoutClassic.cpp new file mode 100644 index 0000000000000000000000000000000000000000..13776e2d1c601b835317aa6ec6c1da4685d256c9 --- /dev/null +++ b/products/BellHybrid/apps/common/src/layouts/UpdateInstructionLayoutClassic.cpp @@ -0,0 +1,187 @@ +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#include "layouts/UpdateInstructionLayoutClassic.hpp" +#include +#include +#include +#include + +namespace +{ + namespace container + { + constexpr auto width = 544U; + constexpr auto height = 436U; + constexpr auto top_margin = 20U; + + namespace centerBox + { + constexpr auto width = 448U; + constexpr auto height = container::height; + } // namespace centerBox + + namespace imageBox + { + constexpr auto width = centerBox::width; + constexpr auto height = 120U; + } // namespace imageBox + + namespace title + { + constexpr auto height = 56U; + constexpr auto width = centerBox::width; + constexpr auto font = style::window::font::large; + constexpr auto bottom_margin = 32U; + } // namespace title + + namespace instruction + { + constexpr auto maxNumberOfLines = 3; + constexpr auto width = centerBox::width - 40U; + constexpr auto minHeight = 43U; + constexpr auto maxHeight = minHeight * maxNumberOfLines; + constexpr auto bottom_margin = 14U; + + namespace number + { + constexpr auto width = 36U; + constexpr auto font = style::window::font::verybiglight; + } // namespace number + + namespace text + { + constexpr auto width = instruction::width - number::width; + constexpr auto font = style::window::font::verybiglight; + } // namespace text + } // namespace instruction + + } // namespace container +} // namespace + +namespace gui +{ + UpdateInstructionLayoutClassic::UpdateInstructionLayoutClassic(const UTF8 &image, + const UTF8 &title, + const Instruction &instruction, + bool leftArrowVisible, + bool rightArrowVisible) + : UpdateInstructionLayoutProvider(image, title, leftArrowVisible, rightArrowVisible), + VBox(nullptr, 0, 0, style::bell_base_layout::w, style::bell_base_layout::h) + { + buildInterface(instruction); + } + + void UpdateInstructionLayoutClassic::buildInterface(const Instruction &instruction) + { + setAlignment(Alignment::Horizontal::Center); + + auto containerThreeBox = new HThreeBox(this); + containerThreeBox->setMinimumSize(container::width, container::height); + containerThreeBox->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center)); + containerThreeBox->setMargins(Margins(0, container::top_margin, 0, 0)); + containerThreeBox->setEdges(RectangleEdge::None); + + // -------------------------- left box ------------------------------------------- + containerThreeBox->firstBox = new HBox(containerThreeBox); + containerThreeBox->firstBox->setAlignment(Alignment(Alignment::Vertical::Center)); + containerThreeBox->firstBox->setEdges(RectangleEdge::None); + containerThreeBox->firstBox->activeItem = false; + + leftArrowBox = new ImageBox(nullptr, new Image("bell_arrow_left_W_M")); + leftArrowBox->setAlignment(Alignment(Alignment::Horizontal::Right, Alignment::Vertical::Center)); + leftArrowBox->setMinimumSizeToFitImage(); + leftArrowBox->setVisible(leftArrowVisible); + leftArrowBox->setEdges(RectangleEdge::None); + containerThreeBox->firstBox->setMinimumSize(leftArrowBox->widgetMinimumArea.w, + leftArrowBox->widgetMinimumArea.h); + + containerThreeBox->firstBox->addWidget(leftArrowBox); + + // -------------------------- center box ------------------------------------------- + containerThreeBox->centerBox = new VBox(containerThreeBox); + containerThreeBox->centerBox->setEdges(RectangleEdge::None); + containerThreeBox->centerBox->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Top)); + containerThreeBox->centerBox->setMinimumSize(container::centerBox::width, container::centerBox::height); + containerThreeBox->centerBox->setMaximumSize(container::centerBox::width, container::centerBox::height); + + imageBox = new ImageBox(nullptr, new Image(image, ImageTypeSpecifier::W_G)); + imageBox->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Top)); + imageBox->setMinimumSizeToFitImage(); + imageBox->setMaximumSize(container::imageBox::width, container::imageBox::height); + imageBox->setVisible(true); + + titleBox = new Text(nullptr, 0, 0, 0, 0); + titleBox->setMinimumSize(container::title::width, container::title::height); + titleBox->setMaximumSize(container::title::width, container::title::height); + titleBox->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Top)); + titleBox->setMargins(Margins(0, 0, 0, container::title::bottom_margin)); + titleBox->setTextType(TextType::SingleLine); + titleBox->setEditMode(EditMode::Browse); + titleBox->setFont(container::title::font); + titleBox->setRichText(utils::translate(title)); + + containerThreeBox->centerBox->addWidget(imageBox); + containerThreeBox->centerBox->addWidget(titleBox); + + for (const auto &point : instruction) { + auto instructionContainer = new HBox(nullptr); + instructionContainer->setEdges(RectangleEdge::None); + instructionContainer->setAlignment(Alignment(Alignment::Horizontal::Left, Alignment::Vertical::Top)); + instructionContainer->setMargins(Margins(0, 0, 0, container::instruction::bottom_margin)); + instructionContainer->setMinimumSize(container::instruction::width, container::instruction::minHeight); + instructionContainer->setMaximumSize(container::instruction::width, container::instruction::maxHeight); + + auto numberBox = new Text(nullptr, 0, 0, 0, 0); + numberBox->setMinimumSize(container::instruction::number::width, container::instruction::minHeight); + numberBox->setAlignment(Alignment::Horizontal::Left); + numberBox->setTextType(TextType::MultiLine); + numberBox->setEditMode(EditMode::Browse); + numberBox->setFont(container::instruction::number::font); + numberBox->setRichText(point.first); + + auto textBox = new Text(nullptr, 0, 0, 0, 0); + textBox->setMinimumSize(container::instruction::text::width, container::instruction::minHeight); + textBox->setMaximumSize(container::instruction::text::width, container::instruction::maxHeight); + textBox->setAlignment(Alignment::Horizontal::Left); + textBox->setTextType(TextType::MultiLine); + textBox->setEditMode(EditMode::Browse); + textBox->setFont(container::instruction::text::font); + textBox->setRichText(utils::translate(point.second)); + + InstructionPoint instructionPoint{.container = std::move(instructionContainer), + .textBox = std::move(textBox), + .numberBox = std::move(numberBox)}; + instructionPoints.push_back(std::move(instructionPoint)); + } + + for (const auto &point : instructionPoints) { + point.container->addWidget(point.numberBox); + point.container->addWidget(point.textBox); + containerThreeBox->centerBox->addWidget(point.container); + } + + // -------------------------- right box ------------------------------------------- + containerThreeBox->lastBox = new HBox(containerThreeBox); + containerThreeBox->lastBox->setAlignment(Alignment(Alignment::Vertical::Center)); + containerThreeBox->lastBox->setEdges(RectangleEdge::None); + containerThreeBox->lastBox->activeItem = false; + + rightArrowBox = new ImageBox(nullptr, new Image("bell_arrow_right_W_M")); + rightArrowBox->setAlignment(Alignment(Alignment::Horizontal::Left, Alignment::Vertical::Center)); + rightArrowBox->setMinimumSizeToFitImage(); + rightArrowBox->setVisible(rightArrowVisible); + rightArrowBox->setEdges(RectangleEdge::None); + containerThreeBox->lastBox->setMinimumSize(rightArrowBox->widgetMinimumArea.w, + rightArrowBox->widgetMinimumArea.h); + + containerThreeBox->lastBox->addWidget(rightArrowBox); + + this->resizeItems(); + } + + auto UpdateInstructionLayoutClassic::getLayout() -> Item * + { + return this; + } +}; // namespace gui diff --git a/products/BellHybrid/apps/common/src/layouts/UpdateInstructionLayouts.cpp b/products/BellHybrid/apps/common/src/layouts/UpdateInstructionLayouts.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9d4882837f8ceb637eda251582eb0c6249dc5ef2 --- /dev/null +++ b/products/BellHybrid/apps/common/src/layouts/UpdateInstructionLayouts.cpp @@ -0,0 +1,24 @@ +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#include "layouts/UpdateInstructionLayouts.hpp" +#include "layouts/UpdateInstructionLayoutClassic.hpp" + +namespace gui::factory +{ + std::vector getUpdateInstructionLayouts() + { + return {{[]() { + const Instruction instructions{{"1.", "app_bell_update_instruction_1st_point"}, + {"2.", "app_bell_update_instruction_2nd_point"}}; + return new UpdateInstructionLayoutClassic( + "bell_mudita_logo", "app_bell_update_instruction_title", instructions, false, true); + }}, + {[]() { + const Instruction instructions{{"3.", "app_bell_update_instruction_3rd_point"}, + {"4.", "app_bell_update_instruction_4th_point"}}; + return new UpdateInstructionLayoutClassic( + "bell_mudita_logo", "app_bell_update_instruction_title", instructions, true, false); + }}}; + } +} // namespace gui::factory diff --git a/products/BellHybrid/apps/common/src/windows/UpdateInstructionWindow.cpp b/products/BellHybrid/apps/common/src/windows/UpdateInstructionWindow.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1ceb303c4b4c86fe84e4791936c3e76475f27628 --- /dev/null +++ b/products/BellHybrid/apps/common/src/windows/UpdateInstructionWindow.cpp @@ -0,0 +1,64 @@ +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#include "windows/UpdateInstructionWindow.hpp" + +#include +#include +#include + +namespace gui +{ + UpdateInstructionWindow::UpdateInstructionWindow( + app::ApplicationCommon *app, + std::unique_ptr &&presenter, + const std::string &name) + : AppWindow(app, name), presenter{std::move(presenter)} + { + this->presenter->attach(this); + buildInterface(); + } + + void UpdateInstructionWindow::buildInterface() + { + AppWindow::buildInterface(); + + statusBar->setVisible(false); + header->setTitleVisibility(false); + navBar->setVisible(false); + + auto layouts = presenter->getLayouts(); + spinner = new WidgetSpinner(this, {layouts.begin(), layouts.end()}, Boundaries::Fixed); + spinner->setSize(style::window_width, style::window_height); + spinner->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center)); + spinner->setFocusEdges(RectangleEdge::None); + auto selectedLayout = presenter->getFirstLayout(); + spinner->setCurrentValue(selectedLayout); + + spinner->onValueChanged = [this](const auto &) { + getApplication()->render(gui::RefreshModes::GUI_REFRESH_DEEP); + }; + + setFocusItem(spinner); + } + + bool UpdateInstructionWindow::isLastLayout() const + { + auto currentLayout = spinner->getCurrentValue(); + return presenter->isLastLayout(currentLayout); + } + + bool UpdateInstructionWindow::onInput(const gui::InputEvent &inputEvent) + { + if (spinner->onInput(inputEvent)) { + return true; + } + + if (presenter->onInput(inputEvent, spinner->getCurrentValue())) { + return true; + } + + return AppWindow::onInput(inputEvent); + } + +} // namespace gui