diff --git a/apps/Makefile b/apps/Makefile index efc2c58d0..15d4774da 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -31,8 +31,8 @@ app_src += $(addprefix apps/,\ variable_box_empty_controller.cpp \ ) -tests_src += apps/exam_mode_configuration_official.cpp -apps_official += apps/exam_mode_configuration_official.cpp +tests_src += apps/exam_mode_configuration_non_official.cpp +apps_official += apps/exam_mode_configuration_non_official.cpp apps_non_official += apps/exam_mode_configuration_non_official.cpp apps_launch_on_boarding_src += apps/apps_container_launch_on_boarding.cpp diff --git a/apps/exam_mode_configuration_non_official.cpp b/apps/exam_mode_configuration_non_official.cpp index ea4a6f5ae..8905e9a79 100644 --- a/apps/exam_mode_configuration_non_official.cpp +++ b/apps/exam_mode_configuration_non_official.cpp @@ -3,7 +3,8 @@ using namespace Poincare; constexpr Settings::SettingsMessageTree s_ledColorChildren[] = {Settings::SettingsMessageTree(I18n::Message::ColorRed), Settings::SettingsMessageTree(I18n::Message::ColorWhite), Settings::SettingsMessageTree(I18n::Message::ColorGreen), Settings::SettingsMessageTree(I18n::Message::ColorBlue), Settings::SettingsMessageTree(I18n::Message::ColorYellow), Settings::SettingsMessageTree(I18n::Message::ColorPurple), Settings::SettingsMessageTree(I18n::Message::ColorOrange)}; -constexpr Settings::SettingsMessageTree ExamModeConfiguration::s_modelExamChildren[] = {Settings::SettingsMessageTree(I18n::Message::LEDColor, s_ledColorChildren), Settings::SettingsMessageTree(I18n::Message::ExamModeModeStandard), Settings::SettingsMessageTree(I18n::Message::ExamModeModeNoSym)}; +constexpr Settings::SettingsMessageTree s_examModeMode[] = {Settings::SettingsMessageTree(I18n::Message::ExamModeModeStandard), Settings::SettingsMessageTree(I18n::Message::ExamModeModeNoSym), Settings::SettingsMessageTree(I18n::Message::ExamModeModeNoSymNoText)}; +constexpr Settings::SettingsMessageTree ExamModeConfiguration::s_modelExamChildren[] = {Settings::SettingsMessageTree(I18n::Message::LEDColor, s_ledColorChildren), Settings::SettingsMessageTree(I18n::Message::ExamModeMode, s_examModeMode), Settings::SettingsMessageTree(I18n::Message::ActivateExamMode)}; int ExamModeConfiguration::numberOfAvailableExamMode() { return 3; @@ -22,13 +23,13 @@ I18n::Message ExamModeConfiguration::examModeActivationWarningMessage(GlobalPref I18n::Message warnings[] = {I18n::Message::ExitExamMode1, I18n::Message::ExitExamMode2, I18n::Message::Default}; return warnings[line]; } - assert(mode == GlobalPreferences::ExamMode::Standard || mode == GlobalPreferences::ExamMode::NoSym); + assert(mode == GlobalPreferences::ExamMode::Standard || mode == GlobalPreferences::ExamMode::NoSym || mode == GlobalPreferences::ExamMode::NoSymNoText); I18n::Message warnings[] = {I18n::Message::ActiveExamModeMessage1, I18n::Message::ActiveExamModeMessage2, I18n::Message::ActiveExamModeMessage3}; return warnings[line]; } KDColor ExamModeConfiguration::examModeColor(GlobalPreferences::ExamMode mode) { - assert(mode == GlobalPreferences::ExamMode::Standard || mode == GlobalPreferences::ExamMode::NoSym); + assert(mode == GlobalPreferences::ExamMode::Standard || mode == GlobalPreferences::ExamMode::NoSym || mode == GlobalPreferences::ExamMode::NoSymNoText); Preferences * preferences = Preferences::sharedPreferences(); switch((int) preferences->colorOfLED()) { diff --git a/apps/exam_mode_configuration_official.cpp b/apps/exam_mode_configuration_official.cpp deleted file mode 100644 index b5f2e65ab..000000000 --- a/apps/exam_mode_configuration_official.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// SPDX-License-Identifier: CC-BY-NC-ND-4.0 -// Caution: Dutch exam mode is subject to a compliance certification by a government agency. Distribution of a non-certified Dutch exam mode is illegal. - -#include "exam_mode_configuration.h" - -constexpr Settings::SettingsMessageTree s_ledColorChildren[7] = {Settings::SettingsMessageTree(I18n::Message::ColorRed), Settings::SettingsMessageTree(I18n::Message::ColorWhite), Settings::SettingsMessageTree(I18n::Message::ColorGreen), Settings::SettingsMessageTree(I18n::Message::ColorBlue), Settings::SettingsMessageTree(I18n::Message::ColorYellow), Settings::SettingsMessageTree(I18n::Message::ColorPurple), Settings::SettingsMessageTree(I18n::Message::ColorOrange)}; -constexpr Settings::SettingsMessageTree s_examModeMode[3] = {Settings::SettingsMessageTree(I18n::Message::ExamModeModeStandard), Settings::SettingsMessageTree(I18n::Message::ExamModeModeNoSym), Settings::SettingsMessageTree(I18n::Message::ExamModeModeDutch)}; -constexpr Settings::SettingsMessageTree ExamModeConfiguration::s_modelExamChildren[3] = {Settings::SettingsMessageTree(I18n::Message::LEDColor, s_ledColorChildren), Settings::SettingsMessageTree(I18n::Message::ExamModeMode, s_examModeMode), Settings::SettingsMessageTree(I18n::Message::ActivateExamMode)}; - - -int ExamModeConfiguration::numberOfAvailableExamMode() { - if (GlobalPreferences::sharedGlobalPreferences()->language() != I18n::Language::EN || GlobalPreferences::sharedGlobalPreferences()->isInExamMode()) { - return 1; - } - return 2; -} - -GlobalPreferences::ExamMode ExamModeConfiguration::examModeAtIndex(int index) { - return index == 0 ? GlobalPreferences::ExamMode::Standard : GlobalPreferences::ExamMode::Dutch; -} - -I18n::Message ExamModeConfiguration::examModeActivationMessage(int index) { - return index == 0 ? I18n::Message::ActivateExamMode : I18n::Message::ActivateDutchExamMode; -} - -I18n::Message ExamModeConfiguration::examModeActivationWarningMessage(GlobalPreferences::ExamMode mode, int line) { - if (mode == GlobalPreferences::ExamMode::Off) { - I18n::Message warnings[] = {I18n::Message::ExitExamMode1, I18n::Message::ExitExamMode2, I18n::Message::Default}; - return warnings[line]; - } else if (mode == GlobalPreferences::ExamMode::Standard || mode == GlobalPreferences::ExamMode::NoSym) { - I18n::Message warnings[] = {I18n::Message::ActiveExamModeMessage1, I18n::Message::ActiveExamModeMessage2, I18n::Message::ActiveExamModeMessage3}; - return warnings[line]; - } - assert(mode == GlobalPreferences::ExamMode::Dutch); - I18n::Message warnings[] = {I18n::Message::ActiveDutchExamModeMessage1, I18n::Message::ActiveDutchExamModeMessage2, I18n::Message::ActiveDutchExamModeMessage3}; - return warnings[line]; -} - -KDColor ExamModeConfiguration::examModeColor(GlobalPreferences::ExamMode mode) { - /* The Dutch exam mode LED is supposed to be orange but we can only make - * blink "pure" colors: with RGB leds on or off (as the PWM is used for - * blinking). The closest "pure" color is Yellow. Moreover, Orange LED is - * already used when the battery is charging. Using yellow, we can assert - * that the yellow LED only means that Dutch exam mode is on and avoid - * confusing states when the battery is charging and states when the Dutch - * exam mode is on. */ - return mode == GlobalPreferences::ExamMode::Dutch ? KDColorYellow : KDColorRed; -} - -bool ExamModeConfiguration::appIsForbiddenInExamMode(I18n::Message appName, GlobalPreferences::ExamMode mode) { - return appName == I18n::Message::CodeApp && mode == GlobalPreferences::ExamMode::Dutch; -} - -bool ExamModeConfiguration::exactExpressionsAreForbidden(GlobalPreferences::ExamMode mode) { - return mode == GlobalPreferences::ExamMode::Dutch; -} diff --git a/apps/global_preferences.cpp b/apps/global_preferences.cpp index d05127172..938cff861 100644 --- a/apps/global_preferences.cpp +++ b/apps/global_preferences.cpp @@ -8,7 +8,7 @@ GlobalPreferences * GlobalPreferences::sharedGlobalPreferences() { GlobalPreferences::ExamMode GlobalPreferences::examMode() const { if (m_examMode == ExamMode::Unknown) { uint8_t mode = Ion::ExamMode::FetchExamMode(); - assert(mode >= 0 && mode < 4); // mode can be cast in ExamMode (Off, Standard, NoSym or Dutch) + assert(mode >= 0 && mode < 5); // mode can be cast in ExamMode (Off, Standard, NoSym, Dutch or NoSymNoText) m_examMode = (ExamMode)mode; } return m_examMode; diff --git a/apps/global_preferences.h b/apps/global_preferences.h index b54ea0b2a..0ff7c00be 100644 --- a/apps/global_preferences.h +++ b/apps/global_preferences.h @@ -10,7 +10,8 @@ public: Off = 0, Standard = 1, NoSym = 2, - Dutch = 3, + NoSymNoText = 3, + Dutch = 4, }; static GlobalPreferences * sharedGlobalPreferences(); I18n::Language language() const { return m_language; } diff --git a/apps/home/controller.cpp b/apps/home/controller.cpp index 4f2f14249..5969657a3 100644 --- a/apps/home/controller.cpp +++ b/apps/home/controller.cpp @@ -59,7 +59,7 @@ bool Controller::handleEvent(Ion::Events::Event event) { if (event == Ion::Events::OK || event == Ion::Events::EXE) { AppsContainer * container = AppsContainer::sharedAppsContainer(); ::App::Snapshot * selectedSnapshot = container->appSnapshotAtIndex(selectionDataSource()->selectedRow()*k_numberOfColumns+selectionDataSource()->selectedColumn()+1); - if ((GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Dutch && selectedSnapshot->descriptor()->examinationLevel() < 2) || + if (((GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Dutch || GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::NoSymNoText) && selectedSnapshot->descriptor()->examinationLevel() < 2) || ((GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Standard || GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::NoSym) && selectedSnapshot->descriptor()->examinationLevel() < 1)) { App::app()->displayWarning(I18n::Message::ForbidenAppInExamMode1, I18n::Message::ForbidenAppInExamMode2); } else { diff --git a/apps/settings/base.de.i18n b/apps/settings/base.de.i18n index e8e4b3750..2735c7830 100644 --- a/apps/settings/base.de.i18n +++ b/apps/settings/base.de.i18n @@ -48,6 +48,7 @@ LEDColor = "LEDs farbe" ExamModeMode = "Modus" ExamModeModeStandard = "Standard " ExamModeModeNoSym = "Ohne symbolisch " +ExamModeModeNoSymNoText = "No sym no text " ExamModeModeDutch = "Niederländisch " ColorRed = "Rot " ColorWhite = "Weiss " diff --git a/apps/settings/base.en.i18n b/apps/settings/base.en.i18n index 377c81d92..a5dcffcb4 100644 --- a/apps/settings/base.en.i18n +++ b/apps/settings/base.en.i18n @@ -48,6 +48,7 @@ LEDColor = "LED color" ExamModeMode = "Mode" ExamModeModeStandard = "Standard " ExamModeModeNoSym = "No sym " +ExamModeModeNoSymNoText = "No sym no text " ExamModeModeDutch = "Dutch " ColorRed = "Red " ColorWhite = "White " diff --git a/apps/settings/base.es.i18n b/apps/settings/base.es.i18n index 68435d29a..a31a327c5 100644 --- a/apps/settings/base.es.i18n +++ b/apps/settings/base.es.i18n @@ -48,6 +48,7 @@ LEDColor = "Color del LED" ExamModeMode = "Modo" ExamModeModeStandard = "Estándar " ExamModeModeNoSym = "Sin simbólico " +ExamModeModeNoSymNoText = "sin simbolismo sin texto " ExamModeModeDutch = "Holandés " ColorRed = "Rojo " ColorWhite = "Blanco " diff --git a/apps/settings/base.fr.i18n b/apps/settings/base.fr.i18n index 2575bf2a9..f9f6afda2 100644 --- a/apps/settings/base.fr.i18n +++ b/apps/settings/base.fr.i18n @@ -48,6 +48,7 @@ LEDColor = "Couleur LED" ExamModeMode = "Mode" ExamModeModeStandard = "Standard " ExamModeModeNoSym = "Sans symbolique " +ExamModeModeNoSymNoText = "Sans symbolique ni texte " ExamModeModeDutch = "Néerlandais " ColorRed = "Rouge " ColorWhite = "Blanc " diff --git a/apps/settings/base.hu.i18n b/apps/settings/base.hu.i18n index de8c16cb6..fd17722fe 100644 --- a/apps/settings/base.hu.i18n +++ b/apps/settings/base.hu.i18n @@ -48,6 +48,7 @@ LEDColor = "LED szín" ExamModeMode = "Üzemmód" ExamModeModeStandard = "Normál" ExamModeModeNoSym = "Nincs sym" +ExamModeModeNoSymNoText = "No Symbolic no text " ExamModeModeDutch = "Holland " ColorRed = "Piros " ColorWhite = "Fehér " diff --git a/apps/settings/base.pt.i18n b/apps/settings/base.pt.i18n index c12556e39..322a38430 100644 --- a/apps/settings/base.pt.i18n +++ b/apps/settings/base.pt.i18n @@ -48,6 +48,7 @@ LEDColor = "Cor LED" ExamModeMode = "Modo" ExamModeModeStandard = "Padrão " ExamModeModeNoSym = "Sem simbólico " +ExamModeModeNoSymNoText = "Sem simbólico sem texto " ExamModeModeDutch = "Holandês " ColorRed = "Vermelho " ColorWhite = "Branco " diff --git a/apps/settings/sub_menu/exam_mode_controller.cpp b/apps/settings/sub_menu/exam_mode_controller.cpp index c60fbbd89..c88c95575 100644 --- a/apps/settings/sub_menu/exam_mode_controller.cpp +++ b/apps/settings/sub_menu/exam_mode_controller.cpp @@ -18,7 +18,9 @@ ExamModeController::ExamModeController(Responder * parentResponder) : m_contentView(&m_selectableTableView), m_cell{}, m_ledController(this), - m_ledColorCell(KDFont::LargeFont, KDFont::SmallFont) + m_examModeModeController(this), + m_ledColorCell(KDFont::LargeFont, KDFont::SmallFont), + m_examModeCell(KDFont::LargeFont, KDFont::SmallFont) { for (int i = 0; i < k_maxNumberOfCells; i++) { m_cell[i].setMessage(ExamModeConfiguration::examModeActivationMessage(i)); @@ -33,6 +35,11 @@ bool ExamModeController::handleEvent(Ion::Events::Event event) { StackViewController * stack = stackController(); stack->push(&m_ledController); return true; + } else if (m_messageTreeModel->children(selectedRow())->label() == I18n::Message::ExamModeMode) { + (&m_examModeModeController)->setMessageTreeModel(m_messageTreeModel->children(selectedRow())); + StackViewController * stack = stackController(); + stack->push(&m_examModeModeController); + return true; } else { AppsContainer::sharedAppsContainer()->displayExamModePopUp(examMode()); return true; @@ -69,6 +76,9 @@ HighlightCell * ExamModeController::reusableCell(int index, int type) { if (m_messageTreeModel->children(index)->label() == I18n::Message::LEDColor) { return &m_ledColorCell; } + if (m_messageTreeModel->children(index)->label() == I18n::Message::ExamModeMode) { + return &m_examModeCell; + } return &m_cell[index]; } @@ -112,7 +122,7 @@ int ExamModeController::initialSelectedRow() const { } GlobalPreferences::ExamMode ExamModeController::examMode() { - GlobalPreferences::ExamMode mode = ExamModeConfiguration::examModeAtIndex(selectedRow()); + GlobalPreferences::ExamMode mode = GlobalPreferences::sharedGlobalPreferences()->tempExamMode(); if (GlobalPreferences::sharedGlobalPreferences()->isInExamMode()) { // If the exam mode is already on, this re-activate the same exam mode mode = GlobalPreferences::sharedGlobalPreferences()->examMode(); diff --git a/apps/settings/sub_menu/exam_mode_controller.h b/apps/settings/sub_menu/exam_mode_controller.h index 22578e9bb..233facd86 100644 --- a/apps/settings/sub_menu/exam_mode_controller.h +++ b/apps/settings/sub_menu/exam_mode_controller.h @@ -28,7 +28,9 @@ private: SelectableViewWithMessages m_contentView; MessageTableCell m_cell[k_maxNumberOfCells]; PreferencesController m_ledController; + PreferencesController m_examModeModeController; MessageTableCellWithChevronAndMessage m_ledColorCell; + MessageTableCellWithChevronAndMessage m_examModeCell; }; } diff --git a/apps/settings/sub_menu/preferences_controller.cpp b/apps/settings/sub_menu/preferences_controller.cpp index c5db57bc7..c32caa5f3 100644 --- a/apps/settings/sub_menu/preferences_controller.cpp +++ b/apps/settings/sub_menu/preferences_controller.cpp @@ -155,6 +155,11 @@ Layout PreferencesController::layoutForPreferences(I18n::Message message) { const char * text = " "; return LayoutHelper::String(text, strlen(text), k_layoutFont); } + case I18n::Message::ExamModeModeNoSymNoText: + { + const char * text = " "; + return LayoutHelper::String(text, strlen(text), k_layoutFont); + } case I18n::Message::ExamModeModeDutch: { const char * text = " "; diff --git a/ion/src/device/shared/drivers/exam_mode.cpp b/ion/src/device/shared/drivers/exam_mode.cpp index 326480d5e..b332a2999 100644 --- a/ion/src/device/shared/drivers/exam_mode.cpp +++ b/ion/src/device/shared/drivers/exam_mode.cpp @@ -23,8 +23,9 @@ char ones[Config::ExamModeBufferSize] * leading 0 bits. If it is equal to: * - 0[3]: the exam mode is off; * - 1[3]: the standard exam mode is activated; - * - 2[3]: the NoSym exam mode is activated. - * - 3[3]: the Dutch exam mode is activated. */ + * - 2[3]: the NoSym exam mode is activated; + * - 3[3]: the Dutch exam mode is activated; + * - 4[3]: the NoSymNoText exam mode is activated. */ /* significantExamModeAddress returns the first uint32_t * in the exam mode * flash sector that does not point to 0. If this flash sector has only 0s or