Emit the message BleRadioEnableToggle to DisplayApp only if the enable state of the radio has actually changed.

This fixes an issue where the BLE connected logo would disappear when opening and closing the BLE setting (without changing it) while InfiniTime was already connected to a companion app.

Co-authored-by: JustScott <development@justscott.me>
This commit is contained in:
Jean-François Milants 2024-03-14 20:51:24 +01:00
parent 004b2bf3a0
commit d3e5410407
2 changed files with 4 additions and 3 deletions

View File

@ -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);
}

View File

@ -20,6 +20,7 @@ namespace Pinetime {
private:
DisplayApp* app;
Pinetime::Controllers::Settings& settings;
CheckboxList checkboxList;
};
}