Add debug filters

pull/1061/head
Alex Baker 4 years ago
parent fca4a721da
commit 5f735673da

@ -7,7 +7,9 @@ package com.todoroo.astrid.core
import android.content.Context
import android.content.res.Resources
import com.todoroo.andlib.sql.Criterion
import com.todoroo.andlib.sql.Criterion.Companion.and
import com.todoroo.andlib.sql.Join
import com.todoroo.andlib.sql.QueryTemplate
import com.todoroo.andlib.utility.AndroidUtilities
import com.todoroo.astrid.api.Filter
@ -16,6 +18,8 @@ import com.todoroo.astrid.data.Task
import com.todoroo.astrid.timers.TimerPlugin
import dagger.hilt.android.qualifiers.ApplicationContext
import org.tasks.R
import org.tasks.data.CaldavTask
import org.tasks.data.GoogleTask
import org.tasks.data.TaskDao
import org.tasks.data.TaskDao.TaskCriteria.activeAndVisible
import org.tasks.filters.RecentlyModifiedFilter
@ -84,6 +88,33 @@ class BuiltInFilterExposer @Inject constructor(
todayValues)
}
fun getNoListFilter(): Filter {
return Filter(
"No list",
QueryTemplate()
.join(Join.left(GoogleTask.TABLE, and(GoogleTask.TASK.eq(Task.ID), GoogleTask.DELETED.eq(0))))
.join(Join.left(CaldavTask.TABLE, and(CaldavTask.TASK.eq(Task.ID), CaldavTask.DELETED.eq(0))))
.where(and(
activeAndVisible(),
GoogleTask.ID.eq(null),
CaldavTask.ID.eq(null))))
.apply {
icon = R.drawable.ic_outline_cloud_off_24px
}
}
fun getNoTitleFilter(): Filter {
return Filter(
"No title",
QueryTemplate()
.where(and(
activeAndVisible(),
Criterion.or(Task.TITLE.eq(null), Task.TITLE.eq("")))))
.apply {
icon = R.drawable.ic_outline_clear_24px
}
}
fun getRecentlyModifiedFilter(r: Resources) =
RecentlyModifiedFilter(r.getString(R.string.BFE_Recent))

@ -70,6 +70,7 @@ class CaldavTask {
companion object {
const val KEY = "caldav"
@JvmField val TABLE = Table("caldav_tasks")
val ID = TABLE.column("cd_id")
@JvmField val TASK = TABLE.column("cd_task")
@JvmField val DELETED = TABLE.column("cd_deleted")
@JvmField val CALENDAR = TABLE.column("cd_calendar")

@ -99,6 +99,7 @@ class GoogleTask {
companion object {
const val KEY = "gtasks"
@JvmField val TABLE = Table("google_tasks")
val ID = TABLE.column("gt_id")
@JvmField val PARENT = TABLE.column("gt_parent")
@JvmField val TASK = TABLE.column("gt_task")
@JvmField val DELETED = TABLE.column("gt_deleted")

@ -238,7 +238,15 @@ SELECT EXISTS(SELECT 1 FROM tasks WHERE parent > 0 AND deleted = 0) AS hasSubtas
return tasks.map(TaskContainer::getTask)
}
@Query("SELECT _id FROM tasks LEFT JOIN google_tasks ON _id = gt_task AND gt_deleted = 0 LEFT JOIN caldav_tasks ON _id = cd_task AND cd_deleted = 0 WHERE gt_id IS NULL AND cd_id IS NULL AND parent = 0")
@Query("""
SELECT _id
FROM tasks
LEFT JOIN google_tasks ON _id = gt_task AND gt_deleted = 0
LEFT JOIN caldav_tasks ON _id = cd_task AND cd_deleted = 0
WHERE gt_id IS NULL
AND cd_id IS NULL
AND parent = 0
""")
abstract suspend fun getLocalTasks(): List<Long>
/** Generates SQL clauses */

@ -48,6 +48,25 @@ class FilterProvider @Inject constructor(
suspend fun drawerCustomizationItems(): List<FilterListItem> =
getAllFilters(showBuiltIn = false)
private fun getDebugFilters(): List<FilterListItem> =
if (BuildConfig.DEBUG) {
val collapsed = preferences.getBoolean(R.string.p_collapse_debug, false)
listOf(NavigationDrawerSubheader(
context.getString(R.string.debug),
false,
collapsed,
SubheaderType.PREFERENCE,
R.string.p_collapse_debug.toLong()))
.apply { if (collapsed) return this }
.plus(listOf(
BuiltInFilterExposer.getNoListFilter(),
BuiltInFilterExposer.getNoTitleFilter()
))
} else {
emptyList()
}
private suspend fun addFilters(showCreate: Boolean, showBuiltIn: Boolean): List<FilterListItem> =
if (!preferences.getBoolean(R.string.p_filters_enabled, true)) {
emptyList()
@ -135,6 +154,7 @@ class FilterProvider @Inject constructor(
} else {
ArrayList<FilterListItem>()
}
.plusAllIf(BuildConfig.DEBUG) { getDebugFilters() }
.asSequence()
.plus(addFilters(showCreate, showBuiltIn))
.plus(addTags(showCreate))

@ -360,6 +360,7 @@
<string name="p_tag_chips">chips_tag</string>
<string name="p_desaturate_colors">desaturate_colors</string>
<string name="p_collapse_filters">collapse_filters</string>
<string name="p_collapse_debug">collapse_debug</string>
<string name="p_collapse_tags">collapse_tags</string>
<string name="p_collapse_locations">collapse_locations</string>
<string name="p_auto_dismiss_datetime_edit_screen">auto_dismiss_datetime_edit_screen</string>

Loading…
Cancel
Save