|
|
|
@ -1,8 +1,11 @@
|
|
|
|
|
package org.tasks.preferences
|
|
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
|
import com.todoroo.astrid.api.*
|
|
|
|
|
import com.todoroo.astrid.api.CaldavFilter
|
|
|
|
|
import com.todoroo.astrid.api.CustomFilter
|
|
|
|
|
import com.todoroo.astrid.api.Filter
|
|
|
|
|
import com.todoroo.astrid.api.GtasksFilter
|
|
|
|
|
import com.todoroo.astrid.api.TagFilter
|
|
|
|
|
import com.todoroo.astrid.core.BuiltInFilterExposer
|
|
|
|
|
import com.todoroo.astrid.core.BuiltInFilterExposer.Companion.getMyTasksFilter
|
|
|
|
|
import com.todoroo.astrid.data.Task
|
|
|
|
@ -10,7 +13,14 @@ import dagger.hilt.android.qualifiers.ApplicationContext
|
|
|
|
|
import kotlinx.coroutines.runBlocking
|
|
|
|
|
import org.tasks.R
|
|
|
|
|
import org.tasks.Strings.isNullOrEmpty
|
|
|
|
|
import org.tasks.data.*
|
|
|
|
|
import org.tasks.data.CaldavDao
|
|
|
|
|
import org.tasks.data.CaldavTask
|
|
|
|
|
import org.tasks.data.FilterDao
|
|
|
|
|
import org.tasks.data.GoogleTask
|
|
|
|
|
import org.tasks.data.GoogleTaskDao
|
|
|
|
|
import org.tasks.data.GoogleTaskListDao
|
|
|
|
|
import org.tasks.data.LocationDao
|
|
|
|
|
import org.tasks.data.TagDataDao
|
|
|
|
|
import org.tasks.filters.PlaceFilter
|
|
|
|
|
import timber.log.Timber
|
|
|
|
|
import javax.inject.Inject
|
|
|
|
@ -131,16 +141,17 @@ class DefaultFilterProvider @Inject constructor(
|
|
|
|
|
private fun getBuiltInFilter(id: Int): Filter = when (id) {
|
|
|
|
|
FILTER_TODAY -> BuiltInFilterExposer.getTodayFilter(context.resources)
|
|
|
|
|
FILTER_RECENTLY_MODIFIED -> BuiltInFilterExposer.getRecentlyModifiedFilter(context.resources)
|
|
|
|
|
FILTER_SNOOZED -> BuiltInFilterExposer.getSnoozedFilter(context.resources)
|
|
|
|
|
else -> getMyTasksFilter(context.resources)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun getBuiltInFilterId(filter: Filter): Int {
|
|
|
|
|
if (BuiltInFilterExposer.isTodayFilter(context, filter)) {
|
|
|
|
|
return FILTER_TODAY
|
|
|
|
|
} else if (BuiltInFilterExposer.isRecentlyModifiedFilter(context, filter)) {
|
|
|
|
|
return FILTER_RECENTLY_MODIFIED
|
|
|
|
|
private fun getBuiltInFilterId(filter: Filter) = with(filter) {
|
|
|
|
|
when {
|
|
|
|
|
isToday() -> FILTER_TODAY
|
|
|
|
|
isRecentlyModified() -> FILTER_RECENTLY_MODIFIED
|
|
|
|
|
isSnoozed() -> FILTER_SNOOZED
|
|
|
|
|
else -> FILTER_MY_TASKS
|
|
|
|
|
}
|
|
|
|
|
return FILTER_MY_TASKS
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
suspend fun getList(task: Task): Filter {
|
|
|
|
@ -176,6 +187,15 @@ class DefaultFilterProvider @Inject constructor(
|
|
|
|
|
return originalList ?: getDefaultList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun Filter.isToday() =
|
|
|
|
|
BuiltInFilterExposer.isTodayFilter(context, this)
|
|
|
|
|
|
|
|
|
|
private fun Filter.isRecentlyModified() =
|
|
|
|
|
BuiltInFilterExposer.isRecentlyModifiedFilter(context, this)
|
|
|
|
|
|
|
|
|
|
private fun Filter.isSnoozed() =
|
|
|
|
|
BuiltInFilterExposer.isSnoozedFilter(context, this)
|
|
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
|
private const val TYPE_FILTER = 0
|
|
|
|
|
private const val TYPE_CUSTOM_FILTER = 1
|
|
|
|
@ -187,5 +207,6 @@ class DefaultFilterProvider @Inject constructor(
|
|
|
|
|
private const val FILTER_TODAY = 1
|
|
|
|
|
@Suppress("unused") private const val FILTER_UNCATEGORIZED = 2
|
|
|
|
|
private const val FILTER_RECENTLY_MODIFIED = 3
|
|
|
|
|
private const val FILTER_SNOOZED = 4
|
|
|
|
|
}
|
|
|
|
|
}
|