Show subtasks on details view. #442
This is far from finalized but I submit it now to get the discussion going.
Questions, notes:
Will using Tasks.PARENT_ID be okay for the subtask query?
UI: How should the subtask list look like? Same view repeated, with only the first having the icon, but same spaces between them as with other task details? Or should subtasks be listed within a 'frame' with maybe less vertical gap between them? Use some actual frame lines? (Current state is just a quick initial setup, not intended to stay like this)
About the loading using RxJava2, I guess there can be many questions there, please check the code and let me know.
I haven't given much thought about packaging the new classes yet, so that's left as well.
Important thing about the loading: currently it is started in onLoadFinished() because when it was in onCreateView(), the view items didn't show up after loading the screen the second time. Not sure what that was, maybe it's only because SubtaskView currently adds the items to a LinearLayout and calls requestLayout() after it, all within a ScrollView, so maybe if that happens before the original content is loaded, then it doesn't work for some reason.
Please check the loading multiple times, it varies greatly for me, sometimes immediate, sometimes delayed compared to the original content. So unfortunately this multiple loading does add some uncertainty here. As I mentioned before, I think one approach could be to do one loading, so zip/merge the 2 flows together and deliver the results once. That requires to 'Rxify' those loading, if we used Rx for the zip.
A little bit related that compared to current state where loading is handled in the fragment, I think it could actually be nicer to have a custom view for the subtasks (/properties) part that handles loading on its own, when let's say update(mTaskUri) is callled on it. But this would mean separate loading.
Please feel free to also comment on specifics already even though it is in initial state.
Shall we create subtasks master branch? To integrate the stories for this epic, like sorting out the relations as well, etc.
How about using the list view row layout for the subtasks on the details view? Or something similar? That would probably mean to omit the icon and replace it with a label "Subtasks".
I created two mock-ups of this view (for some reason the fonts of the subtasks are not correct)

Are you aware that the due date on the sub tasks is not correct? It shows Jan 1st 1970. Also, please re-add the progress indication (the gradient). I know that my mocks don't have any but that's because I didn't find a way to do that in proto.io
How much efforts would it take to split this into multiple PRs? For instance, the progressbar smartview would make sense on its own. Same goes for the OpenTasksPal changes.
I agree that it would be better as multiple PRs. I will split it and create tickets for them.
The DateTime support on the formatter with the corresponding DateTime to Time conversion will also be one.
@lemonboston please rebase.
I've rebased this one, but please note that there is https://github.com/dmfs/opentasks/issues/484 for the OpenTasksPal parts of this changeset and other parts may be submitted separately as well, so it is not worth reviewing this branch further at the moment.
I've updated this pull request with changes from master and also changed several other things.
Most notably, the two SmartViews (SubtasksView and SubtaskView) don't receive RowDataSnapshot any more but dedicatated Params objects, so that the UI is decoupled from the details of the data access layer this way. These Views no longer need to be concerned about projections for example.
The rx.Single that loads the required data - SubtasksViewParamsSource - now produces those ready made parameter objects. It is a special class for this purpose but uses re-usable components inside. It adapts the RowDataSnapshot to those Params before delivering them, so all those details, including the query as well, are hidden in this class.
I like this decoupling of data access layer representation details from the presentation layer.
Another important change I had to make was to move the loading from the ViewTaskFragment's onCreateView() to the updateView() method. This was because on rotation, the updateView() method is called with a delayed post() and it clears the whole content view, so the subtasks part was not shown. Not sure if there is a better option currently where to put it without starting to change those tangled code. I think the way forward could be to refactor the whole fragment, use rx for the loadings of ContentSet and Model so that everything is delivered together. I think any loading could be wrapped in RxJava sources without problems, the part that I haven't checked so far is the automatic updates. But I think that could be included, too. The Observable would just deliver the ContentSet-Model-SubtaskData the same way for initial loading and for updates as well. Most of those states and null checks involved could be removed.
So I think even without getting rid of ContentSet first, we could reduce complexities around loading and state with putting an Rx layer on top, sort of between the data-access and the UI.
(I'd volunteer for such a task. Maybe just a PoC first to see how it would work.)
One more note regarding the RxJava usage: From the four main source types of RxJava2 I used the SingleSource here, since we just have one result to emit. I started using that interface first for declarative classes, but to be able to use any operator on it, like map(), it has to 'wrapped' with the rx.Single class, calling Single.wrap(singleSource).map(..). So I ended up just using Single instead to avoid those boilerplates.
(Side note that in Kotlin I think this problem could be solved with extension functions on SingleSource.)
Back to the loading of the UI, the subtasks section now sometimes appears later, sometimes it is loaded quickly so that it appears to be appearing together with the rest. Because it varies I am not sure if we should try to add some animation, or how to smoothen it. (Especially if we consider switching to unified rx loading, then it wouldn't be needed at that point.)
The branch is ready for review. I am looking forward to hear what you think.
Regarding the packaging of the new classes, I created a detailsscreen package for classes that are completely special to the details screen. ViewTaskFragment could come here as well if you see it fit, I just didn't want to make unnecessary changes here.
Classes in the new readdata package of the app are related to loading data from the provider using RxJava.
I was also able to remove TaskUri class, there was no need for it in that form.
I've rebased this and added commit which changes the subtask loading RxJava source class that it is no longer responsible to know about the views. The RowDataSnapshot -> View.Params adapter classes are now top level ones.
Hi there, this feature would be handy for me and for an organization I am currently trying to manage the tasks via nextcloud. What is the status of merging this subtask feature?
This PR needs to wait for recurrence support which has currently highest priority (after fixing #728). There may be a few required changes after recurrence support is done. I'l get to that whenever my schedule allows me to.