Convert GoogleTaskList to CaldavCalendar

pull/2146/head
Alex Baker 2 years ago
parent a04fbebd0f
commit 513f8b017f

@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 88,
"identityHash": "e6a358a252e68fc5fe426504801c1d0c",
"identityHash": "d9d2cc4048325dbde272d8d4f8e3880f",
"entities": [
{
"tableName": "notification",
@ -899,71 +899,9 @@
"indices": [],
"foreignKeys": []
},
{
"tableName": "google_task_lists",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`gtl_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `gtl_account` TEXT, `gtl_remote_id` TEXT, `gtl_title` TEXT, `gtl_remote_order` INTEGER NOT NULL, `gtl_last_sync` INTEGER NOT NULL, `gtl_color` INTEGER, `gtl_icon` INTEGER)",
"fields": [
{
"fieldPath": "id",
"columnName": "gtl_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "account",
"columnName": "gtl_account",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "remoteId",
"columnName": "gtl_remote_id",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "title",
"columnName": "gtl_title",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "order",
"columnName": "gtl_remote_order",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "lastSync",
"columnName": "gtl_last_sync",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "color",
"columnName": "gtl_color",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "icon",
"columnName": "gtl_icon",
"affinity": "INTEGER",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"gtl_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "caldav_lists",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`cdl_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `cdl_account` TEXT, `cdl_uuid` TEXT, `cdl_name` TEXT, `cdl_color` INTEGER NOT NULL, `cdl_ctag` TEXT, `cdl_url` TEXT, `cdl_icon` INTEGER, `cdl_order` INTEGER NOT NULL, `cdl_access` INTEGER NOT NULL)",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`cdl_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `cdl_account` TEXT, `cdl_uuid` TEXT, `cdl_name` TEXT, `cdl_color` INTEGER NOT NULL, `cdl_ctag` TEXT, `cdl_url` TEXT, `cdl_icon` INTEGER, `cdl_order` INTEGER NOT NULL, `cdl_access` INTEGER NOT NULL, `cdl_last_sync` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
@ -1024,6 +962,12 @@
"columnName": "cdl_access",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "lastSync",
"columnName": "cdl_last_sync",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
@ -1453,7 +1397,7 @@
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'e6a358a252e68fc5fe426504801c1d0c')"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'd9d2cc4048325dbde272d8d4f8e3880f')"
]
}
}

@ -79,7 +79,7 @@ class GtasksListServiceTest : InjectingTestCase() {
setLists(
newRemoteList(
with(RemoteGtaskListMaker.REMOTE_ID, "1"), with(RemoteGtaskListMaker.NAME, "newName")))
assertEquals("newName", googleTaskListDao.getById(1)!!.title)
assertEquals("newName", googleTaskListDao.getById(1)!!.name)
}
@Test

@ -101,7 +101,7 @@ class ManualGoogleTaskQueryTest : InjectingTestCase() {
private suspend fun newTask(id: Long, order: Long, parent: Long = 0) {
taskDao.insert(TaskMaker.newTask(with(ID, id), with(UUID, UUIDHelper.newUUID())))
googleTaskDao.insert(newGoogleTask(with(LIST, filter.list.remoteId), with(TASK, id), with(PARENT, parent), with(ORDER, order)))
googleTaskDao.insert(newGoogleTask(with(LIST, filter.list.uuid), with(TASK, id), with(PARENT, parent), with(ORDER, order)))
}
private suspend fun query(): List<TaskContainer> = taskDao.fetchTasks {

@ -2,19 +2,23 @@ package com.todoroo.astrid.api;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.NonNull;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Join;
import com.todoroo.andlib.sql.QueryTemplate;
import com.todoroo.astrid.data.Task;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.tasks.R;
import org.tasks.data.CaldavCalendar;
import org.tasks.data.GoogleTask;
import org.tasks.data.GoogleTaskList;
import org.tasks.data.TaskDao;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
public class GtasksFilter extends Filter {
/** Parcelable Creator Object */
@ -36,14 +40,14 @@ public class GtasksFilter extends Filter {
}
};
private GoogleTaskList list;
private CaldavCalendar list;
private GtasksFilter() {
super();
}
public GtasksFilter(GoogleTaskList list) {
super(list.getTitle(), getQueryTemplate(list), getValuesForNewTasks(list));
public GtasksFilter(CaldavCalendar list) {
super(list.getName(), getQueryTemplate(list), getValuesForNewTasks(list));
this.list = list;
id = list.getId();
tint = list.getColor();
@ -51,19 +55,19 @@ public class GtasksFilter extends Filter {
order = list.getOrder();
}
private static QueryTemplate getQueryTemplate(GoogleTaskList list) {
private static QueryTemplate getQueryTemplate(CaldavCalendar list) {
return new QueryTemplate()
.join(Join.left(GoogleTask.TABLE, Task.ID.eq(GoogleTask.TASK)))
.where(
Criterion.and(
TaskDao.TaskCriteria.activeAndVisible(),
GoogleTask.DELETED.eq(0),
GoogleTask.LIST.eq(list.getRemoteId())));
GoogleTask.LIST.eq(list.getUuid())));
}
private static Map<String, Object> getValuesForNewTasks(GoogleTaskList list) {
private static Map<String, Object> getValuesForNewTasks(CaldavCalendar list) {
Map<String, Object> values = new HashMap<>();
values.put(GoogleTask.KEY, list.getRemoteId());
values.put(GoogleTask.KEY, list.getUuid());
return values;
}
@ -75,7 +79,7 @@ public class GtasksFilter extends Filter {
return list.getAccount();
}
public GoogleTaskList getList() {
public CaldavCalendar getList() {
return list;
}
@ -98,7 +102,7 @@ public class GtasksFilter extends Filter {
}
public String getRemoteId() {
return list.getRemoteId();
return list.getUuid();
}
@Override

@ -64,8 +64,8 @@ class SearchFilter : Filter {
Task.ID.`in`(
Query.select(GoogleTask.TASK)
.from(GoogleTask.TABLE)
.join(Join.inner(GoogleTaskList.TABLE, GoogleTaskList.REMOTE_ID.eq(GoogleTask.LIST)))
.where(GoogleTaskList.NAME.like(matcher)))
.join(Join.inner(CaldavCalendar.TABLE, CaldavCalendar.UUID.eq(GoogleTask.LIST)))
.where(CaldavCalendar.NAME.like(matcher)))
)))
}
}

@ -118,10 +118,10 @@ class BuiltInFilterExposer @Inject constructor(
QueryTemplate()
.join(Join.left(GoogleTask.TABLE, GoogleTask.TASK.eq(Task.ID)))
.join(Join.left(CaldavTask.TABLE, CaldavTask.TASK.eq(Task.ID)))
.join(Join.left(GoogleTaskList.TABLE, GoogleTaskList.REMOTE_ID.eq(GoogleTask.LIST)))
.join(Join.left(CaldavCalendar.TABLE.`as`("google_task_lists"), CaldavCalendar.TABLE.`as`("google_task_lists").column("cdl_uuid").eq(GoogleTask.LIST)))
.join(Join.left(CaldavCalendar.TABLE, CaldavCalendar.UUID.eq(CaldavTask.CALENDAR)))
.where(or(
and(GoogleTask.ID.gt(0), GoogleTaskList.REMOTE_ID.eq(null)),
and(GoogleTask.ID.gt(0), CaldavCalendar.TABLE.`as`("google_task_lists").column("cdl_uuid").eq(null)),
and(CaldavTask.ID.gt(0), CaldavCalendar.UUID.eq(null))))
).apply {
icon = R.drawable.ic_outline_cloud_off_24px
@ -133,11 +133,11 @@ class BuiltInFilterExposer @Inject constructor(
QueryTemplate()
.join(Join.left(GoogleTask.TABLE, and(GoogleTask.TASK.eq(Task.ID))))
.join(Join.left(CaldavTask.TABLE, and(CaldavTask.TASK.eq(Task.ID))))
.join(Join.left(GoogleTaskList.TABLE, GoogleTaskList.REMOTE_ID.eq(GoogleTask.LIST)))
.join(Join.left(CaldavCalendar.TABLE.`as`("google_task_lists"), CaldavCalendar.TABLE.`as`("google_task_lists").column("cdl_uuid").eq(GoogleTask.LIST)))
.join(Join.left(CaldavCalendar.TABLE, CaldavCalendar.UUID.eq(CaldavTask.CALENDAR)))
.join(Join.left(CaldavAccount.TABLE, CaldavAccount.UUID.eq(CaldavCalendar.ACCOUNT)))
.where(or(
and(GoogleTask.ID.gt(0), CaldavAccount.UUID.eq(null)),
and(GoogleTask.ID.gt(0), CaldavCalendar.TABLE.`as`("google_task_lists").column("cdl_uuid").eq(null)),
and(CaldavTask.ID.gt(0), CaldavAccount.UUID.eq(null))))
).apply {
icon = R.drawable.ic_outline_cloud_off_24px

@ -24,7 +24,6 @@ import org.tasks.notifications.NotificationDao
Tag::class,
GoogleTask::class,
Filter::class,
GoogleTaskList::class,
CaldavCalendar::class,
CaldavTask::class,
CaldavAccount::class,

@ -9,15 +9,15 @@ import com.google.api.services.tasks.model.TaskList
import com.todoroo.astrid.service.TaskDeleter
import org.tasks.LocalBroadcastManager
import org.tasks.data.CaldavAccount
import org.tasks.data.GoogleTaskList
import org.tasks.data.CaldavCalendar
import org.tasks.data.GoogleTaskListDao
import timber.log.Timber
import javax.inject.Inject
class GtasksListService @Inject constructor(
private val googleTaskListDao: GoogleTaskListDao,
private val taskDeleter: TaskDeleter,
private val localBroadcastManager: LocalBroadcastManager) {
private val localBroadcastManager: LocalBroadcastManager,
) {
/**
* Reads in remote list information and updates local list objects.
@ -33,34 +33,27 @@ class GtasksListService @Inject constructor(
for (i in remoteLists.indices) {
val remote = remoteLists[i]
val id = remote.id
var local: GoogleTaskList? = null
var local: CaldavCalendar? = null
for (list in lists) {
if (list.remoteId == id) {
if (list.uuid == id) {
local = list
break
}
}
val title = remote.title
if (local == null) {
val byRemoteId = googleTaskListDao.findExistingList(id)
if (byRemoteId != null) {
byRemoteId.account = account.uuid
local = byRemoteId
} else {
Timber.d("Adding new gtask list %s", title)
local = GoogleTaskList()
local.account = account.uuid
local.remoteId = id
}
local = CaldavCalendar(
account = account.uuid,
uuid = id,
)
}
local.title = title
local.name = remote.title
googleTaskListDao.insertOrReplace(local)
previousLists.remove(local.id)
}
// check for lists that aren't on remote server
for (listId in previousLists) {
taskDeleter.delete(googleTaskListDao.getById(listId)!!)
taskDeleter.deleteGoogleTaskList(googleTaskListDao.getById(listId)!!)
}
localBroadcastManager.broadcastRefreshList()
}

@ -66,8 +66,8 @@ class TaskDeleter @Inject constructor(
localBroadcastManager.broadcastRefresh()
}
fun delete(list: GoogleTaskList) = runBlocking {
val tasks = deletionDao.delete(list)
fun deleteGoogleTaskList(list: CaldavCalendar) = runBlocking {
val tasks = deletionDao.deleteGoogleTaskList(list)
delete(tasks)
localBroadcastManager.broadcastRefreshList()
}

@ -71,7 +71,7 @@ class Upgrader @Inject constructor(
preferences.setBoolean(R.string.p_astrid_sort_enabled, true)
taskMover.migrateLocalTasks()
}
run(from, V9_7) { googleTaskListDao.resetOrders() }
run(from, V9_7) { caldavDao.resetOrders() }
run(from, V9_7_3) { googleTaskDao.updateParents() }
run(from, V10_0_2) {
filterDao.getFilters()
@ -133,10 +133,6 @@ class Upgrader @Inject constructor(
calendar.copy(color = getAndroidColor(calendar.color))
)
}
for (list in googleTaskListDao.getAllLists()) {
list.setColor(getAndroidColor(list.getColor()!!))
googleTaskListDao.update(list)
}
for (tagData in tagDataDao.getAll()) {
tagData.setColor(getAndroidColor(tagData.getColor()!!))
tagDataDao.update(tagData)
@ -248,18 +244,19 @@ class Upgrader @Inject constructor(
}
private suspend fun migrateGoogleTaskAccount() {
val account = preferences.getStringValue("gtasks_user")
if (!isNullOrEmpty(account)) {
val caldavAccount = CaldavAccount()
caldavAccount.uuid = account
caldavAccount.name = account
caldavAccount.username = account
caldavDao.insert(caldavAccount)
for (list in googleTaskListDao.getAllLists()) {
list.account = account
googleTaskListDao.insertOrReplace(list)
}
}
// TODO: migrate google task accounts?
// val account = preferences.getStringValue("gtasks_user")
// if (!isNullOrEmpty(account)) {
// val caldavAccount = CaldavAccount()
// caldavAccount.uuid = account
// caldavAccount.name = account
// caldavAccount.username = account
// caldavDao.insert(caldavAccount)
// for (list in googleTaskListDao.getAllLists()) {
// list.account = account
// googleTaskListDao.insertOrReplace(list)
// }
// }
}
private suspend fun migrateUris() {

@ -1,7 +1,7 @@
package org.tasks.activities
import dagger.hilt.android.lifecycle.HiltViewModel
import org.tasks.data.GoogleTaskList
import org.tasks.data.CaldavCalendar
import org.tasks.googleapis.InvokerFactory
import org.tasks.ui.ActionViewModel
import javax.inject.Inject
@ -9,7 +9,7 @@ import javax.inject.Inject
@HiltViewModel
class DeleteListViewModel @Inject constructor(
private val invoker: InvokerFactory) : ActionViewModel() {
suspend fun deleteList(list: GoogleTaskList) {
run { invoker.getGtasksInvoker(list.account!!).deleteGtaskList(list.remoteId) }
suspend fun deleteList(list: CaldavCalendar) {
run { invoker.getGtasksInvoker(list.account!!).deleteGtaskList(list.uuid) }
}
}

@ -18,7 +18,7 @@ import dagger.hilt.android.AndroidEntryPoint
import org.tasks.R
import org.tasks.Strings.isNullOrEmpty
import org.tasks.data.CaldavAccount
import org.tasks.data.GoogleTaskList
import org.tasks.data.CaldavCalendar
import org.tasks.data.GoogleTaskListDao
import org.tasks.databinding.ActivityGoogleTaskListSettingsBinding
import org.tasks.extensions.Context.toast
@ -34,20 +34,21 @@ class GoogleTaskListSettingsActivity : BaseListSettingsActivity() {
private lateinit var progressView: ProgressBar
private var isNewList = false
private lateinit var gtasksList: GoogleTaskList
private lateinit var gtasksList: CaldavCalendar
private val createListViewModel: CreateListViewModel by viewModels()
private val renameListViewModel: RenameListViewModel by viewModels()
private val deleteListViewModel: DeleteListViewModel by viewModels()
override fun onCreate(savedInstanceState: Bundle?) {
gtasksList = intent.getParcelableExtra(EXTRA_STORE_DATA)
?: GoogleTaskList().apply {
isNewList = true
?: CaldavCalendar(
account = intent.getParcelableExtra<CaldavAccount>(EXTRA_ACCOUNT)!!.username
).apply {
isNewList = true
}
super.onCreate(savedInstanceState)
if (savedInstanceState == null) {
selectedColor = gtasksList.getColor()!!
selectedColor = gtasksList.color
selectedIcon = gtasksList.getIcon()!!
}
if (isNewList) {
@ -55,7 +56,7 @@ class GoogleTaskListSettingsActivity : BaseListSettingsActivity() {
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.showSoftInput(name, InputMethodManager.SHOW_IMPLICIT)
} else {
name.setText(gtasksList.title)
name.setText(gtasksList.name)
}
if (createListViewModel.inProgress
|| renameListViewModel.inProgress
@ -72,7 +73,7 @@ class GoogleTaskListSettingsActivity : BaseListSettingsActivity() {
get() = isNewList
override val toolbarTitle: String?
get() = if (isNew) getString(R.string.new_list) else gtasksList.title!!
get() = if (isNew) getString(R.string.new_list) else gtasksList.name!!
private fun showProgressIndicator() {
progressView.visibility = View.VISIBLE
@ -104,7 +105,7 @@ class GoogleTaskListSettingsActivity : BaseListSettingsActivity() {
}
else -> {
if (colorChanged() || iconChanged()) {
gtasksList.setColor(selectedColor)
gtasksList.color = selectedColor
gtasksList.setIcon(selectedIcon)
googleTaskListDao.insertOrReplace(gtasksList)
setResult(
@ -154,17 +155,17 @@ class GoogleTaskListSettingsActivity : BaseListSettingsActivity() {
selectedColor >= 0 || !isNullOrEmpty(newName)
} else colorChanged() || nameChanged() || iconChanged()
private fun colorChanged() = selectedColor != gtasksList.getColor()
private fun colorChanged() = selectedColor != gtasksList.color
private fun iconChanged() = selectedIcon != gtasksList.getIcon()
private fun nameChanged() = newName != gtasksList.title
private fun nameChanged() = newName != gtasksList.name
private suspend fun onListCreated(taskList: TaskList) {
with(gtasksList) {
remoteId = taskList.id
title = taskList.title
setColor(selectedColor)
uuid = taskList.id
name = taskList.title
color = selectedColor
setIcon(selectedIcon)
id = googleTaskListDao.insertOrReplace(this)
}
@ -176,7 +177,7 @@ class GoogleTaskListSettingsActivity : BaseListSettingsActivity() {
private fun onListDeleted(deleted: Boolean) {
if (deleted) {
taskDeleter.delete(gtasksList)
taskDeleter.deleteGoogleTaskList(gtasksList)
setResult(Activity.RESULT_OK, Intent(TaskListFragment.ACTION_DELETED))
finish()
}
@ -184,8 +185,8 @@ class GoogleTaskListSettingsActivity : BaseListSettingsActivity() {
private suspend fun onListRenamed(taskList: TaskList) {
with(gtasksList) {
title = taskList.title
setColor(selectedColor)
name = taskList.title
color = selectedColor
setIcon(selectedIcon)
googleTaskListDao.insertOrReplace(this)
}

@ -126,7 +126,6 @@ class NavigationDrawerCustomization : ThemedInjectingAppCompatActivity(), Toolba
lifecycleScope.launch {
filterDao.resetOrders()
caldavDao.resetOrders()
googleTaskListDao.resetOrders()
tagDataDao.resetOrders()
locationDao.resetOrders()
updateFilters()
@ -226,7 +225,7 @@ class NavigationDrawerCustomization : ThemedInjectingAppCompatActivity(), Toolba
private suspend fun setOrder(order: Int, filter: FilterListItem) {
when (filter) {
is GtasksFilter -> googleTaskListDao.setOrder(filter.list.id, order)
is GtasksFilter -> caldavDao.setOrder(filter.list.id, order)
is CaldavFilter -> caldavDao.setOrder(filter.calendar.id, order)
is TagFilter -> tagDataDao.setOrder(filter.tagData.id!!, order)
is CustomFilter -> filterDao.setOrder(filter.id, order)

@ -2,7 +2,7 @@ package org.tasks.activities
import com.google.api.services.tasks.model.TaskList
import dagger.hilt.android.lifecycle.HiltViewModel
import org.tasks.data.GoogleTaskList
import org.tasks.data.CaldavCalendar
import org.tasks.googleapis.InvokerFactory
import org.tasks.ui.CompletableViewModel
import javax.inject.Inject
@ -10,7 +10,7 @@ import javax.inject.Inject
@HiltViewModel
class RenameListViewModel @Inject constructor(
private val invoker: InvokerFactory) : CompletableViewModel<TaskList>() {
suspend fun renameList(list: GoogleTaskList, name: String) {
run { invoker.getGtasksInvoker(list.account!!).renameGtaskList(list.remoteId, name)!! }
suspend fun renameList(list: CaldavCalendar, name: String) {
run { invoker.getGtasksInvoker(list.account!!).renameGtaskList(list.uuid, name)!! }
}
}

@ -9,7 +9,6 @@ class BackupContainer(
val places: List<Place>?,
val tags: List<TagData>?,
val filters: List<Filter>?,
val googleTaskLists: List<GoogleTaskList>?,
val caldavAccounts: List<CaldavAccount>?,
val caldavCalendars: List<CaldavCalendar>?,
val taskListMetadata: List<TaskListMetadata>?,
@ -20,6 +19,7 @@ class BackupContainer(
val boolPrefs: Map<String, java.lang.Boolean>?,
val setPrefs: Map<String, java.util.Set<*>>?,
val googleTaskAccounts: List<GoogleTaskAccount>? = emptyList(),
val googleTaskLists: List<GoogleTaskList>? = emptyList(),
) {
class TaskBackup(
val task: Task,

@ -132,7 +132,6 @@ class TasksJsonExporter @Inject constructor(
locationDao.getPlaces(),
tagDataDao.getAll(),
filterDao.getFilters(),
googleTaskListDao.getAllLists(),
caldavDao.getAccounts(),
caldavDao.getCalendars(),
taskListMetadataDao.getAll(),

@ -40,7 +40,6 @@ class TasksJsonImporter @Inject constructor(
private val alarmDao: AlarmDao,
private val tagDao: TagDao,
private val googleTaskDao: GoogleTaskDao,
private val googleTaskListDao: GoogleTaskListDao,
private val filterDao: FilterDao,
private val taskAttachmentDao: TaskAttachmentDao,
private val caldavDao: CaldavDao,
@ -99,9 +98,15 @@ class TasksJsonImporter @Inject constructor(
}
}
backupContainer.googleTaskLists?.forEach { googleTaskList ->
googleTaskList.setColor(themeToColor(context, version, googleTaskList.getColor()!!))
if (googleTaskListDao.getByRemoteId(googleTaskList.remoteId!!) == null) {
googleTaskListDao.insert(googleTaskList)
if (caldavDao.getCalendar(googleTaskList.remoteId!!) == null) {
caldavDao.insert(
CaldavCalendar(
account = googleTaskList.account,
uuid = googleTaskList.remoteId,
color = themeToColor(context, version, googleTaskList.color ?: 0),
)
)
}
}
backupContainer.filters?.forEach { filter ->

@ -25,6 +25,7 @@ data class CaldavCalendar(
@ColumnInfo(name = "cdl_icon") private var icon: Int? = -1,
@ColumnInfo(name = "cdl_order") val order: Int = NO_ORDER,
@ColumnInfo(name = "cdl_access") var access: Int = ACCESS_OWNER,
@ColumnInfo(name = "cdl_last_sync") val lastSync: Long = 0,
) : Parcelable {
@Ignore
constructor(source: Parcel): this(
@ -38,6 +39,7 @@ data class CaldavCalendar(
icon = source.readInt(),
order = source.readInt(),
access = source.readInt(),
lastSync = source.readLong(),
)
@Suppress("RedundantNullableReturnType")
@ -63,6 +65,7 @@ data class CaldavCalendar(
writeInt(getIcon()!!)
writeInt(order)
writeInt(access)
writeLong(lastSync)
}
}

@ -12,6 +12,7 @@ import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import org.tasks.R
import org.tasks.data.CaldavAccount.Companion.TYPE_ETESYNC
import org.tasks.data.CaldavAccount.Companion.TYPE_GOOGLE_TASKS
import org.tasks.data.CaldavAccount.Companion.TYPE_LOCAL
import org.tasks.data.CaldavAccount.Companion.TYPE_OPENTASKS
import org.tasks.data.CaldavAccount.Companion.TYPE_TASKS
@ -188,7 +189,16 @@ SELECT EXISTS(SELECT 1
+ "AND cd_deleted = 0")
abstract suspend fun getCaldavTasksToPush(calendar: String): List<CaldavTaskContainer>
@Query("SELECT * FROM caldav_lists ORDER BY cdl_name COLLATE NOCASE")
@Query("SELECT * FROM caldav_lists " +
"INNER JOIN caldav_accounts ON caldav_lists.cdl_account = caldav_accounts.cda_uuid " +
"WHERE caldav_accounts.cda_account_type = $TYPE_GOOGLE_TASKS " +
"ORDER BY cdl_name COLLATE NOCASE")
abstract suspend fun getGoogleTaskLists(): List<CaldavCalendar>
@Query("SELECT * FROM caldav_lists " +
"INNER JOIN caldav_accounts ON caldav_lists.cdl_account = caldav_accounts.cda_uuid " +
"WHERE caldav_accounts.cda_account_type != $TYPE_GOOGLE_TASKS " +
"ORDER BY cdl_name COLLATE NOCASE")
abstract suspend fun getCalendars(): List<CaldavCalendar>
@Query("""

@ -39,9 +39,6 @@ interface ContentProviderDao {
INNER JOIN caldav_accounts ON cdl_account = cda_uuid""")
fun getLists(): Cursor
@Query("SELECT * FROM google_task_lists")
fun getGoogleTaskLists(): Cursor
@RawQuery
fun rawQuery(query: SupportSQLiteQuery): Cursor
}

@ -24,7 +24,5 @@ class ContentProviderDaoBlocking @Inject constructor(private val dao: ContentPro
fun getLists(): Cursor = dao.getLists()
fun getGoogleTaskLists(): Cursor = dao.getGoogleTaskLists()
fun rawQuery(query: SupportSQLiteQuery): Cursor = dao.rawQuery(query)
}

@ -58,19 +58,16 @@ WHERE recurring = 1
@Query("SELECT gt_task FROM google_tasks WHERE gt_deleted = 0 AND gt_list_id = :listId")
internal abstract suspend fun getActiveGoogleTasks(listId: String): List<Long>
@Delete
internal abstract suspend fun deleteGoogleTaskList(googleTaskList: GoogleTaskList)
@Transaction
open suspend fun delete(googleTaskList: GoogleTaskList): List<Long> {
val tasks = getActiveGoogleTasks(googleTaskList.remoteId!!)
open suspend fun deleteGoogleTaskList(googleTaskList: CaldavCalendar): List<Long> {
val tasks = getActiveGoogleTasks(googleTaskList.uuid!!)
delete(tasks)
deleteGoogleTaskList(googleTaskList)
delete(googleTaskList)
return tasks
}
@Query("SELECT * FROM google_task_lists WHERE gtl_account = :account ORDER BY gtl_title ASC")
abstract suspend fun getLists(account: String): List<GoogleTaskList>
@Query("SELECT * FROM caldav_lists WHERE cdl_account = :account ORDER BY cdl_name ASC")
abstract suspend fun getLists(account: String): List<CaldavCalendar>
@Query("SELECT cd_task FROM caldav_tasks WHERE cd_calendar = :calendar AND cd_deleted = 0")
internal abstract suspend fun getActiveCaldavTasks(calendar: String): List<Long>
@ -100,7 +97,7 @@ WHERE recurring = 1
val deleted = ArrayList<Long>()
if (caldavAccount.isGoogleTasks) {
for (list in getLists(caldavAccount.uuid!!)) {
deleted.addAll(delete(list))
deleted.addAll(deleteGoogleTaskList(list))
}
} else {
for (calendar in getCalendars(caldavAccount.uuid!!)) {

@ -1,126 +1,14 @@
package org.tasks.data
import android.os.Parcel
import android.os.Parcelable
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey
import com.todoroo.andlib.data.Table
import com.todoroo.astrid.api.FilterListItem.NO_ORDER
import org.tasks.themes.CustomIcons.LIST
@Entity(tableName = "google_task_lists")
class GoogleTaskList : Parcelable {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "gtl_id")
@Transient
var id: Long = 0
@ColumnInfo(name = "gtl_account")
var account: String? = null
@ColumnInfo(name = "gtl_remote_id")
var remoteId: String? = null
@ColumnInfo(name = "gtl_title")
var title: String? = null
@ColumnInfo(name = "gtl_remote_order")
var order = NO_ORDER
@ColumnInfo(name = "gtl_last_sync")
var lastSync: Long = 0
@ColumnInfo(name = "gtl_color")
private var color: Int? = null
@ColumnInfo(name = "gtl_icon")
private var icon: Int? = -1
constructor()
@Ignore
constructor(parcel: Parcel) {
id = parcel.readLong()
account = parcel.readString()
remoteId = parcel.readString()
title = parcel.readString()
order = parcel.readInt()
lastSync = parcel.readLong()
color = parcel.readInt()
icon = parcel.readInt()
}
@Suppress("RedundantNullableReturnType")
fun getColor(): Int? = color ?: 0
fun setColor(color: Int?) {
this.color = color
}
@Suppress("RedundantNullableReturnType")
fun getIcon(): Int? = icon ?: LIST
fun setIcon(icon: Int?) {
this.icon = icon
}
override fun describeContents() = 0
override fun writeToParcel(parcel: Parcel, i: Int) {
with(parcel) {
writeLong(id)
writeString(account)
writeString(remoteId)
writeString(title)
writeInt(order)
writeLong(lastSync)
writeInt(getColor()!!)
writeInt(getIcon()!!)
}
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is GoogleTaskList) return false
if (id != other.id) return false
if (account != other.account) return false
if (remoteId != other.remoteId) return false
if (title != other.title) return false
if (order != other.order) return false
if (lastSync != other.lastSync) return false
if (color != other.color) return false
if (icon != other.icon) return false
return true
}
override fun hashCode(): Int {
var result = id.hashCode()
result = 31 * result + (account?.hashCode() ?: 0)
result = 31 * result + (remoteId?.hashCode() ?: 0)
result = 31 * result + (title?.hashCode() ?: 0)
result = 31 * result + order
result = 31 * result + lastSync.hashCode()
result = 31 * result + (color ?: 0)
result = 31 * result + (icon ?: 0)
return result
}
override fun toString(): String =
"GoogleTaskList(id=$id, account=$account, remoteId=$remoteId, title=$title, remoteOrder=$order, lastSync=$lastSync, color=$color, icon=$icon)"
companion object {
@JvmField val TABLE = Table("google_task_lists")
val ACCOUNT = TABLE.column("gtl_account")
@JvmField val REMOTE_ID = TABLE.column("gtl_remote_id")
@JvmField val NAME = TABLE.column("gtl_title")
@JvmField val CREATOR: Parcelable.Creator<GoogleTaskList> = object : Parcelable.Creator<GoogleTaskList> {
override fun createFromParcel(parcel: Parcel): GoogleTaskList = GoogleTaskList(parcel)
override fun newArray(size: Int): Array<GoogleTaskList?> = arrayOfNulls(size)
}
}
}
@Deprecated("Only used for backup migration")
data class GoogleTaskList(
var account: String? = null,
var remoteId: String? = null,
var title: String? = null,
var order: Int = NO_ORDER,
var lastSync: Long = 0,
var color: Int? = null,
var icon: Int? = -1,
)

@ -1,8 +1,6 @@
package org.tasks.data
import androidx.lifecycle.LiveData
import androidx.room.*
import com.todoroo.astrid.api.FilterListItem.NO_ORDER
import org.tasks.data.CaldavAccount.Companion.TYPE_GOOGLE_TASKS
import org.tasks.filters.GoogleTaskFilters
import org.tasks.time.DateTimeUtils.currentTimeMillis
@ -12,50 +10,29 @@ interface GoogleTaskListDao {
@Query("SELECT * FROM caldav_accounts WHERE cda_account_type = $TYPE_GOOGLE_TASKS")
suspend fun getAccounts(): List<CaldavAccount>
@Query("SELECT * FROM google_task_lists WHERE gtl_id = :id")
suspend fun getById(id: Long): GoogleTaskList?
@Query("SELECT * FROM caldav_lists WHERE cdl_id = :id")
suspend fun getById(id: Long): CaldavCalendar?
@Query("SELECT * FROM google_task_lists WHERE gtl_account = :account ORDER BY gtl_title ASC")
suspend fun getLists(account: String): List<GoogleTaskList>
@Query("SELECT * FROM caldav_lists WHERE cdl_account = :account ORDER BY cdl_name ASC")
suspend fun getLists(account: String): List<CaldavCalendar>
@Query("SELECT * FROM google_task_lists WHERE gtl_remote_id = :remoteId LIMIT 1")
suspend fun getByRemoteId(remoteId: String): GoogleTaskList?
@Query("SELECT * FROM caldav_lists WHERE cdl_uuid = :remoteId LIMIT 1")
suspend fun getByRemoteId(remoteId: String): CaldavCalendar?
@Query("SELECT * FROM google_task_lists WHERE gtl_remote_id IN (:remoteIds)")
suspend fun getByRemoteId(remoteIds: List<String>): List<GoogleTaskList>
@Query("SELECT * FROM caldav_lists WHERE cdl_uuid IN (:remoteIds)")
suspend fun getByRemoteId(remoteIds: List<String>): List<CaldavCalendar>
@Query("SELECT * FROM google_task_lists")
fun subscribeToLists(): LiveData<List<GoogleTaskList>>
@Query("SELECT * FROM google_task_lists WHERE gtl_remote_id = :remoteId AND IFNULL(gtl_account, '') = ''")
suspend fun findExistingList(remoteId: String): GoogleTaskList?
@Query("SELECT * FROM google_task_lists")
suspend fun getAllLists(): List<GoogleTaskList>
@Query("UPDATE google_task_lists SET gtl_last_sync = 0 WHERE gtl_account = :account")
@Query("UPDATE caldav_lists SET cdl_last_sync = 0 WHERE cdl_account = :account")
suspend fun resetLastSync(account: String)
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertOrReplace(googleTaskList: GoogleTaskList): Long
@Insert
suspend fun insert(googleTaskList: GoogleTaskList): Long
suspend fun insertOrReplace(googleTaskList: CaldavCalendar): Long
@Update
suspend fun update(list: GoogleTaskList)
@Query("SELECT google_task_lists.*, COUNT(tasks._id) AS count"
+ " FROM google_task_lists "
+ " LEFT JOIN google_tasks ON google_tasks.gt_list_id = google_task_lists.gtl_remote_id"
@Query("SELECT caldav_lists.*, COUNT(tasks._id) AS count"
+ " FROM caldav_lists "
+ " LEFT JOIN google_tasks ON google_tasks.gt_list_id = caldav_lists.cdl_uuid"
+ " LEFT JOIN tasks ON google_tasks.gt_task = tasks._id AND tasks.deleted = 0 AND tasks.completed = 0 AND tasks.hideUntil < :now AND gt_deleted = 0"
+ " WHERE google_task_lists.gtl_account = :account"
+ " GROUP BY google_task_lists.gtl_remote_id")
+ " WHERE caldav_lists.cdl_account = :account"
+ " GROUP BY caldav_lists.cdl_uuid")
suspend fun getGoogleTaskFilters(account: String, now: Long = currentTimeMillis()): List<GoogleTaskFilters>
@Query("UPDATE google_task_lists SET gtl_remote_order = $NO_ORDER")
suspend fun resetOrders()
@Query("UPDATE google_task_lists SET gtl_remote_order = :order WHERE gtl_id = :id")
suspend fun setOrder(id: Long, order: Int)
}

@ -1,12 +1,7 @@
package org.tasks.data
import androidx.paging.DataSource
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.RawQuery
import androidx.room.Update
import androidx.room.withTransaction
import androidx.room.*
import androidx.sqlite.db.SimpleSQLiteQuery
import com.todoroo.andlib.sql.Criterion
import com.todoroo.andlib.sql.Field
@ -67,7 +62,8 @@ abstract class TaskDao(private val database: Database) {
@Query("SELECT tasks.* FROM tasks "
+ "LEFT JOIN google_tasks ON tasks._id = google_tasks.gt_task "
+ "WHERE gt_list_id IN (SELECT gtl_remote_id FROM google_task_lists WHERE gtl_account = :account)"
+ "LEFT JOIN caldav_lists ON google_tasks.gt_list_id = caldav_lists.cdl_uuid "
+ "WHERE cdl_account = :account "
+ "AND (tasks.modified > google_tasks.gt_last_sync OR google_tasks.gt_remote_id = '' OR google_tasks.gt_deleted > 0) "
+ "ORDER BY CASE WHEN gt_parent = 0 THEN 0 ELSE 1 END, gt_order ASC")
abstract suspend fun getGoogleTasksToPush(account: String): List<Task>

@ -591,8 +591,11 @@ object Migrations {
private val MIGRATION_87_88 = object : Migration(87, 88) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE `caldav_lists` ADD COLUMN `cdl_last_sync` INTEGER NOT NULL DEFAULT 0")
database.execSQL("INSERT INTO `caldav_accounts` (`cda_account_type`, `cda_server_type`, `cda_uuid`, `cda_name`, `cda_username`, `cda_collapsed`) SELECT $TYPE_GOOGLE_TASKS, $SERVER_UNKNOWN, `gta_account`, `gta_account`, `gta_account`, `gta_collapsed` FROM `google_task_accounts`")
database.execSQL("INSERT INTO `caldav_lists` (`cdl_account`, `cdl_uuid`, `cdl_name`, `cdl_color`, `cdl_icon`, `cdl_order`, `cdl_last_sync`) SELECT `gtl_account`, `gtl_remote_id`, `gtl_title`, `gtl_color`, `gtl_icon`, `gtl_remote_order`, `gtl_last_sync` FROM `google_task_lists`")
database.execSQL("DROP TABLE `google_task_accounts`")
database.execSQL("DROP TABLE `google_task_lists`")
}
}

@ -9,22 +9,11 @@ import com.todoroo.andlib.sql.Join.Companion.inner
import com.todoroo.andlib.sql.Join.Companion.left
import com.todoroo.andlib.sql.Query.Companion.select
import com.todoroo.andlib.sql.UnaryCriterion.Companion.isNotNull
import com.todoroo.astrid.api.BooleanCriterion
import com.todoroo.astrid.api.CustomFilterCriterion
import com.todoroo.astrid.api.MultipleSelectCriterion
import com.todoroo.astrid.api.PermaSql
import com.todoroo.astrid.api.TextInputCriterion
import com.todoroo.astrid.api.*
import com.todoroo.astrid.data.Task
import dagger.hilt.android.qualifiers.ApplicationContext
import org.tasks.R
import org.tasks.data.Alarm
import org.tasks.data.CaldavDao
import org.tasks.data.CaldavTask
import org.tasks.data.GoogleTask
import org.tasks.data.GoogleTaskListDao
import org.tasks.data.Tag
import org.tasks.data.TagData
import org.tasks.data.TagDataDao
import org.tasks.data.*
import org.tasks.data.TaskDao.TaskCriteria.activeAndVisible
import javax.inject.Inject
@ -297,12 +286,12 @@ class FilterCriteriaProvider @Inject constructor(
r.getString(R.string.CFC_title_contains_name))
private suspend fun gtasksFilterCriteria(): CustomFilterCriterion {
val lists = googleTaskListDao.getAllLists()
val lists = caldavDao.getGoogleTaskLists()
val listNames = arrayOfNulls<String>(lists.size)
val listIds = arrayOfNulls<String>(lists.size)
for (i in lists.indices) {
listNames[i] = lists[i].title
listIds[i] = lists[i].remoteId
listNames[i] = lists[i].name
listIds[i] = lists[i].uuid
}
val values: MutableMap<String, Any> = HashMap()
values[GoogleTask.KEY] = "?"

@ -1,12 +1,15 @@
package org.tasks.filters;
import androidx.room.Embedded;
import com.todoroo.astrid.api.GtasksFilter;
import org.tasks.data.CaldavCalendar;
import java.util.Objects;
import org.tasks.data.GoogleTaskList;
public class GoogleTaskFilters {
@Embedded public GoogleTaskList googleTaskList;
@Embedded public CaldavCalendar googleTaskList;
public int count;
GtasksFilter toGtasksFilter() {

@ -131,13 +131,13 @@ class GoogleTaskSynchronizer @Inject constructor(
}
}
for (list in googleTaskListDao.getByRemoteId(gtaskLists.map { it.id })) {
if (isNullOrEmpty(list.remoteId)) {
if (isNullOrEmpty(list.uuid)) {
firebase.reportException(RuntimeException("Empty remote id"))
continue
}
fetchAndApplyRemoteChanges(gtasksInvoker, list)
if (!preferences.isPositionHackEnabled) {
googleTaskDao.reposition(list.remoteId!!)
googleTaskDao.reposition(list.uuid!!)
}
}
if (preferences.isPositionHackEnabled) {
@ -276,8 +276,10 @@ class GoogleTaskSynchronizer @Inject constructor(
@Throws(IOException::class)
private suspend fun fetchAndApplyRemoteChanges(
gtasksInvoker: GtasksInvoker, list: GoogleTaskList) {
val listId = list.remoteId
gtasksInvoker: GtasksInvoker,
list: CaldavCalendar
) {
val listId = list.uuid
var lastSyncDate = list.lastSync
val tasks: MutableList<Task> = ArrayList()
var nextPageToken: String? = null
@ -342,8 +344,11 @@ class GoogleTaskSynchronizer @Inject constructor(
write(task, googleTask)
}
}
list.lastSync = lastSyncDate
googleTaskListDao.insertOrReplace(list)
googleTaskListDao.insertOrReplace(
list.copy(
lastSync = lastSyncDate
)
)
}
private suspend fun setOrderAndParent(googleTask: GoogleTask, task: Task) {

@ -78,7 +78,7 @@ class DefaultFilterProvider @Inject constructor(
getFilterFromPreference(prefString, getMyTasksFilter(context.resources))!!
private suspend fun getAnyList(): Filter {
val filter = googleTaskListDao.getAllLists().getOrNull(0)?.let(::GtasksFilter)
val filter = caldavDao.getGoogleTaskLists().getOrNull(0)?.let(::GtasksFilter)
?: caldavDao.getCalendars().filterNot { it.access == ACCESS_READ_ONLY }.getOrElse(0) { caldavDao.getLocalList(context) }.let(::CaldavFilter)
defaultList = filter
return filter
@ -100,7 +100,8 @@ class DefaultFilterProvider @Inject constructor(
val tag = tagDataDao.getByUuid(split[1])
if (tag == null || isNullOrEmpty(tag.name)) null else TagFilter(tag)
}
TYPE_GOOGLE_TASKS -> googleTaskListDao.getById(split[1].toLong())?.let { GtasksFilter(it) }
// TODO: convert filters from old ID to uuid
TYPE_GOOGLE_TASKS -> caldavDao.getCalendarByUuid(split[1])?.let { GtasksFilter(it) }
TYPE_CALDAV -> caldavDao.getCalendarByUuid(split[1])?.let { CaldavFilter(it) }
TYPE_LOCATION -> locationDao.getPlace(split[1])?.let { PlaceFilter(it) }
else -> null

@ -45,7 +45,7 @@ class TasksContentProvider : ContentProvider() {
}
URI_TASKS -> hilt.contentProviderDao.getTasks()
URI_LISTS -> hilt.contentProviderDao.getLists()
URI_GOOGLE_TASK_LISTS -> hilt.contentProviderDao.getGoogleTaskLists()
URI_GOOGLE_TASK_LISTS -> null
else -> throw IllegalStateException("Unrecognized URI: $uri")
}
}

@ -1,37 +1,26 @@
package org.tasks.ui
import com.todoroo.astrid.api.CaldavFilter
import com.todoroo.astrid.api.Filter
import com.todoroo.astrid.api.GtasksFilter
import com.todoroo.astrid.api.TagFilter
import org.tasks.LocalBroadcastManager
import org.tasks.data.*
import java.util.*
import org.tasks.data.CaldavCalendar
import org.tasks.data.CaldavDao
import org.tasks.data.TagData
import org.tasks.data.TagDataDao
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class ChipListCache @Inject internal constructor(
googleTaskListDao: GoogleTaskListDao,
caldavDao: CaldavDao,
tagDataDao: TagDataDao,
private val localBroadcastManager: LocalBroadcastManager) {
private val googleTaskLists: MutableMap<String?, GtasksFilter> = HashMap()
private val caldavCalendars: MutableMap<String?, CaldavFilter> = HashMap()
private val caldavCalendars: MutableMap<String?, CaldavCalendar> = HashMap()
private val tagDatas: MutableMap<String?, TagFilter> = HashMap()
private fun updateGoogleTaskLists(updated: List<GoogleTaskList>) {
googleTaskLists.clear()
for (update in updated) {
googleTaskLists[update.remoteId] = GtasksFilter(update)
}
localBroadcastManager.broadcastRefresh()
}
private fun updateCaldavCalendars(updated: List<CaldavCalendar>) {
caldavCalendars.clear()
for (update in updated) {
caldavCalendars[update.uuid] = CaldavFilter(update)
caldavCalendars[update.uuid] = update
}
localBroadcastManager.broadcastRefresh()
}
@ -44,14 +33,11 @@ class ChipListCache @Inject internal constructor(
localBroadcastManager.broadcastRefresh()
}
fun getGoogleTaskList(googleTaskList: String?): Filter? = googleTaskLists[googleTaskList]
fun getCaldavList(caldav: String?): Filter? = caldavCalendars[caldav]
fun getCaldavList(caldav: String?): CaldavCalendar? = caldavCalendars[caldav]
fun getTag(tag: String?): TagFilter? = tagDatas[tag]
init {
googleTaskListDao.subscribeToLists().observeForever { updated: List<GoogleTaskList> -> updateGoogleTaskLists(updated) }
caldavDao.subscribeToCalendars().observeForever { updated: List<CaldavCalendar> -> updateCaldavCalendars(updated) }
tagDataDao.subscribeToTags().observeForever { updated: List<TagData> -> updateTags(updated) }
}

@ -101,9 +101,9 @@ class ChipProvider @Inject constructor(
}
if (!isSubtask && preferences.showListChip) {
if (!isNullOrEmpty(task.googleTaskList) && filter !is GtasksFilter) {
lists.getGoogleTaskList(task.googleTaskList)?.let { list ->
lists.getCaldavList(task.googleTaskList)?.let { list ->
FilterChip(
filter = list,
filter = GtasksFilter(list),
defaultIcon = R.drawable.ic_list_24px,
onClick = onClick,
showText = showText,
@ -114,7 +114,7 @@ class ChipProvider @Inject constructor(
} else if (!isNullOrEmpty(task.caldav) && filter !is CaldavFilter) {
lists.getCaldavList(task.caldav)?.let { list ->
FilterChip(
filter = list,
filter = CaldavFilter(list),
defaultIcon = R.drawable.ic_list_24px,
onClick = onClick,
showText = showText,

@ -76,11 +76,11 @@ class ChipProvider @Inject constructor(
fun getListChip(filter: Filter?, task: TaskContainer): RemoteViews? {
task.googleTaskList
?.takeIf { filter !is GtasksFilter }
?.let { newChip(chipListCache.getGoogleTaskList(it), R.drawable.ic_list_24px) }
?.let { newChip(GtasksFilter(chipListCache.getCaldavList(it)), R.drawable.ic_list_24px) }
?.let { return it }
task.caldav
?.takeIf { filter !is CaldavFilter }
?.let { newChip(chipListCache.getCaldavList(it), R.drawable.ic_list_24px) }
?.let { newChip(CaldavFilter(chipListCache.getCaldavList(it)), R.drawable.ic_list_24px) }
?.let { return it }
return null
}

@ -12,7 +12,7 @@ object GoogleTaskListMaker {
private val instantiator = Instantiator { lookup: PropertyLookup<GoogleTaskList> ->
val list = GoogleTaskList()
list.remoteId = lookup.valueOf(REMOTE_ID, "1234")
list.uuid = lookup.valueOf(REMOTE_ID, "1234")
list.account = lookup.valueOf(ACCOUNT, null as String?)
list.setColor(0)
list

@ -22,8 +22,8 @@ object GtaskListMaker {
val list = GoogleTaskList()
list.id = lookup.valueOf(ID, 0L)
list.account = lookup.valueOf(ACCOUNT, "account")
list.remoteId = lookup.valueOf(REMOTE_ID, "1")
list.title = lookup.valueOf(NAME, "Default")
list.uuid = lookup.valueOf(REMOTE_ID, "1")
list.name = lookup.valueOf(NAME, "Default")
list.order = lookup.valueOf(ORDER, NO_ORDER)
list.lastSync = lookup.valueOf(LAST_SYNC, 0L)
list.setColor(lookup.valueOf(COLOR, 0))

Loading…
Cancel
Save