Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to hide subtasks (conditionally) #104

Open
Zocker1999NET opened this issue Jun 25, 2022 · 4 comments
Open

Option to hide subtasks (conditionally) #104

Zocker1999NET opened this issue Jun 25, 2022 · 4 comments

Comments

@Zocker1999NET
Copy link

I use Tasks as my tasks app and have used subtasks multiple times. Most of them are without due and start date. However, if I enable e.g. "Show tasks without due and start date at the end of the list", this widget will list all subtasks of tasks already shown elsewhere. So it would be great, if an option could be added to hide all subtasks.

Maybe it could also be useful to have an additional option like "Show subtasks only if they have a date and it differs from their parent(s)". So subtasks, which need to be done before their parent would still be shown, but other subtasks which only serve the purpose of being a checkable list would be hidden.

@yvolk
Copy link
Member

yvolk commented Jul 1, 2022

@Zocker1999NET We need to figure out first, how to distinguish tasks from subtasks. I suspect that we will need to query some more info from a task app for this.
Could you figure this out?

@Zocker1999NET
Copy link
Author

Zocker1999NET commented Jul 1, 2022

For me as non-Android dev, it seems as simple as retrieving another column from the app's database: The column parent seems to represent the subtask property. From the structure of the database:

          {
            "fieldPath": "parent",
            "columnName": "parent",
            "affinity": "INTEGER",
            "notNull": true
          }

https://github.com/tasks/tasks/blob/6173192e7207d3b1ec553e503a1ba7eb731f0532/app/schemas/com.todoroo.astrid.dao.Database/84.json#L391-L396

Because of "notNull": true, I expect then that <= 0 represents "having no parent" = "not being a subtask". EDIT: After reading more parts of Tasks's code, I'm sure they use == 0 as no parent.

I may be able to implement an option for just hiding all subtasks. I know Java & Kotlin, but don't expect me to write good code for Android, it would be more like "copy what the others have done before me and change names/titles/…". Implementing the second proposal might take some long time if I try that because I also haven't worked on this repository before. But I might be able to test both implementations if Android Studio can compile it without any special tweaks. (EDIT) Should I try the second as well?

@Zocker1999NET
Copy link
Author

Zocker1999NET commented Jul 1, 2022

I think I implemented nearly everything required for a plain simple "hide subtasks" & data extraction from Astrid's fork Tasks (see #105). However, I do not fully understand the reasoning behind the method matchedFilter I assume I should add the filter to:

protected boolean matchedFilter(TaskEvent task) {
if (getFilterMode() == FilterMode.NO_FILTERING) return true;
if (getFilterMode() == FilterMode.DEBUG_FILTER) {
if (task.getStatus() == TaskStatus.COMPLETED) return false;
if (task.hasStartDate() && task.getStartDate().isAfter(getSettings().getEndOfTimeRange())) return false;
}
if (getSettings().getTaskScheduling() == TaskScheduling.DATE_DUE) {
if (!task.hasStartDate()) {
if (task.hasDueDate() && task.getDueDate().isAfter(getSettings().getEndOfTimeRange())) return false;
}
}
return !mKeywordsFilter.matched(task.getTitle());
}

Which reasoning is behind the different behavior with and without the debug filter? And, if I should add the subtasks filter to this, should it be also applied if the debug filter is enabled?

EDIT: I think I might have understood it by myself. I thought lines 50 and 53-55 check for same properties but just realized they aren't … So I think I can append the filter before the return line, is that correct?

Zocker1999NET added a commit to Zocker1999NET/todoagenda that referenced this issue Jul 1, 2022
- add getting parent id from Astrid's Tasks app

refs andstatus#104
@yvolk
Copy link
Member

yvolk commented Jul 2, 2022

DEBUG_FILTER mode doesn't filter events (e.g. by event dates...) at a provider's side, so on each request our widget receives ALL events from the provider and the filtering is done inside the Widget's code.
So we can make sure that we don't lose any events, can inspect their properties... primarily for debugging purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants