From 9a388ca386cf5fd19fec2087849a67b91b60bb5c Mon Sep 17 00:00:00 2001 From: "Martin.JM" Date: Sun, 18 Feb 2024 20:29:55 +0100 Subject: [PATCH] Updated according to review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thank you José Rebelo! --- .../devices/huawei/HuaweiCoordinator.java | 2 +- .../requests/SendGpsAndTimeToDeviceRequest.java | 11 ++++++----- .../huawei/requests/SendWeatherForecastRequest.java | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiCoordinator.java index 6e0d34856..3bd9f3d10 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiCoordinator.java @@ -345,7 +345,7 @@ public class HuaweiCoordinator { } public boolean supportsWeatherExtended() { - return supportsCommandForService(0x0f, 0x05); + return supportsCommandForService(0x0f, 0x06); } public boolean supportsWeatherForecasts() { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/requests/SendGpsAndTimeToDeviceRequest.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/requests/SendGpsAndTimeToDeviceRequest.java index 5dc3a0430..271299de8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/requests/SendGpsAndTimeToDeviceRequest.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/requests/SendGpsAndTimeToDeviceRequest.java @@ -17,14 +17,15 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests; +import android.location.Location; + import java.util.Calendar; import java.util.List; -import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.GpsAndTime; import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider; -import nodomain.freeyourgadget.gadgetbridge.util.Prefs; +import nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.webview.CurrentPosition; public class SendGpsAndTimeToDeviceRequest extends Request { @@ -37,12 +38,12 @@ public class SendGpsAndTimeToDeviceRequest extends Request { @Override protected List createRequest() throws RequestCreationException { try { - Prefs prefs = GBApplication.getPrefs(); + Location location = new CurrentPosition().getLastKnownLocation(); return new GpsAndTime.CurrentGPSRequest( this.paramsProvider, (int) (Calendar.getInstance().getTime().getTime() / 1000L) - 60, // Backdating a bit seems to work better - prefs.getFloat("location_latitude", 0.0F), - prefs.getFloat("location_longitude", 0.0F) + location.getLatitude(), + location.getLongitude() ).serialize(); } catch (HuaweiPacket.CryptoException e) { throw new RequestCreationException(e); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/requests/SendWeatherForecastRequest.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/requests/SendWeatherForecastRequest.java index 2428b7e09..84c30ba05 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/requests/SendWeatherForecastRequest.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/requests/SendWeatherForecastRequest.java @@ -55,7 +55,7 @@ public class SendWeatherForecastRequest extends Request { // Add today as well WeatherForecastData.DayData today = new WeatherForecastData.DayData(); - today.timestamp = weatherSpec.sunRise; + today.timestamp = weatherSpec.timestamp; today.icon = supportProvider.openWeatherMapConditionCodeToHuaweiIcon(weatherSpec.currentConditionCode); today.highTemperature = (byte) (weatherSpec.todayMaxTemp - 273); today.lowTemperature = (byte) (weatherSpec.todayMinTemp - 273);