Commit 3a4e2163 authored by Ricki Hirner's avatar Ricki Hirner

Minor cleanup (lint)

parent a0d592c7
...@@ -66,8 +66,8 @@ dependencies { ...@@ -66,8 +66,8 @@ dependencies {
compile "org.mnode.ical4j:ical4j:$ical4j_version" compile "org.mnode.ical4j:ical4j:$ical4j_version"
compile 'org.slf4j:slf4j-jdk14:1.7.25' compile 'org.slf4j:slf4j-jdk14:1.7.25'
androidTestCompile 'com.android.support.test:runner:1.0.1' androidTestCompile 'com.android.support.test:runner:1.0.2'
androidTestCompile 'com.android.support.test:rules:1.0.1' androidTestCompile 'com.android.support.test:rules:1.0.2'
testCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12'
} }
...@@ -72,7 +72,7 @@ class MiscUtilsTest { ...@@ -72,7 +72,7 @@ class MiscUtilsTest {
assertEquals(TimeZones.UTC_ID, MiscUtils.getTzId(DtStart(DateTime(1438607288000L)))) assertEquals(TimeZones.UTC_ID, MiscUtils.getTzId(DtStart(DateTime(1438607288000L))))
// DATE-TIME with time zone // DATE-TIME with time zone
assertEquals(tzVienna.getID(), MiscUtils.getTzId(DtStart(DateTime("20150101T000000", tzVienna)))) assertEquals(tzVienna.id, MiscUtils.getTzId(DtStart(DateTime("20150101T000000", tzVienna))))
} }
@Test @Test
......
...@@ -25,7 +25,7 @@ class TestCalendar( ...@@ -25,7 +25,7 @@ class TestCalendar(
companion object { companion object {
fun findOrCreate(account: Account, provider: ContentProviderClient): TestCalendar { fun findOrCreate(account: Account, provider: ContentProviderClient): TestCalendar {
val calendars = AndroidCalendar.find(account, provider, Factory, null, null) val calendars = AndroidCalendar.find(account, provider, Factory, null, null)
if (calendars.isEmpty()) { return if (calendars.isEmpty()) {
val values = ContentValues(3) val values = ContentValues(3)
values.put(CalendarContract.Calendars.NAME, "TestCalendar") values.put(CalendarContract.Calendars.NAME, "TestCalendar")
values.put(CalendarContract.Calendars.CALENDAR_DISPLAY_NAME, "ical4android Test Calendar") values.put(CalendarContract.Calendars.CALENDAR_DISPLAY_NAME, "ical4android Test Calendar")
...@@ -33,9 +33,9 @@ class TestCalendar( ...@@ -33,9 +33,9 @@ class TestCalendar(
CalendarContract.Reminders.METHOD_DEFAULT) CalendarContract.Reminders.METHOD_DEFAULT)
val uri = AndroidCalendar.create(account, provider, values) val uri = AndroidCalendar.create(account, provider, values)
return TestCalendar(account, provider, ContentUris.parseId(uri)) TestCalendar(account, provider, ContentUris.parseId(uri))
} else } else
return calendars.first() calendars.first()
} }
} }
......
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
package at.bitfire.ical4android.impl package at.bitfire.ical4android.impl
import android.content.ContentValues; import android.content.ContentValues
import at.bitfire.ical4android.AndroidTask; import at.bitfire.ical4android.AndroidTask
import at.bitfire.ical4android.AndroidTaskFactory; import at.bitfire.ical4android.AndroidTaskFactory
import at.bitfire.ical4android.AndroidTaskList; import at.bitfire.ical4android.AndroidTaskList
import at.bitfire.ical4android.Task; import at.bitfire.ical4android.Task
class TestTask: AndroidTask { class TestTask: AndroidTask {
......
...@@ -578,11 +578,11 @@ abstract class AndroidEvent( ...@@ -578,11 +578,11 @@ abstract class AndroidEvent(
event.organizer?.let { organizer -> event.organizer?.let { organizer ->
val email: String? val email: String?
val uri = organizer.calAddress val uri = organizer.calAddress
if (uri.scheme.equals("mailto", true)) email = if (uri.scheme.equals("mailto", true))
email = uri.schemeSpecificPart uri.schemeSpecificPart
else { else {
val emailParam = organizer.getParameter(ICalendar.Email.PARAMETER_NAME) as ICalendar.Email? val emailParam = organizer.getParameter(ICalendar.Email.PARAMETER_NAME) as ICalendar.Email?
email = emailParam?.value emailParam?.value
} }
if (email != null) if (email != null)
builder.withValue(Events.ORGANIZER, email) builder.withValue(Events.ORGANIZER, email)
......
...@@ -35,7 +35,7 @@ abstract class AndroidTaskList<out T: AndroidTask>( ...@@ -35,7 +35,7 @@ abstract class AndroidTaskList<out T: AndroidTask>(
companion object { companion object {
/** /**
* Acquires a [ContentProviderClient] for a supported task provider. If multiple providers are * Acquires a [android.content.ContentProviderClient] for a supported task provider. If multiple providers are
* available, a pre-defined priority list is taken into account. * available, a pre-defined priority list is taken into account.
* @return A [TaskProvider], or null if task storage is not available/accessible. * @return A [TaskProvider], or null if task storage is not available/accessible.
* Caller is responsible for calling release()! * Caller is responsible for calling release()!
......
...@@ -67,7 +67,7 @@ class BatchOperation( ...@@ -67,7 +67,7 @@ class BatchOperation(
try { try {
val ops = toCPO(start, end) val ops = toCPO(start, end)
Constants.log.fine("Running {${ops.size}} operations ($start .. ${end-1})") Constants.log.fine("Running ${ops.size} operations ($start .. ${end-1})")
val partResults = providerClient.applyBatch(ops) val partResults = providerClient.applyBatch(ops)
val n = end - start val n = end - start
......
...@@ -113,14 +113,14 @@ class Event: ICalendar() { ...@@ -113,14 +113,14 @@ class Event: ICalendar() {
// If the SEQUENCE is identical, use latest version. // If the SEQUENCE is identical, use latest version.
val event = masterEvents[uid] val event = masterEvents[uid]
if (event == null || (event.sequence != null && sequence >= event.sequence.sequenceNo)) if (event == null || (event.sequence != null && sequence >= event.sequence.sequenceNo))
masterEvents.put(uid, vEvent) masterEvents[uid] = vEvent
} else { } else {
// exception (RECURRENCE-ID) // exception (RECURRENCE-ID)
var ex = exceptions[uid] var ex = exceptions[uid]
// first index level: UID // first index level: UID
if (ex == null) { if (ex == null) {
ex = mutableMapOf<String,VEvent>() ex = mutableMapOf()
exceptions[uid] = ex exceptions[uid] = ex
} }
// second index level: RECURRENCE-ID // second index level: RECURRENCE-ID
......
...@@ -11,6 +11,7 @@ package at.bitfire.ical4android ...@@ -11,6 +11,7 @@ package at.bitfire.ical4android
/** /**
* Represents an RGBA COLOR value, as specified in https://tools.ietf.org/html/rfc7986#section-5.9 * Represents an RGBA COLOR value, as specified in https://tools.ietf.org/html/rfc7986#section-5.9
*/ */
@Suppress("EnumEntryName")
enum class EventColor(val rgba: Int) { enum class EventColor(val rgba: Int) {
// values taken from https://www.w3.org/TR/2011/REC-css3-color-20110607/#svg-color // values taken from https://www.w3.org/TR/2011/REC-css3-color-20110607/#svg-color
aliceblue(0xfff0f8ff.toInt()), aliceblue(0xfff0f8ff.toInt()),
......
...@@ -190,8 +190,8 @@ class Task: ICalendar() { ...@@ -190,8 +190,8 @@ class Task: ICalendar() {
fun isAllDay(): Boolean { fun isAllDay(): Boolean {
val dtStart = dtStart val dtStart = dtStart
val due = due val due = due
return (dtStart != null && !(dtStart.date is DateTime)) || return (dtStart != null && dtStart.date !is DateTime) ||
(due != null && !(due.date is DateTime)) (due != null && due.date !is DateTime)
} }
} }
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
package at.bitfire.ical4android package at.bitfire.ical4android
import android.accounts.Account import android.accounts.Account
import android.annotation.SuppressLint
import android.content.ContentProviderClient import android.content.ContentProviderClient
import android.content.Context import android.content.Context
import android.content.pm.PackageManager import android.content.pm.PackageManager
...@@ -40,12 +41,13 @@ class TaskProvider private constructor( ...@@ -40,12 +41,13 @@ class TaskProvider private constructor(
/** /**
* Acquires a content provider for a given task provider. The content provider will * Acquires a content provider for a given task provider. The content provider will
* be released when the TaskProvider is closed. * be released when the TaskProvider is closed with [close].
* @param context will be used to acquire the content provider client * @param context will be used to acquire the content provider client
* @param name task provider to acquire content provider for * @param name task provider to acquire content provider for
* @return content provider for the given task provider (may be {@code null}) * @return content provider for the given task provider (may be {@code null})
* @throws [ProviderTooOldException] if the tasks provider is installed, but doesn't meet the minimum version requirement * @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: TaskProvider.ProviderName): TaskProvider? {
return try { return try {
checkVersion(context, name) checkVersion(context, name)
......
...@@ -68,25 +68,25 @@ class DateUtilsTest { ...@@ -68,25 +68,25 @@ class DateUtilsTest {
assertEquals(Value.DATE_TIME, exDates.type) assertEquals(Value.DATE_TIME, exDates.type)
assertTrue(exDates.isUtc) assertTrue(exDates.isUtc)
assertEquals(2, exDates.size) assertEquals(2, exDates.size)
assertEquals(1420108210000L, exDates.get(0).time) assertEquals(1420108210000L, exDates[0].time)
assertEquals(1435833020000L, exDates.get(1).time) assertEquals(1435833020000L, exDates[1].time)
// list of time zone times // list of time zone times
exDate = DateUtils.androidStringToRecurrenceSet(tzIdToronto + ";20150103T113030,20150704T113040", ExDate::class.java, false) exDate = DateUtils.androidStringToRecurrenceSet("$tzIdToronto;20150103T113030,20150704T113040", ExDate::class.java, false)
exDates = exDate.dates exDates = exDate.dates
assertEquals(Value.DATE_TIME, exDates.type) assertEquals(Value.DATE_TIME, exDates.type)
assertEquals(DateUtils.tzRegistry.getTimeZone(tzIdToronto), exDates.timeZone) assertEquals(DateUtils.tzRegistry.getTimeZone(tzIdToronto), exDates.timeZone)
assertEquals(2, exDates.size) assertEquals(2, exDates.size)
assertEquals(1420302630000L, exDates.get(0).time) assertEquals(1420302630000L, exDates[0].time)
assertEquals(1436023840000L, exDates.get(1).time) assertEquals(1436023840000L, exDates[1].time)
// list of dates // list of dates
exDate = DateUtils.androidStringToRecurrenceSet("20150101T103010Z,20150702T103020Z", ExDate::class.java, true) exDate = DateUtils.androidStringToRecurrenceSet("20150101T103010Z,20150702T103020Z", ExDate::class.java, true)
exDates = exDate.dates exDates = exDate.dates
assertEquals(Value.DATE, exDates.type) assertEquals(Value.DATE, exDates.type)
assertEquals(2, exDates.size) assertEquals(2, exDates.size)
assertEquals("20150101", exDates.get(0).toString()) assertEquals("20150101", exDates[0].toString())
assertEquals("20150702", exDates.get(1).toString()) assertEquals("20150702", exDates[1].toString())
} }
} }
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