Greetings everyone! So I am actively looking at the best methods that can be utilized to design the new form hierarchy/repeat group view. There's a detailed discussion over on the ODK roadmap repository that started the high-level conversation of how the functionality should work in theory.
So now it's time to look at the programmatic approaches that we can take to get this done.
@Shobhit_Agarwal did some really interesting work on this as well so @Shobhit_Agarwal you are a key person who can help me with making some of these decisions
Based on the mockup created by Tom Smyth, the general idea of the changes that needs to happen with the navigation is once you are on the screen with the list of questions and you click on a
HierarchyElement then it should go to a separate screen/list that has all the items of that repeat group. Currently. when you do this the
HierarchyElement expands and collapses so now the
Children should be displayed on their own screen.
To go back to the main list you simply use the jump button that will allow you to navigate upwards in the hierarchy until you are back to the main screen.
From an Android API standpoint the approaches we could take modifying the way how the FormHierarchyActivity handles hierarchy navigation are as follows:
We could continue to use the same
RecyclerViewthat has all the
HierarchyElementmodels and then when we press a repeat element we simply set the current index of
FormControllerto the repeat group and then the current list of
HierarchyElementmodels that are powering the hierarchy list would be cleared and elements of the repeat group would be added so when the list is notified of changes it would appear that the app navigated to the repeat group itself. Of course, the
refreshViewlogic would probably have to be modified to support this.
n.b Currently, I am not too clear on what happens within that function in its totality so I need to use some breakpoints to figure that out, but for sure I can see that it's very important with handling the different types of indexes and such forth.
We could set the current form index and spawn a new
FormHierarchyActivity' that would then only display therepeat` elements within the list if the logic is customized as such. What I like about this approach is that it would be visually obvious to the user that they are navigating to somewhere else i.e deeper into the form due to the new activity transition taking place on the screen. Also, we would be able to tie into the Android back stack to navigate up out of the whichever depth the group is currently at. The drawback is that we would be spawning a lot of activities for a really big form.
We could use
ViewPager. So each fragment would basically represent a depth of the form and each time the user clicks a repeat item a new fragment is added to the
These are just some general ideas! I will update this some more as I delve deeper into how this can be done but I just want to get the discussion started so we can all contribute to this important change!