Skip to content

Commit

Permalink
4.2.0 - Added initial 6 meditation sessions of 5,10,15,20,25 and 30 m…
Browse files Browse the repository at this point in the history
…inutes with Blip vibration every 5min. Existing sessions will be kept.
  • Loading branch information
dliedke committed Dec 1, 2022
1 parent df94e09 commit f8306d6
Show file tree
Hide file tree
Showing 7 changed files with 84 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="4.1.9">
<iq:application entry="MeditateApp" id="9abb375dcf7c4ace87ff66f4f774f6c8" launcherIcon="@Drawables.launcherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watch-app" version="4.2.0">
<iq:products>
<iq:product id="approachs62"/>
<iq:product id="d2air"/>
Expand Down
48 changes: 45 additions & 3 deletions Meditate/source/sessionSettings/SessionModel.mc
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,56 @@ class SessionModel {
};
}

function reset() {
me.time = 600;
me.color = Gfx.COLOR_BLUE;
function reset(index, addingNew) {

// Set 5,10,15,20,25 and 30min default session

// 5min
if (index == 0) {
me.time = 5 * 60;
me.color = Gfx.COLOR_GREEN;
}

// 10min
if (index == 1) {
me.time = 10 * 60;
me.color = Gfx.COLOR_YELLOW;
}

// 15min
if (index == 2) {
me.time = 15 * 60;
me.color = Gfx.COLOR_BLUE;
}

// 20min
if (index == 3) {
me.time = 20 * 60;
me.color = Gfx.COLOR_GREEN;
}

// 25min
if (index == 4) {
me.time = 25 * 60;
me.color = Gfx.COLOR_YELLOW;
}

// 30min
if (index == 5) {
me.time = 30 * 60;
me.color = Gfx.COLOR_BLUE;
}

me.vibePattern = VibePattern.LongContinuous;
me.activityType = GlobalSettings.loadActivityType();
me.hrvTracking = GlobalSettings.loadHrvTracking();
me.intervalAlerts = new IntervalAlerts();
me.intervalAlerts.reset();

// Only add each 5min blip for sessions longer than 5min
if (index>0 && !addingNew) {
me.intervalAlerts.addNew();
}
}

function copyNonNullFieldsFromSession(otherSession) {
Expand Down
3 changes: 2 additions & 1 deletion Meditate/source/sessionSettings/SessionPickerDelegate.mc
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ class SessionPickerDelegate extends ScreenPicker.ScreenPickerDelegate {

private function setSelectedSessionDetails() {
me.mSessionStorage.selectSession(me.mSelectedPageIndex);
var session = me.mSessionStorage.loadSelectedSession();
var session = me.mSessionStorage.loadSelectedSession();
ScreenPickerDelegate.setPagesCount(me.mSessionStorage.getSessionsCount());
me.updateSelectedSessionDetails(session);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SessionSettingsMenuDelegate extends Ui.MenuInputDelegate {

function onMenuItem(item) {
if (item == :addNew) {
var newSession = me.mSessionStorage.addSession();
var newSession = me.mSessionStorage.addSession(false);
var addEditSessionMenuMenuDelegate = new AddEditSessionMenuDelegate(newSession.intervalAlerts ,method(:onChangeSession));
me.mSessionPickerDelegate.setPagesCount(me.mSessionStorage.getSessionsCount());
me.mSessionPickerDelegate.select(me.mSessionStorage.getSelectedSessionIndex());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ class Alert {
}

function reset() {
me.type = IntervalAlertType.OneOff;
me.type = IntervalAlertType.Repeat;
me.time = 60 * 5;
me.color = Gfx.COLOR_RED;
me.vibePattern = VibePattern.ShorterContinuous;
me.vibePattern = VibePattern.Blip;
}

function getAlertArcPercentageTimes(sessionTime) {
Expand Down
43 changes: 32 additions & 11 deletions Meditate/source/storage/SessionStorage.mc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class SessionStorage {
var session = new SessionModel();
if (loadedSessionDictionary == null) {
me.mSessionsCount = 0;
session = me.addSession();
me.mSelectedSessionIndex = 0;
session = me.addSession(true);
}
else {
session.fromDictionary(loadedSessionDictionary);
Expand All @@ -61,18 +62,38 @@ class SessionStorage {
App.Storage.setValue("sessionsCount", me.mSessionsCount);
}

function addSession() {
var session = new SessionModel();
session.reset();
me.mSessionsCount++;
me.mSelectedSessionIndex = me.mSessionsCount - 1;
if (me.mSelectedSessionIndex > 0) {
me.mSessionKeysStorage.addAfterInitialKey();
function addSession(initialization) {
var finalIndex = 0;
var firstSession;

// If initializing data first time, add the 6 initial mediation sessions
if (initialization) {
finalIndex = 5;
}

for (var index=0; index<=finalIndex; index++) {

var session = new SessionModel();
session.reset(index, !initialization);
me.mSessionsCount++;
me.mSelectedSessionIndex = me.mSessionsCount - 1;
if (me.mSelectedSessionIndex > 0) {
me.mSessionKeysStorage.addAfterInitialKey();
}
me.saveSelectedSession(session);
me.updateSessionStats();

if (index == 0) {
firstSession = session;
}
}
me.saveSelectedSession(session);
me.updateSessionStats();

return session;
if (initialization) {
me.mSelectedSessionIndex = 0;
me.updateSessionStats();
}

return firstSession;
}

function deleteSelectedSession() {
Expand Down
2 changes: 1 addition & 1 deletion MeditateStoreDescription-en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Totally free application developed by vtrifonov and compiled/enhanced for newer

A meditation/yoga app that tracks as an activity the heart rate, stress, respiration rate, heart rate variability (HRV), provides vibration alerts and heart rate chart.

Touch and hold the screen (Touch devices) or hold the left middle button (Button only devices) to edit the meditation sessions, properties and global settings.
Touch and hold the screen (Touch devices) or hold the left middle button to edit the meditation sessions, properties and global settings.

Touch screen or click Start button to start meditation session. Use lap/back button to pause/resume. Use start button to end the meditation session.

Expand Down

0 comments on commit f8306d6

Please sign in to comment.