diff options
| author | Dominik Schürmann <dominik@dominikschuermann.de> | 2013-09-22 19:58:33 +0200 |
|---|---|---|
| committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2013-09-22 19:58:33 +0200 |
| commit | 917c86b52454d2984ac116ace8e56c75f1e244fb (patch) | |
| tree | 408697945836ce5adc36201f95feaaafa63412fe /OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service | |
| parent | 7b2de96d152ab1de922a3303409e85afbbc00778 (diff) | |
| download | open-keychain-917c86b52454d2984ac116ace8e56c75f1e244fb.tar.gz open-keychain-917c86b52454d2984ac116ace8e56c75f1e244fb.tar.bz2 open-keychain-917c86b52454d2984ac116ace8e56c75f1e244fb.zip | |
Import keys with adapter, loader, and new design
Diffstat (limited to 'OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service')
2 files changed, 16 insertions, 43 deletions
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 749b46405..8f8f1bdca 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -27,7 +27,9 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; +import java.util.List; +import org.spongycastle.openpgp.PGPKeyRing; import org.spongycastle.openpgp.PGPPublicKeyRing; import org.spongycastle.openpgp.PGPSecretKey; import org.spongycastle.openpgp.PGPSecretKeyRing; @@ -45,6 +47,7 @@ import org.sufficientlysecure.keychain.pgp.PgpOperation; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.provider.KeychainContract.DataStream; import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry; import org.sufficientlysecure.keychain.util.HkpKeyServer; import org.sufficientlysecure.keychain.util.InputData; import org.sufficientlysecure.keychain.util.KeyServer.KeyInfo; @@ -142,7 +145,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial public static final String IMPORT_INPUT_STREAM = "import_input_stream"; public static final String IMPORT_FILENAME = "import_filename"; public static final String IMPORT_BYTES = "import_bytes"; - // public static final String IMPORT_KEY_TYPE = "importKeyType"; + public static final String IMPORT_KEY_LIST = "import_key_list"; // export key public static final String EXPORT_OUTPUT_STREAM = "export_output_stream"; @@ -630,11 +633,6 @@ public class KeychainIntentService extends IntentService implements ProgressDial /* Input */ int target = data.getInt(TARGET); - // int keyType = Id.type.public_key; - // if (data.containsKey(IMPORT_KEY_TYPE)) { - // keyType = data.getInt(IMPORT_KEY_TYPE); - // } - /* Operation */ InputStream inStream = null; long inLength = -1; @@ -666,8 +664,10 @@ public class KeychainIntentService extends IntentService implements ProgressDial Bundle resultData = new Bundle(); + ArrayList<Long> keyIds = (ArrayList<Long>) data.getSerializable(IMPORT_KEY_LIST); + PgpImportExport pgpImportExport = new PgpImportExport(this, this); - resultData = pgpImportExport.importKeyRings(inputData); + resultData = pgpImportExport.importKeyRings(inputData, keyIds); sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, resultData); } catch (Exception e) { diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java index 0f919fc67..30804ee90 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java @@ -17,10 +17,6 @@ package org.sufficientlysecure.keychain.service.remote; -import java.util.HashMap; - -import org.spongycastle.bcpg.HashAlgorithmTags; -import org.spongycastle.openpgp.PGPEncryptedData; import org.spongycastle.openpgp.PGPSecretKey; import org.spongycastle.openpgp.PGPSecretKeyRing; import org.sufficientlysecure.keychain.Constants; @@ -29,7 +25,8 @@ import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.ui.SelectSecretKeyActivity; -import org.sufficientlysecure.keychain.util.KeyValueSpinnerAdapter; +import org.sufficientlysecure.keychain.ui.adapter.KeyValueSpinnerAdapter; +import org.sufficientlysecure.keychain.util.AlgorithmNames; import org.sufficientlysecure.keychain.util.Log; import android.app.Activity; @@ -114,18 +111,10 @@ public class AppSettingsFragment extends Fragment { mHashAlgorithm = (Spinner) view.findViewById(R.id.api_app_settings_hash_algorithm); mCompression = (Spinner) view.findViewById(R.id.api_app_settings_compression); - HashMap<Integer, String> encryptionMap = new HashMap<Integer, String>(); - encryptionMap.put(PGPEncryptedData.AES_128, "AES-128"); - encryptionMap.put(PGPEncryptedData.AES_192, "AES-192"); - encryptionMap.put(PGPEncryptedData.AES_256, "AES-256"); - encryptionMap.put(PGPEncryptedData.BLOWFISH, "Blowfish"); - encryptionMap.put(PGPEncryptedData.TWOFISH, "Twofish"); - encryptionMap.put(PGPEncryptedData.CAST5, "CAST5"); - encryptionMap.put(PGPEncryptedData.DES, "DES"); - encryptionMap.put(PGPEncryptedData.TRIPLE_DES, "Triple DES"); - encryptionMap.put(PGPEncryptedData.IDEA, "IDEA"); - - encryptionAdapter = new KeyValueSpinnerAdapter(getActivity(), encryptionMap); + AlgorithmNames algorithmNames = new AlgorithmNames(getActivity()); + + encryptionAdapter = new KeyValueSpinnerAdapter(getActivity(), + algorithmNames.getEncryptionNames()); mEncryptionAlgorithm.setAdapter(encryptionAdapter); mEncryptionAlgorithm.setOnItemSelectedListener(new OnItemSelectedListener() { @@ -139,16 +128,7 @@ public class AppSettingsFragment extends Fragment { } }); - HashMap<Integer, String> hashMap = new HashMap<Integer, String>(); - hashMap.put(HashAlgorithmTags.MD5, "MD5"); - hashMap.put(HashAlgorithmTags.RIPEMD160, "RIPEMD-160"); - hashMap.put(HashAlgorithmTags.SHA1, "SHA-1"); - hashMap.put(HashAlgorithmTags.SHA224, "SHA-224"); - hashMap.put(HashAlgorithmTags.SHA256, "SHA-256"); - hashMap.put(HashAlgorithmTags.SHA384, "SHA-384"); - hashMap.put(HashAlgorithmTags.SHA512, "SHA-512"); - - hashAdapter = new KeyValueSpinnerAdapter(getActivity(), hashMap); + hashAdapter = new KeyValueSpinnerAdapter(getActivity(), algorithmNames.getHashNames()); mHashAlgorithm.setAdapter(hashAdapter); mHashAlgorithm.setOnItemSelectedListener(new OnItemSelectedListener() { @@ -162,15 +142,8 @@ public class AppSettingsFragment extends Fragment { } }); - HashMap<Integer, String> compressionMap = new HashMap<Integer, String>(); - compressionMap.put(Id.choice.compression.none, getString(R.string.choice_none) + " (" - + getString(R.string.fast) + ")"); - compressionMap.put(Id.choice.compression.zip, "ZIP (" + getString(R.string.fast) + ")"); - compressionMap.put(Id.choice.compression.zlib, "ZLIB (" + getString(R.string.fast) + ")"); - compressionMap.put(Id.choice.compression.bzip2, "BZIP2 (" + getString(R.string.very_slow) - + ")"); - - compressionAdapter = new KeyValueSpinnerAdapter(getActivity(), compressionMap); + compressionAdapter = new KeyValueSpinnerAdapter(getActivity(), + algorithmNames.getCompressionNames()); mCompression.setAdapter(compressionAdapter); mCompression.setOnItemSelectedListener(new OnItemSelectedListener() { |
