mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-29 12:05:53 +01:00
parent
5e4ecd774b
commit
19ee3a14d4
@ -356,20 +356,35 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
|
||||
gbDevice.setBatteryState(deviceEvent.state);
|
||||
gbDevice.setBatteryVoltage(deviceEvent.voltage);
|
||||
|
||||
//show the notification if the battery level is below threshold and only if not connected to charger
|
||||
if (deviceEvent.level <= gbDevice.getBatteryThresholdPercent() &&
|
||||
(BatteryState.BATTERY_LOW.equals(deviceEvent.state) ||
|
||||
BatteryState.BATTERY_NORMAL.equals(deviceEvent.state))
|
||||
) {
|
||||
GB.updateBatteryNotification(context.getString(R.string.notif_battery_low_percent, gbDevice.getName(), String.valueOf(deviceEvent.level)),
|
||||
deviceEvent.extendedInfoAvailable() ?
|
||||
context.getString(R.string.notif_battery_low_percent, gbDevice.getName(), String.valueOf(deviceEvent.level)) + "\n" +
|
||||
context.getString(R.string.notif_battery_low_bigtext_last_charge_time, DateFormat.getDateTimeInstance().format(deviceEvent.lastChargeTime.getTime())) +
|
||||
context.getString(R.string.notif_battery_low_bigtext_number_of_charges, String.valueOf(deviceEvent.numCharges))
|
||||
: ""
|
||||
, context);
|
||||
if (deviceEvent.level == GBDevice.BATTERY_UNKNOWN) {
|
||||
// no level available, just "high" or "low"
|
||||
if (BatteryState.BATTERY_LOW.equals(deviceEvent.state)) {
|
||||
GB.updateBatteryNotification(context.getString(R.string.notif_battery_low, gbDevice.getName()),
|
||||
deviceEvent.extendedInfoAvailable() ?
|
||||
context.getString(R.string.notif_battery_low_extended, gbDevice.getName(),
|
||||
context.getString(R.string.notif_battery_low_bigtext_last_charge_time, DateFormat.getDateTimeInstance().format(deviceEvent.lastChargeTime.getTime())) +
|
||||
context.getString(R.string.notif_battery_low_bigtext_number_of_charges, String.valueOf(deviceEvent.numCharges)))
|
||||
: ""
|
||||
, context);
|
||||
} else {
|
||||
GB.removeBatteryNotification(context);
|
||||
}
|
||||
} else {
|
||||
GB.removeBatteryNotification(context);
|
||||
//show the notification if the battery level is below threshold and only if not connected to charger
|
||||
if (deviceEvent.level <= gbDevice.getBatteryThresholdPercent() &&
|
||||
(BatteryState.BATTERY_LOW.equals(deviceEvent.state) ||
|
||||
BatteryState.BATTERY_NORMAL.equals(deviceEvent.state))
|
||||
) {
|
||||
GB.updateBatteryNotification(context.getString(R.string.notif_battery_low_percent, gbDevice.getName(), String.valueOf(deviceEvent.level)),
|
||||
deviceEvent.extendedInfoAvailable() ?
|
||||
context.getString(R.string.notif_battery_low_percent, gbDevice.getName(), String.valueOf(deviceEvent.level)) + "\n" +
|
||||
context.getString(R.string.notif_battery_low_bigtext_last_charge_time, DateFormat.getDateTimeInstance().format(deviceEvent.lastChargeTime.getTime())) +
|
||||
context.getString(R.string.notif_battery_low_bigtext_number_of_charges, String.valueOf(deviceEvent.numCharges))
|
||||
: ""
|
||||
, context);
|
||||
} else {
|
||||
GB.removeBatteryNotification(context);
|
||||
}
|
||||
}
|
||||
|
||||
gbDevice.sendDeviceUpdateIntent(context);
|
||||
|
@ -343,6 +343,8 @@
|
||||
<string name="notif_battery_low_percent">%1$s battery left: %2$s%%</string>
|
||||
<string name="notif_battery_low_bigtext_last_charge_time">Last charge: %s \n</string>
|
||||
<string name="notif_battery_low_bigtext_number_of_charges">Number of charges: %s</string>
|
||||
<string name="notif_battery_low">%1$s battery low</string>
|
||||
<string name="notif_battery_low_extended">%1$s battery low: %2$s</string>
|
||||
<string name="notif_export_failed_title">Export database failed! Please check your settings.</string>
|
||||
<string name="sleepchart_your_sleep">Your sleep</string>
|
||||
<string name="weeksleepchart_sleep_a_week">Sleep per week</string>
|
||||
|
Loading…
Reference in New Issue
Block a user