From 1f9c6b4a5174aab1e88ac5f3bba1e1bc791eb207 Mon Sep 17 00:00:00 2001 From: Maciej-Mudita Date: Wed, 12 Oct 2022 17:48:45 +0200 Subject: [PATCH] [MOS-26] Add tethering info on status bar When tethering is on, info appears in the status bar and network coverage indicates "no connection" --- image/assets/lang/Deutsch.json | 1 + image/assets/lang/English.json | 1 + image/assets/lang/Espanol.json | 1 + image/assets/lang/Francais.json | 1 + image/assets/lang/Polski.json | 1 + image/assets/lang/Svenska.json | 1 + .../ApplicationDesktop.hpp | 3 +- .../windows/DesktopMainWindow.cpp | 1 + module-apps/apps-common/ApplicationCommon.cpp | 8 +++ module-apps/apps-common/ApplicationCommon.hpp | 1 + .../locks/windows/LockInputWindow.cpp | 3 +- .../popups/TetheringNotificationPopup.cpp | 3 +- .../popups/data/TetheringParams.hpp | 27 ++++++++++ .../lock-popups/PhoneLockInputWindow.cpp | 1 + .../lock-popups/PhoneLockedInfoWindow.cpp | 1 + .../popups/lock-popups/PhoneLockedWindow.cpp | 1 + module-apps/apps-common/windows/AppWindow.cpp | 9 ++++ module-apps/apps-common/windows/AppWindow.hpp | 1 + module-gui/gui/widgets/CMakeLists.txt | 1 + module-gui/gui/widgets/StatusBar.cpp | 52 ++++++++++++++++++- module-gui/gui/widgets/StatusBar.hpp | 27 ++++++++++ .../widgets/status-bar/SignalStrengthBar.cpp | 11 ++-- .../widgets/status-bar/SignalStrengthBar.hpp | 6 ++- .../widgets/status-bar/SignalStrengthBase.hpp | 6 ++- .../widgets/status-bar/SignalStrengthText.cpp | 5 +- .../widgets/status-bar/SignalStrengthText.hpp | 5 +- module-gui/gui/widgets/status-bar/Style.hpp | 7 ++- .../gui/widgets/status-bar/Tethering.cpp | 23 ++++++++ .../gui/widgets/status-bar/Tethering.hpp | 26 ++++++++++ .../include/service-appmgr/Actions.hpp | 1 + .../service-cellular/ServiceCellular.cpp | 2 + module-utils/EventStore/EventStore.cpp | 10 ++++ module-utils/EventStore/EventStore.hpp | 12 ++++- products/PurePhone/apps/Application.cpp | 1 + .../services/appmgr/ApplicationManager.cpp | 14 +++++ .../services/appmgr/RunAppsInBackground.cpp | 2 + .../include/appmgr/ApplicationManager.hpp | 1 + pure_changelog.md | 1 + 38 files changed, 260 insertions(+), 18 deletions(-) create mode 100644 module-apps/apps-common/popups/data/TetheringParams.hpp create mode 100644 module-gui/gui/widgets/status-bar/Tethering.cpp create mode 100644 module-gui/gui/widgets/status-bar/Tethering.hpp diff --git a/image/assets/lang/Deutsch.json b/image/assets/lang/Deutsch.json index b35d2ae80c43bdbcb0f38c16aab29251da6efd46..8421305b62691360b138edf8cb0cb8c013b09fa9 100644 --- a/image/assets/lang/Deutsch.json +++ b/image/assets/lang/Deutsch.json @@ -622,6 +622,7 @@ "app_desktop_update_success": "MuditaOS wurde erfolgreich auf Version $VERSION aktualisiert.", "app_call_private_number": "Private Nummer", "app_call_ending_call": "Anruf wird beendet", + "statusbar_tethering": "TETHERING", "tethering": "Tethering", "tethering_turn_off_question": "Tethering ausschalten?", "tethering_enable_question": "Sie sind mit dem Computer verbunden.
Tethering einschalten?
(einige Funktionen können deaktiviert sein)
", diff --git a/image/assets/lang/English.json b/image/assets/lang/English.json index 619d8480301d489e9fe8d266441fa89b7b783bae..c75b924ce835f5c863c5f623d49622ce666de387 100644 --- a/image/assets/lang/English.json +++ b/image/assets/lang/English.json @@ -595,6 +595,7 @@ "app_desktop_update_success": "MuditaOS has been updated to ver. $VERSION succesfully.", "app_call_private_number": "Private number", "app_call_ending_call": "Disconnecting call", + "statusbar_tethering": "TETHERING", "tethering": "Tethering", "tethering_turn_off_question": "Turn tethering off?", "tethering_enable_question": "You're connected to the computer.
Turn tethering on?
(some functions may be disabled)
", diff --git a/image/assets/lang/Espanol.json b/image/assets/lang/Espanol.json index 2ead680184a7c6ba7774f0d11db32735d6fe0053..ebbd93a2abe9b25ff88276786deab599c4bd025d 100644 --- a/image/assets/lang/Espanol.json +++ b/image/assets/lang/Espanol.json @@ -623,6 +623,7 @@ "app_desktop_update_success": "El SO de MuditaOS se ha actualizado a la ver. $VERSION correctamente.", "app_call_private_number": "Número privado", "app_call_ending_call": "Desconectando llamada", + "statusbar_tethering": "ANCLAJE DE RED", "tethering": "Anclaje de red", "tethering_turn_off_question": "¿Desactivar el anclaje de red?", "tethering_enable_question": "Estás conectado al ordenador.
¿Activar el anclaje de red?
(algunas funciones podrían desactivarse)
", diff --git a/image/assets/lang/Francais.json b/image/assets/lang/Francais.json index f6fd096d58fbab182284e6092cfd13a666d9788f..21eeadda87ce644f29809ec3c587eacab577564a 100644 --- a/image/assets/lang/Francais.json +++ b/image/assets/lang/Francais.json @@ -590,6 +590,7 @@ "app_desktop_update_success": "La mise à jour de MuditaOS à la version $VERSION a été effectuée avec succès.", "app_call_private_number": "Numéro privé", "app_call_ending_call": "Déconnexion de l'appel", + "statusbar_tethering": "MODE MODEM", "tethering": "Partage de connexion", "tethering_turn_off_question": "Voulez-vous désactiver le partage de connexion?", "tethering_enable_question": "Vous êtes connecté à l'ordinateur.
Voulez-vous activer le partage de connexion?
(certaines fonctions peuvent être désactivées)
", diff --git a/image/assets/lang/Polski.json b/image/assets/lang/Polski.json index 8b68e50d15370bc5e5eef75903867c89d55355ae..695ef5997efed9af17801983962e87c62d730e59 100644 --- a/image/assets/lang/Polski.json +++ b/image/assets/lang/Polski.json @@ -639,6 +639,7 @@ "app_desktop_update_success": "System MuditaOS został pomyślnie zaktualizowany do wer. $VERSION.", "app_call_private_number": "Numer prywatny", "app_call_ending_call": "Kończenie połączenia", + "statusbar_tethering": "TETHERING", "tethering": "Tethering", "tethering_turn_off_question": "Wyłączyć tethering?", "tethering_enable_question": "Połączono z komputerem.
Włączyć tethering?
(Niektóre funkcje mogą być niedostępne)
", diff --git a/image/assets/lang/Svenska.json b/image/assets/lang/Svenska.json index 753e32406e6835762c0aa04f550cb3a72d2e0a62..1fd432a26e06b452b9f7ecc333e2e8f620127e6d 100644 --- a/image/assets/lang/Svenska.json +++ b/image/assets/lang/Svenska.json @@ -524,6 +524,7 @@ "app_desktop_update_unpacking": "Packar upp", "app_call_private_number": "Dolt nummer", "app_call_ending_call": "Avslutar samtalet", + "statusbar_tethering": "INTERNETDELNING", "tethering": "Internetdelning", "tethering_turn_off_question": "Stänga av Internetdelning?", "tethering_enable_question": "Du är ansluten till datorn.
Slå på Internetdelning?
(vissa funktioner kan vara inaktiverade)
", diff --git a/module-apps/application-desktop/include/application-desktop/ApplicationDesktop.hpp b/module-apps/application-desktop/include/application-desktop/ApplicationDesktop.hpp index a2ad5f3971f7c0334bd87d78fc09b4c12ed9e814..62afc34bfb344f8d0c7e9843a9b6dfe36f1d53f4 100644 --- a/module-apps/application-desktop/include/application-desktop/ApplicationDesktop.hpp +++ b/module-apps/application-desktop/include/application-desktop/ApplicationDesktop.hpp @@ -65,7 +65,8 @@ namespace app manager::actions::PhoneModeChanged, manager::actions::BluetoothModeChanged, manager::actions::NotificationsChanged, - manager::actions::AlarmClockStatusChanged}}; + manager::actions::AlarmClockStatusChanged, + manager::actions::TetheringStateChanged}}; } }; diff --git a/module-apps/application-desktop/windows/DesktopMainWindow.cpp b/module-apps/application-desktop/windows/DesktopMainWindow.cpp index 7ce129a6eb254e0da29871dc5361bc2f33250c5d..8754126c2cc41c799bd977ee75f14012b223003e 100644 --- a/module-apps/application-desktop/windows/DesktopMainWindow.cpp +++ b/module-apps/application-desktop/windows/DesktopMainWindow.cpp @@ -74,6 +74,7 @@ namespace gui appConfiguration.enable(status_bar::Indicator::SimCard); appConfiguration.enable(status_bar::Indicator::Bluetooth); appConfiguration.enable(status_bar::Indicator::AlarmClock); + appConfiguration.enable(status_bar::Indicator::Tethering); return appConfiguration; } diff --git a/module-apps/apps-common/ApplicationCommon.cpp b/module-apps/apps-common/ApplicationCommon.cpp index 3fcc44d98e2b50433ca60a9129953e876a21651b..86e0449526cea43737cf3852c379148cad158af9 100644 --- a/module-apps/apps-common/ApplicationCommon.cpp +++ b/module-apps/apps-common/ApplicationCommon.cpp @@ -27,6 +27,7 @@ #include #include +#include #if DEBUG_INPUT_EVENTS == 1 #define debug_input_events(...) LOG_DEBUG(__VA_ARGS__) @@ -119,6 +120,13 @@ namespace app } return actionHandled(); }); + addActionReceiver(app::manager::actions::TetheringStateChanged, [this](auto &¶ms) { + if (params != nullptr) { + auto modeParams = static_cast(params.get()); + this->statusIndicators.tetheringState = modeParams->getTetheringState(); + } + return actionHandled(); + }); addActionReceiver(app::manager::actions::BluetoothModeChanged, [this](auto &¶ms) { if (params != nullptr) { auto modeParams = static_cast(params.get()); diff --git a/module-apps/apps-common/ApplicationCommon.hpp b/module-apps/apps-common/ApplicationCommon.hpp index c88bc59dfc3d063ad3cc147c1458c8e528b64899..8c3b669d4804a913624fca47d7704b7229ea0b1a 100644 --- a/module-apps/apps-common/ApplicationCommon.hpp +++ b/module-apps/apps-common/ApplicationCommon.hpp @@ -125,6 +125,7 @@ namespace app { public: sys::phone_modes::PhoneMode phoneMode = sys::phone_modes::PhoneMode::Uninitialized; + sys::phone_modes::Tethering tetheringState = sys::phone_modes::Tethering::Off; sys::bluetooth::BluetoothMode bluetoothMode = sys::bluetooth::BluetoothMode::Disabled; bool alarmClockStatus = false; }; diff --git a/module-apps/apps-common/locks/windows/LockInputWindow.cpp b/module-apps/apps-common/locks/windows/LockInputWindow.cpp index 0ad74e84f4189bc9978c5c3820998c96093deb4b..dde62b0a1cbb880b692f2e1e6cb841958f9155f2 100644 --- a/module-apps/apps-common/locks/windows/LockInputWindow.cpp +++ b/module-apps/apps-common/locks/windows/LockInputWindow.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "LockInputWindow.hpp" @@ -113,6 +113,7 @@ namespace gui appConfiguration.enable(status_bar::Indicator::SimCard); appConfiguration.enable(status_bar::Indicator::Bluetooth); appConfiguration.enable(status_bar::Indicator::AlarmClock); + appConfiguration.enable(status_bar::Indicator::Tethering); return appConfiguration; } diff --git a/module-apps/apps-common/popups/TetheringNotificationPopup.cpp b/module-apps/apps-common/popups/TetheringNotificationPopup.cpp index 5824948d1511f21c2bb0660c4bb17c031be7d88c..b1e71c0a3b83e4f5af527591e7fa74b7fedb5981 100644 --- a/module-apps/apps-common/popups/TetheringNotificationPopup.cpp +++ b/module-apps/apps-common/popups/TetheringNotificationPopup.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "TetheringNotificationPopup.hpp" @@ -20,6 +20,7 @@ namespace gui appConfiguration.setIndicator(gui::status_bar::Indicator::Battery, true); appConfiguration.setIndicator(gui::status_bar::Indicator::SimCard, false); appConfiguration.setIndicator(gui::status_bar::Indicator::Signal, true); + appConfiguration.setIndicator(gui::status_bar::Indicator::Tethering, true); return appConfiguration; } } // namespace gui diff --git a/module-apps/apps-common/popups/data/TetheringParams.hpp b/module-apps/apps-common/popups/data/TetheringParams.hpp new file mode 100644 index 0000000000000000000000000000000000000000..61505107399d991ae28b769ba2e03778b1a35289 --- /dev/null +++ b/module-apps/apps-common/popups/data/TetheringParams.hpp @@ -0,0 +1,27 @@ +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include "popups/Popups.hpp" + +#include +#include + +namespace gui +{ + class TetheringParams : public app::manager::actions::ActionParams + { + public: + explicit TetheringParams(sys::phone_modes::Tethering state) : tetheringState{state} + {} + + [[nodiscard]] auto getTetheringState() const noexcept + { + return tetheringState; + } + + private: + sys::phone_modes::Tethering tetheringState; + }; +} // namespace gui diff --git a/module-apps/apps-common/popups/lock-popups/PhoneLockInputWindow.cpp b/module-apps/apps-common/popups/lock-popups/PhoneLockInputWindow.cpp index f84a887c62205e7b17ed912fe7f30bf37d77868c..f9950d97e37f03428a1a61b674380eb201f03d2d 100644 --- a/module-apps/apps-common/popups/lock-popups/PhoneLockInputWindow.cpp +++ b/module-apps/apps-common/popups/lock-popups/PhoneLockInputWindow.cpp @@ -44,6 +44,7 @@ namespace gui appConfiguration.enable(status_bar::Indicator::SimCard); appConfiguration.enable(status_bar::Indicator::Bluetooth); appConfiguration.enable(status_bar::Indicator::AlarmClock); + appConfiguration.enable(status_bar::Indicator::Tethering); } else { appConfiguration.enable(status_bar::Indicator::Time); diff --git a/module-apps/apps-common/popups/lock-popups/PhoneLockedInfoWindow.cpp b/module-apps/apps-common/popups/lock-popups/PhoneLockedInfoWindow.cpp index 06356aeb0ca885a16df140dd0f03d00862719ac6..e45233f092ffdc53f496c1f13610cc48144040a7 100644 --- a/module-apps/apps-common/popups/lock-popups/PhoneLockedInfoWindow.cpp +++ b/module-apps/apps-common/popups/lock-popups/PhoneLockedInfoWindow.cpp @@ -101,6 +101,7 @@ status_bar::Configuration PhoneLockedInfoWindow::configureStatusBar(status_bar:: appConfiguration.enable(status_bar::Indicator::Signal); appConfiguration.enable(status_bar::Indicator::Bluetooth); appConfiguration.enable(status_bar::Indicator::AlarmClock); + appConfiguration.enable(status_bar::Indicator::Tethering); return appConfiguration; } diff --git a/module-apps/apps-common/popups/lock-popups/PhoneLockedWindow.cpp b/module-apps/apps-common/popups/lock-popups/PhoneLockedWindow.cpp index 8708b7e8bc14b2c1a30a8cda9cc1b14ca07cbc2c..aa88399464071b2f28fe88958a09d1b95903b129 100644 --- a/module-apps/apps-common/popups/lock-popups/PhoneLockedWindow.cpp +++ b/module-apps/apps-common/popups/lock-popups/PhoneLockedWindow.cpp @@ -150,6 +150,7 @@ namespace gui appConfiguration.disable(status_bar::Indicator::SimCard); appConfiguration.enable(status_bar::Indicator::Bluetooth); appConfiguration.enable(status_bar::Indicator::AlarmClock); + appConfiguration.enable(status_bar::Indicator::Tethering); return appConfiguration; } diff --git a/module-apps/apps-common/windows/AppWindow.cpp b/module-apps/apps-common/windows/AppWindow.cpp index 4ad373e69c764692d3b5d556d046476920cebed9..499de41c83974ad19e1c9f23fdc8539ac114b72f 100644 --- a/module-apps/apps-common/windows/AppWindow.cpp +++ b/module-apps/apps-common/windows/AppWindow.cpp @@ -134,6 +134,15 @@ namespace gui applyToStatusBar(std::move(fn)); } + bool AppWindow::updateTethering(const sys::phone_modes::Tethering state) + { + if (statusBar == nullptr) { + return false; + } + + return statusBar->updateTetheringState(state); + } + bool AppWindow::preventsAutoLocking() const noexcept { return preventsAutoLock; diff --git a/module-apps/apps-common/windows/AppWindow.hpp b/module-apps/apps-common/windows/AppWindow.hpp index 61453215bba477ef770d2143660b7093d151757e..a2a1986d3dccd5e641e6e6e1059cb73096052605 100644 --- a/module-apps/apps-common/windows/AppWindow.hpp +++ b/module-apps/apps-common/windows/AppWindow.hpp @@ -72,6 +72,7 @@ namespace gui bool updateSignalStrength(); bool updateNetworkAccessTechnology(); void updatePhoneMode(sys::phone_modes::PhoneMode mode); + bool updateTethering(const sys::phone_modes::Tethering state); [[nodiscard]] bool preventsAutoLocking() const noexcept; virtual RefreshModes updateTime(); diff --git a/module-gui/gui/widgets/CMakeLists.txt b/module-gui/gui/widgets/CMakeLists.txt index 1d76edd1b37c6ed3f297d770783b4f106eb947a5..b23e4a709ed9c0f80680facbf1af392bc8e031cb 100644 --- a/module-gui/gui/widgets/CMakeLists.txt +++ b/module-gui/gui/widgets/CMakeLists.txt @@ -41,6 +41,7 @@ target_sources( ${PROJECT_NAME} "${CMAKE_CURRENT_LIST_DIR}/status-bar/SignalStrengthText.cpp" "${CMAKE_CURRENT_LIST_DIR}/status-bar/NetworkAccessTechnology.cpp" "${CMAKE_CURRENT_LIST_DIR}/status-bar/PhoneMode.cpp" + "${CMAKE_CURRENT_LIST_DIR}/status-bar/Tethering.cpp" "${CMAKE_CURRENT_LIST_DIR}/status-bar/Time.cpp" "${CMAKE_CURRENT_LIST_DIR}/status-bar/Lock.cpp" "${CMAKE_CURRENT_LIST_DIR}/Style.cpp" diff --git a/module-gui/gui/widgets/StatusBar.cpp b/module-gui/gui/widgets/StatusBar.cpp index 1ffd0447aa0a08fb68e26b5296027f99c27d662a..98a459868b9e11f9f99abb3466864d4b5e6f050a 100644 --- a/module-gui/gui/widgets/StatusBar.cpp +++ b/module-gui/gui/widgets/StatusBar.cpp @@ -13,6 +13,7 @@ #include "status-bar/SignalStrengthText.hpp" #include "status-bar/NetworkAccessTechnology.hpp" #include "status-bar/PhoneMode.hpp" +#include "status-bar/Tethering.hpp" #include "status-bar/AlarmClock.hpp" #include "status-bar/BT.hpp" #include "status-bar/SIM.hpp" @@ -87,6 +88,16 @@ namespace gui::status_bar return mAlarmClockStatus; } + void Configuration::setTetheringState(sys::phone_modes::Tethering tetheringState) + { + mTetheringState = tetheringState; + } + + auto Configuration::getTetheringState() const noexcept -> sys::phone_modes::Tethering + { + return mTetheringState; + } + auto Configuration::isEnabled(Indicator indicator) const -> bool { return indicatorStatuses.at(indicator); @@ -135,6 +146,10 @@ namespace gui::status_bar phoneMode->setMaximumSize(phonemode::maxX, this->drawArea.h); phoneMode->setMargins(gui::Margins(margins::between, 0, 0, margins::textBottom)); phoneMode->setAlignment(Alignment(Alignment::Horizontal::Left, Alignment::Vertical::Bottom)); + tethering = new Tethering(leftBox, 0, 0, 0, 0); + tethering->setMaximumSize(tethering::maxX, this->drawArea.h); + tethering->setMargins(gui::Margins(margins::between, 0, 0, margins::textBottom)); + tethering->setAlignment(Alignment(Alignment::Horizontal::Left, Alignment::Vertical::Bottom)); // center centralBox = new HBox(this, 0, 0, 0, 0); @@ -241,6 +256,9 @@ namespace gui::status_bar case Indicator::PhoneMode: showPhoneMode(enabled); break; + case Indicator::Tethering: + showTethering(enabled); + break; } } @@ -338,7 +356,8 @@ namespace gui::status_bar { const auto signalStrength = Store::GSM::get()->getSignalStrength(); const auto networkStatus = Store::GSM::get()->getNetwork().status; - signal->update(signalStrength, networkStatus); + const auto tethering = Store::GSM::get()->getTethering(); + signal->update(signalStrength, networkStatus, tethering); enabled ? signal->show() : signal->hide(); } @@ -362,7 +381,19 @@ namespace gui::status_bar void StatusBar::showPhoneMode(bool enabled) { - enabled ? phoneMode->show() : phoneMode->hide(); + showPhoneModeOrTethering(enabled, configuration.isEnabled(Indicator::Tethering)); + } + + void StatusBar::showPhoneModeOrTethering(bool phoneModeEnabled, bool tetheringEnabled) + { + if (tetheringEnabled && configuration.getTetheringState() != sys::phone_modes::Tethering::Off) { + phoneMode->hide(); + tethering->show(); + } + else { + tethering->hide(); + phoneModeEnabled ? phoneMode->show() : phoneMode->hide(); + } } bool StatusBar::updateNetworkAccessTechnology() @@ -416,6 +447,23 @@ namespace gui::status_bar return showTime(configuration.isEnabled(Indicator::Time)); } + bool StatusBar::updateTetheringState(const sys::phone_modes::Tethering state) + { + if (tethering == nullptr) { + return false; + } + configuration.setTetheringState(state); + showTethering(configuration.isEnabled(Indicator::Tethering)); + leftBox->resizeItems(); + + return true; + } + + void StatusBar::showTethering(bool enabled) + { + showPhoneModeOrTethering(configuration.isEnabled(Indicator::PhoneMode), enabled); + } + void StatusBar::accept(GuiVisitor &visitor) { visitor.visit(*this); diff --git a/module-gui/gui/widgets/StatusBar.hpp b/module-gui/gui/widgets/StatusBar.hpp index 93f17d40c90510b524ead28cc6e2b6c0cf1bc62a..4b722bebb1e4ad581318fe851f4ed3a13d82a55a 100644 --- a/module-gui/gui/widgets/StatusBar.hpp +++ b/module-gui/gui/widgets/StatusBar.hpp @@ -27,6 +27,7 @@ namespace gui class SIM; class Time; class Lock; + class Tethering; } // namespace status_bar } // namespace gui @@ -48,6 +49,7 @@ namespace gui::status_bar NetworkAccessTechnology, /// NAT (eg 3G, 4G, LTE) PhoneMode, /// phone mode AlarmClock, /// alarm clock active + Tethering, /// tethering status }; using Indicators = std::vector; @@ -87,6 +89,10 @@ namespace gui::status_bar /// @param alarmClockStatus desired alarm clock status void setAlarmClockStatus(bool alarmClockStatus); + /// Set tethering state + /// @param tetheringState desired tethering state + void setTetheringState(sys::phone_modes::Tethering tetheringState); + /// Set a configuration modifier to the specified indicator /// @param indicator indicator type /// @param config desired indicator's configuration @@ -104,6 +110,10 @@ namespace gui::status_bar /// @return alarm clock status [[nodiscard]] auto getAlarmClockStatus() const noexcept -> bool; + /// Get the tethering state configuration + /// @return tethering state + [[nodiscard]] auto getTetheringState() const noexcept -> sys::phone_modes::Tethering; + /// Check if the specified indicator is enabled /// @param indicator indicator to be checked /// @return indicator status @@ -129,6 +139,7 @@ namespace gui::status_bar {Indicator::SimCard, false}, {Indicator::NetworkAccessTechnology, false}, {Indicator::AlarmClock, false}, + {Indicator::Tethering, false}, }; /// Phone mode @@ -140,6 +151,9 @@ namespace gui::status_bar /// Alarm Clock status bool mAlarmClockStatus = false; + /// Tethering state + sys::phone_modes::Tethering mTetheringState = sys::phone_modes::Tethering::Off; + /// Indicator modifiers: IndicatorsModifiers indicatorsModifiers; }; @@ -192,6 +206,9 @@ namespace gui::status_bar /// Update NAT widget state depending on the current configuration bool updateNetworkAccessTechnology(); + /// Update tethering widget state depending on the current configuration + bool updateTetheringState(const sys::phone_modes::Tethering state); + /// Accepts GuiVisitor to update the status bar void accept(GuiVisitor &visitor) override; @@ -236,6 +253,13 @@ namespace gui::status_bar /// @param enabled true to show false to hide the widget void showNetworkAccessTechnology(bool enabled); + /// Show/hide tethering state widget + /// @param enabled true to show false to hide the widget + void showTethering(bool enabled); + + /// Show/hide phone mode or tethering widget + void showPhoneModeOrTethering(bool phoneModeEnabled, bool tetheringEnabled); + /// Sets the status of the specified indicator on the Status bar /// @param indicator indicator id /// @param enabled enable or disable the specified indicator @@ -273,6 +297,9 @@ namespace gui::status_bar /// Pointer to widget with battery status BatteryBase *battery = nullptr; + /// Pointer to widget with tethering state + Tethering *tethering = nullptr; + /// Pointer to the left horizontal box HBox *leftBox = nullptr; diff --git a/module-gui/gui/widgets/status-bar/SignalStrengthBar.cpp b/module-gui/gui/widgets/status-bar/SignalStrengthBar.cpp index 4617e1bfb5f9ec4708961978e10388ed17d10eee..3013534264311bef08143aa1c0e0e01a96ebce11 100644 --- a/module-gui/gui/widgets/status-bar/SignalStrengthBar.cpp +++ b/module-gui/gui/widgets/status-bar/SignalStrengthBar.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "SignalStrengthBar.hpp" @@ -47,7 +47,9 @@ namespace gui::status_bar setMinimumSize(img->getWidth(), style::status_bar::height); } - void SignalStrengthBar::update(const Store::SignalStrength &signal, const Store::Network::Status &status) + void SignalStrengthBar::update(const Store::SignalStrength &signal, + const Store::Network::Status &status, + const Store::Tethering &tethering) { try { if (img == nullptr) { @@ -55,7 +57,10 @@ namespace gui::status_bar return; } - if (status == Store::Network::Status::RegisteredRoaming) { + if (tethering == Store::Tethering::On) { + img->set(signal_none, style::status_bar::imageTypeSpecifier); + } + else if (status == Store::Network::Status::RegisteredRoaming) { img->set(signalMapRoaming.at(signal.rssiBar), style::status_bar::imageTypeSpecifier); } else if (status == Store::Network::Status::RegisteredHomeNetwork) { diff --git a/module-gui/gui/widgets/status-bar/SignalStrengthBar.hpp b/module-gui/gui/widgets/status-bar/SignalStrengthBar.hpp index bac070a971f0fb65c967d7c34ed508149e769696..f3a86b1158d76e8a09878f25010d96846ce884be 100644 --- a/module-gui/gui/widgets/status-bar/SignalStrengthBar.hpp +++ b/module-gui/gui/widgets/status-bar/SignalStrengthBar.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -15,7 +15,9 @@ namespace gui::status_bar { public: SignalStrengthBar(Item *parent, uint32_t x, uint32_t y, uint32_t w, uint32_t h); - void update(const Store::SignalStrength &signal, const Store::Network::Status &status) override; + void update(const Store::SignalStrength &signal, + const Store::Network::Status &status, + const Store::Tethering &tethering) override; private: Image *img = nullptr; diff --git a/module-gui/gui/widgets/status-bar/SignalStrengthBase.hpp b/module-gui/gui/widgets/status-bar/SignalStrengthBase.hpp index 0d1a7c7105a1ba42b7d94208a26d3fb349b81ffe..694b44a203178e270d68f108da2339b3fa316dd6 100644 --- a/module-gui/gui/widgets/status-bar/SignalStrengthBase.hpp +++ b/module-gui/gui/widgets/status-bar/SignalStrengthBase.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -13,6 +13,8 @@ namespace gui::status_bar { public: SignalStrengthBase(Item *parent, uint32_t x, uint32_t y, uint32_t w, uint32_t h); - virtual void update(const Store::SignalStrength &signal, const Store::Network::Status &status) = 0; + virtual void update(const Store::SignalStrength &signal, + const Store::Network::Status &status, + const Store::Tethering &tethering) = 0; }; } // namespace gui::status_bar diff --git a/module-gui/gui/widgets/status-bar/SignalStrengthText.cpp b/module-gui/gui/widgets/status-bar/SignalStrengthText.cpp index 0a0f46eb1d40a51e07d2b7f150eb5ec85d454392..0d0c09dfae3bfa26cc6ac5fec8287e424b0e0585 100644 --- a/module-gui/gui/widgets/status-bar/SignalStrengthText.cpp +++ b/module-gui/gui/widgets/status-bar/SignalStrengthText.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "SignalStrengthText.hpp" @@ -23,7 +23,8 @@ namespace gui::status_bar } void SignalStrengthText::update(const Store::SignalStrength &signal, - [[maybe_unused]] const Store::Network::Status &status) + [[maybe_unused]] const Store::Network::Status &status, + [[maybe_unused]] const Store::Tethering &tethering) { label->setText(utils::to_string(signal.rssidBm) + " dBm"); } diff --git a/module-gui/gui/widgets/status-bar/SignalStrengthText.hpp b/module-gui/gui/widgets/status-bar/SignalStrengthText.hpp index 08314316084a7ad76a58253d1e4f234adf05b4d9..df9bb16e1e8c91ee43e575d7109f9cd7faa30ada 100644 --- a/module-gui/gui/widgets/status-bar/SignalStrengthText.hpp +++ b/module-gui/gui/widgets/status-bar/SignalStrengthText.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -17,7 +17,8 @@ namespace gui::status_bar public: SignalStrengthText(Item *parent, uint32_t x, uint32_t y, uint32_t w, uint32_t h); void update(const Store::SignalStrength &signal, - [[maybe_unused]] const Store::Network::Status &status) override; + [[maybe_unused]] const Store::Network::Status &status, + [[maybe_unused]] const Store::Tethering &tethering) override; private: Label *label = nullptr; diff --git a/module-gui/gui/widgets/status-bar/Style.hpp b/module-gui/gui/widgets/status-bar/Style.hpp index 1da96077b5e4b600444e287bd88854e8cb9279b8..582e2b02ee6627d2d8a1ee24ee411a1dc42f3664 100644 --- a/module-gui/gui/widgets/status-bar/Style.hpp +++ b/module-gui/gui/widgets/status-bar/Style.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -35,6 +35,11 @@ namespace style::status_bar inline constexpr auto maxX = 157u; inline constexpr auto font = style::window::font::verysmall; }; // namespace phonemode + namespace tethering + { + inline constexpr auto maxX = 180u; + inline constexpr auto font = style::window::font::verysmall; + }; // namespace tethering namespace signal { inline constexpr auto font = style::window::font::verysmall; diff --git a/module-gui/gui/widgets/status-bar/Tethering.cpp b/module-gui/gui/widgets/status-bar/Tethering.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e7913f05410a8c1a07d328472823d71b06f1c349 --- /dev/null +++ b/module-gui/gui/widgets/status-bar/Tethering.cpp @@ -0,0 +1,23 @@ +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#include "Tethering.hpp" + +#include +#include + +#include "Item.hpp" +#include "Style.hpp" + +namespace gui::status_bar +{ + Tethering::Tethering(Item *parent, std::uint32_t x, std::uint32_t y, std::uint32_t w, std::uint32_t h) + : StatusBarWidgetBase(parent, x, y, w, h) + { + setEdges(RectangleEdge::None); + setFont(style::status_bar::tethering::font); + setTextEllipsisType(TextEllipsis::Right); + setText(utils::translate("statusbar_tethering")); + setAlignment(gui::Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center)); + } +} // namespace gui::status_bar diff --git a/module-gui/gui/widgets/status-bar/Tethering.hpp b/module-gui/gui/widgets/status-bar/Tethering.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d372fabeac926cfacf63cfb2e1498f52da678c28 --- /dev/null +++ b/module-gui/gui/widgets/status-bar/Tethering.hpp @@ -0,0 +1,26 @@ +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include "StatusBarWidgetBase.hpp" +#include +#include + +namespace gui::status_bar +{ + /// widget drawn on the status bar showing current tethering state: + class Tethering : public StatusBarWidgetBase