From 0e9ce5d1866d05bb414d048c6a1915ac1101ec5e Mon Sep 17 00:00:00 2001 From: Daniele Gobbetti Date: Fri, 30 Dec 2016 19:58:56 +0100 Subject: [PATCH] Pebble: get min/max temperature also for the forecast --- .../pebble/AppMessageHandlerTimeStylePebble.java | 4 ++-- .../weather/notification/ParcelableWeather2.java | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerTimeStylePebble.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerTimeStylePebble.java index d20aa615e..784603a42 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerTimeStylePebble.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerTimeStylePebble.java @@ -105,8 +105,8 @@ public class AppMessageHandlerTimeStylePebble extends AppMessageHandler { pairs.add(new Pair<>(MESSAGE_KEY_WeatherTemperature, (Object) (weather.currentTemp - 273))); pairs.add(new Pair<>(MESSAGE_KEY_WeatherCondition, (Object) (getIconForConditionCode(weather.currentConditionCode, isNight)))); pairs.add(new Pair<>(MESSAGE_KEY_WeatherForecastCondition, (Object) (getIconForConditionCode(weather.forecastConditionCode, isNight)))); - pairs.add(new Pair<>(MESSAGE_KEY_WeatherForecastHighTemp, (Object) (weather.highTemp - 273))); - pairs.add(new Pair<>(MESSAGE_KEY_WeatherForecastLowTemp, (Object) (weather.lowTemp - 273))); + pairs.add(new Pair<>(MESSAGE_KEY_WeatherForecastHighTemp, (Object) (weather.todayHighTemp - 273))); + pairs.add(new Pair<>(MESSAGE_KEY_WeatherForecastLowTemp, (Object) (weather.todayLowTemp - 273))); } return mPebbleProtocol.encodeApplicationMessagePush(PebbleProtocol.ENDPOINT_APPLICATIONMESSAGE, mUUID, pairs); diff --git a/app/src/main/java/ru/gelin/android/weather/notification/ParcelableWeather2.java b/app/src/main/java/ru/gelin/android/weather/notification/ParcelableWeather2.java index 8defe1e05..0fc34ab2c 100644 --- a/app/src/main/java/ru/gelin/android/weather/notification/ParcelableWeather2.java +++ b/app/src/main/java/ru/gelin/android/weather/notification/ParcelableWeather2.java @@ -23,8 +23,10 @@ public class ParcelableWeather2 implements Parcelable { public int currentConditionCode = 3200; String[] forecastConditionType = null; public int forecastConditionCode = 3200; - public int lowTemp = 0; - public int highTemp = 0; + public int todayLowTemp = 0; + public int todayHighTemp = 0; + public int forecastLowTemp = 0; + public int forecastHighTemp = 0; private ParcelableWeather2(Parcel in) { @@ -33,6 +35,7 @@ public class ParcelableWeather2 implements Parcelable { return; } Bundle bundle = in.readBundle(); + location = bundle.getString("weather_location"); time = bundle.getLong("weather_time"); queryTime = bundle.getLong("weather_query_time"); @@ -46,13 +49,15 @@ public class ParcelableWeather2 implements Parcelable { currentConditionType = conditionBundle.getStringArray("weather_condition_types"); currentConditionCode = weatherConditionTypesToOpenWeatherMapIds(currentConditionType[0]); - lowTemp = conditionBundle.getInt("weather_low_temp"); - highTemp = conditionBundle.getInt("weather_high_temp"); + todayLowTemp = conditionBundle.getInt("weather_low_temp"); + todayHighTemp = conditionBundle.getInt("weather_high_temp"); //fetch immediate next forecast if (--conditions > 0) { Bundle forecastBundle = in.readBundle(); forecastConditionType = forecastBundle.getStringArray("weather_condition_types"); forecastConditionCode = weatherConditionTypesToOpenWeatherMapIds(forecastConditionType[0]); + forecastLowTemp = forecastBundle.getInt("weather_low_temp"); + forecastHighTemp = forecastBundle.getInt("weather_high_temp"); } } // get the rest