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()

View file

@ -30,6 +30,10 @@
name="handlers"
type="io.timelimit.android.ui.manage.category.timelimit_rules.edit.Handlers" />
<variable
name="affectsMultipleDays"
type="boolean" />
<import type="android.view.View" />
</data>
@ -75,6 +79,13 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:visibility="@{affectsMultipleDays ? View.VISIBLE : View.GONE}"
android:textAppearance="?android:textAppearanceSmall"
android:text="@string/category_time_limit_rules_warning_multiple_days"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"

View file

@ -31,4 +31,9 @@
<string name="category_time_limit_rules_snackbar_created">Regel wurde erstellt</string>
<string name="category_time_limit_rules_snackbar_updated">Regel wurde geändert</string>
<string name="category_time_limit_rules_snackbar_deleted">Regel wurde gelöscht</string>
<string name="category_time_limit_rules_warning_multiple_days">Diese Regel
wird die Gesamtnutzungsdauer in einer Woche an den gewählten Tagen einschränken.
Wenn Sei die Begrenzung je Tag wollen, dann erstellen Sie eine Regel je Tag.
</string>
</resources>

View file

@ -31,4 +31,9 @@
<string name="category_time_limit_rules_snackbar_created">Rule was created</string>
<string name="category_time_limit_rules_snackbar_updated">Rule was modified</string>
<string name="category_time_limit_rules_snackbar_deleted">Rule was deleted</string>
<string name="category_time_limit_rules_warning_multiple_days">This rule
will limit the total usage duration during one week at the selected days.
If you want it per day, create one rule per day.
</string>
</resources>