mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[usb | recovery] Improve code quality
This commit is contained in:
@@ -148,7 +148,6 @@ bool AppsContainer::dispatchEvent(Ion::Events::Event event) {
|
||||
updateBatteryState();
|
||||
if (switchTo(usbConnectedAppSnapshot())) {
|
||||
Ion::USB::DFU(true, GlobalPreferences::sharedGlobalPreferences()->dfuStatus(), GlobalPreferences::sharedGlobalPreferences()->getDfuLevel());
|
||||
GlobalPreferences::sharedGlobalPreferences()->dfuResetStep();
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuStatus(false);
|
||||
// Update LED when exiting DFU mode
|
||||
Ion::LED::updateColorWithPlugAndCharge();
|
||||
|
||||
@@ -31,14 +31,9 @@ public:
|
||||
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 dfuCurrentStep() const { return m_dfuStep; }
|
||||
void dfuIncreaseStep() { m_dfuStep++; }
|
||||
void dfuResetStep() { m_dfuStep = 0; }
|
||||
void setDfuStatus(bool status) { m_dfuUnlocked = status; }
|
||||
int getDfuLevel() const { return m_dfuProtectLevel; }
|
||||
void setDfuLevel(int level) { m_dfuProtectLevel = level; }
|
||||
bool showDfuDeacAlert() const { return m_showDeacAlert; }
|
||||
void setDfuDeacAlert(bool value) { m_showDeacAlert = value; }
|
||||
bool autocomplete() const { return m_autoComplete; }
|
||||
void setAutocomplete(bool autocomple) { m_autoComplete = autocomple; }
|
||||
int brightnessLevel() const { return m_brightnessLevel; }
|
||||
@@ -57,9 +52,7 @@ private:
|
||||
m_tempExamMode(ExamMode::Standard),
|
||||
m_showPopUp(true),
|
||||
m_dfuUnlocked(false),
|
||||
m_dfuStep(0),
|
||||
m_dfuProtectLevel(0),
|
||||
m_showDeacAlert(true),
|
||||
m_autoComplete(true),
|
||||
m_brightnessLevel(Ion::Backlight::MaxBrightness),
|
||||
m_font(KDFont::LargeFont) {}
|
||||
@@ -71,12 +64,8 @@ private:
|
||||
mutable ExamMode m_tempExamMode;
|
||||
bool m_showPopUp;
|
||||
bool m_dfuUnlocked;
|
||||
int m_dfuStep;
|
||||
int m_dfuProtectLevel; // 0: default; 1: OmegaMode; 2: Paranoid; 3: Paranoid++
|
||||
bool m_showDeacAlert;
|
||||
bool m_autoComplete;
|
||||
int m_brightnessLevel;
|
||||
const KDFont * m_font;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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,7 +15,7 @@ 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)}; // , SettingsMessageTree(I18n::Message::USBMegaParanoidLevel)
|
||||
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)};
|
||||
|
||||
@@ -8,14 +8,14 @@ using namespace Shared;
|
||||
namespace Settings {
|
||||
|
||||
constexpr SettingsMessageTree s_modelMenu[] =
|
||||
{SettingsMessageTree(I18n::Message::MathOptions, s_modelMathOptionsChildren),
|
||||
{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),
|
||||
#ifdef HAS_CODE
|
||||
SettingsMessageTree(I18n::Message::CodeApp, s_codeChildren),
|
||||
SettingsMessageTree(I18n::Message::CodeApp, s_codeChildren),
|
||||
#endif
|
||||
SettingsMessageTree(I18n::Message::UsbSetting, s_usbSteps),
|
||||
SettingsMessageTree(I18n::Message::Accessibility, s_accessibilityChildren),
|
||||
|
||||
@@ -16,119 +16,86 @@ using namespace Shared;
|
||||
|
||||
namespace Settings {
|
||||
|
||||
UsbInfoController::UsbInfoController(Responder *parentResponder) : GenericSubController(parentResponder),
|
||||
m_usbprotectlevel(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);
|
||||
//Ancien code au cas ou on souhaite ajouter d'autres éléments dans le menu
|
||||
// m_cell[i].setMessageFont(KDFont::LargeFont);
|
||||
// m_cell[i].setAccessoryFont(KDFont::SmallFont);
|
||||
// m_cell[i].setAccessoryTextColor(Palette::SecondaryText);
|
||||
}
|
||||
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()->showDfuDeacAlert()){
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuDeacAlert(false);
|
||||
Container::activeApp()->displayWarning(I18n::Message::USBDeacAlert1, I18n::Message::USBDeacAlert2);
|
||||
return true;
|
||||
}
|
||||
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;
|
||||
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);
|
||||
}
|
||||
|
||||
if (GlobalPreferences::sharedGlobalPreferences()->dfuStatus() && event != Ion::Events::USBPlug && event != Ion::Events::USBEnumeration) {
|
||||
Container::activeApp()->displayWarning(I18n::Message::UsbSetting, I18n::Message::USBSettingDeact);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((Ion::Events::OK == event || Ion::Events::EXE == event) && selectedRow() == 1) {
|
||||
GenericSubController *subController = &m_usbprotectlevel;
|
||||
subController->setMessageTreeModel(m_messageTreeModel->childAtIndex(1));
|
||||
StackViewController *stack = stackController();
|
||||
m_lastSelect = selectedRow();
|
||||
stack->push(subController);
|
||||
return true;
|
||||
}
|
||||
GlobalPreferences::sharedGlobalPreferences()->setDfuDeacAlert(true);
|
||||
return GenericSubController::handleEvent(event);
|
||||
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(type == 2 || type == 1);
|
||||
if (type == 2) {
|
||||
assert(index >= 0 && index < k_maxSwitchCells);
|
||||
return &m_switchCells[index];
|
||||
}
|
||||
return &m_dfuLevel;
|
||||
assert(index == 0 || index == 1);
|
||||
return index == 0 ? &m_switchCell : &m_dfuLevelCell;
|
||||
}
|
||||
|
||||
int UsbInfoController::reusableCellCount(int type) {
|
||||
assert(type == 2 || type == 1);
|
||||
if (type == 2) {
|
||||
return k_maxSwitchCells;
|
||||
}
|
||||
return 1;
|
||||
assert(type == 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void UsbInfoController::willDisplayCellForIndex(HighlightCell *cell, int index) {
|
||||
GenericSubController::willDisplayCellForIndex(cell, 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::USBDefaultLevel);
|
||||
mcell->setSubtitle(I18n::Message::USBDefaultLevelDesc);
|
||||
} else if (currentLevel == 1) {
|
||||
// mcell->setSubtitle(I18n::Message::USBLowLevel);
|
||||
mcell->setSubtitle(I18n::Message::USBLowLevelDesc);
|
||||
} else if (currentLevel == 2) {
|
||||
// mcell->setSubtitle(I18n::Message::USBParanoidLevel);
|
||||
mcell->setSubtitle(I18n::Message::USBParanoidLevelDesc);
|
||||
} else {
|
||||
// mcell->setSubtitle(I18n::Message::USBMegaParanoidLevel);
|
||||
mcell->setSubtitle(I18n::Message::USBMegaParanoidLevelDesc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int UsbInfoController::typeAtLocation(int i, int j) {
|
||||
switch (j) {
|
||||
case 0:
|
||||
return 2;
|
||||
default:
|
||||
return 1;
|
||||
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_contentView.reload();
|
||||
|
||||
if (numberOfInfoLines() > 0) {
|
||||
I18n::Message infoMessages[] = {I18n::Message::USBE16_expl1, I18n::Message::USBE16_expl2, I18n::Message::USBE16_expl3};
|
||||
m_contentView.setMessages(infoMessages, numberOfInfoLines());
|
||||
}
|
||||
m_selectableTableView.reload();
|
||||
I18n::Message infoMessages[] = {I18n::Message::USBExplanation1, I18n::Message::USBExplanation2, I18n::Message::USBExplanation3};
|
||||
m_selectableTableView.setMessages(infoMessages, k_numberOfExplanationMessages);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,16 +19,12 @@ class UsbInfoController : public GenericSubController {
|
||||
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_numberOfInfoE16MessageLines = 3;
|
||||
int numberOfInfoLines() const { return k_numberOfInfoE16MessageLines; };
|
||||
static constexpr int k_maxSwitchCells = 1;
|
||||
MessageTableCellWithSwitch m_switchCells[k_maxSwitchCells];
|
||||
UsbProtectionLevelController m_usbprotectlevel;
|
||||
MessageTableCellWithChevronAndMessage m_dfuLevel;
|
||||
SelectableViewWithMessages m_contentView;
|
||||
static constexpr int k_numberOfExplanationMessages = 3;
|
||||
MessageTableCellWithSwitch m_switchCell;
|
||||
UsbProtectionLevelController m_usbProtectionLevelController;
|
||||
MessageTableCellWithChevronAndMessage m_dfuLevelCell;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -5,9 +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."
|
||||
DfuStatus1 = "Status des Rechners:"
|
||||
DfuStatus = "Status des Rechners:"
|
||||
DfuStatusProtected = "GESCHÜTZT"
|
||||
DfuStatusUnProtected = "UNGESCHÜTZT"
|
||||
DfuStatusUnprotected = "UNGESCHÜTZT"
|
||||
USBProtectionLevel0 = "Standardschutz"
|
||||
USBProtectionLevel1 = "Omega Schutz"
|
||||
USBProtectionLevel2 = "Systemschutz"
|
||||
|
||||
@@ -5,9 +5,9 @@ ConnectedMessage3 = "getomega.dev/ide"
|
||||
ConnectedMessage4 = "Press the BACK key of your"
|
||||
ConnectedMessage5 = "calculator or unplug it to"
|
||||
ConnectedMessage6 = "disconnect it."
|
||||
DfuStatus1 = "Calculator status:"
|
||||
DfuStatus = "Calculator status:"
|
||||
DfuStatusProtected = "PROTECTED"
|
||||
DfuStatusUnProtected = "UNPROTECTED"
|
||||
DfuStatusUnprotected = "UNPROTECTED"
|
||||
USBProtectionLevel0 = "Default Protection"
|
||||
USBProtectionLevel1 = "Omega Protection"
|
||||
USBProtectionLevel2 = "System Protection"
|
||||
|
||||
@@ -5,9 +5,9 @@ ConnectedMessage3 = "getomega.dev/ide"
|
||||
ConnectedMessage4 = "Pulse el botón RETURN de la"
|
||||
ConnectedMessage5 = "calculadora o desenchúfela para"
|
||||
ConnectedMessage6 = "desconectarla."
|
||||
DfuStatus1 = "Estado de la calculadora:"
|
||||
DfuStatus = "Estado de la calculadora:"
|
||||
DfuStatusProtected = "PROTEGIDO"
|
||||
DfuStatusUnProtected = "DESABRIGADO"
|
||||
DfuStatusUnprotected = "DESABRIGADO"
|
||||
USBProtectionLevel0 = "Protección predeterminada"
|
||||
USBProtectionLevel1 = "Protección Omega"
|
||||
USBProtectionLevel2 = "Protección del sistema"
|
||||
|
||||
@@ -5,9 +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."
|
||||
DfuStatus1 = "Etat de la calculatrice:"
|
||||
DfuStatus = "Etat de la calculatrice:"
|
||||
DfuStatusProtected = "PROTÉGÉE"
|
||||
DfuStatusUnProtected = "NON PROTÉGÉE"
|
||||
DfuStatusUnprotected = "NON PROTÉGÉE"
|
||||
USBProtectionLevel0 = "Default Protection"
|
||||
USBProtectionLevel1 = "Omega Protection"
|
||||
USBProtectionLevel2 = "System Protection"
|
||||
|
||||
@@ -5,9 +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."
|
||||
DfuStatus1 = "Számológép állapota:"
|
||||
DfuStatus = "Számológép állapota:"
|
||||
DfuStatusProtected = "VÉDETT"
|
||||
DfuStatusUnProtected = "VÉDTELEN"
|
||||
DfuStatusUnprotected = "VÉDTELEN"
|
||||
USBProtectionLevel0 = "Alapértelmezett védelem"
|
||||
USBProtectionLevel1 = "Omega védelem"
|
||||
USBProtectionLevel2 = "Rendszervédelem"
|
||||
|
||||
@@ -5,9 +5,9 @@ ConnectedMessage3 = "getomega.dev/ide"
|
||||
ConnectedMessage4 = "Premere sul tasto INDIETRO della"
|
||||
ConnectedMessage5 = "calcolatrice o scollegatela per"
|
||||
ConnectedMessage6 = "disconnetterla."
|
||||
DfuStatus1 = "Stato della calcolatrice:"
|
||||
DfuStatus = "Stato della calcolatrice:"
|
||||
DfuStatusProtected = "PROTETTO"
|
||||
DfuStatusUnProtected = "INDIFESO"
|
||||
DfuStatusUnprotected = "INDIFESO"
|
||||
USBProtectionLevel0 = "Protezione predefinita"
|
||||
USBProtectionLevel1 = "Protezione Omega"
|
||||
USBProtectionLevel2 = "Protezione del sistema"
|
||||
|
||||
@@ -5,9 +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."
|
||||
DfuStatus1 = "Rekenmachine status:"
|
||||
DfuStatus = "Rekenmachine status:"
|
||||
DfuStatusProtected = "BESCHERMD"
|
||||
DfuStatusUnProtected = "NIET BESCHERMD"
|
||||
DfuStatusUnprotected = "NIET BESCHERMD"
|
||||
USBProtectionLevel0 = "Standaardbeveiliging"
|
||||
USBProtectionLevel1 = "Omega Bescherming"
|
||||
USBProtectionLevel2 = "Systeembeveiliging"
|
||||
|
||||
@@ -5,9 +5,9 @@ ConnectedMessage3 = "getomega.dev/ide"
|
||||
ConnectedMessage4 = "Pressione o botão RETURN na"
|
||||
ConnectedMessage5 = "calculadora ou desligue-a para a"
|
||||
ConnectedMessage6 = "desconectar."
|
||||
DfuStatus1 = "Status da calculadora:"
|
||||
DfuStatus = "Status da calculadora:"
|
||||
DfuStatusProtected = "PROTEGIDO"
|
||||
DfuStatusUnProtected = "DESPROTEGIDO"
|
||||
DfuStatusUnprotected = "DESPROTEGIDO"
|
||||
USBProtectionLevel0 = "Proteção padrão"
|
||||
USBProtectionLevel1 = "Proteção Ômega"
|
||||
USBProtectionLevel2 = "Proteção do sistema"
|
||||
|
||||
@@ -4,137 +4,86 @@
|
||||
|
||||
namespace USB
|
||||
{
|
||||
static constexpr I18n::Message sUSBConnectedMessages[k_numberOfUSBMessages] = {
|
||||
I18n::Message::USBConnected,
|
||||
I18n::Message::ConnectedMessage1,
|
||||
I18n::Message::ConnectedMessage2,
|
||||
I18n::Message::ConnectedMessage3,
|
||||
I18n::Message::BlankMessage,
|
||||
I18n::Message::ConnectedMessage4,
|
||||
I18n::Message::ConnectedMessage5,
|
||||
I18n::Message::ConnectedMessage6,
|
||||
I18n::Message::DfuStatus};
|
||||
|
||||
static I18n::Message sUSBConnectedMessagesProtection0[10] = {
|
||||
I18n::Message::USBConnected,
|
||||
I18n::Message::ConnectedMessage1,
|
||||
I18n::Message::ConnectedMessage2,
|
||||
I18n::Message::ConnectedMessage3,
|
||||
I18n::Message::BlankMessage,
|
||||
I18n::Message::ConnectedMessage4,
|
||||
I18n::Message::ConnectedMessage5,
|
||||
I18n::Message::ConnectedMessage6,
|
||||
I18n::Message::DfuStatus1,
|
||||
I18n::Message::USBProtectionLevel0};
|
||||
|
||||
static I18n::Message sUSBConnectedMessagesProtection1[10] = {
|
||||
I18n::Message::USBConnected,
|
||||
I18n::Message::ConnectedMessage1,
|
||||
I18n::Message::ConnectedMessage2,
|
||||
I18n::Message::ConnectedMessage3,
|
||||
I18n::Message::BlankMessage,
|
||||
I18n::Message::ConnectedMessage4,
|
||||
I18n::Message::ConnectedMessage5,
|
||||
I18n::Message::ConnectedMessage6,
|
||||
I18n::Message::DfuStatus1,
|
||||
I18n::Message::USBProtectionLevel1};
|
||||
|
||||
static I18n::Message sUSBConnectedMessagesProtection2[10] = {
|
||||
I18n::Message::USBConnected,
|
||||
I18n::Message::ConnectedMessage1,
|
||||
I18n::Message::ConnectedMessage2,
|
||||
I18n::Message::ConnectedMessage3,
|
||||
I18n::Message::BlankMessage,
|
||||
I18n::Message::ConnectedMessage4,
|
||||
I18n::Message::ConnectedMessage5,
|
||||
I18n::Message::ConnectedMessage6,
|
||||
I18n::Message::DfuStatus1,
|
||||
I18n::Message::USBProtectionLevel2};
|
||||
static constexpr KDColor sUSBConnectedFGColors[] = {
|
||||
Palette::PrimaryText,
|
||||
Palette::PrimaryText,
|
||||
Palette::PrimaryText,
|
||||
Palette::AccentText,
|
||||
KDColorWhite,
|
||||
Palette::PrimaryText,
|
||||
Palette::PrimaryText,
|
||||
Palette::PrimaryText,
|
||||
Palette::PrimaryText,
|
||||
Palette::AccentText};
|
||||
|
||||
static I18n::Message sUSBConnectedMessagesUnProtected[10] = {
|
||||
I18n::Message::USBConnected,
|
||||
I18n::Message::ConnectedMessage1,
|
||||
I18n::Message::ConnectedMessage2,
|
||||
I18n::Message::ConnectedMessage3,
|
||||
I18n::Message::BlankMessage,
|
||||
I18n::Message::ConnectedMessage4,
|
||||
I18n::Message::ConnectedMessage5,
|
||||
I18n::Message::ConnectedMessage6,
|
||||
I18n::Message::DfuStatus1,
|
||||
I18n::Message::DfuStatusUnProtected};
|
||||
|
||||
static KDColor sUSBConnectedFGColors[] = {
|
||||
Palette::PrimaryText,
|
||||
Palette::PrimaryText,
|
||||
Palette::PrimaryText,
|
||||
Palette::AccentText,
|
||||
KDColorWhite,
|
||||
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,
|
||||
Palette::BackgroundHard,
|
||||
Palette::BackgroundHard};
|
||||
|
||||
USBConnectedController::USBConnectedController() : ViewController(nullptr), step(0), already_init(false), m_messageView(sUSBConnectedMessagesProtection0, sUSBConnectedFGColors, sUSBConnectedBGColors, 10)
|
||||
{
|
||||
if(already_init){
|
||||
return;
|
||||
}
|
||||
if (step == 0 && GlobalPreferences::sharedGlobalPreferences()->dfuStatus())
|
||||
{
|
||||
getMessageView()->update(sUSBConnectedMessagesUnProtected, sUSBConnectedFGColors, sUSBConnectedBGColors, 10);
|
||||
}else if(step == 0){
|
||||
if(GlobalPreferences::sharedGlobalPreferences()->getDfuLevel() == 1){
|
||||
getMessageView()->update(sUSBConnectedMessagesProtection1, sUSBConnectedFGColors, sUSBConnectedBGColors, 10);
|
||||
}else if(GlobalPreferences::sharedGlobalPreferences()->getDfuLevel() == 2){
|
||||
getMessageView()->update(sUSBConnectedMessagesProtection2, sUSBConnectedFGColors, sUSBConnectedBGColors, 10);
|
||||
}
|
||||
}
|
||||
// else if (step == 1 && GlobalPreferences::sharedGlobalPreferences()->dfuStatus())
|
||||
// {
|
||||
// getMessageView()->update(sUSBConnectedMessages2UnProtected, sUSBConnectedFGColors, sUSBConnectedBGColors, 10);
|
||||
// }
|
||||
// else if (step == 1 && !GlobalPreferences::sharedGlobalPreferences()->dfuStatus())
|
||||
// {
|
||||
// getMessageView()->update(sUSBConnectedMessages2Protected, sUSBConnectedFGColors, sUSBConnectedBGColors, 10);
|
||||
// }
|
||||
already_init = true;
|
||||
}
|
||||
|
||||
// bool USBConnectedController::handleEvent(Ion::Events::Event event)
|
||||
// {
|
||||
// if (event.isKeyboardEvent())
|
||||
// {
|
||||
// // Ne fonctionne pas pour l'instant fait bugger les events
|
||||
// // if (step == 0)
|
||||
// // {
|
||||
// // if (GlobalPreferences::sharedGlobalPreferences()->dfuStatus())
|
||||
// // {
|
||||
// // getMessageView()->update(sUSBConnectedMessagesUnProtected, sUSBConnectedFGColors, sUSBConnectedBGColors, 10);
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // getMessageView()->update(sUSBConnectedMessagesProtected, sUSBConnectedFGColors, sUSBConnectedBGColors, 10);
|
||||
// // }
|
||||
// // step = 1;
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // if (GlobalPreferences::sharedGlobalPreferences()->dfuStatus())
|
||||
// // {
|
||||
// // getMessageView()->update(sUSBConnectedMessages2UnProtected, sUSBConnectedFGColors, sUSBConnectedBGColors, 10);
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // getMessageView()->update(sUSBConnectedMessages2Protected, sUSBConnectedFGColors, sUSBConnectedBGColors, 10);
|
||||
// // }
|
||||
// // step = 0;
|
||||
// // }
|
||||
// return false;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
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 "usb_view.h"
|
||||
|
||||
namespace USB {
|
||||
|
||||
@@ -12,13 +11,23 @@ public:
|
||||
View * view() override { return &m_messageView; }
|
||||
USBView * getMessageView() {return &m_messageView; }
|
||||
bool handleEvent(Ion::Events::Event event) override { return false; };
|
||||
private:
|
||||
int step;
|
||||
bool already_init;
|
||||
USBView m_messageView;
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user