mirror of
https://github.com/lone-cloud/prism-android
synced 2026-06-03 19:54:44 -07:00
Send min urgency when registering battery callback
This commit is contained in:
parent
dfb144c5ae
commit
08afb9c9f4
1 changed files with 13 additions and 3 deletions
|
|
@ -22,12 +22,22 @@ object BatteryCallbackFactory : CallbackFactory<BatteryCallbackFactory.MainBatte
|
|||
MessageSender.send(context, ClientMessage.MinUrgency(ClientMessage.Urgency.VeryLow))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Once the battery callback is registered,
|
||||
* we send min urgency depending on the battery level
|
||||
*/
|
||||
override fun register(context: Context) {
|
||||
super.register(context)
|
||||
if (isLowBattery()) {
|
||||
onBatteryLow(context)
|
||||
} else {
|
||||
onBatteryOk(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun new(context: Context): MainBatteryCallback {
|
||||
if (BuildConfig.URGENCY) {
|
||||
MessageSender.send(context, ClientMessage.MinUrgency(ClientMessage.Urgency.VeryLow))
|
||||
}
|
||||
return MainBatteryCallback()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue