mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
Merge branch 'upsilon-dev-usb-protection' into upsilon-dev
This commit is contained in:
@@ -138,7 +138,7 @@ bool AppsContainer::dispatchEvent(Ion::Events::Event event) {
|
||||
Ion::LED::updateColorWithPlugAndCharge();
|
||||
}
|
||||
if (event == Ion::Events::USBEnumeration) {
|
||||
if (Ion::USB::isPlugged()) {
|
||||
if (Ion::USB::isPlugged() && GlobalPreferences::sharedGlobalPreferences()->getDfuLevel() != 3) {
|
||||
App::Snapshot * activeSnapshot = (s_activeApp == nullptr ? appSnapshotAtIndex(0) : s_activeApp->snapshot());
|
||||
/* Just after a software update, the battery timer does not have time to
|
||||
* fire before the calculator enters DFU mode. As the DFU mode blocks the
|
||||
@@ -147,7 +147,8 @@ bool AppsContainer::dispatchEvent(Ion::Events::Event event) {
|
||||
* pictogram. */
|
||||
updateBatteryState();
|
||||
if (switchTo(usbConnectedAppSnapshot())) {
|
||||
Ion::USB::DFU();
|
||||
Ion::USB::DFU(true, GlobalPreferences::sharedGlobalPreferences()->dfuStatus(), GlobalPreferences::sharedGlobalPreferences()->getDfuLevel());
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuStatus(false);
|
||||
// Update LED when exiting DFU mode
|
||||
Ion::LED::updateColorWithPlugAndCharge();
|
||||
bool switched = switchTo(activeSnapshot);
|
||||
|
||||
@@ -30,6 +30,10 @@ public:
|
||||
void setTempExamMode(ExamMode examMode);
|
||||
bool showPopUp() const { return m_showPopUp; }
|
||||
void setShowPopUp(bool showPopUp) { m_showPopUp = showPopUp; }
|
||||
bool dfuStatus() const { return m_dfuUnlocked; }
|
||||
void setDfuStatus(bool status) { m_dfuUnlocked = status; }
|
||||
int getDfuLevel() const { return m_dfuProtectLevel; }
|
||||
void setDfuLevel(int level) { m_dfuProtectLevel = level; }
|
||||
bool autocomplete() const { return m_autoComplete; }
|
||||
void setAutocomplete(bool autocomple) { m_autoComplete = autocomple; }
|
||||
int brightnessLevel() const { return m_brightnessLevel; }
|
||||
@@ -37,6 +41,7 @@ public:
|
||||
const KDFont * font() const { return m_font; }
|
||||
void setFont(const KDFont * font) { m_font = font; }
|
||||
constexpr static int NumberOfBrightnessStates = 15;
|
||||
constexpr static int DfuUnlockStep = 3;
|
||||
private:
|
||||
static_assert(I18n::NumberOfLanguages > 0, "I18n::NumberOfLanguages is not superior to 0"); // There should already have been an error when processing an empty EPSILON_I18N flag
|
||||
static_assert(I18n::NumberOfCountries > 0, "I18n::NumberOfCountries is not superior to 0"); // There should already have been an error when processing an empty EPSILON_COUNTRIES flag
|
||||
@@ -46,6 +51,8 @@ private:
|
||||
m_examMode(ExamMode::Unknown),
|
||||
m_tempExamMode(ExamMode::Standard),
|
||||
m_showPopUp(true),
|
||||
m_dfuUnlocked(false),
|
||||
m_dfuProtectLevel(0),
|
||||
m_autoComplete(true),
|
||||
m_brightnessLevel(Ion::Backlight::MaxBrightness),
|
||||
m_font(KDFont::LargeFont) {}
|
||||
@@ -56,9 +63,9 @@ private:
|
||||
mutable ExamMode m_examMode;
|
||||
mutable ExamMode m_tempExamMode;
|
||||
bool m_showPopUp;
|
||||
bool m_dfuUnlocked;
|
||||
bool m_autoComplete;
|
||||
int m_brightnessLevel;
|
||||
const KDFont * m_font;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,3 +2,5 @@ Apps = "Anwendungen"
|
||||
AppsCapital = "UPSILON"
|
||||
ForbidenAppInExamMode1 = "Diese Anwendung ist im"
|
||||
ForbidenAppInExamMode2 = "Prüfungsmodus nicht erlaubt."
|
||||
DfuWarning1 = "DFU-Schutzwarnung"
|
||||
DfuWarning2 = "Mehr Informationen: bit.ly/upsiDfu"
|
||||
|
||||
@@ -2,3 +2,5 @@ Apps = "Applications"
|
||||
AppsCapital = "UPSILON"
|
||||
ForbidenAppInExamMode1 = "This application is"
|
||||
ForbidenAppInExamMode2 = "forbidden in exam mode"
|
||||
DfuWarning1 = "DFU Protection Warning"
|
||||
DfuWarning2 = "More informations: bit.ly/upsiDfu"
|
||||
|
||||
@@ -2,3 +2,5 @@ Apps = "Aplicaciones"
|
||||
AppsCapital = "UPSILON"
|
||||
ForbidenAppInExamMode1 = "Esta aplicación está prohibida"
|
||||
ForbidenAppInExamMode2 = "en el modo de examen"
|
||||
DfuWarning1 = "Advertencia de protección DFU"
|
||||
DfuWarning2 = "Más información: bit.ly/upsiDfu"
|
||||
|
||||
@@ -2,3 +2,5 @@ Apps = "Applications"
|
||||
AppsCapital = "UPSILON"
|
||||
ForbidenAppInExamMode1 = "Cette application n'est"
|
||||
ForbidenAppInExamMode2 = "pas autorisée en mode examen."
|
||||
DfuWarning1 = "Alerte protection DFU"
|
||||
DfuWarning2 = "Plus d'infos: bit.ly/upsiDfu"
|
||||
|
||||
@@ -2,3 +2,5 @@ Apps = "Alkalmazások"
|
||||
AppsCapital = "UPSILON"
|
||||
ForbidenAppInExamMode1 = "Ez az alkalmazás"
|
||||
ForbidenAppInExamMode2 = "tilos vizsga módban"
|
||||
DfuWarning1 = "DFU védelmi figyelmeztetés"
|
||||
DfuWarning2 = "További információk: bit.ly/upsiDfu"
|
||||
|
||||
@@ -2,3 +2,5 @@ Apps = "Applicazioni"
|
||||
AppsCapital = "UPSILON"
|
||||
ForbidenAppInExamMode1 = "Questa applicazione è"
|
||||
ForbidenAppInExamMode2 = "proibita nella modalità d'esame"
|
||||
DfuWarning1 = "Avviso protezione DFU"
|
||||
DfuWarning2 = "Più informazioni: bit.ly/upsiDfu"
|
||||
|
||||
@@ -2,3 +2,5 @@ Apps = "Applicaties"
|
||||
AppsCapital = "UPSILON"
|
||||
ForbidenAppInExamMode1 = "Deze applicatie is"
|
||||
ForbidenAppInExamMode2 = "uitgesloten in examenstand"
|
||||
DfuWarning1 = "DFU-beveiligingswaarschuwing"
|
||||
DfuWarning2 = "Meer informatie: bit.ly/upsiDfu"
|
||||
|
||||
@@ -2,3 +2,5 @@ Apps = "Aplicações"
|
||||
AppsCapital = "UPSILON"
|
||||
ForbidenAppInExamMode1 = "Esta aplicação é"
|
||||
ForbidenAppInExamMode2 = "proibida no Modo de Exame"
|
||||
DfuWarning1 = "Aviso de proteção DFU"
|
||||
DfuWarning2 = "Mais informações: bit.ly/upsiDfu"
|
||||
|
||||
@@ -87,9 +87,33 @@ Controller::Controller(Responder * parentResponder, SelectableTableViewDataSourc
|
||||
}
|
||||
|
||||
bool Controller::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::Six) {
|
||||
GlobalPreferences::sharedGlobalPreferences()->dfuIncreaseStep();
|
||||
if (GlobalPreferences::sharedGlobalPreferences()->dfuCurrentStep() >= GlobalPreferences::DfuUnlockStep && !GlobalPreferences::sharedGlobalPreferences()->dfuStatus()) {
|
||||
if (!GlobalPreferences::sharedGlobalPreferences()->isInExamMode()) {
|
||||
Ion::LED::setColor(KDColorPurple);
|
||||
Ion::LED::setBlinking(500, 0.5f);
|
||||
}
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuStatus(true);
|
||||
App::app()->displayWarning(I18n::Message::DfuWarning1, I18n::Message::DfuWarning2);
|
||||
return true;
|
||||
} else if (GlobalPreferences::sharedGlobalPreferences()->dfuStatus()) {
|
||||
if (!GlobalPreferences::sharedGlobalPreferences()->isInExamMode()) {
|
||||
Ion::LED::setColor(KDColorBlack);
|
||||
}
|
||||
GlobalPreferences::sharedGlobalPreferences()->dfuResetStep();
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuStatus(false);
|
||||
}
|
||||
}
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
|
||||
AppsContainer * container = AppsContainer::sharedAppsContainer();
|
||||
|
||||
if (!GlobalPreferences::sharedGlobalPreferences()->isInExamMode()) {
|
||||
Ion::LED::setColor(KDColorBlack);
|
||||
}
|
||||
GlobalPreferences::sharedGlobalPreferences()->dfuResetStep();
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuStatus(false);
|
||||
|
||||
int index = selectionDataSource()->selectedRow()*k_numberOfColumns+selectionDataSource()->selectedColumn()+1;
|
||||
#ifdef HOME_DISPLAY_EXTERNALS
|
||||
if (index >= container->numberOfApps()) {
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 9.8 KiB |
@@ -25,6 +25,8 @@ app_settings_src = $(addprefix apps/settings/,\
|
||||
sub_menu/contributors_controller.cpp \
|
||||
sub_menu/math_options_controller.cpp \
|
||||
sub_menu/selectable_view_with_messages.cpp \
|
||||
sub_menu/usb_info_controller.cpp \
|
||||
sub_menu/usb_protection_level_controller.cpp \
|
||||
)
|
||||
|
||||
SFLAGS += -DOMEGA_STATE="$(OMEGA_STATE)"
|
||||
|
||||
@@ -69,3 +69,11 @@ Date = "Datum"
|
||||
Time = "Uhrzeit"
|
||||
RTCWarning1 = "Das Aktivieren der Uhr verkürzt die"
|
||||
RTCWarning2 = "Akkulaufzeit im Bereitschaftsmodus."
|
||||
USBExplanation1= "USB-Schutz schützt Ihren"
|
||||
USBExplanation2= "Taschenrechner vor"
|
||||
USBExplanation3= "unbeabsichtigter Verriegelung"
|
||||
USBProtection= "USB-Schutz"
|
||||
USBLevelProtect = "Akzeptierte Updates"
|
||||
USBDefaultLevel = "Basierend auf Upsilon"
|
||||
USBLowLevel = "Basierend auf Omega"
|
||||
USBParanoidLevel = "Nichts"
|
||||
|
||||
@@ -69,3 +69,11 @@ Date = "Date"
|
||||
Time = "Time"
|
||||
RTCWarning1 = "Enabling the clock drains the battery faster"
|
||||
RTCWarning2 = "when the calculator is powered off."
|
||||
USBExplanation1= "The USB protection protects"
|
||||
USBExplanation2= "the calculator from"
|
||||
USBExplanation3= "unintentional locking"
|
||||
USBProtection= "USB Protection"
|
||||
USBLevelProtect = "Updates accepted"
|
||||
USBDefaultLevel = "Based on Upsilon"
|
||||
USBLowLevel = "Based on Omega"
|
||||
USBParanoidLevel = "None"
|
||||
|
||||
@@ -69,3 +69,11 @@ Date = "Fecha"
|
||||
Time = "Hora"
|
||||
RTCWarning1 = "Activar el reloj gasta la batería más rápido"
|
||||
RTCWarning2 = "cuando la calculadora está apagada."
|
||||
USBExplanation1= "La protección USB protege"
|
||||
USBExplanation2= "su calculadora del"
|
||||
USBExplanation3= "bloqueo involuntario"
|
||||
USBProtection= "Protección USB"
|
||||
USBLevelProtect = "Actualizaciones aceptadas"
|
||||
USBDefaultLevel = "Basado en Upsilon"
|
||||
USBLowLevel = "Basado en Omega"
|
||||
USBParanoidLevel = "Ninguno"
|
||||
|
||||
@@ -69,3 +69,11 @@ Date = "Date"
|
||||
Time = "Heure"
|
||||
RTCWarning1 = "Activer l'horloge décharge la batterie plus"
|
||||
RTCWarning2 = "vite quand la calculatrice est éteinte."
|
||||
USBExplanation1= "La protection USB protège votre"
|
||||
USBExplanation2= "calculatrice contre un verrouillage"
|
||||
USBExplanation3= "non-intentionnel"
|
||||
USBProtection= "Protection USB"
|
||||
USBLevelProtect = "Mise à jour acceptées"
|
||||
USBDefaultLevel = "Basées sur Upsilon"
|
||||
USBLowLevel = "Basées sur Omega"
|
||||
USBParanoidLevel = "Aucune"
|
||||
|
||||
@@ -69,3 +69,12 @@ Date = "Datum"
|
||||
Time = "Óra"
|
||||
RTCWarning1 = "Amikor a számológép alvómódban van, az óra"
|
||||
RTCWarning2 = "használása az elemet gyorsabban meríti ki."
|
||||
USBExplanation1= "Az USB-védelem megvédi"
|
||||
USBExplanation2= "a számológépet a nem"
|
||||
USBExplanation3= "szándékos reteszeléstől"
|
||||
USBProtection= "USB védelem"
|
||||
USBLevelProtect = "Elfogadott frissítések"
|
||||
USBDefaultLevel = "Upsilon alapján"
|
||||
USBLowLevel = "Omega alapján"
|
||||
USBParanoidLevel = "Egyik sem"
|
||||
|
||||
|
||||
@@ -69,3 +69,11 @@ Date = "Date"
|
||||
Time = "Time"
|
||||
RTCWarning1 = "Enabling the clock drains the battery faster"
|
||||
RTCWarning2 = "when the calculator is powered off."
|
||||
USBExplanation1= "La protezione USB protegge"
|
||||
USBExplanation2= "la calcolatrice dal"
|
||||
USBExplanation3= "blocco involontario"
|
||||
USBProtection= "Protezione USB"
|
||||
USBLevelProtect = "Aggiornamenti accettati"
|
||||
USBDefaultLevel = "Basato su Upsilon"
|
||||
USBLowLevel = "A base di Omega"
|
||||
USBParanoidLevel = "Nessuno"
|
||||
|
||||
@@ -69,3 +69,11 @@ Date = "Date"
|
||||
Time = "Time"
|
||||
RTCWarning1 = "Enabling the clock drains the battery faster"
|
||||
RTCWarning2 = "when the calculator is powered off."
|
||||
USBExplanation1= "USB-beveiliging beschermt uw"
|
||||
USBExplanation2= "rekenmachine tegen"
|
||||
USBExplanation3= "onbedoelde vergrendeling"
|
||||
USBProtection= "USB-beveiliging"
|
||||
USBLevelProtect = "Updates geaccepteerd"
|
||||
USBDefaultLevel = "Gebaseerd op Upsilon"
|
||||
USBLowLevel = "Op basis van Omega"
|
||||
USBParanoidLevel = "Geen"
|
||||
|
||||
@@ -69,3 +69,11 @@ Date = "Date"
|
||||
Time = "Time"
|
||||
RTCWarning1 = "Enabling the clock drains the battery faster"
|
||||
RTCWarning2 = "when the calculator is powered off."
|
||||
USBExplanation1= "A proteção USB protege"
|
||||
USBExplanation2= "sua calculadora contra"
|
||||
USBExplanation3= "bloqueios não intencionais"
|
||||
USBProtection= "Proteção USB"
|
||||
USBLevelProtect = "Atualizações aceitas"
|
||||
USBDefaultLevel = "Baseado em Upsilon"
|
||||
USBLowLevel = "Baseado em Ômega"
|
||||
USBParanoidLevel = "Nenhum"
|
||||
|
||||
4
apps/settings/base.universal.i18n
Normal file
4
apps/settings/base.universal.i18n
Normal file
@@ -0,0 +1,4 @@
|
||||
UsbSetting = "USB"
|
||||
USBDefaultLevelDesc = "L0"
|
||||
USBLowLevelDesc = "L1"
|
||||
USBParanoidLevelDesc = "L2"
|
||||
@@ -15,6 +15,8 @@ constexpr SettingsMessageTree s_modelFloatDisplayModeChildren[4] = {SettingsMess
|
||||
constexpr SettingsMessageTree s_modelComplexFormatChildren[3] = {SettingsMessageTree(I18n::Message::Real), SettingsMessageTree(I18n::Message::Cartesian), SettingsMessageTree(I18n::Message::Polar)};
|
||||
constexpr SettingsMessageTree s_modelDateTimeChildren[3] = {SettingsMessageTree(I18n::Message::ActivateClock), SettingsMessageTree(I18n::Message::Date), SettingsMessageTree(I18n::Message::Time)};
|
||||
constexpr SettingsMessageTree s_symbolChildren[4] = {SettingsMessageTree(I18n::Message::SymbolMultiplicationCross),SettingsMessageTree(I18n::Message::SymbolMultiplicationMiddleDot),SettingsMessageTree(I18n::Message::SymbolMultiplicationStar),SettingsMessageTree(I18n::Message::SymbolMultiplicationAutoSymbol)};
|
||||
constexpr SettingsMessageTree s_usbLevelSelector[3] = {SettingsMessageTree(I18n::Message::USBDefaultLevel), SettingsMessageTree(I18n::Message::USBLowLevel), SettingsMessageTree(I18n::Message::USBParanoidLevel)};
|
||||
constexpr SettingsMessageTree s_usbSteps[2] = {SettingsMessageTree(I18n::Message::USBProtection), SettingsMessageTree(I18n::Message::USBLevelProtect, s_usbLevelSelector)};
|
||||
constexpr SettingsMessageTree s_symbolFunctionChildren[3] = {SettingsMessageTree(I18n::Message::SymbolDefaultFunction), SettingsMessageTree(I18n::Message::SymbolArgDefaultFunction), SettingsMessageTree(I18n::Message::SymbolArgFunction)};
|
||||
constexpr SettingsMessageTree s_modelMathOptionsChildren[6] = {SettingsMessageTree(I18n::Message::AngleUnit, s_modelAngleChildren), SettingsMessageTree(I18n::Message::DisplayMode, s_modelFloatDisplayModeChildren), SettingsMessageTree(I18n::Message::EditionMode, s_modelEditionModeChildren), SettingsMessageTree(I18n::Message::SymbolFunction, s_symbolFunctionChildren), SettingsMessageTree(I18n::Message::ComplexFormat, s_modelComplexFormatChildren), SettingsMessageTree(I18n::Message::SymbolMultiplication, s_symbolChildren)};
|
||||
constexpr SettingsMessageTree s_accessibilityChildren[6] = {SettingsMessageTree(I18n::Message::AccessibilityInvertColors), SettingsMessageTree(I18n::Message::AccessibilityMagnify),SettingsMessageTree(I18n::Message::AccessibilityGamma),SettingsMessageTree(I18n::Message::AccessibilityGammaRed),SettingsMessageTree(I18n::Message::AccessibilityGammaGreen),SettingsMessageTree(I18n::Message::AccessibilityGammaBlue)};
|
||||
@@ -41,7 +43,8 @@ MainController::MainController(Responder * parentResponder, InputEventHandlerDel
|
||||
m_codeOptionsController(this),
|
||||
m_examModeController(this),
|
||||
m_aboutController(this),
|
||||
m_preferencesController(this)
|
||||
m_preferencesController(this),
|
||||
m_usbInfoController(this)
|
||||
{
|
||||
for (int i = 0; i < k_numberOfSimpleChevronCells; i++) {
|
||||
m_cells[i].setMessageFont(KDFont::LargeFont);
|
||||
@@ -111,6 +114,8 @@ bool MainController::handleEvent(Ion::Events::Event event) {
|
||||
subController = &m_dateTimeController;
|
||||
} else if (title == I18n::Message::MathOptions) {
|
||||
subController = &m_mathOptionsController;
|
||||
} else if (title == I18n::Message::UsbSetting) {
|
||||
subController = &m_usbInfoController;
|
||||
} else if (title == I18n::Message::CodeApp) {
|
||||
subController = &m_codeOptionsController;
|
||||
} else {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "sub_menu/localization_controller.h"
|
||||
#include "sub_menu/math_options_controller.h"
|
||||
#include "sub_menu/preferences_controller.h"
|
||||
#include "sub_menu/usb_info_controller.h"
|
||||
|
||||
namespace Settings {
|
||||
|
||||
@@ -28,6 +29,8 @@ extern const Shared::SettingsMessageTree s_modelDateTimeChildren[3];
|
||||
extern const Shared::SettingsMessageTree s_accessibilityChildren[6];
|
||||
extern const Shared::SettingsMessageTree s_contributorsChildren[23];
|
||||
extern const Shared::SettingsMessageTree s_modelAboutChildren[9];
|
||||
extern const Shared::SettingsMessageTree s_usbLevelSelector[3];
|
||||
extern const Shared::SettingsMessageTree s_usbSteps[2];
|
||||
extern const Shared::SettingsMessageTree s_model;
|
||||
|
||||
class MainController : public ViewController, public ListViewDataSource, public SelectableTableViewDataSource {
|
||||
@@ -76,6 +79,7 @@ private:
|
||||
ExamModeController m_examModeController;
|
||||
AboutController m_aboutController;
|
||||
PreferencesController m_preferencesController;
|
||||
UsbInfoController m_usbInfoController;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ constexpr SettingsMessageTree s_modelMenu[] =
|
||||
#endif
|
||||
SettingsMessageTree(I18n::Message::BetaPopUp),
|
||||
SettingsMessageTree(I18n::Message::About, s_modelAboutChildren),
|
||||
SettingsMessageTree(I18n::Message::UsbSetting, s_usbSteps),
|
||||
SettingsMessageTree(I18n::Message::Accessibility, s_accessibilityChildren)};
|
||||
|
||||
constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu);
|
||||
|
||||
@@ -1,28 +1,30 @@
|
||||
#include "main_controller.h"
|
||||
#include "../exam_mode_configuration.h"
|
||||
#include <apps/i18n.h>
|
||||
|
||||
#include "../exam_mode_configuration.h"
|
||||
#include "main_controller.h"
|
||||
|
||||
using namespace Shared;
|
||||
|
||||
namespace Settings {
|
||||
|
||||
constexpr SettingsMessageTree s_modelMenu[] =
|
||||
{SettingsMessageTree(I18n::Message::MathOptions, s_modelMathOptionsChildren),
|
||||
SettingsMessageTree(I18n::Message::Brightness),
|
||||
SettingsMessageTree(I18n::Message::DateTime, s_modelDateTimeChildren),
|
||||
SettingsMessageTree(I18n::Message::Language),
|
||||
SettingsMessageTree(I18n::Message::Country),
|
||||
SettingsMessageTree(I18n::Message::ExamMode, ExamModeConfiguration::s_modelExamChildren),
|
||||
SettingsMessageTree(I18n::Message::Brightness),
|
||||
SettingsMessageTree(I18n::Message::DateTime, s_modelDateTimeChildren),
|
||||
SettingsMessageTree(I18n::Message::Language),
|
||||
SettingsMessageTree(I18n::Message::Country),
|
||||
SettingsMessageTree(I18n::Message::ExamMode, ExamModeConfiguration::s_modelExamChildren),
|
||||
#ifdef HAS_CODE
|
||||
SettingsMessageTree(I18n::Message::CodeApp, s_codeChildren),
|
||||
SettingsMessageTree(I18n::Message::CodeApp, s_codeChildren),
|
||||
#endif
|
||||
SettingsMessageTree(I18n::Message::Accessibility, s_accessibilityChildren),
|
||||
SettingsMessageTree(I18n::Message::About, s_modelAboutChildren)};
|
||||
SettingsMessageTree(I18n::Message::UsbSetting, s_usbSteps),
|
||||
SettingsMessageTree(I18n::Message::Accessibility, s_accessibilityChildren),
|
||||
SettingsMessageTree(I18n::Message::About, s_modelAboutChildren)};
|
||||
|
||||
constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu);
|
||||
|
||||
I18n::Message MainController::promptMessage() const {
|
||||
return I18n::Message::Default;
|
||||
return I18n::Message::Default;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Settings
|
||||
|
||||
@@ -18,6 +18,7 @@ constexpr SettingsMessageTree s_modelMenu[] =
|
||||
#endif
|
||||
SettingsMessageTree(I18n::Message::UpdatePopUp),
|
||||
SettingsMessageTree(I18n::Message::Accessibility, s_accessibilityChildren),
|
||||
SettingsMessageTree(I18n::Message::UsbSetting, s_usbSteps),
|
||||
SettingsMessageTree(I18n::Message::About, s_modelAboutChildren)};
|
||||
|
||||
constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu);
|
||||
|
||||
101
apps/settings/sub_menu/usb_info_controller.cpp
Normal file
101
apps/settings/sub_menu/usb_info_controller.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
#include "usb_info_controller.h"
|
||||
|
||||
#include <apps/i18n.h>
|
||||
#include <apps/settings/main_controller.h>
|
||||
#include <assert.h>
|
||||
#include <ion/storage.h>
|
||||
#include <poincare/preferences.h>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "../../apps_container.h"
|
||||
#include "../../global_preferences.h"
|
||||
|
||||
using namespace Poincare;
|
||||
using namespace Shared;
|
||||
|
||||
namespace Settings {
|
||||
|
||||
UsbInfoController::UsbInfoController(Responder *parentResponder):
|
||||
GenericSubController(parentResponder),
|
||||
m_usbProtectionLevelController(this),
|
||||
m_dfuLevel(KDFont::LargeFont, KDFont::SmallFont)
|
||||
{
|
||||
for (int i = 0; i < k_maxSwitchCells; i++) {
|
||||
m_switchCells[i].setMessageFont(KDFont::LargeFont);
|
||||
}
|
||||
}
|
||||
|
||||
bool UsbInfoController::handleEvent(Ion::Events::Event event) {
|
||||
if ((Ion::Events::OK == event || Ion::Events::EXE == event) && selectedRow() == 0) {
|
||||
if (!GlobalPreferences::sharedGlobalPreferences()->dfuStatus()) {
|
||||
if (!GlobalPreferences::sharedGlobalPreferences()->isInExamMode()) {
|
||||
Ion::LED::setColor(KDColorPurple);
|
||||
Ion::LED::setBlinking(500, 0.5f);
|
||||
}
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuStatus(true);
|
||||
Container::activeApp()->displayWarning(I18n::Message::DfuWarning1, I18n::Message::DfuWarning2);
|
||||
} else {
|
||||
if (!GlobalPreferences::sharedGlobalPreferences()->isInExamMode()) {
|
||||
Ion::LED::setColor(KDColorBlack);
|
||||
}
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuStatus(false);
|
||||
}
|
||||
m_selectableTableView.reloadCellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow());
|
||||
AppsContainer::sharedAppsContainer()->redrawWindow(true);
|
||||
return true;
|
||||
}
|
||||
// We cannot use things like willExitResponderChain because this view can disappear due to an USB connection,
|
||||
// and in this case we must keep the DFU status.
|
||||
if ((Ion::Events::Left == event || Ion::Events::Home == event) && GlobalPreferences::sharedGlobalPreferences()->dfuStatus()) {
|
||||
Container::activeApp()->displayWarning(I18n::Message::USBProtectionReanabled);
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuStatus(false);
|
||||
}
|
||||
if ((Ion::Events::OK == event || Ion::Events::EXE == event) && selectedRow() == 1) {
|
||||
GenericSubController *subController = &m_usbProtectionLevelController;
|
||||
subController->setMessageTreeModel(m_messageTreeModel->childAtIndex(1));
|
||||
StackViewController *stack = stackController();
|
||||
m_lastSelect = selectedRow();
|
||||
stack->push(subController);
|
||||
return true;
|
||||
}
|
||||
return GenericSubController::handleEvent(event);
|
||||
}
|
||||
|
||||
HighlightCell *UsbInfoController::reusableCell(int index, int type) {
|
||||
assert(index == 0 || index == 1);
|
||||
return index == 0 ? &m_switchCell : &m_dfuLevelCell;
|
||||
}
|
||||
|
||||
int UsbInfoController::reusableCellCount(int type) {
|
||||
assert(type == 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void UsbInfoController::willDisplayCellForIndex(HighlightCell *cell, int index) {
|
||||
GenericSubController::willDisplayCellForIndex(cell, index);
|
||||
|
||||
if (index == 0) {
|
||||
MessageTableCellWithSwitch *myCell = (MessageTableCellWithSwitch *)cell;
|
||||
SwitchView *mySwitch = (SwitchView *)myCell->accessoryView();
|
||||
mySwitch->setState(!GlobalPreferences::sharedGlobalPreferences()->dfuStatus());
|
||||
} else if (index == 1) {
|
||||
MessageTableCellWithChevronAndMessage *mcell = (MessageTableCellWithChevronAndMessage *)cell;
|
||||
int currentLevel = GlobalPreferences::sharedGlobalPreferences()->getDfuLevel();
|
||||
if (currentLevel == 0) {
|
||||
mcell->setSubtitle(I18n::Message::USBDefaultLevelDesc);
|
||||
} else if (currentLevel == 1) {;
|
||||
mcell->setSubtitle(I18n::Message::USBLowLevelDesc);
|
||||
} else {
|
||||
assert(currentLevel == 2);
|
||||
mcell->setSubtitle(I18n::Message::USBParanoidLevelDesc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UsbInfoController::didEnterResponderChain(Responder *previousFirstResponder) {
|
||||
m_selectableTableView.reload();
|
||||
I18n::Message infoMessages[] = {I18n::Message::USBExplanation1, I18n::Message::USBExplanation2, I18n::Message::USBExplanation3};
|
||||
m_selectableTableView.setMessages(infoMessages, k_numberOfExplanationMessages);
|
||||
}
|
||||
}
|
||||
32
apps/settings/sub_menu/usb_info_controller.h
Normal file
32
apps/settings/sub_menu/usb_info_controller.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef SETTINGS_USB_INFO_CONTROLLER_H
|
||||
#define SETTINGS_USB_INFO_CONTROLLER_H
|
||||
|
||||
#include "generic_sub_controller.h"
|
||||
#include "preferences_controller.h"
|
||||
#include "selectable_view_with_messages.h"
|
||||
#include "usb_protection_level_controller.h"
|
||||
|
||||
namespace Settings {
|
||||
|
||||
class UsbInfoController : public GenericSubController {
|
||||
public:
|
||||
UsbInfoController(Responder* parentResponder);
|
||||
View* view() override { return &m_contentView; }
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
TELEMETRY_ID("UsbInfo");
|
||||
void didEnterResponderChain(Responder* previousFirstResponder) override;
|
||||
|
||||
HighlightCell* reusableCell(int index, int type) override;
|
||||
int reusableCellCount(int type) override;
|
||||
void willDisplayCellForIndex(HighlightCell* cell, int index) override;
|
||||
|
||||
private:
|
||||
static constexpr int k_numberOfExplanationMessages = 3;
|
||||
MessageTableCellWithSwitch m_switchCell;
|
||||
UsbProtectionLevelController m_usbProtectionLevelController;
|
||||
MessageTableCellWithChevronAndMessage m_dfuLevelCell;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
77
apps/settings/sub_menu/usb_protection_level_controller.cpp
Normal file
77
apps/settings/sub_menu/usb_protection_level_controller.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
#include "usb_protection_level_controller.h"
|
||||
|
||||
#include <apps/i18n.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "../../apps_container.h"
|
||||
#include "../../global_preferences.h"
|
||||
|
||||
using namespace Poincare;
|
||||
using namespace Shared;
|
||||
|
||||
namespace Settings {
|
||||
UsbProtectionLevelController::UsbProtectionLevelController(Responder *parentResponder) : GenericSubController(parentResponder) {
|
||||
for (int i = 0; i < k_maxNumberOfCells; i++) {
|
||||
m_cell[i].setMessageFont(KDFont::LargeFont);
|
||||
m_cell[i].setAccessoryFont(KDFont::SmallFont);
|
||||
}
|
||||
}
|
||||
|
||||
bool UsbProtectionLevelController::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
|
||||
for (int i = 0; i < k_maxNumberOfCells; i++) {
|
||||
m_cell[i].setAccessoryText("");
|
||||
}
|
||||
if (m_messageTreeModel->childAtIndex(selectedRow())->label() == I18n::Message::USBLowLevel) {
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuLevel(1);
|
||||
} else if (m_messageTreeModel->childAtIndex(selectedRow())->label() == I18n::Message::USBDefaultLevel) {
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuLevel(0);
|
||||
} else if (m_messageTreeModel->childAtIndex(selectedRow())->label() == I18n::Message::USBParanoidLevel) {
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuLevel(2);
|
||||
} else if (m_messageTreeModel->childAtIndex(selectedRow())->label() == I18n::Message::USBMegaParanoidLevel) {
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuLevel(3);
|
||||
}
|
||||
|
||||
StackViewController * stack = stackController();
|
||||
stack->pop();
|
||||
return true;
|
||||
} else {
|
||||
return GenericSubController::handleEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
HighlightCell *UsbProtectionLevelController::reusableCell(int index, int type) {
|
||||
assert(index >= 0 && index < k_maxNumberOfCells);
|
||||
return &m_cell[index];
|
||||
}
|
||||
|
||||
int UsbProtectionLevelController::reusableCellCount(int type) {
|
||||
return k_maxNumberOfCells;
|
||||
}
|
||||
|
||||
void UsbProtectionLevelController::willDisplayCellForIndex(HighlightCell *cell, int index) {
|
||||
GenericSubController::willDisplayCellForIndex(cell, index);
|
||||
I18n::Message childLabel = m_messageTreeModel->childAtIndex(index)->label();
|
||||
MessageTableCellWithBuffer *messageComp = (MessageTableCellWithBuffer *)cell;
|
||||
|
||||
int currentLevel = GlobalPreferences::sharedGlobalPreferences()->getDfuLevel();
|
||||
|
||||
if (childLabel == I18n::Message::USBLowLevel && currentLevel == 1) {
|
||||
// messageComp->setTextColor(Palette::Green);
|
||||
messageComp->setAccessoryText("√");
|
||||
} else if (childLabel == I18n::Message::USBDefaultLevel && currentLevel == 0) {
|
||||
// messageComp->setTextColor(Palette::Green);
|
||||
messageComp->setAccessoryText("√");
|
||||
} else if (childLabel == I18n::Message::USBParanoidLevel && currentLevel == 2) {
|
||||
// messageComp->setTextColor(Palette::Green);
|
||||
messageComp->setAccessoryText("√");
|
||||
} else if (childLabel == I18n::Message::USBMegaParanoidLevel && currentLevel == 3) {
|
||||
// messageComp->setTextColor(Palette::Green);
|
||||
messageComp->setAccessoryText("√");
|
||||
}
|
||||
}
|
||||
|
||||
int UsbProtectionLevelController::typeAtLocation(int i, int j) {
|
||||
return 0;
|
||||
}
|
||||
} // namespace Settings
|
||||
24
apps/settings/sub_menu/usb_protection_level_controller.h
Normal file
24
apps/settings/sub_menu/usb_protection_level_controller.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef SETTINGS_USB_PROTECTION_LEVEL_CONTROLLER_H
|
||||
#define SETTINGS_USB_PROTECTION_LEVEL_CONTROLLER_H
|
||||
|
||||
#include "generic_sub_controller.h"
|
||||
#include <escher.h>
|
||||
|
||||
namespace Settings {
|
||||
|
||||
class UsbProtectionLevelController : public GenericSubController {
|
||||
public:
|
||||
UsbProtectionLevelController(Responder * parentResponder);
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
HighlightCell * reusableCell(int index, int type) override;
|
||||
int reusableCellCount(int type) override;
|
||||
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
|
||||
int typeAtLocation(int i, int j) override;
|
||||
private:
|
||||
static constexpr int k_maxNumberOfCells = 3;
|
||||
MessageTableCellWithBuffer m_cell[k_maxNumberOfCells];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -99,3 +99,15 @@ ExamModeModeStandard = "Standard "
|
||||
ExamModeModeNoSym = "Kein Symbol "
|
||||
ExamModeModeNoSymNoText = "Kein Symbol kein Text "
|
||||
ExamModeModeDutch = "Niederländisch "
|
||||
USBE16_expl1= "USB-Schutz schützt Ihren"
|
||||
USBE16_expl2= "Taschenrechner vor"
|
||||
USBE16_expl3= "unbeabsichtigter Verriegelung"
|
||||
USBProtection= "USB-Schutz"
|
||||
USBSettingDeact = "Bitte schalte den Schutz ein"
|
||||
USBLevelProtect = "Akzeptierte Updates"
|
||||
USBDefaultLevel = "Basierend auf Upsilon"
|
||||
USBLowLevel = "Basierend auf Omega"
|
||||
USBParanoidLevel = "Nur Python"
|
||||
USBMegaParanoidLevel = "Nichts"
|
||||
USBDeacAlert1 = "Ändern Sie diesen Parameter nur,"
|
||||
USBDeacAlert2 = "wenn Sie wissen, was Sie tun!"
|
||||
|
||||
@@ -99,3 +99,15 @@ ExamModeModeStandard = "Standard "
|
||||
ExamModeModeNoSym = "No sym "
|
||||
ExamModeModeNoSymNoText = "No sym no text "
|
||||
ExamModeModeDutch = "Dutch "
|
||||
USBE16_expl1= "The USB protection protects"
|
||||
USBE16_expl2= "the calculator from"
|
||||
USBE16_expl3= "unintentional locking"
|
||||
USBProtection= "USB Protection"
|
||||
USBSettingDeact = "Please turn on the protection"
|
||||
USBLevelProtect = "Updates accepted"
|
||||
USBDefaultLevel = "Based on Upsilon"
|
||||
USBLowLevel = "Based on Omega"
|
||||
USBParanoidLevel = "Python Only"
|
||||
USBMegaParanoidLevel = "None"
|
||||
USBDeacAlert1 = "Change this parameter only if"
|
||||
USBDeacAlert2 = "you know what you are doing !"
|
||||
|
||||
@@ -99,3 +99,15 @@ ExamModeModeStandard = "Estándar "
|
||||
ExamModeModeNoSym = "Sin simbólico "
|
||||
ExamModeModeNoSymNoText = "Sin simbólico sin texto "
|
||||
ExamModeModeDutch = "Holandés "
|
||||
USBE16_expl1= "La protección USB protege"
|
||||
USBE16_expl2= "su calculadora del"
|
||||
USBE16_expl3= "bloqueo involuntario"
|
||||
USBProtection= "Protección USB"
|
||||
USBSettingDeact = "Enciende la protección"
|
||||
USBLevelProtect = "Actualizaciones aceptadas"
|
||||
USBDefaultLevel = "Basado en Upsilon"
|
||||
USBLowLevel = "Basado en Omega"
|
||||
USBParanoidLevel = "Solo Python"
|
||||
USBMegaParanoidLevel = "Ninguno"
|
||||
USBDeacAlert1 = "¡Cambie este parámetro solo"
|
||||
USBDeacAlert2 = "si sabe lo que está haciendo!"
|
||||
|
||||
@@ -99,3 +99,15 @@ ExamModeModeStandard = "Standard "
|
||||
ExamModeModeNoSym = "Sans symbolique "
|
||||
ExamModeModeNoSymNoText = "Sans symbolique ni texte "
|
||||
ExamModeModeDutch = "Dutch "
|
||||
USBE16_expl1= "La protection USB protège votre"
|
||||
USBE16_expl2= "calculatrice contre un verrouillage"
|
||||
USBE16_expl3= "non-intentionnel"
|
||||
USBProtection= "Protection USB"
|
||||
USBSettingDeact = "Veuillez activer la protection"
|
||||
USBLevelProtect = "Mise à jour acceptées"
|
||||
USBDefaultLevel = "Basées sur Upsilon"
|
||||
USBLowLevel = "Basées sur Omega"
|
||||
USBParanoidLevel = "Aucune"
|
||||
USBMegaParanoidLevel = "Aucune"
|
||||
USBDeacAlert1 = "Ne modifiez ce paramètre que"
|
||||
USBDeacAlert2 = "si vous savez ce que vous faites !"
|
||||
|
||||
@@ -99,3 +99,15 @@ ExamModeModeStandard = "Normál "
|
||||
ExamModeModeNoSym = "Szimbólikus nélkül "
|
||||
ExamModeModeNoSymNoText = "Szimbólikus és szöveg nélkül "
|
||||
ExamModeModeDutch = "Holland "
|
||||
USBE16_expl1= "Az USB-védelem megvédi"
|
||||
USBE16_expl2= "a számológépet a nem"
|
||||
USBE16_expl3= "szándékos reteszeléstől"
|
||||
USBProtection= "USB védelem"
|
||||
USBSettingDeact = "Kérjük, kapcsolja be a védelmet"
|
||||
USBLevelProtect = "Elfogadott frissítések"
|
||||
USBDefaultLevel = "Upsilon alapján"
|
||||
USBLowLevel = "Omega alapján"
|
||||
USBParanoidLevel = "Csak Python"
|
||||
USBMegaParanoidLevel = "Egyik sem"
|
||||
USBDeacAlert1 = "Csak akkor módosítsa ezt a"
|
||||
USBDeacAlert2 = "paramétert, ha tudja, mit csinál!"
|
||||
|
||||
@@ -99,3 +99,15 @@ ExamModeModeStandard = "Standard "
|
||||
ExamModeModeNoSym = "Nessun simbolo "
|
||||
ExamModeModeNoSymNoText = "Nessun simbolo nessun testo "
|
||||
ExamModeModeDutch = "Olandese "
|
||||
USBE16_expl1= "La protezione USB protegge"
|
||||
USBE16_expl2= "la calcolatrice dal"
|
||||
USBE16_expl3= "blocco involontario"
|
||||
USBProtection= "Protezione USB"
|
||||
USBSettingDeact = "Si prega di attivare la protezione"
|
||||
USBLevelProtect = "Aggiornamenti accettati"
|
||||
USBDefaultLevel = "Basato su Upsilon"
|
||||
USBLowLevel = "A base di Omega"
|
||||
USBParanoidLevel = "Solo Python"
|
||||
USBMegaParanoidLevel = "Nessuno"
|
||||
USBDeacAlert1 = "Cambia questo parametro solo"
|
||||
USBDeacAlert2 = "se sai cosa stai facendo !"
|
||||
|
||||
@@ -99,3 +99,15 @@ ExamModeModeStandard = "Standaard "
|
||||
ExamModeModeNoSym = "Geen sym "
|
||||
ExamModeModeNoSymNoText = "Geen sym geen tekst "
|
||||
ExamModeModeDutch = "Nederlands "
|
||||
USBE16_expl1= "USB-beveiliging beschermt uw"
|
||||
USBE16_expl2= "rekenmachine tegen"
|
||||
USBE16_expl3= "onbedoelde vergrendeling"
|
||||
USBProtection= "USB-beveiliging"
|
||||
USBSettingDeact = "Schakel a.u.b. de bescherming in"
|
||||
USBLevelProtect = "Updates geaccepteerd"
|
||||
USBDefaultLevel = "Gebaseerd op Upsilon"
|
||||
USBLowLevel = "Op basis van Omega"
|
||||
USBParanoidLevel = "Alleen Python"
|
||||
USBMegaParanoidLevel = "Geen"
|
||||
USBDeacAlert1 = "Wijzig deze parameter alleen"
|
||||
USBDeacAlert2 = "als u weet wat u doet!"
|
||||
|
||||
@@ -99,3 +99,15 @@ ExamModeModeStandard = "Padrão "
|
||||
ExamModeModeNoSym = "Sem sym "
|
||||
ExamModeModeNoSymNoText = "Sem sym sem texto "
|
||||
ExamModeModeDutch = "holandês "
|
||||
USBE16_expl1= "A proteção USB protege"
|
||||
USBE16_expl2= "sua calculadora contra"
|
||||
USBE16_expl3= "bloqueios não intencionais"
|
||||
USBProtection= "Proteção USB"
|
||||
USBSettingDeact = "Por favor, ligue a proteção"
|
||||
USBLevelProtect = "Atualizações aceitas"
|
||||
USBDefaultLevel = "Baseado em Upsilon"
|
||||
USBLowLevel = "Baseado em Ômega"
|
||||
USBParanoidLevel = "Apenas Python"
|
||||
USBMegaParanoidLevel = "Nenhum"
|
||||
USBDeacAlert1 = "Mude este parâmetro somente"
|
||||
USBDeacAlert2 = "se você souber o que está fazendo!"
|
||||
|
||||
@@ -458,6 +458,11 @@ HartreeConstant = "4.3597447222071·10^-18_J"
|
||||
MagneticFluxQuantum = "2.067833848·10^-15_Wb"
|
||||
ConductanceQuantum = "7.748091729·10^-5_S"
|
||||
CirculationQuantum = "3.6369475516·10^-4_m^2_s^-1"
|
||||
UsbSetting = "USB"
|
||||
USBDefaultLevelDesc = "L0"
|
||||
USBLowLevelDesc = "L1"
|
||||
USBParanoidLevelDesc = "L2"
|
||||
USBMegaParanoidLevelDesc = "L3"
|
||||
Cndcvt_Silver = "6.30·10^7_S_m^-1"
|
||||
Cndcvt_Copper = "5.96·10^7_S_m^-1"
|
||||
Cndcvt_Gold = "4.11·10^7_S_m^-1"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
app_usb_src = $(addprefix apps/usb/,\
|
||||
app.cpp \
|
||||
usb_connected_controller.cpp \
|
||||
usb_view.cpp \
|
||||
)
|
||||
|
||||
apps_src += $(app_usb_src)
|
||||
|
||||
@@ -27,6 +27,7 @@ App::App(Snapshot * snapshot) :
|
||||
}
|
||||
|
||||
bool App::processEvent(Ion::Events::Event e) {
|
||||
// Impossible de gérer mes events ici lorsqu'on active le DFU
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,3 +5,9 @@ ConnectedMessage3 = "getomega.dev/ide."
|
||||
ConnectedMessage4 = "Drücken Sie die Zurück-Taste am"
|
||||
ConnectedMessage5 = "Taschenrechner oder Kabel abziehen,"
|
||||
ConnectedMessage6 = "um die Verbindung zu trennen."
|
||||
DfuStatus = "Status des Rechners:"
|
||||
DfuStatusProtected = "GESCHÜTZT"
|
||||
DfuStatusUnprotected = "UNGESCHÜTZT"
|
||||
USBProtectionLevel0 = "Standardschutz"
|
||||
USBProtectionLevel1 = "Omega Schutz"
|
||||
USBProtectionLevel2 = "Systemschutz"
|
||||
|
||||
@@ -5,3 +5,9 @@ ConnectedMessage3 = "getomega.dev/ide"
|
||||
ConnectedMessage4 = "Press the BACK key of your"
|
||||
ConnectedMessage5 = "calculator or unplug it to"
|
||||
ConnectedMessage6 = "disconnect it."
|
||||
DfuStatus = "Calculator status:"
|
||||
DfuStatusProtected = "PROTECTED"
|
||||
DfuStatusUnprotected = "UNPROTECTED"
|
||||
USBProtectionLevel0 = "Default Protection"
|
||||
USBProtectionLevel1 = "Omega Protection"
|
||||
USBProtectionLevel2 = "System Protection"
|
||||
|
||||
@@ -4,4 +4,10 @@ ConnectedMessage2 = "nuestra página desde su ordenador"
|
||||
ConnectedMessage3 = "getomega.dev/ide"
|
||||
ConnectedMessage4 = "Pulse el botón RETURN de la"
|
||||
ConnectedMessage5 = "calculadora o desenchúfela para"
|
||||
ConnectedMessage6 = "desconectarla."
|
||||
ConnectedMessage6 = "desconectarla."
|
||||
DfuStatus = "Estado de la calculadora:"
|
||||
DfuStatusProtected = "PROTEGIDO"
|
||||
DfuStatusUnprotected = "DESABRIGADO"
|
||||
USBProtectionLevel0 = "Protección predeterminada"
|
||||
USBProtectionLevel1 = "Protección Omega"
|
||||
USBProtectionLevel2 = "Protección del sistema"
|
||||
|
||||
@@ -5,3 +5,9 @@ ConnectedMessage3 = "getomega.dev/ide"
|
||||
ConnectedMessage4 = "Appuyez sur la touche RETOUR"
|
||||
ConnectedMessage5 = "de la calculatrice ou débranchez-la"
|
||||
ConnectedMessage6 = "pour la déconnecter."
|
||||
DfuStatus = "Etat de la calculatrice:"
|
||||
DfuStatusProtected = "PROTÉGÉE"
|
||||
DfuStatusUnprotected = "NON PROTÉGÉE"
|
||||
USBProtectionLevel0 = "Default Protection"
|
||||
USBProtectionLevel1 = "Omega Protection"
|
||||
USBProtectionLevel2 = "System Protection"
|
||||
|
||||
@@ -5,3 +5,9 @@ ConnectedMessage3 = "fel getomega.dev/ide ra."
|
||||
ConnectedMessage4 = "Nyomjon majd a VISSZA gombra"
|
||||
ConnectedMessage5 = "vagy huzza ki a kábelt azért"
|
||||
ConnectedMessage6 = "hogy a másolás véget érjen."
|
||||
DfuStatus = "Számológép állapota:"
|
||||
DfuStatusProtected = "VÉDETT"
|
||||
DfuStatusUnprotected = "VÉDTELEN"
|
||||
USBProtectionLevel0 = "Alapértelmezett védelem"
|
||||
USBProtectionLevel1 = "Omega védelem"
|
||||
USBProtectionLevel2 = "Rendszervédelem"
|
||||
|
||||
@@ -5,3 +5,9 @@ ConnectedMessage3 = "getomega.dev/ide"
|
||||
ConnectedMessage4 = "Premere sul tasto INDIETRO della"
|
||||
ConnectedMessage5 = "calcolatrice o scollegatela per"
|
||||
ConnectedMessage6 = "disconnetterla."
|
||||
DfuStatus = "Stato della calcolatrice:"
|
||||
DfuStatusProtected = "PROTETTO"
|
||||
DfuStatusUnprotected = "INDIFESO"
|
||||
USBProtectionLevel0 = "Protezione predefinita"
|
||||
USBProtectionLevel1 = "Protezione Omega"
|
||||
USBProtectionLevel2 = "Protezione del sistema"
|
||||
|
||||
@@ -5,3 +5,9 @@ ConnectedMessage3 = "getomega.dev/ide"
|
||||
ConnectedMessage4 = "Druk op de TERUG toets van je"
|
||||
ConnectedMessage5 = "rekenmachine of verwijder de"
|
||||
ConnectedMessage6 = " kabel om hem los te koppelen."
|
||||
DfuStatus = "Rekenmachine status:"
|
||||
DfuStatusProtected = "BESCHERMD"
|
||||
DfuStatusUnprotected = "NIET BESCHERMD"
|
||||
USBProtectionLevel0 = "Standaardbeveiliging"
|
||||
USBProtectionLevel1 = "Omega Bescherming"
|
||||
USBProtectionLevel2 = "Systeembeveiliging"
|
||||
|
||||
@@ -5,3 +5,9 @@ ConnectedMessage3 = "getomega.dev/ide"
|
||||
ConnectedMessage4 = "Pressione o botão RETURN na"
|
||||
ConnectedMessage5 = "calculadora ou desligue-a para a"
|
||||
ConnectedMessage6 = "desconectar."
|
||||
DfuStatus = "Status da calculadora:"
|
||||
DfuStatusProtected = "PROTEGIDO"
|
||||
DfuStatusUnprotected = "DESPROTEGIDO"
|
||||
USBProtectionLevel0 = "Proteção padrão"
|
||||
USBProtectionLevel1 = "Proteção Ômega"
|
||||
USBProtectionLevel2 = "Proteção do sistema"
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#include "usb_connected_controller.h"
|
||||
#include <apps/i18n.h>
|
||||
#include "../global_preferences.h"
|
||||
|
||||
namespace USB {
|
||||
|
||||
static I18n::Message sUSBConnectedMessages[] = {
|
||||
namespace USB
|
||||
{
|
||||
static constexpr I18n::Message sUSBConnectedMessages[k_numberOfUSBMessages] = {
|
||||
I18n::Message::USBConnected,
|
||||
I18n::Message::ConnectedMessage1,
|
||||
I18n::Message::ConnectedMessage2,
|
||||
@@ -11,9 +12,10 @@ static I18n::Message sUSBConnectedMessages[] = {
|
||||
I18n::Message::BlankMessage,
|
||||
I18n::Message::ConnectedMessage4,
|
||||
I18n::Message::ConnectedMessage5,
|
||||
I18n::Message::ConnectedMessage6};
|
||||
I18n::Message::ConnectedMessage6,
|
||||
I18n::Message::DfuStatus};
|
||||
|
||||
static KDColor sUSBConnectedFGColors[] = {
|
||||
static constexpr KDColor sUSBConnectedFGColors[] = {
|
||||
Palette::PrimaryText,
|
||||
Palette::PrimaryText,
|
||||
Palette::PrimaryText,
|
||||
@@ -21,22 +23,67 @@ static KDColor sUSBConnectedFGColors[] = {
|
||||
KDColorWhite,
|
||||
Palette::PrimaryText,
|
||||
Palette::PrimaryText,
|
||||
Palette::PrimaryText};
|
||||
Palette::PrimaryText,
|
||||
Palette::PrimaryText,
|
||||
Palette::AccentText};
|
||||
|
||||
static KDColor sUSBConnectedBGColors[] = {
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard};
|
||||
|
||||
USBConnectedController::USBConnectedController() :
|
||||
ViewController(nullptr),
|
||||
m_messageView(sUSBConnectedMessages, sUSBConnectedFGColors, sUSBConnectedBGColors, 8)
|
||||
USBConnectedController::USBConnectedController() :
|
||||
ViewController(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
USBConnectedController::ContentView::ContentView(KDColor * fgcolors, KDColor * bgcolors, uint8_t numberOfMessages) {
|
||||
// We set the styles of the messages
|
||||
for (uint8_t i = 0; i < k_numberOfMessages; i++) {
|
||||
m_messageTextViews[i].setFont(i == 0 ? KDFont::LargeFont : KDFont::SmallFont);
|
||||
m_messageTextViews[i].setAlignment(0.5f, 0.5f);
|
||||
m_messageTextViews[i].setTextColor(fgcolors[i]);
|
||||
m_messageTextViews[i].setBackgroundColor(Palette::BackgroundHard);
|
||||
}
|
||||
|
||||
// We set the texts of the firsts defaults messages
|
||||
for (uint8_t i = 0; i < k_numberOfUSBMessages; i++) {
|
||||
m_messageTextViews[i].setText(sUSBConnectedMessages[i]);
|
||||
}
|
||||
|
||||
// Last message, depending of the USB protection level
|
||||
if (GlobalPreferences::sharedGlobalPreferences()->dfuStatus()) {
|
||||
m_messageTextViews[i].setText(DfuStatusUnprotected);
|
||||
} else {
|
||||
int protectionLevel = GlobalPreferences::sharedGlobalPreferences()->getDfuLevel();
|
||||
switch (protectionLevel) {
|
||||
case 0:
|
||||
m_messageTextViews[9].setText(USBProtectionLevel0);
|
||||
break;
|
||||
case 1:
|
||||
m_messageTextViews[9].setText(USBProtectionLevel1);
|
||||
break;
|
||||
default:
|
||||
assert(protectionLevel == 2);
|
||||
m_messageTextViews[9].setText(USBProtectionLevel2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void USBConnectedController::ContentView::drawRect(KDContext *ctx, KDRect rect) const {
|
||||
ctx->fillRect(bounds(), Palette::BackgroundHard);
|
||||
}
|
||||
|
||||
View *USBConnectedController::ContentView::subviewAtIndex(int index) {
|
||||
assert(index < k_numberOfMessages);
|
||||
return &(m_messageTextViews[index]);
|
||||
}
|
||||
|
||||
void USBConnectedController::ContentView::layoutSubviews(bool force) {
|
||||
KDCoordinate width = bounds().width();
|
||||
KDCoordinate titleHeight = m_messageTextViews[0].minimalSizeForOptimalDisplay().height();
|
||||
KDCoordinate textHeight = KDFont::SmallFont->glyphSize().height();
|
||||
m_messageTextViews[0].setFrame(KDRect(0, k_titleMargin, width, titleHeight), force);
|
||||
for (uint8_t i = 1; i < k_numberOfMessages; i++) {
|
||||
m_messageTextViews[i].setFrame(KDRect(0, k_paragraphHeight + (i - 1) * textHeight, width, textHeight), force);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define USB_USB_CONNECTED_CONTROLLER_H
|
||||
|
||||
#include <escher.h>
|
||||
#include "../shared/message_view.h"
|
||||
|
||||
namespace USB {
|
||||
|
||||
@@ -10,12 +9,25 @@ class USBConnectedController : public ViewController {
|
||||
public:
|
||||
USBConnectedController();
|
||||
View * view() override { return &m_messageView; }
|
||||
bool handleEvent(Ion::Events::Event event) override { return false; }
|
||||
private:
|
||||
MessageView m_messageView;
|
||||
USBView * getMessageView() {return &m_messageView; }
|
||||
bool handleEvent(Ion::Events::Event event) override { return false; };
|
||||
public:
|
||||
ContentView(KDColor * fgcolors, KDColor * bgcolors);
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
protected:
|
||||
int numberOfSubviews() const override { return k_numberOfMessages; }
|
||||
View * subviewAtIndex(int index) override;
|
||||
void layoutSubviews(bool force = false) override;
|
||||
private:
|
||||
constexpr static KDCoordinate k_titleMargin = 30;
|
||||
constexpr static KDCoordinate k_paragraphHeight = 80;
|
||||
constexpr static uint8_t k_numberOfUSBMessages = 9;
|
||||
constexpr static uint8_t k_numberOfMessages = k_numberOfUSBMessages + 1;
|
||||
MessageTextView m_messageTextViews[k_numberOfMessages];
|
||||
};
|
||||
ContentView m_contentView;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
56
apps/usb/usb_view.cpp
Normal file
56
apps/usb/usb_view.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "usb_view.h"
|
||||
#include <assert.h>
|
||||
|
||||
namespace USB {
|
||||
USBView::USBView(I18n::Message *messages, KDColor *fgcolors, KDColor *bgcolors, uint8_t numberOfMessages) {
|
||||
m_numberOfMessages = numberOfMessages < k_maxNumberOfMessages ? numberOfMessages : k_maxNumberOfMessages;
|
||||
for (uint8_t i = 0; i < m_numberOfMessages; i++) {
|
||||
m_messageTextViews[i].setFont(i == 0 ? KDFont::LargeFont : KDFont::SmallFont);
|
||||
m_messageTextViews[i].setMessage(messages[i]);
|
||||
m_messageTextViews[i].setAlignment(0.5f, 0.5f);
|
||||
m_messageTextViews[i].setTextColor(fgcolors[i]);
|
||||
m_messageTextViews[i].setBackgroundColor(bgcolors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void USBView::drawRect(KDContext *ctx, KDRect rect) const {
|
||||
ctx->fillRect(bounds(), Palette::BackgroundHard);
|
||||
}
|
||||
|
||||
View *USBView::subviewAtIndex(int index) {
|
||||
if (index >= m_numberOfMessages) {
|
||||
assert(false);
|
||||
return nullptr;
|
||||
}
|
||||
return &(m_messageTextViews[index]);
|
||||
}
|
||||
|
||||
void USBView::update(I18n::Message *messages, KDColor *fgcolors, KDColor *bgcolors, uint8_t numberOfMessages){
|
||||
m_numberOfMessages = numberOfMessages < k_maxNumberOfMessages ? numberOfMessages : k_maxNumberOfMessages;
|
||||
for (uint8_t i = 0; i < m_numberOfMessages; i++) {
|
||||
m_messageTextViews[i].setFont(i == 0 ? KDFont::LargeFont : KDFont::SmallFont);
|
||||
m_messageTextViews[i].setMessage(messages[i]);
|
||||
m_messageTextViews[i].setAlignment(0.5f, 0.5f);
|
||||
m_messageTextViews[i].setTextColor(fgcolors[i]);
|
||||
m_messageTextViews[i].setBackgroundColor(bgcolors[i]);
|
||||
}
|
||||
reload();
|
||||
}
|
||||
|
||||
void USBView::reload() {
|
||||
markRectAsDirty(bounds());
|
||||
}
|
||||
|
||||
void USBView::layoutSubviews(bool force) {
|
||||
if (m_numberOfMessages == 0) {
|
||||
return;
|
||||
}
|
||||
KDCoordinate width = bounds().width();
|
||||
KDCoordinate titleHeight = m_messageTextViews[0].minimalSizeForOptimalDisplay().height();
|
||||
KDCoordinate textHeight = KDFont::SmallFont->glyphSize().height();
|
||||
m_messageTextViews[0].setFrame(KDRect(0, k_titleMargin, width, titleHeight), force);
|
||||
for (uint8_t i = 1; i < m_numberOfMessages; i++) {
|
||||
m_messageTextViews[i].setFrame(KDRect(0, k_paragraphHeight + (i - 1) * textHeight, width, textHeight), force);
|
||||
}
|
||||
}
|
||||
}
|
||||
30
apps/usb/usb_view.h
Normal file
30
apps/usb/usb_view.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef USB_VIEW_H
|
||||
#define USB_VIEW_H
|
||||
|
||||
#include <escher.h>
|
||||
|
||||
namespace USB
|
||||
{
|
||||
class USBView : public View
|
||||
{
|
||||
public:
|
||||
USBView(I18n::Message *messages, KDColor *fgcolors, KDColor *bgcolors, uint8_t numberOfMessages);
|
||||
void drawRect(KDContext *ctx, KDRect rect) const override;
|
||||
void reload();
|
||||
void update(I18n::Message *messages, KDColor *fgcolors, KDColor *bgcolors, uint8_t numberOfMessages);
|
||||
protected:
|
||||
int numberOfSubviews() const override { return m_numberOfMessages; }
|
||||
View *subviewAtIndex(int index) override;
|
||||
void layoutSubviews(bool force = false) override;
|
||||
|
||||
private:
|
||||
constexpr static KDCoordinate k_titleMargin = 30;
|
||||
constexpr static KDCoordinate k_paragraphHeight = 80;
|
||||
constexpr static uint8_t k_maxNumberOfMessages = 10;
|
||||
MessageTextView m_messageTextViews[k_maxNumberOfMessages];
|
||||
uint8_t m_numberOfMessages;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user