1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-23 13:30:48 +02:00

Fix Weather notification integration

This commit is contained in:
José Rebelo 2023-07-07 09:03:35 +01:00
parent 708cb0c617
commit 665268c419
2 changed files with 9 additions and 3 deletions

View File

@ -405,14 +405,14 @@
<receiver
android:name=".externalevents.WeatherNotificationReceiver"
android:enabled="true"
android:exported="false">
android:exported="true">
<intent-filter>
<action android:name="ru.gelin.android.weather.notification.ACTION_WEATHER_UPDATE_2" />
</intent-filter>
</receiver>
<activity android:name=".externalevents.WeatherNotificationConfig"
android:exported="false">
android:exported="true">
<intent-filter>
<action android:name="ru.gelin.android.weather.notification.ACTION_WEATHER_SKIN_PREFERENCES" />
</intent-filter>

View File

@ -25,6 +25,8 @@ import android.widget.Toast;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
@ -34,6 +36,8 @@ import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
public class GenericWeatherReceiver extends BroadcastReceiver {
private static final Logger LOG = LoggerFactory.getLogger(GenericWeatherReceiver.class);
public final static String ACTION_GENERIC_WEATHER = "nodomain.freeyourgadget.gadgetbridge.ACTION_GENERIC_WEATHER";
public final static String EXTRA_WEATHER_JSON = "WeatherJson";
@ -68,7 +72,7 @@ public class GenericWeatherReceiver extends BroadcastReceiver {
JSONObject forecastJson = forecastArray.getJSONObject(i);
WeatherSpec.Forecast forecast = new WeatherSpec.Forecast();
forecast.conditionCode = safelyGet(forecastJson, Integer.class, "conditionCode", 0);
forecast.humidity = safelyGet(forecastJson, Integer.class, "humidity", 0);
forecast.maxTemp = safelyGet(forecastJson, Integer.class, "maxTemp", 0);
@ -78,6 +82,8 @@ public class GenericWeatherReceiver extends BroadcastReceiver {
}
}
LOG.info("Got generic weather for {}", weatherSpec.location);
Weather.getInstance().setWeatherSpec(weatherSpec);
GBApplication.deviceService().onSendWeather(weatherSpec);
} catch (Exception e) {