diff options
author | uberspot <onexemailx@gmail.com> | 2014-03-12 02:04:04 +0200 |
---|---|---|
committer | uberspot <onexemailx@gmail.com> | 2014-03-12 02:04:04 +0200 |
commit | b955c3de0173cc2014f9b56553ef984d196deb1b (patch) | |
tree | 3e3f378ab53badb356571c62f53329409bdf4f2a /OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper | |
parent | d586ad288d2a6db803c12c8ae4a600630004f7bc (diff) | |
download | open-keychain-b955c3de0173cc2014f9b56553ef984d196deb1b.tar.gz open-keychain-b955c3de0173cc2014f9b56553ef984d196deb1b.tar.bz2 open-keychain-b955c3de0173cc2014f9b56553ef984d196deb1b.zip |
Add Email suggestions in Create Key activity
Diffstat (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper')
-rw-r--r-- | OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ContactHelper.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ContactHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ContactHelper.java new file mode 100644 index 000000000..f8ed21816 --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ContactHelper.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.sufficientlysecure.keychain.helper; + +import android.accounts.Account; +import android.accounts.AccountManager; +import android.content.Context; +import android.util.Patterns; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class ContactHelper { + + public static final List<String> getMailAccounts(Context context) { + final Account[] accounts = AccountManager.get(context).getAccounts(); + final Set<String> emailSet = new HashSet<String>(); + for (Account account : accounts) { + if (Patterns.EMAIL_ADDRESS.matcher(account.name).matches()) { + emailSet.add(account.name); + } + } + return new ArrayList<String>(emailSet); + } +} |