Review comments
This commit is contained in:
@@ -126,6 +126,9 @@ STR_TZ_EST: "US Eastern (EST/EDT)"
|
|||||||
STR_TZ_CST: "US Central (CST/CDT)"
|
STR_TZ_CST: "US Central (CST/CDT)"
|
||||||
STR_TZ_MST: "US Mountain (MST/MDT)"
|
STR_TZ_MST: "US Mountain (MST/MDT)"
|
||||||
STR_TZ_PST: "US Pacific (PST/PDT)"
|
STR_TZ_PST: "US Pacific (PST/PDT)"
|
||||||
|
STR_TZ_AST_ADT: "Atlantic Canada (AST/ADT)"
|
||||||
|
STR_TZ_ACST_ACDT: "Australia Central (ACST/ACDT)"
|
||||||
|
STR_TZ_AKST_AKDT: "Alaska (AKST/AKDT)"
|
||||||
STR_TZ_AEST: "Australia Eastern (AEST/AEDT)"
|
STR_TZ_AEST: "Australia Eastern (AEST/AEDT)"
|
||||||
STR_TZ_NZST: "New Zealand (NZST/NZDT)"
|
STR_TZ_NZST: "New Zealand (NZST/NZDT)"
|
||||||
STR_TZ_MSK: "Russia (MSK)"
|
STR_TZ_MSK: "Russia (MSK)"
|
||||||
|
|||||||
@@ -13,15 +13,6 @@
|
|||||||
#include "components/UITheme.h"
|
#include "components/UITheme.h"
|
||||||
#include "fontIds.h"
|
#include "fontIds.h"
|
||||||
|
|
||||||
namespace {
|
|
||||||
const StrId timeZoneNames[CrossPointSettings::TIMEZONE_COUNT] = {
|
|
||||||
StrId::STR_TZ_UTC, StrId::STR_TZ_CET, StrId::STR_TZ_EET, StrId::STR_TZ_MSK,
|
|
||||||
StrId::STR_TZ_UTC_PLUS4, StrId::STR_TZ_IST, StrId::STR_TZ_UTC_PLUS7, StrId::STR_TZ_UTC_PLUS8,
|
|
||||||
StrId::STR_TZ_UTC_PLUS9, StrId::STR_TZ_AEST, StrId::STR_TZ_NZST, StrId::STR_TZ_UTC_MINUS3,
|
|
||||||
StrId::STR_TZ_EST, StrId::STR_TZ_CST, StrId::STR_TZ_MST, StrId::STR_TZ_PST,
|
|
||||||
StrId::STR_TZ_UTC, StrId::STR_TZ_UTC, StrId::STR_TZ_UTC};
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
void ClockSettingsActivity::buildMenuItems() {
|
void ClockSettingsActivity::buildMenuItems() {
|
||||||
menuItems.reserve(6);
|
menuItems.reserve(6);
|
||||||
menuItems.push_back(SettingInfo::Separator(StrId::STR_SETTINGS_TITLE));
|
menuItems.push_back(SettingInfo::Separator(StrId::STR_SETTINGS_TITLE));
|
||||||
@@ -35,27 +26,8 @@ void ClockSettingsActivity::buildMenuItems() {
|
|||||||
{StrId::STR_TZ_UTC, StrId::STR_TZ_CET, StrId::STR_TZ_EET, StrId::STR_TZ_MSK, StrId::STR_TZ_UTC_PLUS4,
|
{StrId::STR_TZ_UTC, StrId::STR_TZ_CET, StrId::STR_TZ_EET, StrId::STR_TZ_MSK, StrId::STR_TZ_UTC_PLUS4,
|
||||||
StrId::STR_TZ_IST, StrId::STR_TZ_UTC_PLUS7, StrId::STR_TZ_UTC_PLUS8, StrId::STR_TZ_UTC_PLUS9,
|
StrId::STR_TZ_IST, StrId::STR_TZ_UTC_PLUS7, StrId::STR_TZ_UTC_PLUS8, StrId::STR_TZ_UTC_PLUS9,
|
||||||
StrId::STR_TZ_AEST, StrId::STR_TZ_NZST, StrId::STR_TZ_UTC_MINUS3, StrId::STR_TZ_EST, StrId::STR_TZ_CST,
|
StrId::STR_TZ_AEST, StrId::STR_TZ_NZST, StrId::STR_TZ_UTC_MINUS3, StrId::STR_TZ_EST, StrId::STR_TZ_CST,
|
||||||
StrId::STR_TZ_MST, StrId::STR_TZ_PST, StrId::STR_TZ_UTC, StrId::STR_TZ_UTC, StrId::STR_TZ_UTC},
|
StrId::STR_TZ_MST, StrId::STR_TZ_PST, StrId::STR_TZ_AST_ADT, StrId::STR_TZ_ACST_ACDT, StrId::STR_TZ_AKST_AKDT},
|
||||||
"timeZone", StrId::STR_CAT_SYSTEM);
|
"timeZone", StrId::STR_CAT_SYSTEM);
|
||||||
tzSetting.enumLabels = {"UTC (GMT/BST)",
|
|
||||||
"Central European (CET/CEST)",
|
|
||||||
"Eastern European (EET/EEST)",
|
|
||||||
"Moscow (MSK)",
|
|
||||||
"UTC+4",
|
|
||||||
"India (IST)",
|
|
||||||
"UTC+7",
|
|
||||||
"UTC+8",
|
|
||||||
"UTC+9",
|
|
||||||
"Australia Eastern (AEST/AEDT)",
|
|
||||||
"New Zealand (NZST/NZDT)",
|
|
||||||
"UTC-3",
|
|
||||||
"Eastern US/Canada (EST/EDT)",
|
|
||||||
"Central US/Canada (CST/CDT)",
|
|
||||||
"Mountain US/Canada (MST/MDT)",
|
|
||||||
"Pacific US/Canada (PST/PDT)",
|
|
||||||
"Atlantic Canada (AST/ADT)",
|
|
||||||
"Australia Central (ACST/ACDT)",
|
|
||||||
"Alaska (AKST/AKDT)"};
|
|
||||||
menuItems.push_back(std::move(tzSetting));
|
menuItems.push_back(std::move(tzSetting));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,10 @@ bool mapIanaTimezone(const std::string& tz, uint8_t& outSetting) {
|
|||||||
outSetting = TZ::TZ_AKST_AKDT;
|
outSetting = TZ::TZ_AKST_AKDT;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (tz == "Australia/Adelaide" || tz == "Australia/Broken_Hill") {
|
||||||
|
outSetting = TZ::TZ_ACST_ACDT;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (tz == "America/Sao_Paulo" || tz == "America/Argentina/Buenos_Aires" || tz == "America/Montevideo") {
|
if (tz == "America/Sao_Paulo" || tz == "America/Argentina/Buenos_Aires" || tz == "America/Montevideo") {
|
||||||
outSetting = TZ::TZ_UTC_MINUS3;
|
outSetting = TZ::TZ_UTC_MINUS3;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -31,6 +31,12 @@ struct SettingInfo {
|
|||||||
StrId nameId;
|
StrId nameId;
|
||||||
SettingType type;
|
SettingType type;
|
||||||
uint8_t CrossPointSettings::* valuePtr = nullptr;
|
uint8_t CrossPointSettings::* valuePtr = nullptr;
|
||||||
|
// Enum values are used as StrId references for localization via I18N.get().
|
||||||
|
// If enumLabels is populated, it is authoritative for display and index bounds.
|
||||||
|
// In that case it must have the same length as enumValues, because consumers
|
||||||
|
// such as getDisplayValue(), toggleValue(), and CrossPointWebServer::handleGetSettings()
|
||||||
|
// prefer enumLabels when present. Code paths which validate posted enum values
|
||||||
|
// should also use enumLabels.size() when enumLabels is non-empty.
|
||||||
std::vector<StrId> enumValues;
|
std::vector<StrId> enumValues;
|
||||||
std::vector<std::string> enumLabels;
|
std::vector<std::string> enumLabels;
|
||||||
SettingAction action = SettingAction::None;
|
SettingAction action = SettingAction::None;
|
||||||
|
|||||||
@@ -1325,7 +1325,8 @@ void CrossPointWebServer::handlePostSettings() {
|
|||||||
}
|
}
|
||||||
case SettingType::ENUM: {
|
case SettingType::ENUM: {
|
||||||
const int val = doc[s.key].as<int>();
|
const int val = doc[s.key].as<int>();
|
||||||
if (val >= 0 && val < static_cast<int>(s.enumValues.size())) {
|
const auto count = static_cast<int>(s.enumLabels.empty() ? s.enumValues.size() : s.enumLabels.size());
|
||||||
|
if (val >= 0 && val < count) {
|
||||||
if (s.valuePtr) {
|
if (s.valuePtr) {
|
||||||
SETTINGS.*(s.valuePtr) = static_cast<uint8_t>(val);
|
SETTINGS.*(s.valuePtr) = static_cast<uint8_t>(val);
|
||||||
} else if (s.valueSetter) {
|
} else if (s.valueSetter) {
|
||||||
|
|||||||
Reference in New Issue
Block a user