From 20cf15d91fa175bb0400cc433188ba348bd73911 Mon Sep 17 00:00:00 2001 From: Daniel Dakhno Date: Tue, 31 Dec 2019 15:51:52 +0100 Subject: [PATCH] added battery level warning --- .../fossil_hr/FossilHRWatchAdapter.java | 27 +++++-------------- .../ConfigurationGetRequest.java | 7 +++++ 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java index 0e5e97a20..e1670e750 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java @@ -88,11 +88,11 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter { e.printStackTrace(); } // icons - // queueWrite(new NotificationFilterPutHRRequest(new NotificationHRConfiguration[]{ - // new NotificationHRConfiguration("com.whatsapp", -1), - // new NotificationHRConfiguration("asdasdasdasdasd", -1), - // // new NotificationHRConfiguration("twitter", -1), - // }, this)); + queueWrite(new NotificationFilterPutHRRequest(new NotificationHRConfiguration[]{ + // new NotificationHRConfiguration("com.whatsapp", -1), + new NotificationHRConfiguration("generic", -1), + // new NotificationHRConfiguration("twitter", -1), + }, this)); // queueWrite(new PlayNotificationRequest("com.whatsapp", "WhatsAp", "wHATSaPP", this)); // queueWrite(new PlayNotificationRequest("twitterrrr", "Twitterr", "tWITTER", this)); @@ -101,22 +101,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter { setTime(); - // overwriteButtons(null); - - // negotiateSymmetricKey(); - // queueWrite( - // new ConfigurationPutRequest( - // new nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.configuration.ConfigurationPutRequest.CurrentStepCountConfigItem(99999), - // this - // ) - // ); - - queueWrite(new MusicInfoSetRequest( - "This is an artist", - "Some stupid album", - "What the Track!", - this - )); + overwriteButtons(null); queueWrite(new SetDeviceStateRequest(GBDevice.State.INITIALIZED)); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/configuration/ConfigurationGetRequest.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/configuration/ConfigurationGetRequest.java index 8e28a7033..c36ae3e92 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/configuration/ConfigurationGetRequest.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/configuration/ConfigurationGetRequest.java @@ -1,6 +1,8 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.configuration; +import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.BatteryState; import nodomain.freeyourgadget.gadgetbridge.model.GenericItem; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil_hr.FossilHRWatchAdapter; @@ -37,6 +39,11 @@ public class ConfigurationGetRequest extends FileEncryptedLookupAndGetRequest { device.setBatteryLevel((short) ((ConfigurationPutRequest.BatteryConfigItem) item).getBatteryPercentage()); device.setBatteryVoltage(((ConfigurationPutRequest.BatteryConfigItem) item).getBatteryVoltage() / 1000f); device.setBatteryThresholdPercent((short) 15); + + GBDeviceEventBatteryInfo batteryInfo = new GBDeviceEventBatteryInfo(); + batteryInfo.level = (short) ((ConfigurationPutRequest.BatteryConfigItem) item).getBatteryPercentage(); + batteryInfo.state = BatteryState.BATTERY_NORMAL; + getAdapter().getDeviceSupport().handleGBDeviceEvent(batteryInfo); } }