Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit f1969808 authored by Ricki Hirner's avatar Ricki Hirner
Browse files

Better logging for creating/updating/deleting collections

parent d92808f0
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ abstract class AndroidCalendar<out T: AndroidEvent>(

            info.putAll(calendarBaseValues)

            Ical4Android.log.info("Creating local calendar: $info")
            Ical4Android.log.log(Level.FINE, "Creating local calendar", info)
            return provider.insert(Calendars.CONTENT_URI.asSyncAdapter(account), info) ?:
                    throw Exception("Couldn't create calendar: provider returned null")
        }
@@ -168,9 +168,15 @@ abstract class AndroidCalendar<out T: AndroidEvent>(
    }


    fun update(info: ContentValues) = provider.update(calendarSyncURI(), info, null, null)
    fun update(info: ContentValues): Int {
        Ical4Android.log.log(Level.FINE, "Updating local calendar (#$id)", info)
        return provider.update(calendarSyncURI(), info, null, null)
    }

    fun delete() = provider.delete(calendarSyncURI(), null, null)
    fun delete(): Int {
        Ical4Android.log.log(Level.FINE, "Deleting local calendar (#$id)")
        return provider.delete(calendarSyncURI(), null, null)
    }


    /**
+11 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ import org.dmfs.tasks.contract.TaskContract.TaskLists
import org.dmfs.tasks.contract.TaskContract.Tasks
import java.io.FileNotFoundException
import java.util.*
import java.util.logging.Level


/**
@@ -36,7 +37,7 @@ abstract class AndroidTaskList<out T : AndroidTask>(
            info.put(TaskContract.ACCOUNT_NAME, account.name)
            info.put(TaskContract.ACCOUNT_TYPE, account.type)

            Ical4Android.log.info("Creating local task list: $info")
            Ical4Android.log.log(Level.FINE, "Creating ${provider.name.authority} task list", info)
            return provider.client.insert(provider.taskListsUri().asSyncAdapter(account), info)
                ?: throw CalendarStorageException("Couldn't create task list (empty result from provider)")
        }
@@ -106,8 +107,15 @@ abstract class AndroidTaskList<out T : AndroidTask>(
        values.getAsInteger(TaskLists.VISIBLE)?.let { isVisible = it != 0 }
    }

    fun update(info: ContentValues) = provider.client.update(taskListSyncUri(), info, null, null)
    fun delete() = provider.client.delete(taskListSyncUri(), null, null)
    fun update(info: ContentValues): Int {
        Ical4Android.log.log(Level.FINE, "Updating ${provider.name.authority} task list (#$id)", info)
        return provider.client.update(taskListSyncUri(), info, null, null)
    }

    fun delete(): Int {
        Ical4Android.log.log(Level.FINE, "Deleting ${provider.name.authority} task list (#$id)")
        return provider.client.delete(taskListSyncUri(), null, null)
    }

    /**
     * When tasks are added or updated, they may refer to related tasks by UID ([Relation.RELATED_UID]).
+8 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ import net.fortuna.ical4j.model.component.VJournal
import net.fortuna.ical4j.model.component.VToDo
import net.fortuna.ical4j.model.property.Version
import java.util.*
import java.util.logging.Level

open class JtxCollection<out T: JtxICalObject>(val account: Account,
                                               val client: ContentProviderClient,
@@ -26,8 +27,11 @@ open class JtxCollection<out T: JtxICalObject>(val account: Account,

    companion object {

        fun create(account: Account, client: ContentProviderClient, values: ContentValues): Uri =
            client.insert(JtxContract.JtxCollection.CONTENT_URI.asSyncAdapter(account), values)?: throw CalendarStorageException("Couldn't create JTX Collection")
        fun create(account: Account, client: ContentProviderClient, values: ContentValues): Uri {
            Ical4Android.log.log(Level.FINE, "Creating jtx Board collection", values)
            return client.insert(JtxContract.JtxCollection.CONTENT_URI.asSyncAdapter(account), values)
                ?: throw CalendarStorageException("Couldn't create JTX Collection")
        }

        fun<T: JtxCollection<JtxICalObject>> find(account: Account, client: ContentProviderClient, context: Context, factory: JtxCollectionFactory<T>, where: String?, whereArgs: Array<String>?): List<T> {
            val collections = LinkedList<T>()
@@ -56,10 +60,12 @@ open class JtxCollection<out T: JtxICalObject>(val account: Account,


    fun delete() {
        Ical4Android.log.log(Level.FINE, "Deleting jtx Board collection (#$id)")
        client.delete(ContentUris.withAppendedId(JtxContract.JtxCollection.CONTENT_URI.asSyncAdapter(account), id), null, null)
    }

    fun update(values: ContentValues) {
        Ical4Android.log.log(Level.FINE, "Updating jtx Board collection (#$id)", values)
        client.update(ContentUris.withAppendedId(JtxContract.JtxCollection.CONTENT_URI.asSyncAdapter(account), id), values, null, null)
    }

+3 −2
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ class TaskProvider private constructor(
            get() = arrayOf(readPermission, writePermission)
    }


    companion object {

        val TASK_PROVIDERS = listOf(