mirror of https://github.com/tasks/tasks
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.6 KiB
Kotlin
59 lines
1.6 KiB
Kotlin
package com.todoroo.astrid.api
|
|
|
|
import org.tasks.data.sql.Criterion.Companion.and
|
|
import org.tasks.data.sql.Join.Companion.left
|
|
import org.tasks.data.sql.QueryTemplate
|
|
import com.todoroo.andlib.utility.AndroidUtilities
|
|
import org.tasks.data.entity.Task
|
|
import kotlinx.parcelize.Parcelize
|
|
import org.tasks.data.entity.CaldavCalendar
|
|
import org.tasks.data.entity.CaldavTask
|
|
import org.tasks.data.GoogleTask
|
|
import org.tasks.data.NO_COUNT
|
|
import org.tasks.data.dao.TaskDao.TaskCriteria.activeAndVisible
|
|
|
|
@Parcelize
|
|
data class GtasksFilter(
|
|
val list: CaldavCalendar,
|
|
override val count: Int = NO_COUNT,
|
|
) : Filter {
|
|
override val title: String?
|
|
get() = list.name
|
|
|
|
override val sql: String
|
|
get() = QueryTemplate()
|
|
.join(left(CaldavTask.TABLE, Task.ID.eq(CaldavTask.TASK)))
|
|
.where(
|
|
and(
|
|
activeAndVisible(),
|
|
CaldavTask.DELETED.eq(0),
|
|
CaldavTask.CALENDAR.eq(list.uuid)
|
|
)
|
|
)
|
|
.toString()
|
|
|
|
override val valuesForNewTasks: String
|
|
get() = AndroidUtilities.mapToSerializedString(mapOf(GoogleTask.KEY to list.uuid!!))
|
|
|
|
override val order: Int
|
|
get() = list.order
|
|
|
|
override val icon: Int
|
|
get() = list.getIcon()!!
|
|
|
|
override val tint: Int
|
|
get() = list.color
|
|
|
|
val account: String
|
|
get() = list.account!!
|
|
|
|
override fun supportsManualSort() = true
|
|
|
|
val remoteId: String
|
|
get() = list.uuid!!
|
|
|
|
override fun areItemsTheSame(other: FilterListItem): Boolean {
|
|
return other is GtasksFilter && list.id == other.list.id
|
|
}
|
|
}
|