M harmony_changelog.md => harmony_changelog.md +1 -0
@@ 17,6 17,7 @@
* Updated the countdown timer in Meditation app according to the new design
* Updated the countdown timer in Power nap app according to the new design
* Updated the countdown timer in Relaxation app according to the new design
+* Changed the refresh rate of the progress bar screen
## [2.6.1 2024-04-02]
M module-apps/application-meditation/widgets/MeditationTimer.cpp => module-apps/application-meditation/widgets/MeditationTimer.cpp +3 -3
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2022, 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 "MeditationTimer.hpp"
@@ 14,7 14,7 @@
namespace
{
inline constexpr auto meditationTimerName = "MeditationTimer";
- inline constexpr std::chrono::seconds timerTick{1};
+ inline constexpr std::chrono::seconds initialInterval{1};
} // namespace
namespace gui
{
@@ 56,7 56,7 @@ namespace gui
text->setEditMode(EditMode::Browse);
timer = std::make_unique<app::ProgressTimerWithBarGraphAndCounter>(
- application, *this, meditationTimerName, timerTick);
+ application, *this, meditationTimerName, initialInterval);
timer->attach(progressBar);
timer->attach(text);
timer->registerOnIntervalCallback(std::bind(&MeditationTimer::playSound, this));
M module-apps/apps-common/widgets/AbstractProgressTime.hpp => module-apps/apps-common/widgets/AbstractProgressTime.hpp +1 -1
@@ 8,11 8,11 @@
namespace gui
{
-
class AbstractProgressTime
{
public:
virtual ~AbstractProgressTime() = default;
virtual void updateTime(std::uint32_t seconds) = 0;
+ virtual std::chrono::seconds getRefreshTime() = 0;
};
} // namespace gui
M module-apps/apps-common/widgets/ProgressTimer.cpp => module-apps/apps-common/widgets/ProgressTimer.cpp +9 -1
@@ 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 "ProgressTimer.hpp"
@@ 53,6 53,14 @@ namespace app
timerTask.start();
}
+ void ProgressTimer::updateInterval(std::chrono::milliseconds newInterval)
+ {
+ if (baseTickInterval != newInterval) {
+ baseTickInterval = newInterval;
+ timerTask.restart(newInterval);
+ }
+ }
+
auto ProgressTimer::onTimerTimeout(sys::Timer &task) -> bool
{
if (isStopped()) {
M module-apps/apps-common/widgets/ProgressTimer.hpp => module-apps/apps-common/widgets/ProgressTimer.hpp +2 -1
@@ 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
@@ 54,6 54,7 @@ namespace app
utils::time::Duration::DisplayedFormat displayFormat;
void startTimer();
+ void updateInterval(std::chrono::milliseconds newInterval);
[[nodiscard]] auto onTimerTimeout(sys::Timer &timerTask) -> bool;
[[nodiscard]] auto isFinished() const noexcept -> bool;
M module-apps/apps-common/widgets/ProgressTimerWithBarGraphAndCounter.cpp => module-apps/apps-common/widgets/ProgressTimerWithBarGraphAndCounter.cpp +1 -0
@@ 21,6 21,7 @@ namespace app
updateProgress();
updateTimeWidget();
ProgressTimer::update();
+ updateInterval(timeWidget->getRefreshTime());
}
void ProgressTimerWithBarGraphAndCounter::updateText()
M module-apps/apps-common/widgets/TimeMinuteSecondWidget.cpp => module-apps/apps-common/widgets/TimeMinuteSecondWidget.cpp +36 -0
@@ 48,6 48,31 @@ namespace
constexpr auto topMargin = -2;
constexpr auto font = style::window::font::big;
} // namespace description
+
+ namespace refreshTime
+ {
+ constexpr auto defaultValue{std::chrono::seconds{1}};
+ constexpr auto arraySize{3};
+ constexpr std::array<std::pair<std::uint32_t, std::chrono::seconds>, arraySize> values = {{
+ {10 * utils::time::secondsInMinute, std::chrono::seconds{5}},
+ {5 * utils::time::secondsInMinute, std::chrono::seconds{3}},
+ {3 * utils::time::secondsInMinute, std::chrono::seconds{2}},
+ }};
+ constexpr auto maxValue = std::max_element(values.begin(), values.end(), [](const auto &l, const auto &r) {
+ return l.second < r.second;
+ }) -> second;
+
+ std::chrono::seconds get(std::uint32_t totalSeconds)
+ {
+ const auto res = std::find_if(
+ values.begin(), values.end(), [totalSeconds](const auto &e) { return e.first <= totalSeconds; });
+ if (res != values.end()) {
+ return res->second;
+ }
+ return defaultValue;
+ }
+
+ } // namespace refreshTime
} // namespace
namespace gui
@@ 118,6 143,7 @@ namespace gui
if (!totalSeconds.has_value()) {
totalSeconds = seconds;
}
+ secondsLeft = seconds;
if (displayType != DisplayType::OnlySeconds &&
(seconds >= utils::time::secondsInMinute || displayType == DisplayType::OnlyMinutes)) {
const auto minutes = getRoundedMinutes(seconds, totalSeconds.value());
@@ 130,6 156,16 @@ namespace gui
}
}
+ std::chrono::seconds TimeMinuteSecondWidget::getRefreshTime()
+ {
+ if (!totalSeconds.has_value() ||
+ (displayType != DisplayType::OnlyMinutes &&
+ secondsLeft < (utils::time::secondsInMinute + refreshTime::maxValue.count()))) {
+ return refreshTime::defaultValue;
+ }
+ return refreshTime::get(totalSeconds.value());
+ }
+
void TimeMinuteSecondWidget::setText(std::uint32_t value)
{
const auto &digits = valueToDigits(value);
M module-apps/apps-common/widgets/TimeMinuteSecondWidget.hpp => module-apps/apps-common/widgets/TimeMinuteSecondWidget.hpp +2 -0
@@ 27,12 27,14 @@ namespace gui
DisplayType type = DisplayType::OnlyMinutes);
void updateTime(std::uint32_t sec) override;
+ std::chrono::seconds getRefreshTime() override;
void buildInterface(std::uint32_t w, std::uint32_t h);
void setText(std::uint32_t value);
private:
DisplayType displayType;
std::optional<std::uint32_t> totalSeconds;
+ std::uint32_t secondsLeft{0};
static constexpr auto maxDigits{3U};
VBox *mainBox{nullptr};
M products/BellHybrid/apps/application-bell-focus-timer/windows/FocusTimerWindow.cpp => products/BellHybrid/apps/application-bell-focus-timer/windows/FocusTimerWindow.cpp +2 -2
@@ 13,7 13,7 @@
namespace
{
constexpr auto progressTimerName{"FocusProgressTimer"};
- constexpr auto progressTimerPeriod{std::chrono::seconds{1}};
+ constexpr auto initialInterval{std::chrono::seconds{1}};
constexpr auto progressMode{app::ProgressCountdownMode::Increasing};
} // namespace
@@ 227,7 227,7 @@ namespace app::focus
void FocusTimerWindow::configureTimer()
{
auto progressTimer = std::make_unique<app::ProgressTimerWithBarGraphAndCounter>(
- application, *this, progressTimerName, progressTimerPeriod, progressMode);
+ application, *this, progressTimerName, initialInterval, progressMode);
progressTimer->attach(progress);
progressTimer->attach(timer);
presenter->setTimer(std::move(progressTimer));
M products/BellHybrid/apps/application-bell-meditation-timer/windows/MeditationCountdownWindow.cpp => products/BellHybrid/apps/application-bell-meditation-timer/windows/MeditationCountdownWindow.cpp +2 -2
@@ 14,7 14,7 @@
namespace
{
constexpr auto meditationCountdownTimerName{"MeditationCountdownTimer"};
- constexpr std::chrono::seconds meditationCountdownTimerPeriod{1};
+ constexpr std::chrono::seconds initialInterval{1};
constexpr auto meditationCountdownMode{app::ProgressCountdownMode::Increasing};
constexpr auto leftBoxSize{1};
} // namespace
@@ 110,7 110,7 @@ namespace gui
void MeditationCountdownWindow::configureTimer()
{
auto progressTimer = std::make_unique<app::ProgressTimerWithBarGraphAndCounter>(
- application, *this, meditationCountdownTimerName, meditationCountdownTimerPeriod, meditationCountdownMode);
+ application, *this, meditationCountdownTimerName, initialInterval, meditationCountdownMode);
progressTimer->attach(timer);
presenter->setTimer(std::move(progressTimer));
}
M products/BellHybrid/apps/application-bell-meditation-timer/windows/MeditationRunningWindow.cpp => products/BellHybrid/apps/application-bell-meditation-timer/windows/MeditationRunningWindow.cpp +2 -2
@@ 15,7 15,7 @@
namespace
{
constexpr auto meditationProgressTimerName{"MeditationProgressTimer"};
- constexpr std::chrono::seconds meditationProgressTimerPeriod{1};
+ constexpr std::chrono::seconds initialInterval{1};
constexpr auto meditationProgressMode{app::ProgressCountdownMode::Increasing};
} // namespace
@@ 152,7 152,7 @@ namespace gui
void MeditationRunningWindow::configureTimer()
{
auto progressTimer = std::make_unique<app::ProgressTimerWithBarGraphAndCounter>(
- application, *this, meditationProgressTimerName, meditationProgressTimerPeriod, meditationProgressMode);
+ application, *this, meditationProgressTimerName, initialInterval, meditationProgressMode);
progressTimer->attach(progress);
progressTimer->attach(timer);
presenter->setTimer(std::move(progressTimer));
M products/BellHybrid/apps/application-bell-powernap/windows/PowerNapProgressWindow.cpp => products/BellHybrid/apps/application-bell-powernap/windows/PowerNapProgressWindow.cpp +2 -2
@@ 11,7 11,7 @@
namespace
{
constexpr auto powerNapTimerName{"PowerNapTimer"};
- constexpr auto powerNapTimerPeriod{std::chrono::seconds{1}};
+ constexpr auto initialInterval{std::chrono::seconds{1}};
} // namespace
namespace gui
@@ 97,7 97,7 @@ namespace gui
void PowerNapProgressWindow::configureTimer()
{
auto progressTimer = std::make_unique<app::ProgressTimerWithBarGraphAndCounter>(
- application, *this, powerNapTimerName, powerNapTimerPeriod, app::ProgressCountdownMode::Increasing);
+ application, *this, powerNapTimerName, initialInterval, app::ProgressCountdownMode::Increasing);
progressTimer->attach(progress);
progressTimer->attach(timer);
presenter->setTimer(std::move(progressTimer));
M products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningProgressWindow.cpp => products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningProgressWindow.cpp +2 -2
@@ 13,7 13,7 @@
namespace
{
constexpr auto relaxationProgressTimerName{"RelaxationProgressTimer"};
- constexpr std::chrono::seconds relaxationProgressTimerPeriod{1};
+ constexpr std::chrono::seconds initialInterval{1};
constexpr auto relaxationProgressMode{app::ProgressCountdownMode::Increasing};
} // namespace
@@ 154,7 154,7 @@ namespace gui
void RelaxationRunningProgressWindow::configureTimer()
{
auto progressTimer = std::make_unique<app::ProgressTimerWithBarGraphAndCounter>(
- application, *this, relaxationProgressTimerName, relaxationProgressTimerPeriod, relaxationProgressMode);
+ application, *this, relaxationProgressTimerName, initialInterval, relaxationProgressMode);
progressTimer->attach(progress);
progressTimer->attach(timer);
presenter->setTimer(std::move(progressTimer));
M products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationVolumeWindow.cpp => products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationVolumeWindow.cpp +0 -1
@@ 7,7 7,6 @@
#include <popups/data/PopupData.hpp>
#include <apps-common/widgets/BellBaseLayout.hpp>
-#include <apps-common/widgets/ProgressTimerWithBarGraphAndCounter.hpp>
namespace gui
{
M products/BellHybrid/apps/common/include/common/widgets/list_items/details.hpp => products/BellHybrid/apps/common/include/common/widgets/list_items/details.hpp +0 -1
@@ 8,7 8,6 @@
#include <common/data/StyleCommon.hpp>
#include <apps-common/widgets/spinners/Spinners.hpp>
-#include <apps-common/widgets/ProgressTimerWithBarGraphAndCounter.hpp>
#include <apps-common/widgets/BarGraph.hpp>
#include "common/data/ListItemBarStyle.hpp"