Skip to content

Commit ec1d35a

Browse files
authored
Merge pull request #256 from lukasgit/staging
Sync staging 0.6.3 with master
2 parents 044ec2c + ed03011 commit ec1d35a

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [0.6.3] - September 21, 2021
2+
3+
* Android: added method getContactsByEmail (@fjbatresv)
4+
15
## [0.6.2] - September 21, 2021
26

37
* Refactored all usages of Iterable to use List (@Abion47)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ To use this plugin, add `contacts_service` as a [dependency in your `pubspec.yam
1212
For example:
1313
```yaml
1414
dependencies:
15-
contacts_service: ^0.6.2
15+
contacts_service: ^0.6.3
1616
```
1717
1818
## Permissions

android/src/main/java/flutter/plugins/contactsservice/contactsservice/ContactsServicePlugin.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ public void onMethodCall(MethodCall call, Result result) {
107107
} case "getContactsForPhone": {
108108
this.getContactsForPhone(call.method, (String)call.argument("phone"), (boolean)call.argument("withThumbnails"), (boolean)call.argument("photoHighResolution"), (boolean)call.argument("orderByGivenName"), (boolean)call.argument("androidLocalizedLabels"), result);
109109
break;
110+
} case "getContactsForEmail": {
111+
this.getContactsForEmail(call.method, (String)call.argument("email"), (boolean)call.argument("withThumbnails"), (boolean)call.argument("photoHighResolution"), (boolean)call.argument("orderByGivenName"), (boolean)call.argument("androidLocalizedLabels"), result);
112+
break;
110113
} case "getAvatar": {
111114
final Contact contact = Contact.fromMap((HashMap)call.argument("contact"));
112115
this.getAvatar(contact, (boolean)call.argument("photoHighResolution"), result);
@@ -212,6 +215,10 @@ private void getContactsForPhone(String callMethod, String phone, boolean withTh
212215
new GetContactsTask(callMethod, result, withThumbnails, photoHighResolution, orderByGivenName, localizedLabels).executeOnExecutor(executor, phone, true);
213216
}
214217

218+
private void getContactsForEmail(String callMethod, String email, boolean withThumbnails, boolean photoHighResolution, boolean orderByGivenName, boolean localizedLabels, Result result) {
219+
new GetContactsTask(callMethod, result, withThumbnails, photoHighResolution, orderByGivenName, localizedLabels).executeOnExecutor(executor, email, true);
220+
}
221+
215222
@Override
216223
public void onAttachedToActivity(ActivityPluginBinding binding) {
217224
if (delegate instanceof ContactServiceDelegate) {
@@ -443,6 +450,7 @@ protected ArrayList<HashMap> doInBackground(Object... params) {
443450
case "openDeviceContactPicker": contacts = getContactsFrom(getCursor(null, (String) params[0]), localizedLabels); break;
444451
case "getContacts": contacts = getContactsFrom(getCursor((String) params[0], null), localizedLabels); break;
445452
case "getContactsForPhone": contacts = getContactsFrom(getCursorForPhone(((String) params[0])), localizedLabels); break;
453+
case "getContactsForEmail": contacts = getContactsFrom(getCursorForEmail(((String) params[0])), localizedLabels); break;
446454
default: return null;
447455
}
448456

@@ -537,6 +545,14 @@ private Cursor getCursorForPhone(String phone) {
537545
return null;
538546
}
539547

548+
private Cursor getCursorForEmail(String email) {
549+
if (email.isEmpty())
550+
return null;
551+
ArrayList<String> selectionArgs = new ArrayList<>(Arrays.asList("%" + email + "%"));
552+
String selection = Email.ADDRESS + " LIKE ?";
553+
return contentResolver.query(ContactsContract.Data.CONTENT_URI, PROJECTION, selection, selectionArgs.toArray(new String[selectionArgs.size()]), null);
554+
}
555+
540556
/**
541557
* Builds the list of contacts from the cursor
542558
* @param cursor

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: contacts_service
22
description: A Flutter plugin to retrieve and manage contacts on Android and iOS devices.
3-
version: 0.6.2
3+
version: 0.6.3
44
homepage: https://github.com/lukasgit/flutter_contacts
55
maintainer: Lukas Dickie (@lukasgit)
66

0 commit comments

Comments
 (0)