Skip to content

Commit

Permalink
twilights indicator fix - hide indicator if position is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
Radko Najman committed Apr 2, 2022
1 parent 1c5b39f commit 34aee31
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 1.3.2 (April 2, 2022)
* twilights indicator fix - hide indicator if position is not available

# 1.3.1 (March 6, 2022)
* small bugfix for twilights indicator

Expand Down
Binary file added connect_iq_store/vivoactive3_cover_ukraine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion manifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- 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="SmartArcsTripApp" id="547fb49c0626476280e1121801561e5c" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watchface" version="1.3.1">
<iq:application entry="SmartArcsTripApp" id="547fb49c0626476280e1121801561e5c" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watchface" version="1.3.2">
<iq:products>
<iq:product id="d2air"/>
<iq:product id="d2charlie"/>
Expand Down
2 changes: 1 addition & 1 deletion manifest.xml.beta
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- 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="SmartArcsTripApp" id="5b7bdde686cc4867be63faf4c6ca83fb" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watchface" version="1.3.0">
<iq:application entry="SmartArcsTripApp" id="5b7bdde686cc4867be63faf4c6ca83fb" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watchface" version="1.3.15">
<iq:products>
<iq:product id="d2air"/>
<iq:product id="d2charlie"/>
Expand Down
2 changes: 1 addition & 1 deletion manifest.xml.prod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- 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="SmartArcsTripApp" id="547fb49c0626476280e1121801561e5c" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watchface" version="1.3.1">
<iq:application entry="SmartArcsTripApp" id="547fb49c0626476280e1121801561e5c" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watchface" version="1.3.2">
<iq:products>
<iq:product id="d2air"/>
<iq:product id="d2charlie"/>
Expand Down
2 changes: 2 additions & 0 deletions resources/settings/properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@

<property id="sunriseColor" type="number">0xAA0000</property>
<property id="sunsetColor" type="number">0x0000FF</property>
<property id="locationLatitude" type="number">-999</property>
<property id="locationLongitude" type="number">-999</property>

<!--
<property id="dateFormat" type="number">1</property>
Expand Down
25 changes: 22 additions & 3 deletions source/SmartArcsTripView.mc
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ class SmartArcsTripView extends WatchUi.WatchFace {
var powerSaverIconColor;
var sunriseColor;
var sunsetColor;
var locationLatitude;
var locationLongitude;

function initialize() {
loadUserSettings();
Expand Down Expand Up @@ -485,6 +487,9 @@ class SmartArcsTripView extends WatchUi.WatchFace {
}
powerSaverRefreshInterval = app.getProperty("powerSaverRefreshInterval");
powerSaverIconColor = app.getProperty("powerSaverIconColor");

locationLatitude = app.getProperty("locationLatitude");
locationLongitude = app.getProperty("locationLongitude");

//ensure that constants will be pre-computed
precompute = true;
Expand Down Expand Up @@ -994,7 +999,21 @@ class SmartArcsTripView extends WatchUi.WatchFace {
if (posInfo != null && posInfo.position != null) {
var sc = new SunCalc();
var time_now = Time.now();
var loc = posInfo.position.toRadians();
var loc = posInfo.position.toRadians();
var hasLocation = (loc[0].format("%.2f").equals("3.14") && loc[1].format("%.2f").equals("3.14")) || (loc[0] == 0 && loc[1] == 0) ? false : true;

if (!hasLocation && locationLatitude != -999) {
loc[0] = locationLatitude;
loc[1] = locationLongitude;
}

if (hasLocation) {
Application.getApp().setProperty("locationLatitude", loc[0]);
Application.getApp().setProperty("locationLongitude", loc[1]);
locationLatitude = loc[0];
locationLongitude = loc[1];
}

sunriseStartAngle = computeSunAngle(sc.calculate(time_now, loc, SunCalc.DAWN));
sunriseEndAngle = computeSunAngle(sc.calculate(time_now, loc, SunCalc.SUNRISE));
sunsetStartAngle = computeSunAngle(sc.calculate(time_now, loc, SunCalc.SUNSET));
Expand All @@ -1013,7 +1032,7 @@ class SmartArcsTripView extends WatchUi.WatchFace {
dc.setPenWidth(7);

//draw sunrise
if (sunriseColor != offSettingFlag) {
if (sunriseColor != offSettingFlag && locationLatitude != -999) {
dc.setColor(sunriseColor, Graphics.COLOR_TRANSPARENT);
if (sunriseStartAngle > sunriseEndAngle) {
dc.drawArc(screenRadius, screenRadius, screenRadius - 17, Graphics.ARC_CLOCKWISE, sunriseStartAngle, sunriseEndAngle);
Expand All @@ -1023,7 +1042,7 @@ class SmartArcsTripView extends WatchUi.WatchFace {
}

//draw sunset
if (sunsetColor != offSettingFlag) {
if (sunsetColor != offSettingFlag && locationLatitude != -999) {
dc.setColor(sunsetColor, Graphics.COLOR_TRANSPARENT);
if (sunsetStartAngle > sunsetEndAngle) {
dc.drawArc(screenRadius, screenRadius, screenRadius - 13, Graphics.ARC_CLOCKWISE, sunsetStartAngle, sunsetEndAngle);
Expand Down

0 comments on commit 34aee31

Please sign in to comment.