Browse Source

When lat & lon don't have values show --:-- instead of nothing for sunrise and sunset

master
Darren Croton 9 years ago
parent
commit
6bebb3d782
  1. BIN
      bin/SnapshotWatch.prg
  2. 106
      bin/SnapshotWatch.prg.debug.xml
  3. 16
      source/SnapshotWatchView.mc

BIN
bin/SnapshotWatch.prg

Binary file not shown.

106
bin/SnapshotWatch.prg.debug.xml

@ -268,46 +268,47 @@
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="516" pc="268443648" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="516" pc="268443648" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="517" pc="268443672" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="517" pc="268443672" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="518" pc="268443672" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="518" pc="268443672" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="520" pc="268443672" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="519" pc="268443672" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="521" pc="268443695" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="520" pc="268443679" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="523" pc="268443702" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="523" pc="268443686" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="524" pc="268443736" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="524" pc="268443709" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="528" pc="268443773" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="526" pc="268443716" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="529" pc="268443811" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="527" pc="268443750" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="530" pc="268443846" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="531" pc="268443787" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="531" pc="268443884" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="532" pc="268443825" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="537" pc="268443919" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="533" pc="268443860" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="539" pc="268443936" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="534" pc="268443898" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="540" pc="268443936" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="540" pc="268443933" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="542" pc="268443936" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="542" pc="268443950" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="543" pc="268443988" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="544" pc="268443950" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="544" pc="268444033" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="545" pc="268444002" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="546" pc="268444078" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="546" pc="268444047" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="547" pc="268444109" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="548" pc="268444092" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="549" pc="268444140" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="549" pc="268444123" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="550" pc="268444147" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="551" pc="268444154" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="551" pc="268444164" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="552" pc="268444161" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="553" pc="268444174" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="553" pc="268444178" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="554" pc="268444269" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="554" pc="268444188" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="556" pc="268444347" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="556" pc="268444283" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="557" pc="268444354" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="557" pc="268444290" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="558" pc="268444371" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="558" pc="268444307" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="560" pc="268444381" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="559" pc="268444317" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="561" pc="268444476" symbol="drawSunriseSunset"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="562" pc="268444415" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="568" pc="268444558" symbol="to12hourFormat"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="563" pc="268444493" symbol="drawSunriseSunset"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="570" pc="268444562" symbol="to12hourFormat"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="568" pc="268444572" symbol="to12hourFormat"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="571" pc="268444572" symbol="to12hourFormat"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="570" pc="268444576" symbol="to12hourFormat"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="572" pc="268444583" symbol="to12hourFormat"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="571" pc="268444586" symbol="to12hourFormat"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="574" pc="268444593" symbol="to12hourFormat"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="572" pc="268444597" symbol="to12hourFormat"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="578" pc="268444597" symbol="authenticate"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="574" pc="268444607" symbol="to12hourFormat"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="580" pc="268444601" symbol="authenticate"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="578" pc="268444611" symbol="authenticate"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchApp.mc" lineNum="5" pc="268444613" symbol="initialize"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchView.mc" lineNum="580" pc="268444615" symbol="authenticate"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchApp.mc" lineNum="6" pc="268444617" symbol="initialize"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchApp.mc" lineNum="5" pc="268444627" symbol="initialize"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchApp.mc" lineNum="10" pc="268444636" symbol="onStart"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchApp.mc" lineNum="6" pc="268444631" symbol="initialize"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchApp.mc" lineNum="14" pc="268444641" symbol="onStop"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchApp.mc" lineNum="10" pc="268444650" symbol="onStart"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchApp.mc" lineNum="18" pc="268444646" symbol="getInitialView"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchApp.mc" lineNum="14" pc="268444655" symbol="onStop"/>
<entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchApp.mc" lineNum="19" pc="268444650" symbol="getInitialView"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchApp.mc" lineNum="18" pc="268444660" symbol="getInitialView"/>
<entry filename="Rez" lineNum="41" pc="268444688" symbol="WatchFace"/> <entry filename="/Users/dcroton/Documents/Eclipse/SnapshotWatch/source/SnapshotWatchApp.mc" lineNum="19" pc="268444664" symbol="getInitialView"/>
<entry filename="Rez" lineNum="41" pc="268444702" symbol="WatchFace"/>
</pcToLineNum> </pcToLineNum>
<symbolTable> <symbolTable>
<entry id="8389719" method="true" symbol="round"/> <entry id="8389719" method="true" symbol="round"/>
@ -491,18 +492,19 @@
<entry endPc="268443640" name="offsetHour" stackId="3" startPc="268443369"/> <entry endPc="268443640" name="offsetHour" stackId="3" startPc="268443369"/>
<entry endPc="268443640" name="ampm" stackId="4" startPc="268443369"/> <entry endPc="268443640" name="ampm" stackId="4" startPc="268443369"/>
<entry endPc="268443640" name="timeString" stackId="5" startPc="268443369"/> <entry endPc="268443640" name="timeString" stackId="5" startPc="268443369"/>
<entry endPc="268444554" name="now" stackId="8" startPc="268443936"/> <entry endPc="268444412" name="now" stackId="9" startPc="268443950"/>
<entry endPc="268444554" name="ampm" stackId="6" startPc="268443936"/> <entry endPc="268444412" name="ampm" stackId="8" startPc="268443950"/>
<entry endPc="268444554" name="timeInfoSunrise" stackId="11" startPc="268443936"/> <entry endPc="268444412" name="timeInfoSunrise" stackId="12" startPc="268443950"/>
<entry endPc="268444554" name="timeInfoSunset" stackId="12" startPc="268443936"/> <entry endPc="268444412" name="timeInfoSunset" stackId="13" startPc="268443950"/>
<entry endPc="268444554" name="timeString" stackId="7" startPc="268443936"/> <entry endPc="268444412" name="sunrise_moment" stackId="10" startPc="268443950"/>
<entry endPc="268444554" name="sunrise_moment" stackId="9" startPc="268443936"/> <entry endPc="268444412" name="sunset_moment" stackId="11" startPc="268443950"/>
<entry endPc="268444554" name="sunset_moment" stackId="10" startPc="268443936"/> <entry endPc="268444571" name="timeStringRise" stackId="5" startPc="268443648"/>
<entry endPc="268444557" name="lat" stackId="3" startPc="268443648"/> <entry endPc="268444571" name="lat" stackId="3" startPc="268443648"/>
<entry endPc="268444557" name="loc" stackId="5" startPc="268443648"/> <entry endPc="268444571" name="loc" stackId="7" startPc="268443648"/>
<entry endPc="268444557" name="lon" stackId="4" startPc="268443648"/> <entry endPc="268444571" name="lon" stackId="4" startPc="268443648"/>
<entry endPc="268444557" name="sc" stackId="2" startPc="268443648"/> <entry endPc="268444571" name="sc" stackId="2" startPc="268443648"/>
<entry endPc="268444596" name="hour12" stackId="2" startPc="268444562"/> <entry endPc="268444571" name="timeStringSet" stackId="6" startPc="268443648"/>
<entry endPc="268444610" name="hour12" stackId="2" startPc="268444576"/>
</localVars> </localVars>
<annotations/> <annotations/>
<functions> <functions>

16
source/SnapshotWatchView.mc

@ -516,6 +516,9 @@ class SnapshotWatchView extends Ui.WatchFace {
var sc = new SunCalc(); var sc = new SunCalc();
var lat; var lat;
var lon; var lon;
var timeStringRise = " --:--";
var timeStringSet = " --:--";
var loc = Activity.getActivityInfo().currentLocation; var loc = Activity.getActivityInfo().currentLocation;
if (loc == null) if (loc == null)
@ -537,7 +540,6 @@ class SnapshotWatchView extends Ui.WatchFace {
if(lat != null && lon != null) if(lat != null && lon != null)
{ {
var ampm; var ampm;
var timeString;
var now = new Time.Moment(Time.now().value()); var now = new Time.Moment(Time.now().value());
var sunrise_moment = sc.calculate(now, lat.toDouble(), lon.toDouble(), SUNRISE); var sunrise_moment = sc.calculate(now, lat.toDouble(), lon.toDouble(), SUNRISE);
@ -549,18 +551,16 @@ class SnapshotWatchView extends Ui.WatchFace {
ampm = "a"; ampm = "a";
if (timeInfoSunrise.hour >= 12) if (timeInfoSunrise.hour >= 12)
{ ampm = "p"; } { ampm = "p"; }
timeStringRise = Lang.format("$1$:$2$$3$", [to12hourFormat(timeInfoSunrise.hour), timeInfoSunrise.min.format("%02d"), ampm]);
timeString = Lang.format("$1$:$2$$3$", [to12hourFormat(timeInfoSunrise.hour), timeInfoSunrise.min.format("%02d"), ampm]);
dc.drawText(3, height_screen/2 - 14, Gfx.FONT_SMALL, timeString, Gfx.TEXT_JUSTIFY_LEFT|Graphics.TEXT_JUSTIFY_VCENTER);
ampm = "a"; ampm = "a";
if (timeInfoSunset.hour >= 12) if (timeInfoSunset.hour >= 12)
{ ampm = "p"; } { ampm = "p"; }
timeStringSet = Lang.format("$1$:$2$$3$", [to12hourFormat(timeInfoSunset.hour), timeInfoSunset.min.format("%02d"), ampm]);
timeString = Lang.format("$1$:$2$$3$", [to12hourFormat(timeInfoSunset.hour), timeInfoSunset.min.format("%02d"), ampm]);
dc.drawText(3, height_screen/2 + 11, Gfx.FONT_SMALL, timeString, Gfx.TEXT_JUSTIFY_LEFT|Graphics.TEXT_JUSTIFY_VCENTER);
} }
dc.drawText(3, height_screen/2 - 14, Gfx.FONT_SMALL, timeStringRise, Gfx.TEXT_JUSTIFY_LEFT|Graphics.TEXT_JUSTIFY_VCENTER);
dc.drawText(3, height_screen/2 + 11, Gfx.FONT_SMALL, timeStringSet, Gfx.TEXT_JUSTIFY_LEFT|Graphics.TEXT_JUSTIFY_VCENTER);
} }

Loading…
Cancel
Save