Closed tatocaster closed 2 years ago
Thank you for the feature request @tatocaster!
Could you tell me more about your use case and what you are trying to achieve in your app? What kind of sorting order do you need?
Nothing special, I'm just on vacation and contributing to open-source 😃 But regarding the sorting, it would be nice if the user could sort by starred column or by display name but DESC
instead of ASC
. All of these cases are possible after .collect
like sortedByDescending {sortOrder}
but why bother when SQLite can do it naturally and feels more intuitive? For me, ContactStore feels like a better wrapper and ORM for the existing bad API that Android SDK offers, and intuitively think of that I can query and manipulate data on the lower level but with the better API. Maybe it's just me, you know the vision better as a creator of this library.
I would be happy to support such a feature when people find that this is something they need in their day to day development. I wouldn't want to migrate every feature of the existing Contacts API to Contact Store though. It might happen eventually, but this is not the plan.
The existing Contacts API has been out there for 10 years or so without much update. It is powerful given that you have access to an SQL-like syntax. I am assuming that a lot of the features it provides were introduced because the platform developers were coding against the ContactProvider interface instead of supporting the features app developers would eventually end up using.
Keeping the API lean allows for faster iterations/releases too as there is less things to maintain. I am not saying that the requested feature is not important or it will never make it to Contact Store. Instead, I would rather have the features and capabilities of the API to be driven by dev requirements.
💯 agree with you on that. I believe the issue can be closed for now.
That is a good catch @NLLAPPS. I will make sure to include it in the next release
An update on this. I added the option to choose if you prefer DISPLAY_NAME_PRIMARY or DISPLAY_NAME_ALTERNATIVE when fetching contacts. The sorting order is affected according to the option. See https://github.com/alexstyl/contactstore/pull/39
It would be really nice if users could sort the data by fields and ASC/DESC order. More specifically, support it on query level in content provider and not on the call site when the data is already fetched. Currently
ContactQueries.kt
useContacts.DISPLAY_NAME_PRIMARY
as a sort order by default in multiple lookups.I suggest adding the overloading method
fetchContacts
with the 3rd parametersortOrder
nullable by default, this will not break the existing code to the users and accept sorting order. Instead of String, there can be created some kind of data structure to predefined fields and ASC/DESC behavior.queryContacts
function by default will acceptContacts.DISPLAY_NAME_PRIMARY
as a parameter.