Skip to content

Commit

Permalink
8.7.0 - Added support for Auto Save & Exit in "Confirm Save" menu for…
Browse files Browse the repository at this point in the history
… Global Settings. This allow people to meditate and sleep right after session with notification disabled.
  • Loading branch information
dliedke committed Dec 29, 2024
1 parent 7c628a2 commit 6111aa2
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Meditate/manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!-- This is a generated file. It is highly recommended that you DO NOT edit this file. -->
<iq:manifest xmlns:iq="http://www.garmin.com/xml/connectiq" version="3">
<iq:application entry="MeditateApp" id="9abb375dcf7c4ace87ff66f4f774f6c8" launcherIcon="@Drawables.launcherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watch-app" version="8.6.0">
<iq:application entry="MeditateApp" id="9abb375dcf7c4ace87ff66f4f774f6c8" launcherIcon="@Drawables.launcherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watch-app" version="8.7.0">
<iq:products>
<iq:product id="approachs62"/>
<iq:product id="approachs7042mm"/>
Expand Down
3 changes: 2 additions & 1 deletion Meditate/resources-deu/strings/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<string id="menuConfirmSaveActivityOptions_autoYes">Auto Ja</string>
<string id="menuConfirmSaveActivityOptions_autoNo">Auto Nein</string>
<string id="menuConfirmSaveActivityOptions_askSimple">Fragen</string>
<string id="menuConfirmSaveActivityOptions_autoYesExit">Auto Ja &amp; Beenden</string>

<string id="menuMultiSessionOptions_title">Mehr. Sitz.</string>
<string id="menuMultiSessionOptions_yes">Ja</string>
Expand Down Expand Up @@ -165,7 +166,7 @@
<string id="HRVready">HRV Bereit</string>
<string id="HRVoff">HRV aus</string>

<string id="about_AppVersion">Meditate 8.6.0</string>
<string id="about_AppVersion">Meditate 8.7.0</string>
<string id="about_vtrifonov"> vtrifonov</string>
<string id="about_dliedke"> dliedke</string>
<string id="about_falsetru"> falsetru</string>
Expand Down
3 changes: 2 additions & 1 deletion Meditate/resources-kor/strings/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<string id="menuConfirmSaveActivityOptions_autoYes">예 (자동 저장)</string>
<string id="menuConfirmSaveActivityOptions_autoNo">아니오 (저장 안함)</string>
<string id="menuConfirmSaveActivityOptions_askSimple">물어보기</string>
<string id="menuConfirmSaveActivityOptions_autoYesExit">자동 예 &amp; 종료</string>

<string id="menuMultiSessionOptions_title">다중 세션</string>
<string id="menuMultiSessionOptions_yes">예</string>
Expand Down Expand Up @@ -165,7 +166,7 @@
<string id="HRVready">HRV 준비됨</string>
<string id="HRVoff">HRV 꺼짐</string>

<string id="about_AppVersion">Meditate 8.6.0</string>
<string id="about_AppVersion">Meditate 8.7.0</string>
<string id="about_vtrifonov"> vtrifonov</string>
<string id="about_dliedke"> dliedke</string>
<string id="about_falsetru"> falsetru</string>
Expand Down
3 changes: 2 additions & 1 deletion Meditate/resources-por/strings/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<string id="menuConfirmSaveActivityOptions_autoYes">Auto Sim</string>
<string id="menuConfirmSaveActivityOptions_autoNo">Auto Não</string>
<string id="menuConfirmSaveActivityOptions_askSimple">Perguntar</string>
<string id="menuConfirmSaveActivityOptions_autoYesExit">Auto Sim &amp; Sair</string>

<string id="menuMultiSessionOptions_title">Multi-Sessão</string>
<string id="menuMultiSessionOptions_yes">Sim</string>
Expand Down Expand Up @@ -166,7 +167,7 @@
<string id="HRVready">VFC Pronto</string>
<string id="HRVoff">VFC Deslig.</string>

<string id="about_AppVersion">Meditate 8.6.0</string>
<string id="about_AppVersion">Meditate 8.7.0</string>
<string id="about_vtrifonov"> vtrifonov</string>
<string id="about_dliedke"> dliedke</string>
<string id="about_falsetru"> falsetru</string>
Expand Down
3 changes: 2 additions & 1 deletion Meditate/resources-spa/strings/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<string id="menuConfirmSaveActivityOptions_autoYes">Sí Auto</string>
<string id="menuConfirmSaveActivityOptions_autoNo">No Auto</string>
<string id="menuConfirmSaveActivityOptions_askSimple">Preguntar</string>
<string id="menuConfirmSaveActivityOptions_autoYesExit">Auto Sí &amp; Salir</string>

<string id="menuMultiSessionOptions_title">Multi-Sesión</string>
<string id="menuMultiSessionOptions_yes">Sí</string>
Expand Down Expand Up @@ -165,7 +166,7 @@
<string id="HRVready">HRV Listo</string>
<string id="HRVoff">HRV apagado</string>

<string id="about_AppVersion">Meditate 8.6.0</string>
<string id="about_AppVersion">Meditate 8.7.0</string>
<string id="about_vtrifonov"> vtrifonov</string>
<string id="about_dliedke"> dliedke</string>
<string id="about_falsetru"> falsetru</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<menu id="confirmSaveActivityOptionsMenu" title="@Strings.menuConfirmSaveActivityOptions_title">
<menu-item id="ask" label="@Strings.menuConfirmSaveActivityOptions_ask" />
<menu-item id="autoYes" label="@Strings.menuConfirmSaveActivityOptions_autoYes" />
<menu-item id="autoYesExit" label="@Strings.menuConfirmSaveActivityOptions_autoYesExit" />
<menu-item id="autoNo" label="@Strings.menuConfirmSaveActivityOptions_autoNo" />
</menu>
3 changes: 2 additions & 1 deletion Meditate/resources/strings/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<string id="menuConfirmSaveActivityOptions_autoYes">Auto Yes</string>
<string id="menuConfirmSaveActivityOptions_autoNo">Auto No</string>
<string id="menuConfirmSaveActivityOptions_askSimple">Ask</string>
<string id="menuConfirmSaveActivityOptions_autoYesExit">Auto Yes &amp; Exit</string>

<string id="menuMultiSessionOptions_title">Multi-Session</string>
<string id="menuMultiSessionOptions_yes">Yes</string>
Expand Down Expand Up @@ -165,7 +166,7 @@
<string id="HRVready">HRV Ready</string>
<string id="HRVoff">HRV off</string>

<string id="about_AppVersion">Meditate 8.6.0</string>
<string id="about_AppVersion">Meditate 8.7.0</string>
<string id="about_vtrifonov"> vtrifonov</string>
<string id="about_dliedke"> dliedke</string>
<string id="about_falsetru"> falsetru</string>
Expand Down
12 changes: 11 additions & 1 deletion Meditate/source/activity/DelayedFinishingView.mc
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
using Toybox.WatchUi as Ui;
using Toybox.Timer;
using Toybox.Application as App;

class DelayedFinishingView extends Ui.View {
private var mOnShow;
private var mShouldAutoExit;

function initialize(onShow) {
function initialize(onShow, shouldAutoExit) {
View.initialize();
me.mOnShow = onShow;
me.mShouldAutoExit = shouldAutoExit;
}

function onViewDrawn() {

// Exit app if required
if (me.mShouldAutoExit) {
System.exit();
return;
}

me.mOnShow.invoke();
}

Expand Down
31 changes: 19 additions & 12 deletions Meditate/source/activity/MeditateDelegate.mc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class MeditateDelegate extends Ui.BehaviorDelegate {
private var mSessionPickerDelegate;
private var mHeartbeatIntervalsSensor;
private var mSummaryModel;
private var mShouldAutoExit;

function initialize(meditateModel, summaryModels, heartbeatIntervalsSensor, sessionPickerDelegate) {
BehaviorDelegate.initialize();
Expand All @@ -20,43 +21,49 @@ class MeditateDelegate extends Ui.BehaviorDelegate {

public function stopActivity() {
me.mMeditateActivity.stop();

// If there is no finalize time, show delayed finished view
if (GlobalSettings.loadFinalizeTime()==0) {

// Store auto-exit state as class member
var confirmSaveActivity = GlobalSettings.loadConfirmSaveActivity();
me.mShouldAutoExit = (confirmSaveActivity == ConfirmSaveActivity.AutoYesExit);

// If there is no finalize time, proceed directly to finishing flow
if (GlobalSettings.loadFinalizeTime() == 0) {
onShowDelayedFinishedView();
return;
}

// Show finalize time view and delayed finished view session once the time is over
var meditatePrepareView = new MeditatePrepareView(method(:onShowDelayedFinishedView), 0);
var meditatePrepareDelegate = new MeditatePrepareDelegate(me, meditatePrepareView);
Ui.switchToView(meditatePrepareView, meditatePrepareDelegate, Ui.SLIDE_IMMEDIATE);
}

function onShowDelayedFinishedView()
{
var calculatingResultsView = new DelayedFinishingView(method(:onFinishActivity));
Ui.switchToView(calculatingResultsView, me, Ui.SLIDE_IMMEDIATE);
function onShowDelayedFinishedView() {
var calculatingResultsView = new DelayedFinishingView(method(:onFinishActivity), me.mShouldAutoExit);
Ui.switchToView(calculatingResultsView, me, Ui.SLIDE_IMMEDIATE);
}

function onFinishActivity() {
me.mSummaryModel = me.mMeditateActivity.calculateSummaryFields();

var confirmSaveActivity = GlobalSettings.loadConfirmSaveActivity();
if (confirmSaveActivity == ConfirmSaveActivity.AutoYes) {

if (confirmSaveActivity == ConfirmSaveActivity.AutoYes ||
confirmSaveActivity == ConfirmSaveActivity.AutoYesExit) {

//Made sure reading/writing session settings for the next session in multi-session mode happens before saving the FIT file.
//If both happen at the same time FIT file gets corrupted
me.mMeditateActivity.finish();
var saveActivityView = new DelayedFinishingView(me.method(:onShowNextView));
var saveActivityView = new DelayedFinishingView(me.method(:onShowNextView), me.mShouldAutoExit);
Ui.switchToView(saveActivityView, me, Ui.SLIDE_IMMEDIATE);
}
else if (confirmSaveActivity == ConfirmSaveActivity.AutoNo) {
me.mMeditateActivity.discard();
var nextView = new DelayedFinishingView(method(:onShowNextView));
var nextView = new DelayedFinishingView(method(:onShowNextView), me.mShouldAutoExit);
Ui.switchToView(nextView, me, Ui.SLIDE_IMMEDIATE);
}
else {
var nextView = new DelayedFinishingView(method(:onShowNextViewConfirmDialog));
var nextView = new DelayedFinishingView(method(:onShowNextViewConfirmDialog), me.mShouldAutoExit);
Ui.switchToView(nextView, me, Ui.SLIDE_IMMEDIATE);
}
}
Expand Down
3 changes: 2 additions & 1 deletion Meditate/source/globalSettings/GlobalSettings.mc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ module ConfirmSaveActivity {
enum {
Ask = 0,
AutoNo = 1,
AutoYes = 2
AutoYes = 2,
AutoYesExit = 3
}
}

Expand Down
8 changes: 8 additions & 0 deletions Meditate/source/globalSettings/GlobalSettingsDelegate.mc
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ class GlobalSettingsDelegate extends ScreenPicker.ScreenPickerDelegate {
:color => Gfx.COLOR_GREEN
});
confirmSaveSetting = Ui.loadResource(Rez.Strings.menuConfirmSaveActivityOptions_autoYes);
}
if (saveActivityConfirmation == ConfirmSaveActivity.AutoYesExit) {
details.detailLines[2].icon = new ScreenPicker.Icon({
:font => StatusIconFonts.fontAwesomeFreeSolid,
:symbol => StatusIconFonts.Rez.Strings.faSaveSession,
:color => Gfx.COLOR_GREEN
});
confirmSaveSetting = Ui.loadResource(Rez.Strings.menuConfirmSaveActivityOptions_autoYesExit);
}
if (saveActivityConfirmation == ConfirmSaveActivity.AutoNo) {
details.detailLines[2].icon = new ScreenPicker.Icon({
Expand Down
3 changes: 3 additions & 0 deletions Meditate/source/globalSettings/GlobalSettingsMenuDelegate.mc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class GlobalSettingsMenuDelegate extends Ui.MenuInputDelegate {
else if (item == :autoYes) {
GlobalSettings.saveConfirmSaveActivity(ConfirmSaveActivity.AutoYes);
}
else if (item == :autoYesExit) {
GlobalSettings.saveConfirmSaveActivity(ConfirmSaveActivity.AutoYesExit);
}
else if (item == :autoNo) {
GlobalSettings.saveConfirmSaveActivity(ConfirmSaveActivity.AutoNo);
}
Expand Down

0 comments on commit 6111aa2

Please sign in to comment.