Commit 93307b64 authored by Ricki Hirner's avatar Ricki Hirner

Minor refactoring; Kotlin update

parent a3fd1ac9
Pipeline #17845491 failed with stages
in 6 minutes 3 seconds
......@@ -14,6 +14,20 @@ to your needs.
Generated KDoc: https://bitfireAT.gitlab.io/dav4android/dokka/dav4android/
## Contact
```
bitfire web engineering – Stockmann, Hirner GesnbR
Florastraße 27
2540 Bad Vöslau, AUSTRIA
```
Email: [play@bitfire.at](mailto:play@bitfire.at) (do not use this)
For questions, suggestions etc. please use the DAVdroid forum:
https://www.davdroid.com/forums/
## License
Copyright (C) bitfire web engineering (Ricki Hirner, Bernhard Stockmann).
......
buildscript {
ext.kotlin_version = '1.2.10'
ext.kotlin_version = '1.2.21'
ext.dokka_version = '0.9.15'
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
google()
}
dependencies {
......@@ -19,9 +17,7 @@ buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
google()
}
apply plugin: 'com.android.library'
......@@ -59,7 +55,6 @@ dependencies {
compile 'com.squareup.okhttp3:okhttp:3.9.1'
androidTestCompile 'com.squareup.okhttp3:mockwebserver:3.9.1'
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test:runner:1.0.1'
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
......
......@@ -68,8 +68,7 @@ class DavAddressBook @JvmOverloads constructor(
checkStatus(response, false)
assertMultiStatus(response)
members.clear()
related.clear()
resetMembers()
response.body()?.charStream()?.use { processMultiStatus(it) }
}
......@@ -122,8 +121,7 @@ class DavAddressBook @JvmOverloads constructor(
checkStatus(response, false)
assertMultiStatus(response)
members.clear()
related.clear()
resetMembers()
response.body()?.charStream()?.use { processMultiStatus(it) }
}
......
......@@ -25,7 +25,8 @@ class DavCalendar @JvmOverloads constructor(
companion object {
@JvmField
val MIME_ICALENDAR = MediaType.parse("text/calendar;charset=utf-8")
val MIME_ICALENDAR = MediaType.parse("text/calendar")
val MIME_ICALENDAR_UTF8 = MediaType.parse("text/calendar;charset=utf-8")
}
private val timeFormatUTC = SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'", Locale.US)
......@@ -89,8 +90,7 @@ class DavCalendar @JvmOverloads constructor(
checkStatus(response, false)
assertMultiStatus(response)
members.clear()
related.clear()
resetMembers()
response.body()?.charStream()?.use { processMultiStatus(it) }
}
......@@ -137,8 +137,7 @@ class DavCalendar @JvmOverloads constructor(
checkStatus(response, false)
assertMultiStatus(response)
members.clear()
related.clear()
resetMembers()
response.body()?.charStream()?.use { processMultiStatus(it) }
}
......
......@@ -22,7 +22,7 @@ open class DavCollection(
log: Logger = Constants.log
): DavResource(httpClient, location, log) {
/**
/**
* Sends a REPORT sync-collection request. If a sync-token is returned, it will be made
* available in [properties].
*
......@@ -79,8 +79,7 @@ open class DavCollection(
checkStatus(response, false)
assertMultiStatus(response)
members.clear()
related.clear()
resetMembers()
response.body()?.charStream()?.use { processMultiStatus(it) }
}
......
......@@ -39,7 +39,7 @@ open class DavResource @JvmOverloads constructor(
) {
companion object {
val MAX_REDIRECTS = 5
const val MAX_REDIRECTS = 5
val MIME_XML = MediaType.parse("application/xml; charset=utf-8")
}
......@@ -283,11 +283,9 @@ open class DavResource @JvmOverloads constructor(
checkStatus(response!!, false)
assertMultiStatus(response)
if (depth > 0) {
if (depth > 0)
// collection listing requested, drop old member information
members.clear()
related.clear()
}
resetMembers()
// process and close multi-status response body
response.body()?.charStream()?.use { processMultiStatus(it) }
......@@ -656,4 +654,10 @@ open class DavResource @JvmOverloads constructor(
return Collections.unmodifiableList(result)
}
protected fun resetMembers() {
members.clear()
removedMembers.clear()
related.clear()
}
}
......@@ -120,10 +120,10 @@ object HttpUtils {
class AuthScheme(
val name: String
) {
val nameValue = Pattern.compile("^([^=]+)=(.*)$")!!
private val nameValue = Pattern.compile("^([^=]+)=(.*)$")!!
/** Map (name -> value) authentication parameters. Names are always lower-case. */
val params = HashMap<String, String>()
val params = mutableMapOf<String, String>()
val unnamedParams = LinkedList<String>()
fun addRawParam(authParam: String) {
......@@ -133,7 +133,7 @@ object HttpUtils {
var value = m.group(2)
val len = value.length
if (value[0] == '"' && value[len - 1] == '"')
// quoted-string
// quoted-string
value = value
.substring(1, len - 1)
.replace("\\\"", "\"")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment