From d86ae69961231aaa177ed146ad829c93943f600c Mon Sep 17 00:00:00 2001 From: Maxim Leshchenko Date: Tue, 28 Sep 2021 22:50:09 +0300 Subject: [PATCH 1/2] Alarm: Close the popup with information about the time until alarm with the back button Previously, pressing the back button would close the alarm app anyway. Now if you press on it and the popup with information is open, it will first close and the second press will close the application --- src/displayapp/screens/Alarm.cpp | 11 +++++++++++ src/displayapp/screens/Alarm.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/displayapp/screens/Alarm.cpp b/src/displayapp/screens/Alarm.cpp index 959cb0b2..371593a2 100644 --- a/src/displayapp/screens/Alarm.cpp +++ b/src/displayapp/screens/Alarm.cpp @@ -174,6 +174,17 @@ void Alarm::OnButtonEvent(lv_obj_t* obj, lv_event_t event) { } } +bool Alarm::OnButtonPushed() { + if (txtMessage != nullptr && btnMessage != nullptr) { + lv_obj_del(txtMessage); + lv_obj_del(btnMessage); + txtMessage = nullptr; + btnMessage = nullptr; + return true; + } + return false; +} + void Alarm::UpdateAlarmTime() { lv_label_set_text_fmt(time, "%02d:%02d", alarmHours, alarmMinutes); alarmController.SetAlarmTime(alarmHours, alarmMinutes); diff --git a/src/displayapp/screens/Alarm.h b/src/displayapp/screens/Alarm.h index abf97eba..edd211b5 100644 --- a/src/displayapp/screens/Alarm.h +++ b/src/displayapp/screens/Alarm.h @@ -31,6 +31,7 @@ namespace Pinetime { ~Alarm() override; void SetAlerting(); void OnButtonEvent(lv_obj_t* obj, lv_event_t event); + bool OnButtonPushed() override; private: bool running; From 05f8850acf163f255d58e6224a3f9382b42e6ed4 Mon Sep 17 00:00:00 2001 From: Maxim Leshchenko Date: Wed, 29 Sep 2021 19:15:23 +0300 Subject: [PATCH 2/2] Fixes based on code reviews --- src/displayapp/screens/Alarm.cpp | 16 ++++++++-------- src/displayapp/screens/Alarm.h | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/displayapp/screens/Alarm.cpp b/src/displayapp/screens/Alarm.cpp index 371593a2..6b45a36e 100644 --- a/src/displayapp/screens/Alarm.cpp +++ b/src/displayapp/screens/Alarm.cpp @@ -120,10 +120,7 @@ void Alarm::OnButtonEvent(lv_obj_t* obj, lv_event_t event) { return; } if (obj == btnMessage) { - lv_obj_del(txtMessage); - lv_obj_del(btnMessage); - txtMessage = nullptr; - btnMessage = nullptr; + HideInfo(); return; } // If any other button was pressed, disable the alarm @@ -176,10 +173,7 @@ void Alarm::OnButtonEvent(lv_obj_t* obj, lv_event_t event) { bool Alarm::OnButtonPushed() { if (txtMessage != nullptr && btnMessage != nullptr) { - lv_obj_del(txtMessage); - lv_obj_del(btnMessage); - txtMessage = nullptr; - btnMessage = nullptr; + HideInfo(); return true; } return false; @@ -235,6 +229,12 @@ void Alarm::ShowInfo() { } } +void Alarm::HideInfo() { + lv_obj_del(btnMessage); + txtMessage = nullptr; + btnMessage = nullptr; +} + void Alarm::SetRecurButtonState() { using Pinetime::Controllers::AlarmController; switch (alarmController.Recurrence()) { diff --git a/src/displayapp/screens/Alarm.h b/src/displayapp/screens/Alarm.h index edd211b5..32a14d2f 100644 --- a/src/displayapp/screens/Alarm.h +++ b/src/displayapp/screens/Alarm.h @@ -47,6 +47,7 @@ namespace Pinetime { void SetRecurButtonState(); void SetAlarm(); void ShowInfo(); + void HideInfo(); void ToggleRecurrence(); void UpdateAlarmTime(); };