mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[apps/settings] Enable/unable update popup
Change-Id: Ib772623728a481afd49c92968f7102d7c7d2d77b
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"},
|
||||
|
||||
@@ -237,6 +237,7 @@ namespace I18n {
|
||||
Sci,
|
||||
SoftwareVersion,
|
||||
SerialNumber,
|
||||
UpdatePopUp,
|
||||
|
||||
/* On boarding */
|
||||
UpdateAvailable,
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <escher/message_table_cell_with_switch.h>
|
||||
#include <escher/palette.h>
|
||||
|
||||
MessageTableCellWithSwitch::MessageTableCellWithSwitch(I18n::Message message) :
|
||||
MessageTableCell(message),
|
||||
MessageTableCellWithSwitch::MessageTableCellWithSwitch(I18n::Message message, KDText::FontSize size) :
|
||||
MessageTableCell(message, size),
|
||||
m_accessoryView()
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user