[apps/on_boarding] Remember language choice

When choosing a language and then pressing back from the country menu to
get back to the language menu, the previously selected language remains
selected.

Change-Id: I018c51cce09d47b15bb4864c135d381a94b2a72f
This commit is contained in:
Gabriel Ozouf
2020-09-25 11:52:04 +02:00
committed by Émilie Feral
parent 54c28fc87f
commit 64e7057d50
4 changed files with 8 additions and 3 deletions

View File

@@ -7,7 +7,7 @@ namespace OnBoarding {
int LocalizationController::indexOfCellToSelectOnReset() const {
return mode() == Mode::Language ?
0 :
Shared::LocalizationController::indexOfCellToSelectOnReset() :
IndexOfCountry(I18n::DefaultCountryForLanguage[static_cast<uint8_t>(GlobalPreferences::sharedGlobalPreferences()->language())]);
}

View File

@@ -6,7 +6,7 @@ namespace Settings {
int LocalizationController::indexOfCellToSelectOnReset() const {
return mode() == Mode::Language ?
static_cast<int>(GlobalPreferences::sharedGlobalPreferences()->language()) :
Shared::LocalizationController::indexOfCellToSelectOnReset() :
IndexOfCountry(GlobalPreferences::sharedGlobalPreferences()->country());
}

View File

@@ -142,6 +142,11 @@ void LocalizationController::setMode(LocalizationController::Mode mode) {
m_contentView.modeHasChanged();
}
int LocalizationController::indexOfCellToSelectOnReset() const {
assert(mode() == Mode::Language);
return static_cast<int>(GlobalPreferences::sharedGlobalPreferences()->language());
}
const char * LocalizationController::title() {
if (mode() == Mode::Language) {
return I18n::translate(I18n::Message::Language);

View File

@@ -22,7 +22,7 @@ public:
Mode mode() const { return m_mode; }
void setMode(Mode mode);
virtual int indexOfCellToSelectOnReset() const = 0;
virtual int indexOfCellToSelectOnReset() const;
virtual bool shouldDisplayTitle() const = 0;
bool shouldDisplayWarning() const { return mode() == Mode::Country; }