-
Notifications
You must be signed in to change notification settings - Fork 36
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
New API for specialized matching of phone numbers (PhoneLookup) #259
Comments
eagerly waiting for this feature :D |
I'm starting to look at this. It seems like the public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns,
ContactsColumns, ContactOptionsColumns, ContactNameColumns It is essentially an index that has a lot of the same columns as the Data table, which also has joins on protected interface PhoneLookupColumns {
public static final String DATA_ID = "data_id";
public static final String CONTACT_ID = "contact_id";
public static final String NUMBER = "number";
public static final String TYPE = "type";
public static final String LABEL = "label";
public static final String NORMALIZED_NUMBER = "normalized_number";
} Apart from Just like Data table queries, this means that results may contain the same
If we go with option 1, then each contact may appear multiple times in the results but with different values for
If we go with option 2, then each contact will appear only once in the results and will contain aggregate phone numbers and other data. For example;
Option 2 is pretty much just like For now, I will go with option 2. UPDATE: It also seems like option 2 is a better option regardless because the UPDATE 2: This only matches numbers EXACTLY. No partial matching. Therefore, only duplicate numbers from 1 or more contacts will yield more than one result. This makes option 1 even less "important". |
Yes! I actually just realized this as I was trying to look for an alternative. Also, I just found out that the Makes me wonder why they added I'll take a risk and just use the |
Maybe the But... Just to be safe + future proofing, I'll do the following; if (API >= 24) PhoneLookup.CONTACT_ID else PhoneLookup._ID |
Something I've realized. The So, if we have contacts with the following numbers;
Searching for "123" will only return the one contact with the number "123". Searching for "1234" will return the contact(s) with the number "1234". I'll add this to the API documentation! |
Okay. I should have all the information I need to implement this! Research complete! I'll also add support for |
@mianaliasjad, this issue is done! It will be included in the next release, 0.2.4, which I'm aiming to publish some time this week 🔥 Full documentation is already available at https://vestrel00.github.io/contacts-android/basics/query-contacts-by-phone-or-sip/ It looks something like this; val contacts = Contacts(context)
.phoneLookupQuery()
.whereExactlyMatches("03123456789")
.find() |
I am not sure about that. I shall test it for 🙂 |
Exactly that's what we try to achieve while searching for the name of incoming call. We need exact result. |
Sure. Please double check me =) |
I just read the documentation and you are correct. The coulmn Check here . |
I'm a bit embarrassed for being caught not checking the official documentation. I just assumed there would be no documentation around the |
You should not be embarrassed 😅 because in android documentation says something else and on device functionality is something else mostly 🤣 So yeah you have done actual on device testing. Now we are 100% sure that those two are same thing 😉 |
This is included in 0.2.4! |
Problem
As @mianaliasjad pointed out in #258 (comment), the
BroadQuery
API currently does not match phone numbers that uses a country code (e.g. "+923123456789") when a search string is provided that does not use the country code (e.g. 03123456789).The following will not return the contact;
This is due to (intentionally) NOT using
ContactsContract.PhoneLookup.CONTENT_FILTER_URI
for the matching process because it's purpose is to emulate the behavior of the other major Contacts app, which it is doing.More info in the discussion #258
Solution
Implement a new API, which I might call
PhoneLookup
(name not final), that usesContactsContract.PhoneLookup.CONTENT_FILTER_URI
for the matching process.permissions
extensionsasync
extensionsgh-pages
The text was updated successfully, but these errors were encountered: