Update Import and Export to account for missing year
- Add custom ics tag Constants.MISSING_YEAR that would be set to 1 if an event has the Constants.MISSING_YEAR_FLAG - While Importing, check for the presence of the custom tag. If it is present and set to 1, add the Constants.MISSING_YEAR_FLAG to the event
This commit is contained in:
parent
fa45ef98e9
commit
1f0ae80d73
|
@ -628,7 +628,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||
val flags = if(format in yearDateFormats){
|
||||
FLAG_ALL_DAY
|
||||
}else {
|
||||
FLAG_ALL_DAY or FLAG_MISSING_YEAR_EVENT
|
||||
FLAG_ALL_DAY or FLAG_MISSING_YEAR
|
||||
}
|
||||
|
||||
val timestamp = date.time / 1000L
|
||||
|
|
|
@ -93,7 +93,7 @@ const val REPEAT_ORDER_WEEKDAY = 4 // i.e. every 4th sunday
|
|||
// special event flags
|
||||
const val FLAG_ALL_DAY = 1
|
||||
const val FLAG_IS_PAST_EVENT = 2
|
||||
const val FLAG_MISSING_YEAR_EVENT = 4
|
||||
const val FLAG_MISSING_YEAR = 4
|
||||
|
||||
// constants related to ICS file exporting / importing
|
||||
const val BEGIN_CALENDAR = "BEGIN:VCALENDAR"
|
||||
|
@ -130,6 +130,7 @@ const val SEQUENCE = "SEQUENCE"
|
|||
// this tag isn't a standard ICS tag, but there's no official way of adding a category color in an ics file
|
||||
const val CATEGORY_COLOR = "X-SMT-CATEGORY-COLOR:"
|
||||
const val CATEGORY_COLOR_LEGACY = "CATEGORY_COLOR:"
|
||||
const val MISSING_YEAR = "X-SMT-MISSING-YEAR:"
|
||||
|
||||
const val DISPLAY = "DISPLAY"
|
||||
const val EMAIL = "EMAIL"
|
||||
|
|
|
@ -307,7 +307,7 @@ class EventsHelper(val context: Context) {
|
|||
(anniversaryEventId != -1L && it.eventType == anniversaryEventId)){
|
||||
val eventStartDate = Formatter.getDateFromTS(it.startTS)
|
||||
val originalEventStartDate = Formatter.getDateFromTS(originalEvent.startTS)
|
||||
if(it.flags and FLAG_MISSING_YEAR_EVENT == 0){
|
||||
if(it.hasMissingYear().not()){
|
||||
val years = (eventStartDate.year - originalEventStartDate.year).coerceAtLeast(0)
|
||||
if(years > 0){
|
||||
it.title = "${it.title} ($years)"
|
||||
|
|
|
@ -58,6 +58,7 @@ class IcsExporter {
|
|||
event.startTS.let { out.writeLn("$DTSTART:${Formatter.getExportedTime(it * 1000L)}") }
|
||||
event.endTS.let { out.writeLn("$DTEND:${Formatter.getExportedTime(it * 1000L)}") }
|
||||
}
|
||||
event.hasMissingYear().let { out.writeLn("$MISSING_YEAR${if(it) 1 else 0}") }
|
||||
|
||||
out.writeLn("$DTSTAMP$exportTime")
|
||||
out.writeLn("$STATUS$CONFIRMED")
|
||||
|
|
|
@ -128,6 +128,10 @@ class IcsImporter(val activity: SimpleActivity) {
|
|||
if (color.trimStart('-').areDigitsOnly()) {
|
||||
curCategoryColor = Integer.parseInt(color)
|
||||
}
|
||||
} else if (line.startsWith(MISSING_YEAR)) {
|
||||
if (line.substring(MISSING_YEAR.length) == "1") {
|
||||
curFlags = curFlags or FLAG_MISSING_YEAR
|
||||
}
|
||||
} else if (line.startsWith(CATEGORIES) && !overrideFileEventTypes) {
|
||||
val categories = line.substring(CATEGORIES.length)
|
||||
tryAddCategories(categories)
|
||||
|
|
|
@ -138,6 +138,7 @@ data class Event(
|
|||
}
|
||||
|
||||
fun getIsAllDay() = flags and FLAG_ALL_DAY != 0
|
||||
fun hasMissingYear() = flags and FLAG_MISSING_YEAR != 0
|
||||
|
||||
fun getReminders() = setOf(
|
||||
Reminder(reminder1Minutes, reminder1Type),
|
||||
|
|
Loading…
Reference in New Issue