mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[usb | recovery] Make the code works
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() && GlobalPreferences::sharedGlobalPreferences()->getDfuLevel() != 3) {
|
||||
if (Ion::USB::isPlugged()) {
|
||||
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,8 +147,7 @@ bool AppsContainer::dispatchEvent(Ion::Events::Event event) {
|
||||
* pictogram. */
|
||||
updateBatteryState();
|
||||
if (switchTo(usbConnectedAppSnapshot())) {
|
||||
Ion::USB::DFU(true, GlobalPreferences::sharedGlobalPreferences()->dfuStatus(), GlobalPreferences::sharedGlobalPreferences()->getDfuLevel());
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuStatus(false);
|
||||
Ion::USB::DFU(true, GlobalPreferences::sharedGlobalPreferences()->dfuUnlocked(), GlobalPreferences::sharedGlobalPreferences()->dfuLevel());
|
||||
// Update LED when exiting DFU mode
|
||||
Ion::LED::updateColorWithPlugAndCharge();
|
||||
bool switched = switchTo(activeSnapshot);
|
||||
|
||||
@@ -30,10 +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 dfuUnlocked() const { return m_dfuUnlocked; }
|
||||
void setDfuUnlocked(bool unlocked) { m_dfuUnlocked = unlocked; }
|
||||
int dfuLevel() const { return m_dfuLevel; }
|
||||
void setDfuLevel(int level) { m_dfuLevel = level; }
|
||||
bool autocomplete() const { return m_autoComplete; }
|
||||
void setAutocomplete(bool autocomple) { m_autoComplete = autocomple; }
|
||||
int brightnessLevel() const { return m_brightnessLevel; }
|
||||
@@ -41,7 +41,6 @@ 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
|
||||
@@ -52,7 +51,7 @@ private:
|
||||
m_tempExamMode(ExamMode::Standard),
|
||||
m_showPopUp(true),
|
||||
m_dfuUnlocked(false),
|
||||
m_dfuProtectLevel(0),
|
||||
m_dfuLevel(0),
|
||||
m_autoComplete(true),
|
||||
m_brightnessLevel(Ion::Backlight::MaxBrightness),
|
||||
m_font(KDFont::LargeFont) {}
|
||||
@@ -64,8 +63,10 @@ private:
|
||||
mutable ExamMode m_tempExamMode;
|
||||
bool m_showPopUp;
|
||||
bool m_dfuUnlocked;
|
||||
uint8_t m_dfuLevel;
|
||||
bool m_autoComplete;
|
||||
int m_brightnessLevel;
|
||||
const KDFont * m_font;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,5 +2,3 @@ Apps = "Anwendungen"
|
||||
AppsCapital = "UPSILON"
|
||||
ForbidenAppInExamMode1 = "Diese Anwendung ist im"
|
||||
ForbidenAppInExamMode2 = "Prüfungsmodus nicht erlaubt."
|
||||
DfuWarning1 = "DFU-Schutzwarnung"
|
||||
DfuWarning2 = "Mehr Informationen: bit.ly/upsiDfu"
|
||||
|
||||
@@ -2,5 +2,3 @@ Apps = "Applications"
|
||||
AppsCapital = "UPSILON"
|
||||
ForbidenAppInExamMode1 = "This application is"
|
||||
ForbidenAppInExamMode2 = "forbidden in exam mode"
|
||||
DfuWarning1 = "DFU Protection Warning"
|
||||
DfuWarning2 = "More informations: bit.ly/upsiDfu"
|
||||
|
||||
@@ -2,5 +2,3 @@ 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,5 +2,3 @@ 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,5 +2,3 @@ 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,5 +2,3 @@ Apps = "Applicazioni"
|
||||
AppsCapital = "UPSILON"
|
||||
ForbidenAppInExamMode1 = "Questa applicazione è"
|
||||
ForbidenAppInExamMode2 = "proibita nella modalità d'esame"
|
||||
DfuWarning1 = "Avviso protezione DFU"
|
||||
DfuWarning2 = "Più informazioni: bit.ly/upsiDfu"
|
||||
|
||||
@@ -2,5 +2,3 @@ Apps = "Applicaties"
|
||||
AppsCapital = "UPSILON"
|
||||
ForbidenAppInExamMode1 = "Deze applicatie is"
|
||||
ForbidenAppInExamMode2 = "uitgesloten in examenstand"
|
||||
DfuWarning1 = "DFU-beveiligingswaarschuwing"
|
||||
DfuWarning2 = "Meer informatie: bit.ly/upsiDfu"
|
||||
|
||||
@@ -2,5 +2,3 @@ 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,33 +87,9 @@ 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()) {
|
||||
|
||||
@@ -25,8 +25,7 @@ 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 \
|
||||
sub_menu/usb_protection_controller.cpp \
|
||||
)
|
||||
|
||||
SFLAGS += -DOMEGA_STATE="$(OMEGA_STATE)"
|
||||
@@ -34,6 +33,6 @@ SFLAGS += -DOMEGA_STATE="$(OMEGA_STATE)"
|
||||
app_settings_src += $(app_settings_test_src)
|
||||
apps_src += $(app_settings_src)
|
||||
|
||||
i18n_files += $(call i18n_without_universal_for,settings/base)
|
||||
i18n_files += $(call i18n_with_universal_for,settings/base)
|
||||
|
||||
$(eval $(call depends_on_image,apps/settings/app.cpp,apps/settings/settings_icon.png))
|
||||
|
||||
@@ -73,7 +73,7 @@ USBExplanation1= "USB-Schutz schützt Ihren"
|
||||
USBExplanation2= "Taschenrechner vor"
|
||||
USBExplanation3= "unbeabsichtigter Verriegelung"
|
||||
USBProtection= "USB-Schutz"
|
||||
USBLevelProtect = "Akzeptierte Updates"
|
||||
USBProtectionLevel = "Akzeptierte Updates"
|
||||
USBDefaultLevel = "Basierend auf Upsilon"
|
||||
USBLowLevel = "Basierend auf Omega"
|
||||
USBParanoidLevel = "Nichts"
|
||||
|
||||
@@ -73,7 +73,7 @@ USBExplanation1= "The USB protection protects"
|
||||
USBExplanation2= "the calculator from"
|
||||
USBExplanation3= "unintentional locking"
|
||||
USBProtection= "USB Protection"
|
||||
USBLevelProtect = "Updates accepted"
|
||||
USBProtectionLevel = "Updates accepted"
|
||||
USBDefaultLevel = "Based on Upsilon"
|
||||
USBLowLevel = "Based on Omega"
|
||||
USBParanoidLevel = "None"
|
||||
|
||||
@@ -73,7 +73,7 @@ USBExplanation1= "La protección USB protege"
|
||||
USBExplanation2= "su calculadora del"
|
||||
USBExplanation3= "bloqueo involuntario"
|
||||
USBProtection= "Protección USB"
|
||||
USBLevelProtect = "Actualizaciones aceptadas"
|
||||
USBProtectionLevel = "Actualizaciones aceptadas"
|
||||
USBDefaultLevel = "Basado en Upsilon"
|
||||
USBLowLevel = "Basado en Omega"
|
||||
USBParanoidLevel = "Ninguno"
|
||||
|
||||
@@ -73,7 +73,7 @@ USBExplanation1= "La protection USB protège votre"
|
||||
USBExplanation2= "calculatrice contre un verrouillage"
|
||||
USBExplanation3= "non-intentionnel"
|
||||
USBProtection= "Protection USB"
|
||||
USBLevelProtect = "Mise à jour acceptées"
|
||||
USBProtectionLevel = "Mise à jour acceptées"
|
||||
USBDefaultLevel = "Basées sur Upsilon"
|
||||
USBLowLevel = "Basées sur Omega"
|
||||
USBParanoidLevel = "Aucune"
|
||||
|
||||
@@ -73,8 +73,7 @@ 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"
|
||||
USBProtectionLevel = "Elfogadott frissítések"
|
||||
USBDefaultLevel = "Upsilon alapján"
|
||||
USBLowLevel = "Omega alapján"
|
||||
USBParanoidLevel = "Egyik sem"
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ USBExplanation1= "La protezione USB protegge"
|
||||
USBExplanation2= "la calcolatrice dal"
|
||||
USBExplanation3= "blocco involontario"
|
||||
USBProtection= "Protezione USB"
|
||||
USBLevelProtect = "Aggiornamenti accettati"
|
||||
USBProtectionLevel = "Aggiornamenti accettati"
|
||||
USBDefaultLevel = "Basato su Upsilon"
|
||||
USBLowLevel = "A base di Omega"
|
||||
USBParanoidLevel = "Nessuno"
|
||||
|
||||
@@ -73,7 +73,7 @@ USBExplanation1= "USB-beveiliging beschermt uw"
|
||||
USBExplanation2= "rekenmachine tegen"
|
||||
USBExplanation3= "onbedoelde vergrendeling"
|
||||
USBProtection= "USB-beveiliging"
|
||||
USBLevelProtect = "Updates geaccepteerd"
|
||||
USBProtectionLevel = "Updates geaccepteerd"
|
||||
USBDefaultLevel = "Gebaseerd op Upsilon"
|
||||
USBLowLevel = "Op basis van Omega"
|
||||
USBParanoidLevel = "Geen"
|
||||
|
||||
@@ -73,7 +73,7 @@ USBExplanation1= "A proteção USB protege"
|
||||
USBExplanation2= "sua calculadora contra"
|
||||
USBExplanation3= "bloqueios não intencionais"
|
||||
USBProtection= "Proteção USB"
|
||||
USBLevelProtect = "Atualizações aceitas"
|
||||
USBProtectionLevel = "Atualizações aceitas"
|
||||
USBDefaultLevel = "Baseado em Upsilon"
|
||||
USBLowLevel = "Baseado em Ômega"
|
||||
USBParanoidLevel = "Nenhum"
|
||||
|
||||
@@ -15,8 +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_usbProtectionChildren[2] = {SettingsMessageTree(I18n::Message::USBProtection), SettingsMessageTree(I18n::Message::USBProtectionLevel, s_usbProtectionLevelChildren)};
|
||||
constexpr SettingsMessageTree s_usbProtectionLevelChildren[3] = {SettingsMessageTree(I18n::Message::USBDefaultLevel), SettingsMessageTree(I18n::Message::USBLowLevel), SettingsMessageTree(I18n::Message::USBParanoidLevel)};
|
||||
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)};
|
||||
|
||||
@@ -12,7 +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"
|
||||
#include "sub_menu/usb_protection_controller.h"
|
||||
|
||||
namespace Settings {
|
||||
|
||||
@@ -29,8 +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_usbProtectionChildren[2];
|
||||
extern const Shared::SettingsMessageTree s_usbProtectionLevelChildren[3];
|
||||
extern const Shared::SettingsMessageTree s_model;
|
||||
|
||||
class MainController : public ViewController, public ListViewDataSource, public SelectableTableViewDataSource {
|
||||
|
||||
@@ -18,7 +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::UsbSetting, s_usbProtectionChildren),
|
||||
SettingsMessageTree(I18n::Message::Accessibility, s_accessibilityChildren)};
|
||||
|
||||
constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu);
|
||||
|
||||
@@ -17,14 +17,14 @@ constexpr SettingsMessageTree s_modelMenu[] =
|
||||
#ifdef HAS_CODE
|
||||
SettingsMessageTree(I18n::Message::CodeApp, s_codeChildren),
|
||||
#endif
|
||||
SettingsMessageTree(I18n::Message::UsbSetting, s_usbSteps),
|
||||
SettingsMessageTree(I18n::Message::UsbSetting, s_usbProtectionChildren),
|
||||
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,7 +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::UsbSetting, s_usbProtectionChildren),
|
||||
SettingsMessageTree(I18n::Message::About, s_modelAboutChildren)};
|
||||
|
||||
constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu);
|
||||
|
||||
@@ -170,6 +170,15 @@ Layout PreferencesController::layoutForPreferences(I18n::Message message) {
|
||||
return LayoutHelper::String(text, strlen(text), font);
|
||||
}
|
||||
|
||||
// DFU Protection level
|
||||
case I18n::Message::USBDefaultLevel:
|
||||
case I18n::Message::USBLowLevel:
|
||||
case I18n::Message::USBParanoidLevel:
|
||||
{
|
||||
const char * text = " ";
|
||||
return LayoutHelper::String(text, strlen(text), k_layoutFont);
|
||||
}
|
||||
|
||||
default:
|
||||
assert(false);
|
||||
return Layout();
|
||||
@@ -213,6 +222,8 @@ void PreferencesController::setPreferenceWithValueIndex(I18n::Message message, i
|
||||
preferences->setSymbolOfFunction((Preferences::SymbolFunction)valueIndex);
|
||||
} else if (message == I18n::Message::FontSizes) {
|
||||
GlobalPreferences::sharedGlobalPreferences()->setFont(valueIndex == 0 ? KDFont::LargeFont : KDFont::SmallFont);
|
||||
} else if (message == I18n::Message::USBProtectionLevel) {
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuLevel(valueIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,6 +250,9 @@ int PreferencesController::valueIndexForPreference(I18n::Message message) const
|
||||
if (message == I18n::Message::FontSizes) {
|
||||
return GlobalPreferences::sharedGlobalPreferences()->font() == KDFont::LargeFont ? 0 : 1;
|
||||
}
|
||||
if (message == I18n::Message::USBProtectionLevel) {
|
||||
return GlobalPreferences::sharedGlobalPreferences()->dfuLevel();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
#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
|
||||
@@ -1,13 +1,10 @@
|
||||
#include "usb_info_controller.h"
|
||||
#include "usb_protection_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"
|
||||
|
||||
@@ -19,37 +16,36 @@ namespace Settings {
|
||||
UsbInfoController::UsbInfoController(Responder *parentResponder):
|
||||
GenericSubController(parentResponder),
|
||||
m_usbProtectionLevelController(this),
|
||||
m_dfuLevel(KDFont::LargeFont, KDFont::SmallFont)
|
||||
m_contentView(&m_selectableTableView)
|
||||
{
|
||||
for (int i = 0; i < k_maxSwitchCells; i++) {
|
||||
m_switchCells[i].setMessageFont(KDFont::LargeFont);
|
||||
}
|
||||
m_switchCell.setMessageFont(KDFont::LargeFont);
|
||||
m_dfuLevelCell.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()->dfuUnlocked()) {
|
||||
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);
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuUnlocked(true);
|
||||
} else {
|
||||
if (!GlobalPreferences::sharedGlobalPreferences()->isInExamMode()) {
|
||||
Ion::LED::setColor(KDColorBlack);
|
||||
}
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuStatus(false);
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuUnlocked(false);
|
||||
}
|
||||
m_selectableTableView.reloadCellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow());
|
||||
AppsContainer::sharedAppsContainer()->redrawWindow(true);
|
||||
m_selectableTableView.reloadCellAtLocation(0, 0);
|
||||
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::Left == event || Ion::Events::Home == event || Ion::Events::Back == event) && GlobalPreferences::sharedGlobalPreferences()->dfuUnlocked()) {
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuUnlocked(false);
|
||||
m_selectableTableView.reloadCellAtLocation(0, 0);
|
||||
Container::activeApp()->displayWarning(I18n::Message::USBProtectionReactivated);
|
||||
return true;
|
||||
}
|
||||
if ((Ion::Events::OK == event || Ion::Events::EXE == event) && selectedRow() == 1) {
|
||||
GenericSubController *subController = &m_usbProtectionLevelController;
|
||||
@@ -63,13 +59,16 @@ bool UsbInfoController::handleEvent(Ion::Events::Event event) {
|
||||
}
|
||||
|
||||
HighlightCell *UsbInfoController::reusableCell(int index, int type) {
|
||||
assert(index == 0 || index == 1);
|
||||
return index == 0 ? &m_switchCell : &m_dfuLevelCell;
|
||||
if (index == 0) {
|
||||
return &m_switchCell;
|
||||
}
|
||||
assert(index == 1);
|
||||
return &m_dfuLevelCell;
|
||||
}
|
||||
|
||||
int UsbInfoController::reusableCellCount(int type) {
|
||||
assert(type == 0);
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
void UsbInfoController::willDisplayCellForIndex(HighlightCell *cell, int index) {
|
||||
@@ -78,10 +77,10 @@ void UsbInfoController::willDisplayCellForIndex(HighlightCell *cell, int index)
|
||||
if (index == 0) {
|
||||
MessageTableCellWithSwitch *myCell = (MessageTableCellWithSwitch *)cell;
|
||||
SwitchView *mySwitch = (SwitchView *)myCell->accessoryView();
|
||||
mySwitch->setState(!GlobalPreferences::sharedGlobalPreferences()->dfuStatus());
|
||||
mySwitch->setState(!GlobalPreferences::sharedGlobalPreferences()->dfuUnlocked());
|
||||
} else if (index == 1) {
|
||||
MessageTableCellWithChevronAndMessage *mcell = (MessageTableCellWithChevronAndMessage *)cell;
|
||||
int currentLevel = GlobalPreferences::sharedGlobalPreferences()->getDfuLevel();
|
||||
int currentLevel = GlobalPreferences::sharedGlobalPreferences()->dfuLevel();
|
||||
if (currentLevel == 0) {
|
||||
mcell->setSubtitle(I18n::Message::USBDefaultLevelDesc);
|
||||
} else if (currentLevel == 1) {;
|
||||
@@ -94,8 +93,8 @@ void UsbInfoController::willDisplayCellForIndex(HighlightCell *cell, int index)
|
||||
}
|
||||
|
||||
void UsbInfoController::didEnterResponderChain(Responder *previousFirstResponder) {
|
||||
m_selectableTableView.reload();
|
||||
m_contentView.reload();
|
||||
I18n::Message infoMessages[] = {I18n::Message::USBExplanation1, I18n::Message::USBExplanation2, I18n::Message::USBExplanation3};
|
||||
m_selectableTableView.setMessages(infoMessages, k_numberOfExplanationMessages);
|
||||
m_contentView.setMessages(infoMessages, k_numberOfExplanationMessages);
|
||||
}
|
||||
}
|
||||
30
apps/settings/sub_menu/usb_protection_controller.h
Normal file
30
apps/settings/sub_menu/usb_protection_controller.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef SETTINGS_usb_protection_controller_H
|
||||
#define SETTINGS_usb_protection_controller_H
|
||||
|
||||
#include "generic_sub_controller.h"
|
||||
#include "preferences_controller.h"
|
||||
#include "selectable_view_with_messages.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;
|
||||
PreferencesController m_usbProtectionLevelController;
|
||||
SelectableViewWithMessages m_contentView;
|
||||
MessageTableCellWithSwitch m_switchCell;
|
||||
MessageTableCellWithChevronAndMessage m_dfuLevelCell;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,77 +0,0 @@
|
||||
#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
|
||||
@@ -1,24 +0,0 @@
|
||||
#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,15 +99,3 @@ 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,15 +99,3 @@ 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,15 +99,3 @@ 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,15 +99,3 @@ 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,15 +99,3 @@ 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,15 +99,3 @@ 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,15 +99,3 @@ 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,15 +99,3 @@ 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,11 +458,6 @@ 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,7 +1,6 @@
|
||||
app_usb_src = $(addprefix apps/usb/,\
|
||||
app.cpp \
|
||||
usb_connected_controller.cpp \
|
||||
usb_view.cpp \
|
||||
)
|
||||
|
||||
apps_src += $(app_usb_src)
|
||||
|
||||
@@ -27,7 +27,6 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,3 +11,4 @@ DfuStatusUnprotected = "UNGESCHÜTZT"
|
||||
USBProtectionLevel0 = "Standardschutz"
|
||||
USBProtectionLevel1 = "Omega Schutz"
|
||||
USBProtectionLevel2 = "Systemschutz"
|
||||
USBProtectionReactivated = "USB-Schutz wurde wieder aktiviert"
|
||||
|
||||
@@ -11,3 +11,4 @@ DfuStatusUnprotected = "UNPROTECTED"
|
||||
USBProtectionLevel0 = "Default Protection"
|
||||
USBProtectionLevel1 = "Omega Protection"
|
||||
USBProtectionLevel2 = "System Protection"
|
||||
USBProtectionReactivated = "USB Protection reactivated"
|
||||
|
||||
@@ -11,3 +11,4 @@ DfuStatusUnprotected = "DESABRIGADO"
|
||||
USBProtectionLevel0 = "Protección predeterminada"
|
||||
USBProtectionLevel1 = "Protección Omega"
|
||||
USBProtectionLevel2 = "Protección del sistema"
|
||||
USBProtectionReactivated = "La protección de la calculadora ha sido reactivada"
|
||||
@@ -11,3 +11,4 @@ DfuStatusUnprotected = "NON PROTÉGÉE"
|
||||
USBProtectionLevel0 = "Default Protection"
|
||||
USBProtectionLevel1 = "Omega Protection"
|
||||
USBProtectionLevel2 = "System Protection"
|
||||
USBProtectionReactivated = "La protection USB a été réactivée"
|
||||
@@ -11,3 +11,4 @@ DfuStatusUnprotected = "VÉDTELEN"
|
||||
USBProtectionLevel0 = "Alapértelmezett védelem"
|
||||
USBProtectionLevel1 = "Omega védelem"
|
||||
USBProtectionLevel2 = "Rendszervédelem"
|
||||
USBProtectionReactivated = "A védelem újra aktiválva"
|
||||
|
||||
@@ -11,3 +11,4 @@ DfuStatusUnprotected = "INDIFESO"
|
||||
USBProtectionLevel0 = "Protezione predefinita"
|
||||
USBProtectionLevel1 = "Protezione Omega"
|
||||
USBProtectionLevel2 = "Protezione del sistema"
|
||||
USBProtectionReactivated = "Protezione riattivata"
|
||||
|
||||
@@ -11,3 +11,4 @@ DfuStatusUnprotected = "NIET BESCHERMD"
|
||||
USBProtectionLevel0 = "Standaardbeveiliging"
|
||||
USBProtectionLevel1 = "Omega Bescherming"
|
||||
USBProtectionLevel2 = "Systeembeveiliging"
|
||||
USBProtectionReactivated = "USB-bescherming is geactiveerd"
|
||||
|
||||
@@ -11,3 +11,4 @@ DfuStatusUnprotected = "DESPROTEGIDO"
|
||||
USBProtectionLevel0 = "Proteção padrão"
|
||||
USBProtectionLevel1 = "Proteção Ômega"
|
||||
USBProtectionLevel2 = "Proteção do sistema"
|
||||
USBProtectionReactivated = "Proteção reativada"
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
#include <apps/i18n.h>
|
||||
#include "../global_preferences.h"
|
||||
|
||||
namespace USB
|
||||
{
|
||||
static constexpr I18n::Message sUSBConnectedMessages[k_numberOfUSBMessages] = {
|
||||
namespace USB {
|
||||
|
||||
static constexpr I18n::Message sUSBConnectedMessages[] = {
|
||||
I18n::Message::USBConnected,
|
||||
I18n::Message::ConnectedMessage1,
|
||||
I18n::Message::ConnectedMessage2,
|
||||
@@ -33,35 +33,35 @@ USBConnectedController::USBConnectedController() :
|
||||
|
||||
}
|
||||
|
||||
USBConnectedController::ContentView::ContentView(KDColor * fgcolors, KDColor * bgcolors, uint8_t numberOfMessages) {
|
||||
USBConnectedController::ContentView::ContentView() {
|
||||
// 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].setTextColor(sUSBConnectedFGColors[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]);
|
||||
m_messageTextViews[i].setText(I18n::translate(sUSBConnectedMessages[i]));
|
||||
}
|
||||
|
||||
// Last message, depending of the USB protection level
|
||||
if (GlobalPreferences::sharedGlobalPreferences()->dfuStatus()) {
|
||||
m_messageTextViews[i].setText(DfuStatusUnprotected);
|
||||
if (GlobalPreferences::sharedGlobalPreferences()->dfuUnlocked()) {
|
||||
m_messageTextViews[k_numberOfUSBMessages].setText(I18n::translate(I18n::Message::DfuStatusUnprotected));
|
||||
} else {
|
||||
int protectionLevel = GlobalPreferences::sharedGlobalPreferences()->getDfuLevel();
|
||||
int protectionLevel = GlobalPreferences::sharedGlobalPreferences()->dfuLevel();
|
||||
switch (protectionLevel) {
|
||||
case 0:
|
||||
m_messageTextViews[9].setText(USBProtectionLevel0);
|
||||
m_messageTextViews[9].setText(I18n::translate(I18n::Message::USBProtectionLevel0));
|
||||
break;
|
||||
case 1:
|
||||
m_messageTextViews[9].setText(USBProtectionLevel1);
|
||||
m_messageTextViews[9].setText(I18n::translate(I18n::Message::USBProtectionLevel1));
|
||||
break;
|
||||
default:
|
||||
assert(protectionLevel == 2);
|
||||
m_messageTextViews[9].setText(USBProtectionLevel2);
|
||||
m_messageTextViews[9].setText(I18n::translate(I18n::Message::USBProtectionLevel2));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,11 +8,12 @@ namespace USB {
|
||||
class USBConnectedController : public ViewController {
|
||||
public:
|
||||
USBConnectedController();
|
||||
View * view() override { return &m_messageView; }
|
||||
USBView * getMessageView() {return &m_messageView; }
|
||||
View * view() override { return &m_contentView; }
|
||||
bool handleEvent(Ion::Events::Event event) override { return false; };
|
||||
private:
|
||||
class ContentView : public View {
|
||||
public:
|
||||
ContentView(KDColor * fgcolors, KDColor * bgcolors);
|
||||
ContentView();
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
protected:
|
||||
int numberOfSubviews() const override { return k_numberOfMessages; }
|
||||
|
||||
Reference in New Issue
Block a user