set the default daily rule to EVERY_DAY when daily repetition is selected

This commit is contained in:
tibbi 2017-04-15 12:40:54 +02:00
parent c166ce8f1c
commit cfd40fd486
3 changed files with 16 additions and 8 deletions

View File

@ -151,6 +151,10 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
mRepeatInterval = interval mRepeatInterval = interval
updateRepetitionText() updateRepetitionText()
checkRepeatTexts(interval) checkRepeatTexts(interval)
if (mRepeatInterval == DAY) {
setRepeatRule(EVERY_DAY)
}
} }
private fun checkRepeatTexts(limit: Int) { private fun checkRepeatTexts(limit: Int) {
@ -190,18 +194,22 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
private fun showRepetitionRuleDialog() { private fun showRepetitionRuleDialog() {
if (mRepeatInterval == DAY) { if (mRepeatInterval == DAY) {
RepeatRuleDailyDialog(this, mRepeatRule) { RepeatRuleDailyDialog(this, mRepeatRule) {
mRepeatRule = it setRepeatRule(it)
checkRepetitionRuleText()
if (it == 0) {
setRepeatInterval(0)
}
} }
} }
} }
private fun setRepeatRule(rule: Int) {
mRepeatRule = rule
checkRepetitionRuleText()
if (rule == 0) {
setRepeatInterval(0)
}
}
private fun checkRepetitionRuleText() { private fun checkRepetitionRuleText() {
if (mRepeatInterval == DAY) { if (mRepeatInterval == DAY) {
event_repetition_rule.text = getString(if (mRepeatRule == 127) R.string.every_day else R.string.selected_days) event_repetition_rule.text = getString(if (mRepeatRule == EVERY_DAY) R.string.every_day else R.string.selected_days)
} }
} }

View File

@ -54,7 +54,7 @@ val THURSDAY = 8
val FRIDAY = 16 val FRIDAY = 16
val SATURDAY = 32 val SATURDAY = 32
val SUNDAY = 64 val SUNDAY = 64
val ALL_DAYS = 127 val EVERY_DAY = 127
// repeat_rule for monthly repetition // repeat_rule for monthly repetition
val REPEAT_MONTH_SAME_DAY = 1 val REPEAT_MONTH_SAME_DAY = 1

View File

@ -593,7 +593,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
do { do {
val eventId = cursor.getIntValue(COL_EVENT_ID) val eventId = cursor.getIntValue(COL_EVENT_ID)
val interval = cursor.getIntValue(COL_REPEAT_INTERVAL) val interval = cursor.getIntValue(COL_REPEAT_INTERVAL)
var rule = ALL_DAYS var rule = EVERY_DAY
if (interval == MONTH) { if (interval == MONTH) {
rule = REPEAT_MONTH_SAME_DAY rule = REPEAT_MONTH_SAME_DAY
} }