Skip to content

Commit

Permalink
Fixed issue displaying adjusted remaining time when changed in config…
Browse files Browse the repository at this point in the history
… settings
  • Loading branch information
arburk committed Jul 16, 2023
1 parent 34b5610 commit 581fb46
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class TimerService : Service(), SharedPreferences.OnSharedPreferenceChangeListen
}
notificationNextRound().also { notifyMgr.notify(it.hashCode(), it) }
// TODO: why is notification channel not playing sound?

return
}

Expand Down Expand Up @@ -228,8 +228,17 @@ class TimerService : Service(), SharedPreferences.OnSharedPreferenceChangeListen
Log.v("TimerService", "called MyListener#onSharedPreferenceChanged for $sharedPreferences")

when (key) {
pref_key_min_per_round -> config.minPerRound =
sharedPreferences.getString(pref_key_min_per_round, config.minPerRound.toString())!!.toInt()
pref_key_min_per_round -> {
config.minPerRound =
sharedPreferences.getString(pref_key_min_per_round, config.minPerRound.toString())!!.toInt().also {
//recalculate remaining time
if (it > config.minPerRound) {
remainingSeconds += (it - config.minPerRound) * 60
} else {
remainingSeconds = it * 60
}
}
}

pref_key_min_per_warning -> config.minPerWarning =
sharedPreferences.getString(pref_key_min_per_warning, config.minPerWarning.toString())!!.toInt()
Expand Down

0 comments on commit 581fb46

Please sign in to comment.