mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-11 03:25:05 -05:00
ContactHelper can read email addresses from contact list
This commit is contained in:
parent
13d4a6d902
commit
7865b92285
@ -53,6 +53,7 @@
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.NFC" />
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
|
||||
<!-- android:allowBackup="false": Don't allow backup over adb backup or other apps! -->
|
||||
<application
|
||||
|
@ -19,7 +19,10 @@ package org.sufficientlysecure.keychain.helper;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.provider.ContactsContract;
|
||||
import android.util.Patterns;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -39,4 +42,22 @@ public class ContactHelper {
|
||||
}
|
||||
return new ArrayList<String>(emailSet);
|
||||
}
|
||||
|
||||
public static List<String> getContactMails(Context context) {
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
Cursor mailCursor = resolver.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,
|
||||
new String[]{ContactsContract.CommonDataKinds.Email.DATA},
|
||||
null, null, null);
|
||||
if (mailCursor == null) return null;
|
||||
|
||||
Set<String> mails = new HashSet<String>();
|
||||
while (mailCursor.moveToNext()) {
|
||||
String email = mailCursor.getString(0);
|
||||
if (email != null) {
|
||||
mails.add(email);
|
||||
}
|
||||
}
|
||||
mailCursor.close();
|
||||
return new ArrayList<String>(mails);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user