contactstore icon indicating copy to clipboard operation
contactstore copied to clipboard

Primary Phone/Email support?

Open bmc08gt opened this issue 1 year ago • 1 comments

Does this exist in the current API scheme with fetching? Im not seeing an easy way to check this data without a secondary cursor query on the phones and emails.

bmc08gt avatar Apr 17 '23 17:04 bmc08gt

This is not something currently supported by ContactStore but it seems like a straightforward thing to support.

It should be a as simple as adding a isPrimary boolean to LabeledValue and forwarding the respective value in ContactQueries If you are up for contributing. (Line 301ish)

columnsToFetch.contains(Phones) && mimetype == PhoneColumns.CONTENT_ITEM_TYPE -> {
                          val phoneNumberString = item.getAsStringOrEmpty(PhoneColumns.NUMBER)
                          val id = item.getAsLong(PhoneColumns._ID)
                          if (phoneNumberString.isNotBlank() && id != null) {
                              // check if primary
                              val isPrimary = item.getAsInteger(PhoneColumns.IS_PRIMARY) != 0
                              val value = PhoneNumber(phoneNumberString)
                              val phoneEntry =
                                  // forward primary to LabeledValue
                                  LabeledValue(value, phoneLabelFrom(item), id, account, isPrimary)
                              phones.add(phoneEntry)
                          }
                      }

this would need to be done for all ContactColumns.

alexstyl avatar Apr 23 '23 15:04 alexstyl