Commit 5ede9f9c authored by Ricki Hirner's avatar Ricki Hirner 🐑

Update dependencies, lint

parent 5991809c
Pipeline #94425033 canceled with stage
in 21 minutes and 23 seconds
......@@ -12,7 +12,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:3.5.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:${versions.dokka}"
}
......@@ -29,7 +29,7 @@ apply plugin: 'org.jetbrains.dokka-android'
android {
compileSdkVersion 29
buildToolsVersion '29.0.1'
buildToolsVersion '29.0.2'
defaultConfig {
minSdkVersion 19
......
......@@ -55,7 +55,7 @@ abstract class AndroidCalendar<out T: AndroidEvent>(
info.put(Calendars.ALLOWED_AVAILABILITY, "${Events.AVAILABILITY_BUSY},${Events.AVAILABILITY_FREE},${Events.AVAILABILITY_TENTATIVE}")
info.put(Calendars.ALLOWED_ATTENDEE_TYPES, "${Attendees.TYPE_NONE},${Attendees.TYPE_OPTIONAL},${Attendees.TYPE_REQUIRED},${Attendees.TYPE_RESOURCE}")
Constants.log.info("Creating local calendar: " + info.toString())
Constants.log.info("Creating local calendar: $info")
return provider.insert(syncAdapterURI(Calendars.CONTENT_URI, account), info) ?:
throw Exception("Couldn't create calendar: provider returned null")
}
......@@ -69,8 +69,8 @@ abstract class AndroidCalendar<out T: AndroidEvent>(
Constants.log.info("Inserting event colors for account $account")
val values = ContentValues(5)
values.put(CalendarContract.Colors.ACCOUNT_NAME, account.name)
values.put(CalendarContract.Colors.ACCOUNT_TYPE, account.type)
values.put(Colors.ACCOUNT_NAME, account.name)
values.put(Colors.ACCOUNT_TYPE, account.type)
values.put(Colors.COLOR_TYPE, Colors.TYPE_EVENT)
for (color in Css3Color.values()) {
values.put(Colors.COLOR_KEY, color.name)
......@@ -100,8 +100,8 @@ abstract class AndroidCalendar<out T: AndroidEvent>(
}
fun<T: AndroidCalendar<AndroidEvent>> findByID(account: Account, provider: ContentProviderClient, factory: AndroidCalendarFactory<T>, id: Long): T {
val iterCalendars = CalendarContract.CalendarEntity.newEntityIterator(
provider.query(syncAdapterURI(ContentUris.withAppendedId(CalendarContract.CalendarEntity.CONTENT_URI, id), account), null, null, null, null)
val iterCalendars = CalendarEntity.newEntityIterator(
provider.query(syncAdapterURI(ContentUris.withAppendedId(CalendarEntity.CONTENT_URI, id), account), null, null, null, null)
)
try {
if (iterCalendars.hasNext()) {
......@@ -117,8 +117,8 @@ abstract class AndroidCalendar<out T: AndroidEvent>(
}
fun<T: AndroidCalendar<AndroidEvent>> find(account: Account, provider: ContentProviderClient, factory: AndroidCalendarFactory<T>, where: String?, whereArgs: Array<String>?): List<T> {
val iterCalendars = CalendarContract.CalendarEntity.newEntityIterator(
provider.query(syncAdapterURI(CalendarContract.CalendarEntity.CONTENT_URI, account), null, where, whereArgs, null)
val iterCalendars = CalendarEntity.newEntityIterator(
provider.query(syncAdapterURI(CalendarEntity.CONTENT_URI, account), null, where, whereArgs, null)
)
try {
val calendars = LinkedList<T>()
......@@ -137,7 +137,7 @@ abstract class AndroidCalendar<out T: AndroidEvent>(
fun syncAdapterURI(uri: Uri, account: Account) = uri.buildUpon()
.appendQueryParameter(Calendars.ACCOUNT_NAME, account.name)
.appendQueryParameter(Calendars.ACCOUNT_TYPE, account.type)
.appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
.appendQueryParameter(CALLER_IS_SYNCADAPTER, "true")
.build()!!
}
......@@ -188,7 +188,7 @@ abstract class AndroidCalendar<out T: AndroidEvent>(
fun syncAdapterURI(uri: Uri) = uri.buildUpon()
.appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
.appendQueryParameter(CALLER_IS_SYNCADAPTER, "true")
.appendQueryParameter(Calendars.ACCOUNT_NAME, account.name)
.appendQueryParameter(Calendars.ACCOUNT_TYPE, account.type)
.build()!!
......
......@@ -15,7 +15,6 @@ import android.content.ContentValues
import android.content.EntityIterator
import android.net.Uri
import android.os.RemoteException
import android.provider.CalendarContract
import android.provider.CalendarContract.*
import android.util.Base64
import at.bitfire.ical4android.MiscUtils.CursorHelper.toValues
......@@ -99,9 +98,9 @@ abstract class AndroidEvent(
var iterEvents: EntityIterator? = null
try {
iterEvents = CalendarContract.EventsEntity.newEntityIterator(
iterEvents = EventsEntity.newEntityIterator(
calendar.provider.query(
calendar.syncAdapterURI(ContentUris.withAppendedId(CalendarContract.EventsEntity.CONTENT_URI, id)),
calendar.syncAdapterURI(ContentUris.withAppendedId(EventsEntity.CONTENT_URI, id)),
null, null, null, null),
calendar.provider
)
......@@ -116,7 +115,7 @@ abstract class AndroidEvent(
when (subValue.uri) {
Attendees.CONTENT_URI -> populateAttendee(subValue.values)
Reminders.CONTENT_URI -> populateReminder(subValue.values)
CalendarContract.ExtendedProperties.CONTENT_URI -> populateExtended(subValue.values)
ExtendedProperties.CONTENT_URI -> populateExtended(subValue.values)
}
populateExceptions()
......@@ -280,8 +279,7 @@ abstract class AndroidEvent(
params.add(if (type == Attendees.TYPE_RESOURCE) CuType.RESOURCE else CuType.INDIVIDUAL)
// role
val relationship = row.getAsInteger(Attendees.ATTENDEE_RELATIONSHIP)
when (relationship) {
when (row.getAsInteger(Attendees.ATTENDEE_RELATIONSHIP)) {
Attendees.RELATIONSHIP_ORGANIZER,
Attendees.RELATIONSHIP_ATTENDEE,
Attendees.RELATIONSHIP_PERFORMER,
......@@ -685,8 +683,7 @@ abstract class AndroidEvent(
builder.withValue(Attendees.ATTENDEE_RELATIONSHIP, relationship)
}
val partStat = attendee.getParameter(Parameter.PARTSTAT) as? PartStat
val status = when(partStat) {
val status = when(attendee.getParameter(Parameter.PARTSTAT) as? PartStat) {
null,
PartStat.NEEDS_ACTION -> Attendees.ATTENDEE_STATUS_INVITED
PartStat.ACCEPTED -> Attendees.ATTENDEE_STATUS_ACCEPTED
......
......@@ -179,8 +179,7 @@ abstract class AndroidTask(
protected open fun populateProperty(values: ContentValues) {
val task = requireNotNull(task)
val type = values.getAsString(Properties.MIMETYPE)
when (type) {
when (val type = values.getAsString(Properties.MIMETYPE)) {
Category.CONTENT_ITEM_TYPE ->
task.categories += values.getAsString(Category.CATEGORY_NAME)
else ->
......@@ -327,7 +326,7 @@ abstract class AndroidTask(
fun getTimeZone(): TimeZone {
val task = requireNotNull(task)
var tz: java.util.TimeZone? = null
var tz: TimeZone? = null
task.dtStart?.timeZone?.let { tz = it }
tz = tz ?: task.due?.timeZone
......
......@@ -59,7 +59,7 @@ abstract class AndroidTaskList<out T: AndroidTask>(
info.put(TaskContract.ACCOUNT_TYPE, account.type)
info.put(TaskLists.ACCESS_LEVEL, 0)
Constants.log.info("Creating local task list: " + info.toString())
Constants.log.info("Creating local task list: $info")
return provider.client.insert(TaskProvider.syncAdapterUri(provider.taskListsUri(), account), info) ?:
throw CalendarStorageException("Couldn't create task list (empty result from provider)")
}
......
......@@ -12,7 +12,7 @@ import java.util.logging.Logger
object Constants {
val log = Logger.getLogger("ical4android")!!
val log = Logger.getLogger("ical4android")
const val ical4jVersion = BuildConfig.version_ical4j
......
......@@ -8,6 +8,8 @@
package at.bitfire.ical4android
import kotlin.math.sqrt
/**
* Represents an RGBA COLOR value, as specified in https://tools.ietf.org/html/rfc7986#section-5.9
*
......@@ -175,7 +177,7 @@ enum class Css3Color(val argb: Int) {
*/
fun fromString(name: String) =
try {
Css3Color.valueOf(name)
valueOf(name)
} catch (e: IllegalArgumentException) {
Constants.log.warning("Unknown color: $name")
null
......@@ -199,7 +201,7 @@ enum class Css3Color(val argb: Int) {
val deltaB = (rgb and 0xFF) - (cssColor and 0xFF)
val deltaR2 = deltaR*deltaR
val deltaG2 = deltaG*deltaG
Math.sqrt(2.0*deltaR2 + 4.0*deltaG2 + 3.0*deltaB*deltaB + (r*(deltaR2 - deltaG2))/256.0)
sqrt(2.0*deltaR2 + 4.0*deltaG2 + 3.0*deltaB*deltaB + (r*(deltaR2 - deltaG2))/256.0)
}
val idx = distance.withIndex().minBy { it.value }!!.index
return values()[idx]
......
......@@ -92,7 +92,7 @@ open class ICalendar {
}
// remove TZURL
tz.properties.filter { it is TzUrl }.forEach {
tz.properties.filterIsInstance<TzUrl>().forEach {
tz.properties.remove(it)
}
}
......
......@@ -49,7 +49,7 @@ class TaskProvider private constructor(
* @throws [ProviderTooOldException] if the tasks provider is installed, but doesn't meet the minimum version requirement
*/
@SuppressLint("Recycle")
fun acquire(context: Context, name: TaskProvider.ProviderName): TaskProvider? {
fun acquire(context: Context, name: ProviderName): TaskProvider? {
return try {
checkVersion(context, name)
......
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