As fas as I have understood the Android contacts concept, it’s not task of a sync adapter to manage groups.
This depends on what you understand of “managing groups”. Ideally, the sync adapter synchronizes the groups in a two way manner: from phone to server and from server to phone. Unfortunately, CardDAV does not provide a list of existing groups (you can only see non-empty groups). Consequently, the “normal” (easy) way is not applicable and a more complicated “management” of groups is required. Therefore I wold suggest the above mentioned workaround in order to deal with some problems that occur due to this limitations of CardDAV.
In order to respond to your doubts, I would like to split the DAVdroid users into two cluster:
The addressbook app does not allow any changes to groups.
Here, groups can only be created, deleted and assigned on the server. Empty groups are not synchronized, which is not a real problem, because they are useless on the phone. If a new group is assigned to contacts on the server, the group will be created on the phone on synchronization. But if the group is deleted on the server, an empty and useless group remains at the phone after the next synchronization. The user can’t delete it – this is a problem.
With the above mentioned workaround, this empty group will be deleted on the phone. For the user, it does not matter if the group on the server is deleted or only empty. We do not need it on the phone. So, everything is fine.
The addressbook app is able to create, delete and assign groups.
Indeed, this situation is more complicated. I have to make some assumptions about the intension of the user. So let us distinct some cases:
- The group is created locally on the phone: It is clear, that the user wants to do something with the group. So we do not touch it, even if it is empty. This is respected in the above mentioned workaround, so everything is fine.
- The group is created on the server and deleted later: here, the same problem occurs like in the first cluster (no changes to groups possible on the phone). This means, that the intrinsically deleted group will not be deleted on the phone. In my point of view, this is a problem and this problem will not occur anymore using the above mentioned workaround. So everything is fine.
- The group is created on the server and then remains empty: in this case, the empty group should remain as empty group an the phone. Here (and only here!), the above mentioned workaround would delete the group, although it is possible that the user eventually wants to add a contact to this group on the phone.
The current situation is that deleted groups remain on the phone and in same cases the user has no possibility to delete these groups from the phone.
In the above mentioned workaround, these groups are deleted automatically. However, there is one instance in which an empty group is deleted although it is perhaps eventually used. This case occurs rarely, since most people will edit their contacts and groups only on the phone or only on the server. But if this case really occurs, then the user can easily add a contact to the group on the server or add the group again on the phone and the group will not be deleted again.
It’s a trade-off, but I think the workaround makes the situation better. How do other users think about this issue?