Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set of proposed changes and various fixes #2

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
7 changes: 5 additions & 2 deletions Open Weather Widget/manifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<!-- 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">
<?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="OpenWeatherWidgetApp" id="2c3dfe98f99e43c795da045af2c71777" launcherIcon="@Drawables.LauncherIcon" minApiLevel="3.0.0" name="@Strings.AppName" type="widget" version="1.0.0">
<iq:products>
<iq:product id="approachs62"/>
Expand Down Expand Up @@ -80,7 +82,8 @@
</iq:permissions>
<iq:languages>
<iq:language>eng</iq:language>
<iq:language>fre</iq:language>
</iq:languages>
<iq:barrels/>
</iq:application>
</iq:manifest>
</iq:manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<drawables>
<bitmap id="LauncherIcon" filename="launcher_icon.png" scope="glance"/>
</drawables>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions Open Weather Widget/resources-fre/strings/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<strings>
<string id="AppName">Open Weather</string>
<string id="AppVersion">12</string>

<string id="m0">Never, refresh on the app start only</string>
<string id="m15">15 min</string>
<string id="m30">30 min</string>
<string id="m60">1 heure</string>
<string id="m120">2 heures</string>
<string id="m180">3 heures</string>
<string id="m240">4 heures</string>

<string id="APIKeyTitle">Clé API Open Weather Map</string>
<string id="RefreshRateTitle">Intervale de mise à jour</string>
<string id="UseGarminLocationTitle">Use phone location provided by Garmin Weather (if available)</string>
<string id="SpeedUnitsTitle">Unité de vitesse</string>
<string id="UnitsTitle">Unité de température</string>

<string id="SystemSpeed">Système (Allure/Vitesse)</string>
<string id="kmh">km/h</string>
<string id="mph">MPH</string>
<string id="kts">nœuds</string>
<string id="mps">m/s</string>
<string id="bft">Beaufort</string>

<string id="PressureUnitsTitle">Unité de pression</string>
<string id="hPa">hPa</string>
<string id="inHG">inHG</string>
<string id="mmHG">mmHG</string>

<string id="NoLocation">Pas de localisation.\nPresser le bouton MENU\npour utiliser le GNSS.</string>
<string id="WaitForGPS">Attente du signal\n satellite. Merci\n de rester sur cet\nécran...</string>

<string id="NoData">Attente des données...</string>
<string id="InvalidData">Données OWM invalides</string>
<string id="NoKey">Pas de clé d'API OWM</string>
<string id="InvalidKey">Clé d'API OWM invalide</string>
<string id="NoLocation">Pas de localisation</string>
<string id="InvalidLocation">Localisation invalide</string>
<string id="SuspendedKey">Clé d'API OWM\nsuspendue</string>
<string id="OWMerror">Erreur OWM :</string>
<string id="NoAPIkey">Paramétrer\nla clé d'API\nOpen Weather.</string>
<string id="BLE_UNAVAILABLE">Bluetooth \nnon disponible.</string>

<string id="RefreshWeather">Mettre à jour la météo</string>
<string id="GetGPSlocation">Localiser avec le GNSS</string>
<string id="AppVersionTitle">Version</string>

<string id="ToWind">à</string>
</strings>

38 changes: 19 additions & 19 deletions Open Weather Widget/resources/drawables/drawables.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<drawables>
<bitmap id="LauncherIcon" filename="launcher_icon.png" />
<bitmap id="LauncherIcon" filename="launcher_icon.png" scope="glance"/>

<bitmap id="iq_icon" filename="iq_icon.png" />

<bitmap id="d01" filename="01d.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" />
<bitmap id="n01" filename="01n.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" />
<bitmap id="d02" filename="02d.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" />
<bitmap id="n02" filename="02n.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" />
<bitmap id="d03" filename="03d.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" />
<bitmap id="n03" filename="03n.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" />
<bitmap id="d04" filename="04d.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" />
<bitmap id="n04" filename="04n.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" />
<bitmap id="d09" filename="09d.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" />
<bitmap id="n09" filename="09n.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" />
<bitmap id="d10" filename="10d.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" />
<bitmap id="n10" filename="10n.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" />
<bitmap id="d11" filename="11d.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" />
<bitmap id="n11" filename="11n.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" />
<bitmap id="d13" filename="13d.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" />
<bitmap id="n13" filename="13n.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" />
<bitmap id="d50" filename="50d.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" />
<bitmap id="n50" filename="50n.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" />
<bitmap id="d01" filename="01d.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" scope="glance" />
<bitmap id="n01" filename="01n.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" scope="glance" />
<bitmap id="d02" filename="02d.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" scope="glance" />
<bitmap id="n02" filename="02n.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" scope="glance" />
<bitmap id="d03" filename="03d.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" scope="glance" />
<bitmap id="n03" filename="03n.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" scope="glance" />
<bitmap id="d04" filename="04d.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" scope="glance" />
<bitmap id="n04" filename="04n.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" scope="glance" />
<bitmap id="d09" filename="09d.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" scope="glance" />
<bitmap id="n09" filename="09n.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" scope="glance" />
<bitmap id="d10" filename="10d.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" scope="glance" />
<bitmap id="n10" filename="10n.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" scope="glance" />
<bitmap id="d11" filename="11d.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" scope="glance" />
<bitmap id="n11" filename="11n.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" scope="glance" />
<bitmap id="d13" filename="13d.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" scope="glance" />
<bitmap id="n13" filename="13n.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" scope="glance" />
<bitmap id="d50" filename="50d.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" scope="glance" />
<bitmap id="n50" filename="50n.png" scaleX="20%" scaleY="20%" scaleRelativeTo="screen" scope="glance" />
</drawables>
3 changes: 2 additions & 1 deletion Open Weather Widget/resources/fonts/owm_font.fnt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ chars count=5
char id=61520 x=0 y=30 width=33 height=16 xoffset=-1 yoffset=11 xadvance=31 page=0 chnl=15
char id=61521 x=34 y=0 width=34 height=25 xoffset=-1 yoffset=2 xadvance=32 page=0 chnl=15
char id=61522 x=0 y=0 width=33 height=29 xoffset=-1 yoffset=2 xadvance=32 page=0 chnl=15
char id=61523 x=38 y=30 width=24 height=24 xoffset=-1 yoffset=12 xadvance=23 page=0 chnl=15
char id=61560 x=91 y=0 width=15 height=19 xoffset=-1 yoffset=7 xadvance=14 page=0 chnl=15
char id=61561 x=69 y=0 width=21 height=23 xoffset=-1 yoffset=6 xadvance=19 page=0 chnl=15
char id=61561 x=69 y=0 width=21 height=23 xoffset=-1 yoffset=6 xadvance=19 page=0 chnl=15
Binary file modified Open Weather Widget/resources/fonts/owm_font_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 9 additions & 4 deletions Open Weather Widget/resources/strings/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<strings>
<string id="AppName">Open Weather</string>
<string id="AppVersion">12</string>
<string id="AppVersion">15</string>

<string id="m0">Never, refresh on the app start only</string>
<string id="m15">15 min</string>
Expand All @@ -17,10 +17,10 @@
<string id="UnitsTitle">Temperature units</string>

<string id="SystemSpeed">System (Pace/Speed)</string>
<string id="kmh">KM/H</string>
<string id="kmh">km/h</string>
<string id="mph">MPH</string>
<string id="kts">Knots</string>
<string id="mps">Meters/Sec</string>
<string id="mps">m/s</string>
<string id="bft">Beaufort</string>

<string id="PressureUnitsTitle">Pressure Units</string>
Expand All @@ -33,14 +33,19 @@

<string id="NoData">Waiting for data...</string>
<string id="InvalidData">Invalid OWM Data</string>
<string id="InvalidKey">Invalid OWM API key</string>
<string id="NoKey" scope="glance">No OWM API key</string>
<string id="InvalidKey" scope="glance">Invalid API key</string>
<string id="NoLocation" scope="glance">No Location</string>
<string id="InvalidLocation">Invalid Location</string>
<string id="SuspendedKey">Suspended OWM\nAPI key</string>
<string id="OWMerror">OWM Error:</string>
<string id="NoAPIkey">Please set Open\nWeather API key in\nsettings.</string>
<string id="BLE_UNAVAILABLE">Bluetooth is\nunavailable.</string>

<string id="RefreshWeather">Request Weather refresh</string>
<string id="GetGPSlocation">Get location from GPS</string>
<string id="AppVersionTitle">App Version</string>

<string id="ToWind">to</string>
</strings>

34 changes: 34 additions & 0 deletions Open Weather Widget/source/GlobalCode.mc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Toybox.Application as App;
using Toybox.Time;
using Toybox.WatchUi as Ui;
using Toybox.System as Sys;
using Toybox.WatchUi;
using Toybox.StringUtil;
Expand Down Expand Up @@ -57,6 +58,39 @@ function windDegreeToName (windDegree) {
return windName;
}

(:glance)
function weatherToIcon(weatherData) {
var iconsDictionary = {
"01d" => Rez.Drawables.d01,
"01n" => Rez.Drawables.n01,
"02d" => Rez.Drawables.d02,
"02n" => Rez.Drawables.n02,
"03d" => Rez.Drawables.d03,
"03n" => Rez.Drawables.n03,
"04d" => Rez.Drawables.d04,
"04n" => Rez.Drawables.n04,
"09d" => Rez.Drawables.d09,
"09n" => Rez.Drawables.n09,
"10d" => Rez.Drawables.d10,
"10n" => Rez.Drawables.n10,
"11d" => Rez.Drawables.d11,
"11n" => Rez.Drawables.n11,
"13d" => Rez.Drawables.d13,
"13n" => Rez.Drawables.n13,
"50d" => Rez.Drawables.d50,
"50n" => Rez.Drawables.n50
};

var weatherImage;
if (iconsDictionary[weatherData[4]] != null) {
weatherImage = App.loadResource(iconsDictionary[weatherData[4]]);
} else {
weatherImage = App.loadResource(Rez.Drawables.LauncherIcon);
}

return weatherImage;
}

const DEGREE_SYMBOL = "\u00B0";

(:background)
Expand Down
1 change: 1 addition & 0 deletions Open Weather Widget/source/MenuSettings.mc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ using Toybox.Application as App;
using Toybox.Activity;
using Toybox.Graphics as G;
using Toybox.WatchUi;
using Toybox.Attention;

class MenuSettingsView extends WatchUi.Menu2 {

Expand Down
13 changes: 9 additions & 4 deletions Open Weather Widget/source/OpenWeatherGlanceView.mc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class OpenWeatherGlanceView extends Ui.GlanceView {
function onShow() as Void {}

// Update the view
(:glance)
function onUpdate(dc as Dc) as Void {
GlanceView.onUpdate(dc);
//p("Glance onUpdate");
Expand All @@ -37,23 +38,27 @@ class OpenWeatherGlanceView extends Ui.GlanceView {
dc.setColor(G.COLOR_WHITE, -1);
dc.setPenWidth(1);
dc.drawLine(0, GH /2, GW, GH/2);
dc.drawText(0, GH/4, G.FONT_SYSTEM_TINY, "Open Weather", G.TEXT_JUSTIFY_LEFT | G.TEXT_JUSTIFY_VCENTER);
dc.drawText(55, GH/4, G.FONT_SYSTEM_TINY, "OWM", G.TEXT_JUSTIFY_LEFT | G.TEXT_JUSTIFY_VCENTER);
// Retrieve weather data
var weatherData = App.Storage.getValue("weather");
var str = "-";

var apiKey = App.Properties.getValue("api_key");
if (apiKey == null || apiKey.length() == 0) {str = "No API key";}
else if (App.Storage.getValue("last_location") == null) {str = "No Location";}
if (apiKey == null || apiKey.length() == 0) {str = App.loadResource(Rez.Strings.NoKey);}
else if (App.Storage.getValue("last_location") == null) {str = App.loadResource(Rez.Strings.NoLocation);}

if (weatherData != null && weatherData[0] == 401) {str = "Invalid API key";}
if (weatherData != null && weatherData[0] == 401) {str = App.loadResource(Rez.Strings.InvalidKey);}

if (weatherData != null && weatherData[0] == 200 && weatherData.size() > 16) {
if (weatherData[10] == null) {weatherData[10] = 0;}

str = (tempCelsius ? weatherData[10].format("%.0f") : celsius2fahrenheit(weatherData[10]).format("%.0f")) + DEGREE_SYMBOL + (tempCelsius ? "C" : "F");
str += ": " + capitalize(weatherData[3]);
}
if(weatherData != null && weatherData[0] != 401) {
var weatherImage = $.weatherToIcon(weatherData);
dc.drawBitmap(0, GH / 4 - weatherImage.getHeight() / 2, weatherImage);
}

dc.drawText(0, GH*0.75, G.FONT_SYSTEM_TINY, str, G.TEXT_JUSTIFY_LEFT | G.TEXT_JUSTIFY_VCENTER);
}
Expand Down
1 change: 1 addition & 0 deletions Open Weather Widget/source/OpenWeatherWidgetApp.mc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class OpenWeatherWidgetApp extends App.AppBase {

var mainView = null;

(:glance)
function initialize() {
AppBase.initialize();
}
Expand Down
Loading