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

Add support for Contact LOOKUP_KEY #140

Closed
9 tasks done
vestrel00 opened this issue Dec 21, 2021 · 2 comments
Closed
9 tasks done

Add support for Contact LOOKUP_KEY #140

vestrel00 opened this issue Dec 21, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@vestrel00
Copy link
Owner

vestrel00 commented Dec 21, 2021

As the official documentation states, ContactsContract.ContactsColumns#LOOKUP_KEY is...

An opaque value that contains hints on how to find the contact if its row id changed as a result of a sync or aggregation.

This will be useful for consumers that want to save a reference to a Contact in order to load it later. Currently, the only way for consumers to do this is via the Contact.id, which could change "as a result of a sync or aggregation".

Problem

Here is a common scenario that could occur,

  1. Consumer app shows details of Contact with ID of 7.
  2. Consumer app is backgrounded.
  3. Another Contacts app is opened.
  4. The Contact with ID of 7 is forcefully linked to another Contact in the other Contacts app.
  5. The Contact with ID of 7 is now aggregated to a Contact with ID of 11.
  6. Consumer app is resumed and tries to recreate the activity, reloading the Contact with ID of 7.
  7. Consumer app shows that it is unable to find that Contact.

Solution

Implement Contact.lookupKey so that consumers can save a reference to a Contact that can be held long term.

  • Document that lookup key is not a required field like the IDs. This allows memory optimizations for certain queries as lookup keys are strings that can be lengthy.
  • Update sample app to use lookup key instead of ID
  • Document Contact lookup key behavior for associating local contacts (not associated with an Account) with an Account and vice versa.
  • Document Contact lookup key behavior when linking/unlinking.
  • Document Contact lookup key vs id.
  • Document RawContacts DOES NOT have a lookup key.
  • Mention getting contacts by lookup key vs ID in howto page for Query.
  • Verify implementation on minSdkVersion (API 19)
  • Verify implementation on targetSdkVersion (API 31)

Notes

As mentioned in #139, it seems like the LOOKUP_KEY is the same across devices as long as data has been synced (up-to-date) with the servers!

This is probably also required to implement #70 .

@vestrel00 vestrel00 added the enhancement New feature or request label Dec 21, 2021
@vestrel00 vestrel00 self-assigned this Dec 21, 2021
@vestrel00 vestrel00 changed the title Add support for ContactsContract.ContactsColumns#LOOKUP_KEY Add support for Contact LOOKUP_KEY Dec 21, 2021
@vestrel00 vestrel00 pinned this issue Dec 21, 2021
@vestrel00 vestrel00 unpinned this issue Dec 22, 2021
@vestrel00 vestrel00 pinned this issue Dec 30, 2021
@vestrel00 vestrel00 unpinned this issue Jan 4, 2022
@vestrel00 vestrel00 pinned this issue Jan 9, 2022
vestrel00 added a commit that referenced this issue Jan 22, 2022
@vestrel00
Copy link
Owner Author

vestrel00 commented Jan 22, 2022

I'm doing a lot of research and documentation here! It is definitely tougher than just coding 😭 But I WILL PERSEVERE FOR THE COMMUNITY ❤️ 🔥

@vestrel00
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant