~aleteoryx/muditaos

790c64396795dbde37afe86f1aca75e776b8d07b — Lefucjusz 1 year, 10 months ago e7aa67a
[BH-1856] Add setting onboarding year to build year

Added mechanism automatically setting
the default year shown in the onboarding
to the year of build to avoid changing
it manually every year.
M harmony_changelog.md => harmony_changelog.md +2 -1
@@ 6,6 6,8 @@
* Fixed source clock frequency computation for PWM module

### Added
* Added setting onboarding year to build date year
* Added low battery notification on the home screen

### Changed / Improved



@@ 15,7 17,6 @@
* Added gradual alarm volume increase
* Added progress bar for all volume control windows
* Improved factory reset procedure to remove user files
* Added low battery notification on the home screen

### Changed / Improved
* Increased clock font in Relaxation, Meditation, Power nap mode

M module-services/service-time/ServiceTime.cpp => module-services/service-time/ServiceTime.cpp +13 -10
@@ 1,4 1,4 @@
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "ServiceTime.hpp"


@@ 18,12 18,16 @@

namespace stm
{
    constexpr auto automaticTimezoneName  = "";
    constexpr auto automaticTimezoneRules = "UTC0";
    namespace
    {
        constexpr auto serviceTimeStackDepth  = 1024 * 16;
        constexpr auto automaticTimezoneName  = "";
        constexpr auto automaticTimezoneRules = "UTC0";
    } // namespace

    ServiceTime::ServiceTime(std::shared_ptr<alarms::IAlarmOperationsFactory> alarmOperationsFactory)
        : sys::Service(service::name::service_time, "", StackDepth), timeManager{std::make_unique<TimeManager>(
                                                                         std::make_unique<RTCCommand>(this))},
        : sys::Service(service::name::service_time, "", serviceTimeStackDepth),
          timeManager{std::make_unique<TimeManager>(std::make_unique<RTCCommand>(this))},
          alarmOperationsFactory{std::move(alarmOperationsFactory)}
    {
        bus.channels.push_back(sys::BusChannel::ServiceDBNotifications);


@@ 218,7 222,7 @@ namespace stm
    {
        auto message = static_cast<stm::message::SetAutomaticDateAndTimeRequest *>(request);
        if (stm::api::isAutomaticDateAndTime() == message->getValue()) {
            LOG_WARN("The selected value is already set. Ignore.");
            LOG_INFO("The selected automatic date and time value is already set, ignoring");
            return std::shared_ptr<sys::ResponseMessage>();
        }
        settings->setValue(settings::SystemProperties::automaticDateAndTimeIsOn, std::to_string(message->getValue()));


@@ 242,7 246,7 @@ namespace stm
    {
        auto message = static_cast<stm::message::SetTimeFormatRequest *>(request);
        if (stm::api::timeFormat() == message->getTimeFormat()) {
            LOG_WARN("The selected value is already set. Ignore.");
            LOG_INFO("The selected time format value is already set, ignoring");
            return std::shared_ptr<sys::ResponseMessage>();
        }
        settings->setValue(settings::SystemProperties::timeFormat,


@@ 255,7 259,7 @@ namespace stm
    {
        auto message = static_cast<stm::message::SetDateFormatRequest *>(request);
        if (stm::api::dateFormat() == message->getDateFormat()) {
            LOG_WARN("The selected value is already set. Ignore.");
            LOG_INFO("The selected date format value is already set, ignoring");
            return std::shared_ptr<sys::ResponseMessage>();
        }
        settings->setValue(settings::SystemProperties::dateFormat,


@@ 326,5 330,4 @@ namespace stm
    {
        return std::make_shared<stm::message::GetAutomaticDateAndTimeResponse>(stm::api::isAutomaticDateAndTime());
    }

} /* namespace stm */
} // namespace stm

M module-services/service-time/ServiceTime.hpp => module-services/service-time/ServiceTime.hpp +1 -7
@@ 1,4 1,4 @@
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once


@@ 29,14 29,9 @@ namespace stm
    class ServiceTime : public sys::Service
    {
      private:
        static constexpr auto StackDepth = 2048 * 8;

        std::unique_ptr<TimeManager> timeManager;

        std::unique_ptr<settings::Settings> settings;

        std::unique_ptr<alarms::AlarmMessageHandler> alarmMessageHandler;

        std::shared_ptr<alarms::IAlarmOperationsFactory> alarmOperationsFactory;

        void registerMessageHandlers();


@@ 60,7 55,6 @@ namespace stm

        sys::MessagePointer DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp = nullptr) override;
    };

} /* namespace stm */

namespace sys

M products/BellHybrid/apps/application-bell-settings/models/DateTimeUnitsModel.cpp => products/BellHybrid/apps/application-bell-settings/models/DateTimeUnitsModel.cpp +15 -8
@@ 1,4 1,4 @@
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "models/DateTimeUnitsModel.hpp"


@@ 15,12 15,19 @@
#include <service-time/api/TimeSettingsApi.hpp>
#include <service-time/service-time/TimeMessage.hpp>
#include <widgets/DateSetSpinner.hpp>
#include <widgets/TimeSetFmtSpinner.hpp>

#include <ctime>

namespace app::bell_settings
{
    namespace
    {
        auto getBuildYear() -> date::year
        {
            constexpr auto yearOffset = 7;
            constexpr auto yearString = &__DATE__[yearOffset]; // __DATE__ is a string in 'Mmm dd yyyy' format
            return date::year{utils::toNumeric(yearString)};
        }
    } // namespace

    DateTimeUnitsModel::DateTimeUnitsModel(app::ApplicationCommon *app) : application(app)
    {}



@@ 191,10 198,10 @@ namespace app::bell_settings
    {
        using namespace date::literals;

        /// Default date/time after factory reset: 2023/01/01 12:00 (in 24h format)
        const auto factoryResetDate    = 2023_y / jan / 1_d;
        const auto factoryResetTimeFmt = utils::time::Locale::TimeFormat::FormatTime24H;
        const auto factoryResetDateFmt = utils::time::Locale::DateFormat::DD_MM_YYYY;
        /// Default date/time after factory reset: buildYear/01/01 12:00 (in 24h format)
        constexpr auto factoryResetTimeFmt = utils::time::Locale::TimeFormat::FormatTime24H;
        constexpr auto factoryResetDateFmt = utils::time::Locale::DateFormat::DD_MM_YYYY;
        const auto factoryResetDate        = getBuildYear() / jan / 1_d;

        yearSetListItem->dateSetSpinner->setDate(factoryResetDate);
        timeSetListItem->timeSetSpinner->setTimeFormat(factoryResetTimeFmt);