Show warning if time limit rule affects multiple days

This commit is contained in:
Jonas L 2019-02-12 16:13:05 +01:00
parent 1808710e0b
commit b74350f85f
4 changed files with 24 additions and 1 deletions

View file

@ -134,7 +134,9 @@ class EditTimeLimitRuleDialogFragment : BottomSheetDialogFragment() {
view.applyToExtraTime = newRule.applyToExtraTimeUsage
view.timeSpan.timeInMillis = newRule.maximumTimeInMillis.toLong()
view.timeSpan.maxDays = Math.max(0, (0..6).map { (newRule.dayMask.toInt() shr it) and 1 }.sum() - 1)
val affectedDays = Math.max(0, (0..6).map { (newRule.dayMask.toInt() shr it) and 1 }.sum())
view.timeSpan.maxDays = affectedDays - 1
view.affectsMultipleDays = affectedDays >= 2
}
bindRule()