Skip to content

Commit

Permalink
Merge pull request #256 from lukasgit/staging
Browse files Browse the repository at this point in the history
Sync staging 0.6.3 with master
  • Loading branch information
lukasgit authored Sep 22, 2021
2 parents 044ec2c + ed03011 commit ec1d35a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [0.6.3] - September 21, 2021

* Android: added method getContactsByEmail (@fjbatresv)

## [0.6.2] - September 21, 2021

* Refactored all usages of Iterable to use List (@Abion47)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ To use this plugin, add `contacts_service` as a [dependency in your `pubspec.yam
For example:
```yaml
dependencies:
contacts_service: ^0.6.2
contacts_service: ^0.6.3
```
## Permissions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ public void onMethodCall(MethodCall call, Result result) {
} case "getContactsForPhone": {
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);
break;
} case "getContactsForEmail": {
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);
break;
} case "getAvatar": {
final Contact contact = Contact.fromMap((HashMap)call.argument("contact"));
this.getAvatar(contact, (boolean)call.argument("photoHighResolution"), result);
Expand Down Expand Up @@ -212,6 +215,10 @@ private void getContactsForPhone(String callMethod, String phone, boolean withTh
new GetContactsTask(callMethod, result, withThumbnails, photoHighResolution, orderByGivenName, localizedLabels).executeOnExecutor(executor, phone, true);
}

private void getContactsForEmail(String callMethod, String email, boolean withThumbnails, boolean photoHighResolution, boolean orderByGivenName, boolean localizedLabels, Result result) {
new GetContactsTask(callMethod, result, withThumbnails, photoHighResolution, orderByGivenName, localizedLabels).executeOnExecutor(executor, email, true);
}

@Override
public void onAttachedToActivity(ActivityPluginBinding binding) {
if (delegate instanceof ContactServiceDelegate) {
Expand Down Expand Up @@ -443,6 +450,7 @@ protected ArrayList<HashMap> doInBackground(Object... params) {
case "openDeviceContactPicker": contacts = getContactsFrom(getCursor(null, (String) params[0]), localizedLabels); break;
case "getContacts": contacts = getContactsFrom(getCursor((String) params[0], null), localizedLabels); break;
case "getContactsForPhone": contacts = getContactsFrom(getCursorForPhone(((String) params[0])), localizedLabels); break;
case "getContactsForEmail": contacts = getContactsFrom(getCursorForEmail(((String) params[0])), localizedLabels); break;
default: return null;
}

Expand Down Expand Up @@ -537,6 +545,14 @@ private Cursor getCursorForPhone(String phone) {
return null;
}

private Cursor getCursorForEmail(String email) {
if (email.isEmpty())
return null;
ArrayList<String> selectionArgs = new ArrayList<>(Arrays.asList("%" + email + "%"));
String selection = Email.ADDRESS + " LIKE ?";
return contentResolver.query(ContactsContract.Data.CONTENT_URI, PROJECTION, selection, selectionArgs.toArray(new String[selectionArgs.size()]), null);
}

/**
* Builds the list of contacts from the cursor
* @param cursor
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: contacts_service
description: A Flutter plugin to retrieve and manage contacts on Android and iOS devices.
version: 0.6.2
version: 0.6.3
homepage: https://github.com/lukasgit/flutter_contacts
maintainer: Lukas Dickie (@lukasgit)

Expand Down

0 comments on commit ec1d35a

Please sign in to comment.