From 4b522a7ce8e052a2d3480f630436fb15c6a4943f Mon Sep 17 00:00:00 2001 From: Trevor Terris Date: Mon, 28 Jun 2021 16:06:28 -0400 Subject: [PATCH] Change NOW() query to check for all-day tasks Update query logic in FilterCriteriaProvider to use EOD time instead of current time for all-day tasks. Also, change the default start time for tasks to be non-time-specific (only relevant for when the filter being used to create a task is NOW). --- .../main/java/com/todoroo/astrid/service/TaskCreator.kt | 3 ++- .../main/java/org/tasks/filters/FilterCriteriaProvider.kt | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/todoroo/astrid/service/TaskCreator.kt b/app/src/main/java/com/todoroo/astrid/service/TaskCreator.kt index 8bdba2cbd..6f347493b 100644 --- a/app/src/main/java/com/todoroo/astrid/service/TaskCreator.kt +++ b/app/src/main/java/com/todoroo/astrid/service/TaskCreator.kt @@ -111,7 +111,8 @@ class TaskCreator @Inject constructor( when (key) { Tag.KEY -> tags.add(value as String) GoogleTask.KEY, CaldavTask.KEY, Place.KEY -> task.putTransitory(key, value) - DUE_DATE.name -> value.substitute()?.toLongOrNull()?.let { task.dueDate = it } + DUE_DATE.name -> value.substitute()?.toLongOrNull()?.let { task.dueDate = + createDueDate(Task.URGENCY_SPECIFIC_DAY, it) } IMPORTANCE.name -> value.substitute()?.toIntOrNull()?.let { task.priority = it } HIDE_UNTIL.name -> value.substitute()?.toLongOrNull()?.let { task.hideUntil = it.startOfDay() } diff --git a/app/src/main/java/org/tasks/filters/FilterCriteriaProvider.kt b/app/src/main/java/org/tasks/filters/FilterCriteriaProvider.kt index 593568510..e0711741d 100644 --- a/app/src/main/java/org/tasks/filters/FilterCriteriaProvider.kt +++ b/app/src/main/java/org/tasks/filters/FilterCriteriaProvider.kt @@ -192,7 +192,13 @@ class FilterCriteriaProvider @Inject constructor( and( activeAndVisible(), or(field("?").eq(0), Task.DUE_DATE.gt(0)), - Task.DUE_DATE.lte("?"))) + // find tasks that have due dates before the specified + // date, or all-day tasks that have due dates before + // EOD today if the specified date is NOW + or(Task.DUE_DATE.lte("?"), + and(field("${Task.DUE_DATE} / 1000 % 60").eq(0), + field("?").eq(field("${PermaSql.VALUE_NOW}")), + Task.DUE_DATE.lte("${PermaSql.VALUE_EOD}"))))) .toString(), values, r.getStringArray(R.array.CFC_dueBefore_entries),