Merge branch 'main' into wb/wadokei-merge
This commit is contained in:
@@ -36,17 +36,19 @@ namespace {
|
||||
|
||||
SettingBluetooth::SettingBluetooth(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
|
||||
: app {app},
|
||||
settings {settingsController},
|
||||
checkboxList(
|
||||
0,
|
||||
1,
|
||||
"Bluetooth",
|
||||
Symbols::bluetooth,
|
||||
settingsController.GetBleRadioEnabled() ? 0 : 1,
|
||||
[&settings = settingsController](uint32_t index) {
|
||||
[this](uint32_t index) {
|
||||
const bool priorMode = settings.GetBleRadioEnabled();
|
||||
const bool newMode = options[index].radioEnabled;
|
||||
if (newMode != priorMode) {
|
||||
settings.SetBleRadioEnabled(newMode);
|
||||
this->app->PushMessage(Pinetime::Applications::Display::Messages::BleRadioEnableToggle);
|
||||
}
|
||||
},
|
||||
CreateOptionArray()) {
|
||||
@@ -54,6 +56,4 @@ SettingBluetooth::SettingBluetooth(Pinetime::Applications::DisplayApp* app, Pine
|
||||
|
||||
SettingBluetooth::~SettingBluetooth() {
|
||||
lv_obj_clean(lv_scr_act());
|
||||
// Pushing the message in the OnValueChanged function causes a freeze?
|
||||
app->PushMessage(Pinetime::Applications::Display::Messages::BleRadioEnableToggle);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Pinetime {
|
||||
|
||||
private:
|
||||
DisplayApp* app;
|
||||
Pinetime::Controllers::Settings& settings;
|
||||
CheckboxList checkboxList;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
using namespace Pinetime::Applications::Screens;
|
||||
|
||||
namespace {
|
||||
constexpr int16_t POS_X_LAT = -80;
|
||||
constexpr int16_t POS_X_LONG = 0;
|
||||
constexpr int16_t POS_X_TZ = 80;
|
||||
constexpr int16_t POS_Y_TEXT = 25;
|
||||
|
||||
void ValueChangedHandler(void* userData) {
|
||||
@@ -27,6 +30,7 @@ SettingLocation::SettingLocation(Pinetime::Controllers::Settings& settingsContro
|
||||
|
||||
lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
|
||||
|
||||
lv_label_set_text_static(icon, Symbols::map);
|
||||
lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
|
||||
lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
|
||||
@@ -34,21 +38,18 @@ SettingLocation::SettingLocation(Pinetime::Controllers::Settings& settingsContro
|
||||
Controllers::Settings::Location loc = settingsController.GetLocation();
|
||||
|
||||
latCounter.Create();
|
||||
latCounter.SetWidth(80);
|
||||
latCounter.SetValue(loc.latitude);
|
||||
lv_obj_align(latCounter.GetObject(), nullptr, LV_ALIGN_CENTER, -90, POS_Y_TEXT);
|
||||
lv_obj_align(latCounter.GetObject(), nullptr, LV_ALIGN_CENTER, POS_X_LAT, POS_Y_TEXT);
|
||||
latCounter.SetValueChangedEventCallback(this, ValueChangedHandler);
|
||||
|
||||
longCounter.Create();
|
||||
longCounter.SetWidth(110);
|
||||
longCounter.SetValue(loc.longitude);
|
||||
lv_obj_align(longCounter.GetObject(), nullptr, LV_ALIGN_CENTER, -5, POS_Y_TEXT);
|
||||
lv_obj_align(longCounter.GetObject(), nullptr, LV_ALIGN_CENTER, POS_X_LONG, POS_Y_TEXT);
|
||||
longCounter.SetValueChangedEventCallback(this, ValueChangedHandler);
|
||||
|
||||
tzCounter.Create();
|
||||
tzCounter.SetWidth(60);
|
||||
tzCounter.SetValue(loc.tzOffset);
|
||||
lv_obj_align(tzCounter.GetObject(), nullptr, LV_ALIGN_CENTER, 75, POS_Y_TEXT);
|
||||
lv_obj_align(tzCounter.GetObject(), nullptr, LV_ALIGN_CENTER, POS_X_TZ, POS_Y_TEXT);
|
||||
tzCounter.SetValueChangedEventCallback(this, ValueChangedHandler);
|
||||
|
||||
UpdateScreen();
|
||||
@@ -66,4 +67,4 @@ void SettingLocation::UpdateScreen() {
|
||||
tzOffset: (int8_t)tzCounter.GetValue(),
|
||||
};
|
||||
settingsController.SetLocation(loc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ namespace Pinetime {
|
||||
private:
|
||||
Controllers::Settings& settingsController;
|
||||
|
||||
Widgets::Counter latCounter = Widgets::Counter(-90, 90, jetbrains_mono_42);
|
||||
Widgets::Counter longCounter = Widgets::Counter(-180, 180, jetbrains_mono_42);
|
||||
Widgets::Counter tzCounter = Widgets::Counter(-12, 12, jetbrains_mono_42);
|
||||
Widgets::Counter latCounter = Widgets::Counter(-90, 90, jetbrains_mono_bold_20);
|
||||
Widgets::Counter longCounter = Widgets::Counter(-180, 180, jetbrains_mono_bold_20);
|
||||
Widgets::Counter tzCounter = Widgets::Counter(-12, 12, jetbrains_mono_bold_20);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,37 @@ using namespace Pinetime::Applications::Screens;
|
||||
constexpr const char* SettingWatchFace::title;
|
||||
constexpr const char* SettingWatchFace::symbol;
|
||||
|
||||
namespace {
|
||||
uint32_t IndexOf(const std::array<Pinetime::Applications::Screens::SettingWatchFace::Item,
|
||||
Pinetime::Applications::UserWatchFaceTypes::Count>& watchfaces,
|
||||
Pinetime::Applications::WatchFace watchface) {
|
||||
size_t index = 0;
|
||||
auto found = std::find_if(watchfaces.begin(),
|
||||
watchfaces.end(),
|
||||
[&index, &watchface](const Pinetime::Applications::Screens::SettingWatchFace::Item& item) {
|
||||
const bool result = item.watchface == watchface;
|
||||
if (!result) {
|
||||
index++;
|
||||
}
|
||||
return result;
|
||||
});
|
||||
if (found == watchfaces.end()) {
|
||||
index = 0;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
Pinetime::Applications::WatchFace IndexToWatchFace(const std::array<Pinetime::Applications::Screens::SettingWatchFace::Item,
|
||||
Pinetime::Applications::UserWatchFaceTypes::Count>& watchfaces,
|
||||
size_t index) {
|
||||
if (index >= watchfaces.size()) {
|
||||
return watchfaces[0].watchface;
|
||||
}
|
||||
return watchfaces[index].watchface;
|
||||
}
|
||||
}
|
||||
|
||||
auto SettingWatchFace::CreateScreenList() const {
|
||||
std::array<std::function<std::unique_ptr<Screen>()>, nScreens> screens;
|
||||
for (size_t i = 0; i < screens.size(); i++) {
|
||||
@@ -20,7 +51,7 @@ auto SettingWatchFace::CreateScreenList() const {
|
||||
}
|
||||
|
||||
SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app,
|
||||
std::array<Screens::CheckboxList::Item, UserWatchFaceTypes::Count>&& watchfaceItems,
|
||||
std::array<Screens::SettingWatchFace::Item, UserWatchFaceTypes::Count>&& watchfaceItems,
|
||||
Pinetime::Controllers::Settings& settingsController,
|
||||
Pinetime::Controllers::FS& filesystem)
|
||||
: app {app},
|
||||
@@ -44,7 +75,8 @@ std::unique_ptr<Screen> SettingWatchFace::CreateScreen(unsigned int screenNum) c
|
||||
if (i + (screenNum * settingsPerScreen) >= watchfaceItems.size()) {
|
||||
watchfacesOnThisScreen[i] = {"", false};
|
||||
} else {
|
||||
watchfacesOnThisScreen[i] = watchfaceItems[i + (screenNum * settingsPerScreen)];
|
||||
auto& item = watchfaceItems[i + (screenNum * settingsPerScreen)];
|
||||
watchfacesOnThisScreen[i] = Screens::CheckboxList::Item {item.name, item.enabled};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,9 +85,9 @@ std::unique_ptr<Screen> SettingWatchFace::CreateScreen(unsigned int screenNum) c
|
||||
nScreens,
|
||||
title,
|
||||
symbol,
|
||||
static_cast<uint32_t>(settingsController.GetWatchFace()),
|
||||
[&settings = settingsController](uint32_t index) {
|
||||
settings.SetWatchFace(static_cast<WatchFace>(index));
|
||||
static_cast<uint32_t>(IndexOf(watchfaceItems, settingsController.GetWatchFace())),
|
||||
[this, &settings = settingsController](uint32_t index) {
|
||||
settings.SetWatchFace(IndexToWatchFace(watchfaceItems, index));
|
||||
settings.SaveSettings();
|
||||
},
|
||||
watchfacesOnThisScreen);
|
||||
|
||||
@@ -19,8 +19,14 @@ namespace Pinetime {
|
||||
|
||||
class SettingWatchFace : public Screen {
|
||||
public:
|
||||
struct Item {
|
||||
const char* name;
|
||||
WatchFace watchface;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
SettingWatchFace(DisplayApp* app,
|
||||
std::array<Screens::CheckboxList::Item, UserWatchFaceTypes::Count>&& watchfaceItems,
|
||||
std::array<Item, UserWatchFaceTypes::Count>&& watchfaceItems,
|
||||
Pinetime::Controllers::Settings& settingsController,
|
||||
Pinetime::Controllers::FS& filesystem);
|
||||
~SettingWatchFace() override;
|
||||
@@ -33,7 +39,7 @@ namespace Pinetime {
|
||||
std::unique_ptr<Screen> CreateScreen(unsigned int screenNum) const;
|
||||
|
||||
static constexpr int settingsPerScreen = 4;
|
||||
std::array<Screens::CheckboxList::Item, UserWatchFaceTypes::Count> watchfaceItems;
|
||||
std::array<Item, UserWatchFaceTypes::Count> watchfaceItems;
|
||||
static constexpr int nScreens = UserWatchFaceTypes::Count > 0 ? (UserWatchFaceTypes ::Count - 1) / settingsPerScreen + 1 : 1;
|
||||
|
||||
Controllers::Settings& settingsController;
|
||||
|
||||
Reference in New Issue
Block a user