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

Group mutableCopy function should not return null even if readOnly is true in order to support usages by sync adapters #304

Closed
6 tasks done
vestrel00 opened this issue Aug 30, 2023 · 2 comments
Assignees
Labels
breaking change This may break integration of the library for some consumers enhancement New feature or request

Comments

@vestrel00
Copy link
Owner

vestrel00 commented Aug 30, 2023

Problem

The Group.mutableCopy() function returns null if Group.readOnly is true. It was intentionally written this way to prevent applications from attempting to perform an update operation because it would fail if the group is read-only.

As a consequence, sync adapters are unable to use this API unless they bypass this limitation by using the following workaround,

val nonNullGroup = group.copy(readOnly = false).mutableCopy()!!

Here's the official documentation on ContactsContract.GroupsColumns.GROUP_IS_READ_ONLY,

Screenshot 2023-08-30 at 9 45 12 AM

Solution

The Group.mutableCopy() function should not return null even if it is read-only.

This may cause users of this library to attempt to update read-only groups, which will result in a failed operation. However, this behavior is actually more in-line with the rest of the API design so it should be okay.

  • Check/update all usages of Group.mutableCopy().
  • Change GroupsUpdate.groups function to only allow non-nullable groups and update function docs.
  • Update all in-code documentation.
  • Update docs, where necessary.
  • Update gh-pages branch, if necessary.
  • Provide migration guide.

Note

I am aware that the APIs in this library currently does not support setting CALLER_IS_SYNCADAPTER to true. This means that even with the resolution of this issue, users will still be unable to update/delete read-only groups even if they are building a sync adapter. Future support for setting CALLER_IS_SYNCADAPTER in library APIs IS coming in #308!

@vestrel00 vestrel00 added enhancement New feature or request breaking change This may break integration of the library for some consumers labels Aug 30, 2023
@vestrel00 vestrel00 self-assigned this Aug 30, 2023
@vestrel00 vestrel00 added this to In progress in General maintenance Aug 30, 2023
@vestrel00 vestrel00 moved this from In progress to Done in General maintenance Aug 31, 2023
@vestrel00 vestrel00 changed the title Group mutableCopy function should not return null even if readOnly is true in order to support sync adapter usages Group mutableCopy function should not return null even if readOnly is true in order to support usages by sync adapters Aug 31, 2023
@vestrel00
Copy link
Owner Author

Migration guide (to be included in release notes)

PREVIOUSLY, the Group.mutableCopy() function may return null if the group is read-only.

NOW, it will no longer return null even if the group is read-only.

🗒️ Read the new documentation for the full guide!

@vestrel00
Copy link
Owner Author

🔥 🔥 🔥 🔥 🔥 🔥 🔥 🔥
This is now release in 0.3.1!
🔥 🔥 🔥 🔥 🔥 🔥 🔥 🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change This may break integration of the library for some consumers enhancement New feature or request
Projects
Development

No branches or pull requests

1 participant