Updated according to review

Thank you José Rebelo!
This commit is contained in:
Martin.JM 2024-02-18 20:29:55 +01:00 committed by José Rebelo
parent c66051f580
commit 9a388ca386
3 changed files with 8 additions and 7 deletions

View File

@ -345,7 +345,7 @@ public class HuaweiCoordinator {
} }
public boolean supportsWeatherExtended() { public boolean supportsWeatherExtended() {
return supportsCommandForService(0x0f, 0x05); return supportsCommandForService(0x0f, 0x06);
} }
public boolean supportsWeatherForecasts() { public boolean supportsWeatherForecasts() {

View File

@ -17,14 +17,15 @@
package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests; package nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.requests;
import android.location.Location;
import java.util.Calendar; import java.util.Calendar;
import java.util.List; import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiPacket;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.GpsAndTime; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.packets.GpsAndTime;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider; 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 { public class SendGpsAndTimeToDeviceRequest extends Request {
@ -37,12 +38,12 @@ public class SendGpsAndTimeToDeviceRequest extends Request {
@Override @Override
protected List<byte[]> createRequest() throws RequestCreationException { protected List<byte[]> createRequest() throws RequestCreationException {
try { try {
Prefs prefs = GBApplication.getPrefs(); Location location = new CurrentPosition().getLastKnownLocation();
return new GpsAndTime.CurrentGPSRequest( return new GpsAndTime.CurrentGPSRequest(
this.paramsProvider, this.paramsProvider,
(int) (Calendar.getInstance().getTime().getTime() / 1000L) - 60, // Backdating a bit seems to work better (int) (Calendar.getInstance().getTime().getTime() / 1000L) - 60, // Backdating a bit seems to work better
prefs.getFloat("location_latitude", 0.0F), location.getLatitude(),
prefs.getFloat("location_longitude", 0.0F) location.getLongitude()
).serialize(); ).serialize();
} catch (HuaweiPacket.CryptoException e) { } catch (HuaweiPacket.CryptoException e) {
throw new RequestCreationException(e); throw new RequestCreationException(e);

View File

@ -55,7 +55,7 @@ public class SendWeatherForecastRequest extends Request {
// Add today as well // Add today as well
WeatherForecastData.DayData today = new WeatherForecastData.DayData(); WeatherForecastData.DayData today = new WeatherForecastData.DayData();
today.timestamp = weatherSpec.sunRise; today.timestamp = weatherSpec.timestamp;
today.icon = supportProvider.openWeatherMapConditionCodeToHuaweiIcon(weatherSpec.currentConditionCode); today.icon = supportProvider.openWeatherMapConditionCodeToHuaweiIcon(weatherSpec.currentConditionCode);
today.highTemperature = (byte) (weatherSpec.todayMaxTemp - 273); today.highTemperature = (byte) (weatherSpec.todayMaxTemp - 273);
today.lowTemperature = (byte) (weatherSpec.todayMinTemp - 273); today.lowTemperature = (byte) (weatherSpec.todayMinTemp - 273);