Add battery level handler

This commit is contained in:
Tommaso Berlose
2020-05-16 14:34:04 +02:00
parent b81461f725
commit 233761a169
13 changed files with 207 additions and 83 deletions

View File

@ -14,7 +14,6 @@ object GlanceProviderHelper {
val enabledProviders = Preferences.enabledGlanceProviderOrder.split(",").filter { it != "" }
val providers = Constants.GlanceProviderId.values()
.filter { it != Constants.GlanceProviderId.BATTERY_LEVEL_LOW }
.filter {
context.checkIfFitInstalled() || it != Constants.GlanceProviderId.GOOGLE_FIT_STEPS
}.toTypedArray()
@ -80,10 +79,11 @@ object GlanceProviderHelper {
fun showGlanceProviders(context: Context): Boolean {
val eventRepository = EventRepository(context)
BatteryHelper.updateBatteryInfo(context)
val showGlance = Preferences.showGlance && eventRepository.getEventsCount() == 0 && (
(Preferences.showNextAlarm && AlarmHelper.getNextAlarm(context) != "") ||
(MediaPlayerHelper.isSomeonePlaying(context)) ||
(Preferences.isBatteryLevelLow) ||
(Preferences.showBatteryCharging && Preferences.isCharging || Preferences.isBatteryLevelLow) ||
(Preferences.customNotes.isNotEmpty()) ||
(Preferences.showDailySteps && Preferences.googleFitSteps > 0)
)