mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-25 11:26:47 +01:00
WaspOS: fix battery chart
This commit is contained in:
parent
ed1836a2bd
commit
33569d73d7
@ -37,6 +37,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
|
||||||
@ -152,23 +153,17 @@ public class WaspOSDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
GB.toast(getContext(), "Bangle.js: " + json.getString("msg"), Toast.LENGTH_LONG, GB.ERROR);
|
GB.toast(getContext(), "Bangle.js: " + json.getString("msg"), Toast.LENGTH_LONG, GB.ERROR);
|
||||||
break;
|
break;
|
||||||
case "status": {
|
case "status": {
|
||||||
Context context = getContext();
|
GBDeviceEventBatteryInfo batteryInfo = new GBDeviceEventBatteryInfo();
|
||||||
if (json.has("bat")) {
|
if (json.has("bat")) {
|
||||||
int b = json.getInt("bat");
|
int b = json.getInt("bat");
|
||||||
if (b<0) b=0;
|
if (b < 0) b = 0;
|
||||||
if (b>100) b=100;
|
if (b > 100) b = 100;
|
||||||
gbDevice.setBatteryLevel((short)b);
|
batteryInfo.level = b;
|
||||||
if (b < 30) {
|
batteryInfo.state = BatteryState.BATTERY_NORMAL;
|
||||||
gbDevice.setBatteryState(BatteryState.BATTERY_LOW);
|
|
||||||
GB.updateBatteryNotification(context.getString(R.string.notif_battery_low_percent, gbDevice.getName(), String.valueOf(b)), "", context);
|
|
||||||
} else {
|
|
||||||
gbDevice.setBatteryState(BatteryState.BATTERY_NORMAL);
|
|
||||||
GB.removeBatteryNotification(context);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (json.has("volt"))
|
if (json.has("volt"))
|
||||||
gbDevice.setBatteryVoltage((float)json.getDouble("volt"));
|
batteryInfo.voltage = (float) json.getDouble("volt");
|
||||||
gbDevice.sendDeviceUpdateIntent(context);
|
handleGBDeviceEvent(batteryInfo);
|
||||||
} break;
|
} break;
|
||||||
case "findPhone": {
|
case "findPhone": {
|
||||||
boolean start = json.has("n") && json.getBoolean("n");
|
boolean start = json.has("n") && json.getBoolean("n");
|
||||||
|
Loading…
Reference in New Issue
Block a user