~aleteoryx/muditaos

7d1428ec405c467e4b1b7162389bf20ecbfc6b8e — Paweł Joński 4 years ago 885d70d
[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
M image/assets/lang/English.json => image/assets/lang/English.json +1 -0
@@ 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": "<text>Alarm deactivated</text>",
  "app_bell_alarm_set_not_active": "<text>Alarm set.<br />Deep press to activate.</text>",

M module-apps/apps-common/widgets/AlarmSetSpinner.cpp => module-apps/apps-common/widgets/AlarmSetSpinner.cpp +12 -1
@@ 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();
    }


M module-apps/apps-common/widgets/AlarmSetSpinner.hpp => module-apps/apps-common/widgets/AlarmSetSpinner.hpp +10 -0
@@ 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;


M products/BellHybrid/apps/application-bell-main/windows/BellHomeScreenWindow.cpp => products/BellHybrid/apps/application-bell-main/windows/BellHomeScreenWindow.cpp +3 -0
@@ 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();
    }


M products/BellHybrid/apps/common/include/common/models/AlarmModel.hpp => products/BellHybrid/apps/common/include/common/models/AlarmModel.hpp +1 -0
@@ 46,6 46,7 @@ namespace app
        void updateAlarm(AlarmEventRecord &alarm);
        AlarmEventRecord generateDefaultAlarm() const;
        std::shared_ptr<AlarmEventRecord> getAlarmPtr() const;
        void disableSnooze(AlarmEventRecord &alarm);

        ApplicationCommon *app{};
        State state{State::Invalid};

M products/BellHybrid/apps/common/src/AlarmModel.cpp => products/BellHybrid/apps/common/src/AlarmModel.cpp +9 -0
@@ 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<alarms::TurnOffSnoozeRequestMessage>(alarm.ID),
                                                       service::name::service_time);
        request->execute(app, this, responseCallback);
    }
    bool AlarmModel::isActive() const
    {
        if (!cachedRecord.parent) {

M products/BellHybrid/apps/common/src/TimeUtils.cpp => products/BellHybrid/apps/common/src/TimeUtils.cpp +7 -5
@@ 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";