From 7d1428ec405c467e4b1b7162389bf20ecbfc6b8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jo=C5=84ski?= Date: Mon, 11 Oct 2021 14:14:45 +0200 Subject: [PATCH] [BH-1008] Fix Snooze UI and turnoff Actually stop the snooze when turning off the alarm Center bottom text temperature after other popup Correct notification when setting alarm for "now" Fix ringing alarm icon --- image/assets/lang/English.json | 1 + module-apps/apps-common/widgets/AlarmSetSpinner.cpp | 13 ++++++++++++- module-apps/apps-common/widgets/AlarmSetSpinner.hpp | 10 ++++++++++ .../windows/BellHomeScreenWindow.cpp | 3 +++ .../common/include/common/models/AlarmModel.hpp | 1 + products/BellHybrid/apps/common/src/AlarmModel.cpp | 9 +++++++++ products/BellHybrid/apps/common/src/TimeUtils.cpp | 12 +++++++----- 7 files changed, 43 insertions(+), 6 deletions(-) diff --git a/image/assets/lang/English.json b/image/assets/lang/English.json index d06cfa99d90e50b45b41d848c6c7076763a4be9b..16b3d06c48778c6aa2ba6e1a176ab58da7771102 100644 --- a/image/assets/lang/English.json +++ b/image/assets/lang/English.json @@ -626,6 +626,7 @@ "app_bell_settings_alarm_settings_snooze_chime_volume": "Snooze chime volume", "app_bellmain_home_screen_bottom_desc": "Next alarm will ring", "app_bellmain_home_screen_bottom_desc_in": "in", + "app_bellmain_home_screen_bottom_desc_less_than": "less than", "app_bellmain_home_screen_bottom_desc_dp": "Deep press to activate", "app_bell_alarm_deactivated": "Alarm deactivated", "app_bell_alarm_set_not_active": "Alarm set.
Deep press to activate.
", diff --git a/module-apps/apps-common/widgets/AlarmSetSpinner.cpp b/module-apps/apps-common/widgets/AlarmSetSpinner.cpp index 0833cf485e0bbb21e0e07e3bb9ef2fe7bc3abbcb..ec4aa20b795328e8d7ab8a87f756e36a356bebf2 100644 --- a/module-apps/apps-common/widgets/AlarmSetSpinner.cpp +++ b/module-apps/apps-common/widgets/AlarmSetSpinner.cpp @@ -24,7 +24,8 @@ namespace gui alarmImg = new ImageBox(this, 0, 0, 0, 0, new Image("bell_alarm_deactivated_W_M")); alarmImg->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center)); alarmImg->setMargins(Margins(0, 0, 0, 0)); - alarmImg->setMinimumSize(style::alarm_set_spinner::arrow::w, style::alarm_set_spinner::arrow::h); + alarmImg->setMinimumSize(style::alarm_set_spinner::image_default::w, + style::alarm_set_spinner::image_default::h); timeSpinner = new TimeSetFmtSpinner(this, TimeSetSpinner::Size::SMALL); timeSpinner->setFont(style::window::font::largelight); @@ -94,6 +95,15 @@ namespace gui { alarmStatus = status; + if (alarmStatus == Status::RINGING) { + alarmImg->setMinimumSize(style::alarm_set_spinner::image_alarm_ringing::w, + style::alarm_set_spinner::image_alarm_ringing::h); + } + else { + alarmImg->setMinimumSize(style::alarm_set_spinner::image_default::w, + style::alarm_set_spinner::image_default::h); + } + switch (alarmStatus) { case Status::ACTIVATED: alarmImg->setImage("bell_alarm_activated_W_M"); @@ -115,6 +125,7 @@ namespace gui alarmImg->setImage("bell_alarm_deactivated_W_M"); break; } + resizeItems(); } diff --git a/module-apps/apps-common/widgets/AlarmSetSpinner.hpp b/module-apps/apps-common/widgets/AlarmSetSpinner.hpp index 44ef4b31a27ce9f877f249800fec1f6e3b5fe13c..c248c2c5fd9c9af4069d676faef250e73e6749f3 100644 --- a/module-apps/apps-common/widgets/AlarmSetSpinner.hpp +++ b/module-apps/apps-common/widgets/AlarmSetSpinner.hpp @@ -16,6 +16,16 @@ namespace style::alarm_set_spinner inline constexpr auto w = 64U; inline constexpr auto h = 64U; } // namespace arrow + namespace image_default + { + inline constexpr auto w = 64U; + inline constexpr auto h = 64U; + } // namespace image_default + namespace image_alarm_ringing + { + inline constexpr auto w = 84U; + inline constexpr auto h = 64U; + } // namespace image_alarm_ringing inline constexpr auto w = 440U; inline constexpr auto h = 64U; diff --git a/products/BellHybrid/apps/application-bell-main/windows/BellHomeScreenWindow.cpp b/products/BellHybrid/apps/application-bell-main/windows/BellHomeScreenWindow.cpp index 851941922cf9e22225fadde7995a1e6c0e9706cb..d4f21552bae5e71f71c84b7fb0a55711d88502ab 100644 --- a/products/BellHybrid/apps/application-bell-main/windows/BellHomeScreenWindow.cpp +++ b/products/BellHybrid/apps/application-bell-main/windows/BellHomeScreenWindow.cpp @@ -180,6 +180,9 @@ namespace gui if (!battery->visible) { bottomText->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Top)); } + else { + bottomText->setAlignment(Alignment(Alignment::Horizontal::Right, Alignment::Vertical::Center)); + } bottomBox->resizeItems(); } diff --git a/products/BellHybrid/apps/common/include/common/models/AlarmModel.hpp b/products/BellHybrid/apps/common/include/common/models/AlarmModel.hpp index 8033ff61643f00feff67ea18a0d66b418ec36fd0..0b8b88901a64ea62e1f692bf8e51cbd41c8d68e9 100644 --- a/products/BellHybrid/apps/common/include/common/models/AlarmModel.hpp +++ b/products/BellHybrid/apps/common/include/common/models/AlarmModel.hpp @@ -46,6 +46,7 @@ namespace app void updateAlarm(AlarmEventRecord &alarm); AlarmEventRecord generateDefaultAlarm() const; std::shared_ptr getAlarmPtr() const; + void disableSnooze(AlarmEventRecord &alarm); ApplicationCommon *app{}; State state{State::Invalid}; diff --git a/products/BellHybrid/apps/common/src/AlarmModel.cpp b/products/BellHybrid/apps/common/src/AlarmModel.cpp index a8135810e5a0447e954723b40aeca4fe47b6f943..adc584535c841880b57ddfd816d86a4512d08416 100644 --- a/products/BellHybrid/apps/common/src/AlarmModel.cpp +++ b/products/BellHybrid/apps/common/src/AlarmModel.cpp @@ -75,6 +75,9 @@ namespace app } alarmEventPtr->enabled = value; updateAlarm(*alarmEventPtr); + if (!value) { + disableSnooze(*alarmEventPtr); + } } void AlarmModel::updateAlarm(AlarmEventRecord &alarm) { @@ -84,6 +87,12 @@ namespace app cachedRecord = alarm.getNextSingleEvent(TimePointNow()); } + void AlarmModel::disableSnooze(AlarmEventRecord &alarm) + { + auto request = AsyncRequest::createFromMessage(std::make_unique(alarm.ID), + service::name::service_time); + request->execute(app, this, responseCallback); + } bool AlarmModel::isActive() const { if (!cachedRecord.parent) { diff --git a/products/BellHybrid/apps/common/src/TimeUtils.cpp b/products/BellHybrid/apps/common/src/TimeUtils.cpp index b5f2d6612ba17fadc768d511543df8baa4e7f8e2..1d3f4215565679926cd2998a6bb36499d6907c1b 100644 --- a/products/BellHybrid/apps/common/src/TimeUtils.cpp +++ b/products/BellHybrid/apps/common/src/TimeUtils.cpp @@ -29,11 +29,13 @@ namespace utils::time const auto prefix = translate("app_bellmain_home_screen_bottom_desc"); const auto duration = Duration{timestamp}; const auto timeText = [](time_t hours, time_t minutes) -> std::string { - if (hours == 0 && minutes == 0) { - return "1 min"; - } - else if (hours == 0) { - return std::to_string(minutes) + " min"; + if (hours == 0) { + if (minutes == 1) { + return translate("app_bellmain_home_screen_bottom_desc_less_than") + " 1 min"; + } + else { + return std::to_string(minutes) + " min"; + } } else if (minutes == 0) { return std::to_string(hours) + " h";