fix importing and exporting new monthly repetition types
This commit is contained in:
parent
078db574ca
commit
9785900e21
|
@ -227,16 +227,19 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
|||
setRepeatRule(it)
|
||||
}
|
||||
} else if (mRepeatInterval.isXMonthlyRepetition()) {
|
||||
val items = arrayListOf(
|
||||
RadioItem(REPEAT_MONTH_SAME_DAY, getString(R.string.repeat_on_the_same_day)),
|
||||
RadioItem(REPEAT_MONTH_ORDER_WEEKDAY, getRepeatXthDayString(true, REPEAT_MONTH_ORDER_WEEKDAY)))
|
||||
val items = arrayListOf(RadioItem(REPEAT_MONTH_SAME_DAY, getString(R.string.repeat_on_the_same_day)))
|
||||
|
||||
// split Every Last Sunday and Every Fourth Sunday of the month, if the month has 4 sundays
|
||||
if (isLastWeekDayOfMonth()) {
|
||||
val order = (mEventStartDateTime.dayOfMonth - 1) / 7 + 1
|
||||
if (order == 4) {
|
||||
items.add(RadioItem(REPEAT_MONTH_ORDER_WEEKDAY, getRepeatXthDayString(true, REPEAT_MONTH_ORDER_WEEKDAY)))
|
||||
items.add(RadioItem(REPEAT_MONTH_ORDER_WEEKDAY_USE_LAST, getRepeatXthDayString(true, REPEAT_MONTH_ORDER_WEEKDAY_USE_LAST)))
|
||||
} else if (order == 5) {
|
||||
items.add(RadioItem(REPEAT_MONTH_ORDER_WEEKDAY_USE_LAST, getRepeatXthDayString(true, REPEAT_MONTH_ORDER_WEEKDAY_USE_LAST)))
|
||||
}
|
||||
} else {
|
||||
items.add(RadioItem(REPEAT_MONTH_ORDER_WEEKDAY, getRepeatXthDayString(true, REPEAT_MONTH_ORDER_WEEKDAY)))
|
||||
}
|
||||
|
||||
if (isLastDayOfTheMonth()) {
|
||||
|
|
|
@ -57,7 +57,6 @@ class IcsExporter {
|
|||
out.writeLn(END_CALENDAR)
|
||||
}
|
||||
|
||||
|
||||
callback(when {
|
||||
eventsExported == 0 -> EXPORT_FAIL
|
||||
eventsFailed > 0 -> EXPORT_PARTIAL
|
||||
|
|
|
@ -41,7 +41,7 @@ class Parser {
|
|||
if (repeatInterval.isXWeeklyRepetition()) {
|
||||
repeatRule = handleRepeatRule(value)
|
||||
} else if (repeatInterval.isXMonthlyRepetition()) {
|
||||
repeatRule = REPEAT_MONTH_ORDER_WEEKDAY
|
||||
repeatRule = if (value.startsWith("-1")) REPEAT_MONTH_ORDER_WEEKDAY_USE_LAST else REPEAT_MONTH_ORDER_WEEKDAY
|
||||
}
|
||||
} else if (key == BYMONTHDAY && value.toInt() == -1) {
|
||||
repeatRule = REPEAT_MONTH_LAST_DAY
|
||||
|
@ -131,12 +131,13 @@ class Parser {
|
|||
val days = getByDayString(event.repeatRule)
|
||||
";$BYDAY=$days"
|
||||
}
|
||||
event.repeatInterval.isXMonthlyRepetition() -> when {
|
||||
event.repeatRule == REPEAT_MONTH_LAST_DAY -> ";$BYMONTHDAY=-1"
|
||||
event.repeatRule == REPEAT_MONTH_ORDER_WEEKDAY -> {
|
||||
event.repeatInterval.isXMonthlyRepetition() -> when (event.repeatRule) {
|
||||
REPEAT_MONTH_LAST_DAY -> ";$BYMONTHDAY=-1"
|
||||
REPEAT_MONTH_ORDER_WEEKDAY_USE_LAST, REPEAT_MONTH_ORDER_WEEKDAY -> {
|
||||
val start = Formatter.getDateTimeFromTS(event.startTS)
|
||||
val dayOfMonth = start.dayOfMonth
|
||||
val order = (dayOfMonth - 1) / 7 + 1
|
||||
val isLastWeekday = start.monthOfYear != start.plusDays(7).monthOfYear
|
||||
val order = if (isLastWeekday) "-1" else ((dayOfMonth - 1) / 7 + 1).toString()
|
||||
val day = getDayLetters(start.dayOfWeek)
|
||||
";$BYDAY=$order$day"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue