-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
4.4.0 - Implemented meditation preparation time that can be customize…
…d in global settings for 0s, 15s, 30s or 60s.
- Loading branch information
Showing
19 changed files
with
228 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
Meditate/resources/menus/globalSettings/prepareTimeOptionsMenu.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<menu id="prepareTimeOptionsMenu" title="@Strings.menuPrepareTimeOptions_title"> | ||
<menu-item id="time_0" label="@Strings.menuPrepareTimeOptions_0" /> | ||
<menu-item id="time_15" label="@Strings.menuPrepareTimeOptions_15" /> | ||
<menu-item id="time_30" label="@Strings.menuPrepareTimeOptions_30" /> | ||
<menu-item id="time_60" label="@Strings.menuPrepareTimeOptions_60" /> | ||
</menu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Toybox.WatchUi as Ui; | ||
using Toybox.Lang; | ||
|
||
class MeditatePrepareDelegate extends Ui.BehaviorDelegate { | ||
|
||
var mSessionPickerDelegate; | ||
|
||
function initialize(sessionPickerDelegate) { | ||
mSessionPickerDelegate = sessionPickerDelegate; | ||
Ui.BehaviorDelegate.initialize(); | ||
} | ||
|
||
function onBack() { | ||
return true; | ||
} | ||
|
||
function onKey(keyEvent) { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
using Toybox.Lang; | ||
using Toybox.Timer; | ||
using Toybox.WatchUi as Ui; | ||
using Toybox.Graphics as Gfx; | ||
using Toybox.Application as App; | ||
|
||
class MeditatePrepareView extends Ui.View { | ||
private var mOnShow; | ||
private var mMainDurationRenderer; | ||
private var mSeconds; | ||
private var mTotalSeconds; | ||
|
||
function initialize(onShow) { | ||
View.initialize(); | ||
me.mOnShow = onShow; | ||
mSeconds = 0; | ||
mTotalSeconds = GlobalSettings.loadPrepareTime(); | ||
} | ||
|
||
function onViewDrawn() { | ||
|
||
if (mSeconds >= mTotalSeconds+1) { | ||
return; | ||
} | ||
|
||
mSeconds += 1; | ||
Ui.requestUpdate(); | ||
|
||
// Start the meditation session after XX seconds | ||
if (mSeconds == mTotalSeconds+1) { | ||
|
||
// Vibrate short to notify session starts | ||
Vibe.vibrate(VibePattern.Blip); | ||
|
||
// Starts the meditation session | ||
me.mOnShow.invoke(); | ||
|
||
return; | ||
} | ||
|
||
// Try to keep backlight on during preparation time | ||
try { | ||
|
||
if ((Attention has :backlight) ) { | ||
if (mSeconds == 1 || (mSeconds % 8 == 0)) { | ||
Attention.backlight(true); | ||
} | ||
} | ||
|
||
} catch(ex) { | ||
|
||
// Just in case we get a BacklightOnTooLongException for OLED display devices (ex: Venu2) | ||
if ((Attention has :backlight) ) { | ||
Attention.backlight(false); | ||
} | ||
} | ||
} | ||
|
||
function onLayout(dc) { | ||
|
||
// Clear the screen | ||
renderBackground(dc); | ||
|
||
var durationArcRadius = dc.getWidth() / 2; | ||
var mainDurationArcWidth = dc.getWidth() / 4; | ||
|
||
// For rectangle screens we need to set this manually | ||
var mainDurationArcWidthConfig = App.getApp().getProperty("meditateActivityDurationArcWidth"); | ||
if (mainDurationArcWidthConfig != null) { | ||
mainDurationArcWidth = mainDurationArcWidthConfig; | ||
} | ||
|
||
// Configure the arc render for progress | ||
me.mMainDurationRenderer = new ElapsedDurationRenderer(Gfx.COLOR_BLUE, durationArcRadius, mainDurationArcWidth); | ||
} | ||
|
||
private function renderBackground(dc) { | ||
|
||
// Clear the screen | ||
dc.setColor(Gfx.COLOR_TRANSPARENT, Gfx.COLOR_BLACK); | ||
dc.clear(); | ||
} | ||
|
||
function onShow() { | ||
var viewDrawnTimer = new Timer.Timer(); | ||
viewDrawnTimer.start(method(:onViewDrawn), 1000, true); | ||
} | ||
|
||
function onUpdate(dc) { | ||
View.onUpdate(dc); | ||
|
||
// Draw arc with the progress | ||
me.mMainDurationRenderer.drawOverallElapsedTime(dc, mSeconds, mTotalSeconds); | ||
|
||
// Calculate center of the screen | ||
var centerX = dc.getWidth()/2; | ||
var centerY = dc.getHeight()/2; | ||
|
||
// Render main text with number of seconds remaining to start the session | ||
dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_TRANSPARENT); | ||
dc.drawText(centerX, | ||
centerY-centerY/3, | ||
Gfx.FONT_SYSTEM_TINY, | ||
Ui.loadResource(Rez.Strings.meditateActivityPrepare) + " " + (mTotalSeconds-mSeconds).toString() + "s", | ||
Graphics.TEXT_JUSTIFY_CENTER); | ||
} | ||
|
||
function onHide() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.