From 965964a6b744dffe926eca5acfa32ce61f9778b9 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sat, 14 Apr 2018 21:56:10 +0200 Subject: [PATCH] Weather: get wind direction and speed also from CM weather reciver --- .../gadgetbridge/externalevents/CMWeatherReceiver.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CMWeatherReceiver.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CMWeatherReceiver.java index 6df259e9e..87610fea9 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CMWeatherReceiver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CMWeatherReceiver.java @@ -46,6 +46,7 @@ import static cyanogenmod.providers.WeatherContract.WeatherColumns.WeatherCode.N import static cyanogenmod.providers.WeatherContract.WeatherColumns.WeatherCode.SCATTERED_SNOW_SHOWERS; import static cyanogenmod.providers.WeatherContract.WeatherColumns.WeatherCode.SCATTERED_THUNDERSTORMS; import static cyanogenmod.providers.WeatherContract.WeatherColumns.WeatherCode.SHOWERS; +import static cyanogenmod.providers.WeatherContract.WeatherColumns.WindSpeedUnit.MPH; public class CMWeatherReceiver extends BroadcastReceiver implements CMWeatherManager.WeatherUpdateRequestListener, CMWeatherManager.LookupCityRequestListener { @@ -148,6 +149,13 @@ public class CMWeatherReceiver extends BroadcastReceiver implements CMWeatherMan weatherSpec.todayMaxTemp = (int) weatherInfo.getTodaysHigh() + 273; weatherSpec.todayMinTemp = (int) weatherInfo.getTodaysLow() + 273; } + if (weatherInfo.getWindSpeedUnit() == MPH) { + weatherSpec.windSpeed = (float) weatherInfo.getWindSpeed() * 1.609344f; + } else { + weatherSpec.windSpeed = (float) weatherInfo.getWindSpeed(); + } + weatherSpec.windDirection = (int) weatherInfo.getWindDirection(); + weatherSpec.currentConditionCode = Weather.mapToOpenWeatherMapCondition(CMtoYahooCondintion(weatherInfo.getConditionCode())); weatherSpec.currentCondition = Weather.getConditionString(weatherSpec.currentConditionCode); weatherSpec.currentHumidity = (int) weatherInfo.getHumidity();