diff options
author | Riku Isokoski <riksu9000@gmail.com> | 2022-04-02 16:03:20 +0300 |
---|---|---|
committer | JF <JF002@users.noreply.github.com> | 2022-04-02 16:16:47 +0200 |
commit | 78365548f70d9a6ef9a040d8e0039e640e386dc3 (patch) | |
tree | 06464442b965cb0a15e3e841c8df870066717892 /src/displayapp/screens/settings | |
parent | 8f436e1d74ffdd497c68dc2f34f6a67e430a1932 (diff) |
Replace airplane mode with a bluetooth toggle
Diffstat (limited to 'src/displayapp/screens/settings')
-rw-r--r-- | src/displayapp/screens/settings/SettingBluetooth.cpp (renamed from src/displayapp/screens/settings/SettingAirplaneMode.cpp) | 46 | ||||
-rw-r--r-- | src/displayapp/screens/settings/SettingBluetooth.h (renamed from src/displayapp/screens/settings/SettingAirplaneMode.h) | 10 | ||||
-rw-r--r-- | src/displayapp/screens/settings/Settings.cpp | 2 |
3 files changed, 29 insertions, 29 deletions
diff --git a/src/displayapp/screens/settings/SettingAirplaneMode.cpp b/src/displayapp/screens/settings/SettingBluetooth.cpp index 85172787..ab1af223 100644 --- a/src/displayapp/screens/settings/SettingAirplaneMode.cpp +++ b/src/displayapp/screens/settings/SettingBluetooth.cpp @@ -1,4 +1,4 @@ -#include "displayapp/screens/settings/SettingAirplaneMode.h" +#include "displayapp/screens/settings/SettingBluetooth.h" #include <lvgl/lvgl.h> #include "displayapp/DisplayApp.h" #include "displayapp/Messages.h" @@ -9,18 +9,18 @@ using namespace Pinetime::Applications::Screens; namespace { - static void OnAirplaneModeEnabledEvent(lv_obj_t* obj, lv_event_t event) { - auto* screen = static_cast<SettingAirplaneMode*>(obj->user_data); - screen->OnAirplaneModeEnabled(obj, event); + static void OnBluetoothDisabledEvent(lv_obj_t* obj, lv_event_t event) { + auto* screen = static_cast<SettingBluetooth*>(obj->user_data); + screen->OnBluetoothDisabled(obj, event); } - static void OnAirplaneModeDisabledEvent(lv_obj_t* obj, lv_event_t event) { - auto* screen = static_cast<SettingAirplaneMode*>(obj->user_data); - screen->OnAirplaneModeDisabled(obj, event); + static void OnBluetoothEnabledEvent(lv_obj_t* obj, lv_event_t event) { + auto* screen = static_cast<SettingBluetooth*>(obj->user_data); + screen->OnBluetoothEnabled(obj, event); } } -SettingAirplaneMode::SettingAirplaneMode(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController) +SettingBluetooth::SettingBluetooth(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController) : Screen(app), settingsController {settingsController} { lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr); @@ -36,38 +36,38 @@ SettingAirplaneMode::SettingAirplaneMode(Pinetime::Applications::DisplayApp* app lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT); lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_text_static(title, "Airplane mode"); + lv_label_set_text_static(title, "Bluetooth"); lv_label_set_align(title, LV_LABEL_ALIGN_CENTER); lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15); 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::airplane); + lv_label_set_text_static(icon, Symbols::bluetooth); lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER); lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); cbEnabled = lv_checkbox_create(container1, nullptr); - lv_checkbox_set_text(cbEnabled, " Enable"); + lv_checkbox_set_text(cbEnabled, " Enabled"); cbEnabled->user_data = this; - lv_obj_set_event_cb(cbEnabled, OnAirplaneModeEnabledEvent); + lv_obj_set_event_cb(cbEnabled, OnBluetoothEnabledEvent); SetRadioButtonStyle(cbEnabled); cbDisabled = lv_checkbox_create(container1, nullptr); - lv_checkbox_set_text(cbDisabled, " Disable"); + lv_checkbox_set_text(cbDisabled, " Disabled"); cbDisabled->user_data = this; - lv_obj_set_event_cb(cbDisabled, OnAirplaneModeDisabledEvent); + lv_obj_set_event_cb(cbDisabled, OnBluetoothDisabledEvent); SetRadioButtonStyle(cbDisabled); if (settingsController.GetBleRadioEnabled()) { - lv_checkbox_set_checked(cbDisabled, true); + lv_checkbox_set_checked(cbEnabled, true); priorMode = true; } else { - lv_checkbox_set_checked(cbEnabled, true); + lv_checkbox_set_checked(cbDisabled, true); priorMode = false; } } -SettingAirplaneMode::~SettingAirplaneMode() { +SettingBluetooth::~SettingBluetooth() { lv_obj_clean(lv_scr_act()); // Do not call SaveSettings - see src/components/settings/Settings.h if (priorMode != settingsController.GetBleRadioEnabled()) { @@ -75,18 +75,18 @@ SettingAirplaneMode::~SettingAirplaneMode() { } } -void SettingAirplaneMode::OnAirplaneModeEnabled(lv_obj_t* object, lv_event_t event) { +void SettingBluetooth::OnBluetoothDisabled(lv_obj_t* object, lv_event_t event) { if (event == LV_EVENT_VALUE_CHANGED) { - lv_checkbox_set_checked(cbEnabled, true); - lv_checkbox_set_checked(cbDisabled, false); + lv_checkbox_set_checked(cbEnabled, false); + lv_checkbox_set_checked(cbDisabled, true); settingsController.SetBleRadioEnabled(false); } } -void SettingAirplaneMode::OnAirplaneModeDisabled(lv_obj_t* object, lv_event_t event) { +void SettingBluetooth::OnBluetoothEnabled(lv_obj_t* object, lv_event_t event) { if (event == LV_EVENT_VALUE_CHANGED) { - lv_checkbox_set_checked(cbEnabled, false); - lv_checkbox_set_checked(cbDisabled, true); + lv_checkbox_set_checked(cbEnabled, true); + lv_checkbox_set_checked(cbDisabled, false); settingsController.SetBleRadioEnabled(true); } } diff --git a/src/displayapp/screens/settings/SettingAirplaneMode.h b/src/displayapp/screens/settings/SettingBluetooth.h index b3478c64..12bb459a 100644 --- a/src/displayapp/screens/settings/SettingAirplaneMode.h +++ b/src/displayapp/screens/settings/SettingBluetooth.h @@ -12,13 +12,13 @@ namespace Pinetime { namespace Applications { namespace Screens { - class SettingAirplaneMode : public Screen { + class SettingBluetooth : public Screen { public: - SettingAirplaneMode(DisplayApp* app, Pinetime::Controllers::Settings& settingsController); - ~SettingAirplaneMode() override; + SettingBluetooth(DisplayApp* app, Pinetime::Controllers::Settings& settingsController); + ~SettingBluetooth() override; - void OnAirplaneModeEnabled(lv_obj_t* object, lv_event_t event); - void OnAirplaneModeDisabled(lv_obj_t* object, lv_event_t event); + void OnBluetoothEnabled(lv_obj_t* object, lv_event_t event); + void OnBluetoothDisabled(lv_obj_t* object, lv_event_t event); private: Controllers::Settings& settingsController; diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp index dce0c071..bc7efcc2 100644 --- a/src/displayapp/screens/settings/Settings.cpp +++ b/src/displayapp/screens/settings/Settings.cpp @@ -64,7 +64,7 @@ std::unique_ptr<Screen> Settings::CreateScreen3() { {Symbols::clock, "Chimes", Apps::SettingChimes}, {Symbols::tachometer, "Shake Calib.", Apps::SettingShakeThreshold}, {Symbols::check, "Firmware", Apps::FirmwareValidation}, - {Symbols::airplane, "Airplane mode", Apps::SettingAirplaneMode} + {Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth} }}; return std::make_unique<Screens::List>(2, 4, app, settingsController, applications); |