react-native-contacts 7.0.4 → 7.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ react-native unlink react-native-contacts
|
|
|
60
60
|
npm install latest version of react-native-contacts
|
|
61
61
|
Your good to go!
|
|
62
62
|
```
|
|
63
|
-
### react native version 60 and above
|
|
63
|
+
### react native version 60 and above
|
|
64
64
|
|
|
65
65
|
If you are using react native version 0.60 or above you do not have to link this library.
|
|
66
66
|
|
|
@@ -230,11 +230,21 @@ If you'd like to read/write the contact's notes, call the `iosEnableNotesUsage(t
|
|
|
230
230
|
imAddresses: [
|
|
231
231
|
{ username: '0123456789', service: 'ICQ'},
|
|
232
232
|
{ username: 'johndoe123', service: 'Facebook'}
|
|
233
|
-
]
|
|
233
|
+
],
|
|
234
|
+
isStarred: false,
|
|
234
235
|
}
|
|
235
236
|
```
|
|
236
|
-
|
|
237
|
+
|
|
238
|
+
### Android only
|
|
239
|
+
|
|
237
240
|
* on Android versions below 8 the entire display name is passed in the `givenName` field. `middleName` and `familyName` will be `""`.
|
|
241
|
+
* isStarred field
|
|
242
|
+
* writePhotoToPath() - writes the contact photo to a given path
|
|
243
|
+
|
|
244
|
+
## iOS only
|
|
245
|
+
|
|
246
|
+
checkPermission(): Promise - checks permission to access Contacts
|
|
247
|
+
requestPermission(): Promise - request permission to access Contacts
|
|
238
248
|
|
|
239
249
|
## Adding Contacts
|
|
240
250
|
Currently all fields from the contact record except for thumbnailPath are supported for writing
|
|
@@ -110,10 +110,15 @@ public class ContactsManager extends ReactContextBaseJavaModule implements Activ
|
|
|
110
110
|
ContentResolver cr = context.getContentResolver();
|
|
111
111
|
|
|
112
112
|
ContactsProvider contactsProvider = new ContactsProvider(cr);
|
|
113
|
-
|
|
113
|
+
try {
|
|
114
|
+
Integer contacts = contactsProvider.getContactsCount();
|
|
115
|
+
promise.resolve(contacts);
|
|
116
|
+
} catch (Exception e) {
|
|
117
|
+
promise.reject(e);
|
|
118
|
+
}
|
|
114
119
|
|
|
115
|
-
promise.resolve(contacts);
|
|
116
120
|
return null;
|
|
121
|
+
|
|
117
122
|
}
|
|
118
123
|
};
|
|
119
124
|
myAsyncTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
|
@@ -37,6 +37,7 @@ public class ContactsProvider {
|
|
|
37
37
|
add(ContactsContract.Data.CONTACT_ID);
|
|
38
38
|
add(ContactsContract.Data.RAW_CONTACT_ID);
|
|
39
39
|
add(ContactsContract.Data.LOOKUP_KEY);
|
|
40
|
+
add(ContactsContract.Data.STARRED);
|
|
40
41
|
add(ContactsContract.Contacts.Data.MIMETYPE);
|
|
41
42
|
add(ContactsContract.Profile.DISPLAY_NAME);
|
|
42
43
|
add(Contactables.PHOTO_URI);
|
|
@@ -344,10 +345,13 @@ public class ContactsProvider {
|
|
|
344
345
|
Contact contact = map.get(contactId);
|
|
345
346
|
String mimeType = cursor.getString(cursor.getColumnIndex(ContactsContract.Data.MIMETYPE));
|
|
346
347
|
String name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
|
|
348
|
+
int starred = cursor.getInt(cursor.getColumnIndex(ContactsContract.Data.STARRED));
|
|
349
|
+
Boolean isStarred = starred == 1;
|
|
347
350
|
contact.rawContactId = rawContactId;
|
|
348
351
|
if (!TextUtils.isEmpty(name) && TextUtils.isEmpty(contact.displayName)) {
|
|
349
352
|
contact.displayName = name;
|
|
350
353
|
}
|
|
354
|
+
contact.isStarred = isStarred;
|
|
351
355
|
|
|
352
356
|
if (TextUtils.isEmpty(contact.photoUri)) {
|
|
353
357
|
String rawPhotoURI = cursor.getString(cursor.getColumnIndex(Contactables.PHOTO_URI));
|
|
@@ -599,6 +603,7 @@ public class ContactsProvider {
|
|
|
599
603
|
private List<Item> urls = new ArrayList<>();
|
|
600
604
|
private List<Item> instantMessengers = new ArrayList<>();
|
|
601
605
|
private boolean hasPhoto = false;
|
|
606
|
+
private boolean isStarred = false;
|
|
602
607
|
private String photoUri;
|
|
603
608
|
private List<Item> emails = new ArrayList<>();
|
|
604
609
|
private List<Item> phones = new ArrayList<>();
|
|
@@ -626,6 +631,7 @@ public class ContactsProvider {
|
|
|
626
631
|
contact.putString("note", note);
|
|
627
632
|
contact.putBoolean("hasThumbnail", this.hasPhoto);
|
|
628
633
|
contact.putString("thumbnailPath", photoUri == null ? "" : photoUri);
|
|
634
|
+
contact.putBoolean("isStarred", this.isStarred);
|
|
629
635
|
|
|
630
636
|
WritableArray phoneNumbers = Arguments.createArray();
|
|
631
637
|
for (Item item : phones) {
|
package/index.d.ts
CHANGED