mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
properly handle all really long lines at importing, not just at the description
This commit is contained in:
@@ -64,7 +64,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:5.33.26'
|
implementation 'com.simplemobiletools:commons:5.33.28'
|
||||||
implementation 'joda-time:joda-time:2.10.1'
|
implementation 'joda-time:joda-time:2.10.1'
|
||||||
implementation 'androidx.multidex:multidex:2.0.1'
|
implementation 'androidx.multidex:multidex:2.0.1'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||||
|
@@ -38,7 +38,6 @@ class IcsImporter(val activity: SimpleActivity) {
|
|||||||
private var curCategoryColor = -2
|
private var curCategoryColor = -2
|
||||||
private var isNotificationDescription = false
|
private var isNotificationDescription = false
|
||||||
private var isProperReminderAction = false
|
private var isProperReminderAction = false
|
||||||
private var isDescription = false
|
|
||||||
private var isSequence = false
|
private var isSequence = false
|
||||||
private var isParsingEvent = false
|
private var isParsingEvent = false
|
||||||
private var curReminderTriggerMinutes = REMINDER_OFF
|
private var curReminderTriggerMinutes = REMINDER_OFF
|
||||||
@@ -54,7 +53,7 @@ class IcsImporter(val activity: SimpleActivity) {
|
|||||||
val eventTypes = eventsHelper.getEventTypesSync()
|
val eventTypes = eventsHelper.getEventTypesSync()
|
||||||
val existingEvents = activity.eventsDB.getEventsWithImportIds().toMutableList() as ArrayList<Event>
|
val existingEvents = activity.eventsDB.getEventsWithImportIds().toMutableList() as ArrayList<Event>
|
||||||
val eventsToInsert = ArrayList<Event>()
|
val eventsToInsert = ArrayList<Event>()
|
||||||
var prevLine = ""
|
var line = ""
|
||||||
|
|
||||||
val inputStream = if (path.contains("/")) {
|
val inputStream = if (path.contains("/")) {
|
||||||
File(path).inputStream()
|
File(path).inputStream()
|
||||||
@@ -64,22 +63,14 @@ class IcsImporter(val activity: SimpleActivity) {
|
|||||||
|
|
||||||
inputStream.bufferedReader().use {
|
inputStream.bufferedReader().use {
|
||||||
while (true) {
|
while (true) {
|
||||||
var line = it.readLine() ?: break
|
val curLine = it.readLine() ?: break
|
||||||
if (line.trim().isEmpty()) {
|
if (curLine.trim().isEmpty()) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.substring(0, 1) == " ") {
|
if (curLine.startsWith("\t") || curLine.substring(0, 1) == " ") {
|
||||||
line = prevLine + line.trim()
|
line += curLine.removePrefix("\t").removePrefix(" ")
|
||||||
eventsFailed--
|
continue
|
||||||
}
|
|
||||||
|
|
||||||
if (isDescription) {
|
|
||||||
if (line.startsWith('\t')) {
|
|
||||||
curDescription += line.trimStart('\t').replace("\\n", "\n")
|
|
||||||
} else {
|
|
||||||
isDescription = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line == BEGIN_EVENT) {
|
if (line == BEGIN_EVENT) {
|
||||||
@@ -107,7 +98,6 @@ class IcsImporter(val activity: SimpleActivity) {
|
|||||||
if (curDescription.trim().isEmpty()) {
|
if (curDescription.trim().isEmpty()) {
|
||||||
curDescription = ""
|
curDescription = ""
|
||||||
}
|
}
|
||||||
isDescription = true
|
|
||||||
} else if (line.startsWith(UID)) {
|
} else if (line.startsWith(UID)) {
|
||||||
curImportId = line.substring(UID.length).trim()
|
curImportId = line.substring(UID.length).trim()
|
||||||
} else if (line.startsWith(RRULE)) {
|
} else if (line.startsWith(RRULE)) {
|
||||||
@@ -226,7 +216,7 @@ class IcsImporter(val activity: SimpleActivity) {
|
|||||||
eventsImported++
|
eventsImported++
|
||||||
resetValues()
|
resetValues()
|
||||||
}
|
}
|
||||||
prevLine = line
|
line = curLine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user