Commit a576701e authored by Ricki Hirner's avatar Ricki Hirner 🐑

Code cleanup (lint)

parent 40bca54c
Pipeline #21256185 failed with stage
in 1 minute and 24 seconds
......@@ -90,8 +90,8 @@ dependencies {
compile 'org.apache.commons:commons-collections4:4.1'
// for tests
androidTestCompile 'com.android.support.test:runner:1.0.1'
androidTestCompile 'com.android.support.test:rules:1.0.1'
androidTestCompile 'com.android.support.test:runner:1.0.2'
androidTestCompile 'com.android.support.test:rules:1.0.2'
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.squareup.okhttp3:mockwebserver:3.10.0'
......
......@@ -9,6 +9,7 @@ package at.bitfire.davdroid
import android.accounts.Account
import android.accounts.AccountManager
import android.annotation.SuppressLint
import android.content.*
import android.os.Build
import android.os.Bundle
......@@ -177,11 +178,11 @@ class AccountSettings(
fun getTimeRangePastDays(): Int? {
val strDays = accountManager.getUserData(account, KEY_TIME_RANGE_PAST_DAYS)
if (strDays != null) {
return if (strDays != null) {
val days = Integer.valueOf(strDays)
return if (days < 0) null else days
if (days < 0) null else days
} else
return DEFAULT_TIME_RANGE_PAST_DAYS
DEFAULT_TIME_RANGE_PAST_DAYS
}
fun setTimeRangePastDays(days: Int?) =
......@@ -290,6 +291,7 @@ class AccountSettings(
}
@Suppress("unused")
@SuppressLint("ParcelClassLoader")
private fun update_5_6() {
context.contentResolver.acquireContentProviderClient(ContactsContract.AUTHORITY)?.let { provider ->
val parcel = Parcel.obtain()
......@@ -497,6 +499,7 @@ class AccountSettings(
}
@Suppress("unused")
@SuppressLint("Recycle")
private fun update_1_2() {
/* - KEY_ADDRESSBOOK_URL ("addressbook_url"),
- KEY_ADDRESSBOOK_CTAG ("addressbook_ctag"),
......
......@@ -33,7 +33,7 @@ object DavUtils {
// the list returned by HttpUrl.pathSegments() is unmodifiable, so we have to create a copy
val segments = LinkedList<String>(httpUrl.pathSegments())
Collections.reverse(segments)
segments.reverse()
return segments.firstOrNull { it.isNotEmpty() } ?: "/"
}
......
......@@ -103,7 +103,7 @@ class LocalAddressBook(
}
override val title = account.name
override val title = account.name!!
/**
* Whether contact groups ([LocalGroup]) are included in query results
......
......@@ -72,14 +72,14 @@ class SharedPreferencesProvider(
Pair(true, true)
private fun<T> putValue(key: String, value: T?, writer: (SharedPreferences.Editor, T) -> Unit): Boolean {
if (value == null)
return remove(key)
return if (value == null)
remove(key)
else {
Logger.log.fine("Writing setting $key = $value")
val edit = preferences.edit()
writer(edit, value)
edit.apply()
return true
true
}
}
......
......@@ -76,7 +76,7 @@ abstract class SyncManager<out ResourceType: LocalResource<*>, out CollectionTyp
account
protected val notificationManager = NotificationManagerCompat.from(context)
protected val notificationTag = Companion.notificationTag(authority, mainAccount)
protected val notificationTag = notificationTag(authority, mainAccount)
/** Local resource we're currently operating on. Used for error notifications. **/
protected val currentLocalResource = LinkedList<LocalResource<*>>()
......
......@@ -640,7 +640,7 @@ class AccountActivity: AppCompatActivity(), Toolbar.OnMenuItemClickListener, Pop
companion object {
val ARG_ACCOUNT = "account"
const val ARG_ACCOUNT = "account"
fun newInstance(account: Account): RenameAccountFragment {
val fragment = RenameAccountFragment()
......
......@@ -219,7 +219,7 @@ class DavResourceFinder(
if (resourceType.types.contains(ResourceType.ADDRESSBOOK)) {
addressBook.location = UrlUtils.withTrailingSlash(addressBook.location)
log.info("Found address book at ${addressBook.location}")
config.collections.put(addressBook.location.uri(), CollectionInfo(addressBook))
config.collections[addressBook.location.uri()] = CollectionInfo(addressBook)
}
}
......@@ -241,7 +241,7 @@ class DavResourceFinder(
if (resourceType.types.contains(ResourceType.CALENDAR)) {
calendar.location = UrlUtils.withTrailingSlash(calendar.location)
log.info("Found calendar at ${calendar.location}")
config.collections.put(calendar.location.uri(), CollectionInfo(calendar))
config.collections[calendar.location.uri()] = CollectionInfo(calendar)
}
}
......@@ -269,7 +269,7 @@ class DavResourceFinder(
return true
} catch(e: Exception) {
log.log(Level.SEVERE, "Couldn't detect services on " + url, e)
log.log(Level.SEVERE, "Couldn't detect services on $url", e)
if (e !is HttpException && e !is DavException)
throw e
}
......
......@@ -107,7 +107,7 @@ class DefaultLoginCredentialsFragment: Fragment(), CompoundButton.OnCheckedChang
valid = false
}
val password = view.email_password.getText().toString()
val password = view.email_password.text.toString()
if (password.isEmpty()) {
view.email_password.error = getString(R.string.login_password_required)
valid = false
......
Subproject commit 1db526617e3ea5d8916d892b3b97ddb30e44d299
Subproject commit a9a47088d173c6e32bd1b759e66073b46463e785
Subproject commit 41c9f1897523989678e82c04ea7a3bc927a1406a
Subproject commit a54f0ac50903b8c469ede99fbf3a631dca7492b6
Subproject commit a0d592c7f0afa4f31ff7088cd4c60de6fc8782d8
Subproject commit 69ec4f527a09b42f995c57aa424f5073739ca897
Subproject commit 4da2606aa5a8095bc1b1a1325b4794af071a7a48
Subproject commit bc7009f64f74def00b04b79c6fb7f63d7232d1ae
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