fix #461, properly handle the Location field at importing

This commit is contained in:
tibbi
2018-05-04 16:32:09 +02:00
parent 0f97ce7153
commit 5d472fa30d
3 changed files with 10 additions and 4 deletions

View File

@@ -182,8 +182,6 @@ class CalDAVHandler(val context: Context) {
colors.put(colorKey, color) colors.put(colorKey, color)
} while (cursor.moveToNext()) } while (cursor.moveToNext())
} }
} catch (e: Exception) {
Log.e("DEBUG", "exc $e")
} finally { } finally {
cursor?.close() cursor?.close()
} }

View File

@@ -87,7 +87,7 @@ const val STATUS = "STATUS:"
const val EXDATE = "EXDATE" const val EXDATE = "EXDATE"
const val BYDAY = "BYDAY" const val BYDAY = "BYDAY"
const val BYMONTHDAY = "BYMONTHDAY" const val BYMONTHDAY = "BYMONTHDAY"
const val LOCATION = "LOCATION:" const val LOCATION = "LOCATION"
// this tag isn't a standard ICS tag, but there's no official way of adding a category color in an ics file // 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 = "CATEGORY_COLOR:" const val CATEGORY_COLOR = "CATEGORY_COLOR:"

View File

@@ -119,7 +119,7 @@ class IcsImporter(val activity: SimpleActivity) {
curRepeatExceptions.add(getTimestamp(value)) curRepeatExceptions.add(getTimestamp(value))
} else if (line.startsWith(LOCATION)) { } else if (line.startsWith(LOCATION)) {
curLocation = line.substring(LOCATION.length).replace("\\,", ",") curLocation = getLocation(line.substring(LOCATION.length).replace("\\,", ","))
} else if (line == END_ALARM) { } else if (line == END_ALARM) {
if (isProperReminderAction && curReminderTriggerMinutes != -1) { if (isProperReminderAction && curReminderTriggerMinutes != -1) {
curReminderMinutes.add(curReminderTriggerMinutes) curReminderMinutes.add(curReminderTriggerMinutes)
@@ -203,6 +203,14 @@ class IcsImporter(val activity: SimpleActivity) {
} }
} }
private fun getLocation(fullString: String): String {
return if (fullString.startsWith(":")) {
fullString.trimStart(':')
} else {
fullString.substringAfter(':').trim()
}
}
private fun tryAddCategories(categories: String, context: Context) { private fun tryAddCategories(categories: String, context: Context) {
val eventTypeTitle = if (categories.contains(",")) { val eventTypeTitle = if (categories.contains(",")) {
categories.split(",")[0] categories.split(",")[0]