diff --git a/apps/apps_container.cpp b/apps/apps_container.cpp index 0d380746e..7ece3d73b 100644 --- a/apps/apps_container.cpp +++ b/apps/apps_container.cpp @@ -133,7 +133,7 @@ VariableBoxController * AppsContainer::variableBoxController() { } void AppsContainer::suspend(bool checkIfPowerKeyReleased) { - if (activeApp() != m_onBoardingApp) { + if (activeApp() != m_onBoardingApp && GlobalPreferences::sharedGlobalPreferences()->showUpdatePopUp()) { activeApp()->displayModalViewController(&m_updateController, 0.f, 0.f); } Ion::Power::suspend(checkIfPowerKeyReleased); diff --git a/apps/global_preferences.cpp b/apps/global_preferences.cpp index 7c12f9710..3bf4e2a47 100644 --- a/apps/global_preferences.cpp +++ b/apps/global_preferences.cpp @@ -4,7 +4,8 @@ static GlobalPreferences s_globalPreferences; GlobalPreferences::GlobalPreferences() : m_language(I18n::Language::French), - m_examMode(ExamMode::Desactivate) + m_examMode(ExamMode::Desactivate), + m_showUpdatePopUp(true) { } @@ -31,3 +32,13 @@ void GlobalPreferences::setExamMode(ExamMode examMode) { m_examMode = examMode; } } + +bool GlobalPreferences::showUpdatePopUp() const { + return m_showUpdatePopUp; +} + +void GlobalPreferences::setShowUpdatePopUp(bool showUpdatePopUp) { + if (showUpdatePopUp != m_showUpdatePopUp) { + m_showUpdatePopUp = showUpdatePopUp; + } +} diff --git a/apps/global_preferences.h b/apps/global_preferences.h index d3b85506a..27548975a 100644 --- a/apps/global_preferences.h +++ b/apps/global_preferences.h @@ -15,9 +15,12 @@ public: void setLanguage(I18n::Language language); ExamMode examMode() const; void setExamMode(ExamMode examMode); + bool showUpdatePopUp() const; + void setShowUpdatePopUp(bool showUpdatePopUp); private: I18n::Language m_language; ExamMode m_examMode; + bool m_showUpdatePopUp; }; #endif diff --git a/apps/i18n.cpp b/apps/i18n.cpp index 62e93c705..b0006189c 100644 --- a/apps/i18n.cpp +++ b/apps/i18n.cpp @@ -17,7 +17,7 @@ constexpr static char deviationFrenchDefinition[] = {Ion::Charset::SmallSigma, ' constexpr static char deviationEnglishDefinition[] = {Ion::Charset::SmallSigma, ':', ' ', 'S', 't', 'a', 'n', 'd', 'a', 'r', 'd', ' ','d','e', 'v', 'i', 'a', 't','i','o','n', 0}; constexpr static char deviationSpanishDefinition[] = {Ion::Charset::SmallSigma, ' ', ':', ' ', 'D', 'e','s','v','i','a','c','i','o','n',' ','t','i','p','i','c','a',0}; -const char * messages[217][3] { +const char * messages[218][3] { {"Attention", "Warning", "Cuidado"}, {"Valider", "Confirm", "Confirmar"}, {"Annuler", "Cancel", "Cancelar"}, @@ -264,6 +264,7 @@ const char * messages[217][3] { {"sci/", "sci/", "sci/"}, {"Version du logiciel", "Software version", "Version de software"}, {"Numero serie", "Serial number", "Numero serie"}, + {"Rappel mise a jour", "Update pop-up", "Aviso emergente de actualizacion"}, /* On boarding */ {"MISE A JOUR DISPONIBLE", "UPDATE AVAILABLE", "ACTUALIZACION DISPONIBLE"}, diff --git a/apps/i18n.h b/apps/i18n.h index 015e4fd9f..fd390f9ae 100644 --- a/apps/i18n.h +++ b/apps/i18n.h @@ -237,6 +237,7 @@ namespace I18n { Sci, SoftwareVersion, SerialNumber, + UpdatePopUp, /* On boarding */ UpdateAvailable, diff --git a/apps/settings/main_controller.cpp b/apps/settings/main_controller.cpp index e5b854c91..fe52588a6 100644 --- a/apps/settings/main_controller.cpp +++ b/apps/settings/main_controller.cpp @@ -17,15 +17,16 @@ const SettingsNode languageChildren[I18n::NumberOfLanguages] = {SettingsNode(I18 const SettingsNode examChildren[1] = {SettingsNode(I18n::Message::ActivateExamMode)}; const SettingsNode aboutChildren[2] = {SettingsNode(I18n::Message::SoftwareVersion), SettingsNode(I18n::Message::SerialNumber)}; -const SettingsNode menu[6] = {SettingsNode(I18n::Message::AngleUnit, angleChildren, 2), SettingsNode(I18n::Message::DisplayMode, FloatDisplayModeChildren, 2), SettingsNode(I18n::Message::ComplexFormat, complexFormatChildren, 2), - SettingsNode(I18n::Message::Language, languageChildren, 3), SettingsNode(I18n::Message::ExamMode, examChildren, 1), SettingsNode(I18n::Message::About, aboutChildren, 2)}; -const SettingsNode model = SettingsNode(I18n::Message::SettingsApp, menu, 6); +const SettingsNode menu[7] = {SettingsNode(I18n::Message::AngleUnit, angleChildren, 2), SettingsNode(I18n::Message::DisplayMode, FloatDisplayModeChildren, 2), SettingsNode(I18n::Message::ComplexFormat, complexFormatChildren, 2), + SettingsNode(I18n::Message::Language, languageChildren, 3), SettingsNode(I18n::Message::ExamMode, examChildren, 1), SettingsNode(I18n::Message::UpdatePopUp), SettingsNode(I18n::Message::About, aboutChildren, 2)}; +const SettingsNode model = SettingsNode(I18n::Message::SettingsApp, menu, 7); MainController::MainController(Responder * parentResponder) : ViewController(parentResponder), m_cells{MessageTableCellWithChevronAndMessage(KDText::FontSize::Large, KDText::FontSize::Small), MessageTableCellWithChevronAndMessage(KDText::FontSize::Large, KDText::FontSize::Small), MessageTableCellWithChevronAndMessage(KDText::FontSize::Large, KDText::FontSize::Small), MessageTableCellWithChevronAndMessage(KDText::FontSize::Large, KDText::FontSize::Small), MessageTableCellWithChevronAndMessage(KDText::FontSize::Large, KDText::FontSize::Small)}, m_complexFormatCell(MessageTableCellWithChevronAndExpression(I18n::Message::Default, KDText::FontSize::Large)), + m_updateCell(I18n::Message::Default, KDText::FontSize::Large), m_complexFormatLayout(nullptr), m_selectableTableView(SelectableTableView(this, this, 0, 1, Metric::CommonTopMargin, Metric::CommonRightMargin, Metric::CommonBottomMargin, Metric::CommonLeftMargin, this)), @@ -57,6 +58,11 @@ void MainController::didBecomeFirstResponder() { bool MainController::handleEvent(Ion::Events::Event event) { if (event == Ion::Events::OK || event == Ion::Events::EXE) { + if (m_nodeModel->children(selectedRow())->numberOfChildren() == 0) { + GlobalPreferences::sharedGlobalPreferences()->setShowUpdatePopUp(!GlobalPreferences::sharedGlobalPreferences()->showUpdatePopUp()); + m_selectableTableView.reloadData(); + return true; + } m_subController.setNodeModel(m_nodeModel->children(selectedRow()), selectedRow()); StackViewController * stack = stackController(); stack->push(&m_subController); @@ -88,12 +94,15 @@ HighlightCell * MainController::reusableCell(int index, int type) { return &m_cells[index]; } assert(index == 0); - return &m_complexFormatCell; + if (type == 1) { + return &m_complexFormatCell; + } + return &m_updateCell; } int MainController::reusableCellCount(int type) { if (type == 0) { - return k_totalNumberOfCell-1; + return k_totalNumberOfCell-2; } return 1; } @@ -102,6 +111,9 @@ int MainController::typeAtLocation(int i, int j) { if (j == 2) { return 1; } + if (j == 5) { + return 2; + } return 0; } @@ -126,6 +138,12 @@ void MainController::willDisplayCellForIndex(HighlightCell * cell, int index) { myExpCell->setExpression(m_complexFormatLayout); return; } + if (index == 5) { + MessageTableCellWithSwitch * mySwitchCell = (MessageTableCellWithSwitch *)cell; + SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView(); + mySwitch->setState(GlobalPreferences::sharedGlobalPreferences()->showUpdatePopUp()); + return; + } MessageTableCellWithChevronAndMessage * myTextCell = (MessageTableCellWithChevronAndMessage *)cell; switch (index) { case 0: diff --git a/apps/settings/main_controller.h b/apps/settings/main_controller.h index 3d97570c5..cb527808b 100644 --- a/apps/settings/main_controller.h +++ b/apps/settings/main_controller.h @@ -30,9 +30,10 @@ public: void viewWillAppear() override; private: StackViewController * stackController() const; - constexpr static int k_totalNumberOfCell = 6; + constexpr static int k_totalNumberOfCell = 7; MessageTableCellWithChevronAndMessage m_cells[k_totalNumberOfCell-1]; MessageTableCellWithChevronAndExpression m_complexFormatCell; + MessageTableCellWithSwitch m_updateCell; Poincare::ExpressionLayout * m_complexFormatLayout; SelectableTableView m_selectableTableView; Node * m_nodeModel; diff --git a/apps/settings/sub_controller.cpp b/apps/settings/sub_controller.cpp index a5d7a8e6d..7ce7f3822 100644 --- a/apps/settings/sub_controller.cpp +++ b/apps/settings/sub_controller.cpp @@ -59,7 +59,7 @@ void SubController::didEnterResponderChain(Responder * previousResponder) { bool SubController::handleEvent(Ion::Events::Event event) { /* We hide here the activation hardware test app: in the menu "about", by * clicking on '6' on the serial number row. */ - if (event == Ion::Events::Six && m_preferenceIndex == 5 && selectedRow() == 1) { + if (event == Ion::Events::Six && m_preferenceIndex == 6 && selectedRow() == 1) { AppsContainer * appsContainer = (AppsContainer *)app()->container(); appsContainer->switchTo(appsContainer->hardwareTestApp()); return true; @@ -75,7 +75,7 @@ bool SubController::handleEvent(Ion::Events::Event event) { return true; } /* Behaviour of "About" menu */ - if (m_preferenceIndex == 5) { + if (m_preferenceIndex == 6) { if (selectedRow() == 1) { return false; } @@ -136,7 +136,7 @@ void SubController::willDisplayCellForIndex(HighlightCell * cell, int index) { if (m_preferenceIndex == 4 && GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Activate) { myCell->setMessage(I18n::Message::ExamModeActive); } - if (m_preferenceIndex == 5) { + if (m_preferenceIndex == 6) { myCell->setMessageFontSize(KDText::FontSize::Small); const char * accessoryMessage = Ion::softwareVersion(); if (index == 1) { @@ -192,10 +192,6 @@ int SubController::valueIndexAtPreferenceIndex(int preferenceIndex) { return (int)Preferences::sharedPreferences()->complexFormat(); case 3: return (int)GlobalPreferences::sharedGlobalPreferences()->language()-1; - case 4: - return 0; - case 5: - return 0; default: assert(false); return 0; diff --git a/escher/include/escher/message_table_cell_with_switch.h b/escher/include/escher/message_table_cell_with_switch.h index 2b54e1bf8..3edff521d 100644 --- a/escher/include/escher/message_table_cell_with_switch.h +++ b/escher/include/escher/message_table_cell_with_switch.h @@ -6,7 +6,7 @@ class MessageTableCellWithSwitch : public MessageTableCell { public: - MessageTableCellWithSwitch(I18n::Message message = (I18n::Message)0); + MessageTableCellWithSwitch(I18n::Message message = (I18n::Message)0, KDText::FontSize size = KDText::FontSize::Small); View * accessoryView() const override; private: SwitchView m_accessoryView; diff --git a/escher/src/message_table_cell_with_switch.cpp b/escher/src/message_table_cell_with_switch.cpp index ff2f9ab3e..aa9312860 100644 --- a/escher/src/message_table_cell_with_switch.cpp +++ b/escher/src/message_table_cell_with_switch.cpp @@ -1,8 +1,8 @@ #include #include -MessageTableCellWithSwitch::MessageTableCellWithSwitch(I18n::Message message) : - MessageTableCell(message), +MessageTableCellWithSwitch::MessageTableCellWithSwitch(I18n::Message message, KDText::FontSize size) : + MessageTableCell(message, size), m_accessoryView() { }