~aleteoryx/muditaos

b3976f596020b27428a8b6772589431d2a7068d5 — rrandomsky 1 year, 9 months ago 8c2bef8
[BH-1922] Add a Summary screen to Focuse timer

Added a summary screen that tells the user how much time they spent in focus.
This screen is displayed after the last focus time.
M image/system_a/data/lang/Deutsch.json => image/system_a/data/lang/Deutsch.json +1 -0
@@ 67,6 67,7 @@
    "app_bell_relaxation_sounds": "Entspannende Sounds",
    "app_bell_relaxation_timer_title": "Timer",
    "app_bell_relaxation_uploaded_sounds": "Hochgeladene Sounds",
    "app_bell_focus_timer_summary": "",
    "app_bell_settings_about": "Information",
    "app_bell_settings_about_info_text": "www.mudita.com",
    "app_bell_settings_about_info_title": "Handbuch & Zertifikat-Info",

M image/system_a/data/lang/English.json => image/system_a/data/lang/English.json +1 -0
@@ 100,6 100,7 @@
    "app_bell_relaxation_sounds": "Relaxation sounds",
    "app_bell_relaxation_timer_title": "Relaxation time",
    "app_bell_relaxation_uploaded_sounds": "Uploaded sounds",
    "app_bell_focus_timer_summary": "<text>Well done!  <token>$VALUE</token> focus complete.</text>",
    "app_bell_reset_message": "<text>Resetting Mudita<br />Harmony</text>",
    "app_bell_settings_about": "About",
    "app_bell_settings_about_info_text": "www.mudita.com",

M image/system_a/data/lang/Espanol.json => image/system_a/data/lang/Espanol.json +1 -0
@@ 66,6 66,7 @@
    "app_bell_relaxation_sounds": "Sonidos de relajaci\u00f3n",
    "app_bell_relaxation_timer_title": "Temporizador",
    "app_bell_relaxation_uploaded_sounds": "Sonidos subidos",
    "app_bell_focus_timer_summary": "",
    "app_bell_settings_about": "Informaci\u00f3n",
    "app_bell_settings_about_info_text": "www.mudita.com",
    "app_bell_settings_about_info_title": "Manual y certificaci\u00f3n",

M image/system_a/data/lang/Francais.json => image/system_a/data/lang/Francais.json +1 -0
@@ 68,6 68,7 @@
    "app_bell_relaxation_sounds": "Sons de relaxation",
    "app_bell_relaxation_timer_title": "Minuterie",
    "app_bell_relaxation_uploaded_sounds": "Sons t\u00e9l\u00e9charg\u00e9s",
    "app_bell_focus_timer_summary": "",
    "app_bell_settings_about": "\u00c0 propos",
    "app_bell_settings_about_info_text": "www.mudita.com",
    "app_bell_settings_about_info_title": "Manuel et certification",

M image/system_a/data/lang/Polski.json => image/system_a/data/lang/Polski.json +1 -0
@@ 67,6 67,7 @@
    "app_bell_relaxation_sounds": "D\u017awi\u0119ki relaksacji",
    "app_bell_relaxation_timer_title": "Wy\u0142\u0105cznik czasowy",
    "app_bell_relaxation_uploaded_sounds": "Przes\u0142ane d\u017awi\u0119ki",
    "app_bell_focus_timer_summary": "",
    "app_bell_settings_about": "O produkcie",
    "app_bell_settings_about_info_text": "www.mudita.com",
    "app_bell_settings_about_info_title": "Instrukcja i informacje dot. certyfikacji",

M products/BellHybrid/apps/application-bell-focus-timer/ApplicationFocusTimer.cpp => products/BellHybrid/apps/application-bell-focus-timer/ApplicationFocusTimer.cpp +5 -0
@@ 77,6 77,11 @@ namespace app
                                  return std::make_unique<gui::SessionPausedWindow>(app);
                              });

        windowsFactory.attach(gui::window::bell_finished::defaultName,
                              [](ApplicationCommon *app, const std::string &name) {
                                  return std::make_unique<gui::BellFinishedWindow>(app, name);
                              });

        attachPopups({gui::popup::ID::AlarmActivated,
                      gui::popup::ID::AlarmDeactivated,
                      gui::popup::ID::PowerOff,

M products/BellHybrid/apps/application-bell-focus-timer/presenter/FocusTimerPresenter.cpp => products/BellHybrid/apps/application-bell-focus-timer/presenter/FocusTimerPresenter.cpp +26 -2
@@ 14,7 14,16 @@

namespace
{
    static constexpr std::chrono::milliseconds betweenSessionDelayTime{5000};
    constexpr std::chrono::milliseconds betweenSessionDelayTime{5000};
    constexpr auto summaryWindowTimeout = std::chrono::seconds{5};

    std::string createSummaryText(const std::string &str, const std::string &minutesOfFocus)
    {
        auto parser = gui::text::RichTextParser{};
        const auto result =
            parser.parse(str, nullptr, gui::text::RichTextParser::TokenMap({{"$VALUE", minutesOfFocus}}));
        return result->getText();
    }
} // namespace

namespace app::focus


@@ 102,7 111,22 @@ namespace app::focus
    {
        timer->stop();
        betweenSessionTimer.stop();
        app->switchWindow(focus::window::name::main);

        const auto elapsed        = std::chrono::duration_cast<std::chrono::minutes>(timer->getElapsed());
        const auto minutesInFocus = ((currentTimerPhase == FocusTimerPhase::FocusTime) ? elapsed.count() : 0) +
                                    (allFocusSessionsCount - focusSessionsLeft) * focusSessionDuration.count();
        const auto sumOfFocusTime =
            std::to_string(minutesInFocus) + " " + utils::language::getCorrectMinutesAccusativeForm(minutesInFocus);
        const auto textToComplete = utils::translate("app_bell_focus_timer_summary");
        const auto summaryText    = createSummaryText(textToComplete, sumOfFocusTime);

        app->switchWindow(
            gui::window::bell_finished::defaultName,
            gui::BellFinishedWindowData::Factory::create("big_namaste_W_G",
                                                         focus::window::name::main,
                                                         summaryText,
                                                         gui::BellFinishedWindowData::ExitBehaviour::SwitchWindow,
                                                         summaryWindowTimeout));
    }

    void FocusTimerPresenter::executeNextStep()