diff options
Diffstat (limited to 'OpenPGP-Keychain')
21 files changed, 194 insertions, 182 deletions
diff --git a/OpenPGP-Keychain/build.gradle b/OpenPGP-Keychain/build.gradle index 2f3a0d81a..a1bf3b783 100644 --- a/OpenPGP-Keychain/build.gradle +++ b/OpenPGP-Keychain/build.gradle @@ -4,24 +4,29 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:0.4.+' + classpath 'com.android.tools.build:gradle:0.5.+' } } apply plugin: 'android' +repositories { + mavenCentral() +} + dependencies { compile fileTree(dir: 'libs', includes: ['*.jar'], excludes: ['android-support-v4.jar']) - compile project(':libraries:ActionBarSherlock') + compile 'com.android.support:support-v4:13.0.+' + compile 'com.actionbarsherlock:actionbarsherlock:4.4.+@aar' } android { - compileSdkVersion 17 - buildToolsVersion "17" + compileSdkVersion 18 + buildToolsVersion "18.0.1" defaultConfig { minSdkVersion 8 - targetSdkVersion 17 + targetSdkVersion 18 } sourceSets { @@ -38,26 +43,28 @@ android { instrumentTest.setRoot('tests') } - /* - * To sign release build, create file gradle.properties in .gradle/ with this content: - * - * signingStoreLocation=/home/key.store - * signingStorePassword=xxx - * signingKeyAlias=alias - * signingKeyPassword=xxx - */ - signingConfigs { - myConfig { - storeFile file(signingStoreLocation) - storePassword signingStorePassword - keyAlias signingKeyAlias - keyPassword signingKeyPassword - } - } + if (project.hasProperty('signingStoreLocation')) { + /* + * To sign release build, create file gradle.properties in .gradle/ with this content: + * + * signingStoreLocation=/home/key.store + * signingStorePassword=xxx + * signingKeyAlias=alias + * signingKeyPassword=xxx + */ + signingConfigs { + myConfig { + storeFile file(signingStoreLocation) + storePassword signingStorePassword + keyAlias signingKeyAlias + keyPassword signingKeyPassword + } + } - buildTypes { - release { - signingConfig signingConfigs.myConfig + buildTypes { + release { + signingConfig signingConfigs.myConfig + } } } } diff --git a/OpenPGP-Keychain/libs/scpg-jdk15on-1.47.0.3-SNAPSHOT.jar b/OpenPGP-Keychain/libs/scpg-jdk15on-1.47.0.3-SNAPSHOT.jar Binary files differindex 55c28d5b7..a63969c8a 100644 --- a/OpenPGP-Keychain/libs/scpg-jdk15on-1.47.0.3-SNAPSHOT.jar +++ b/OpenPGP-Keychain/libs/scpg-jdk15on-1.47.0.3-SNAPSHOT.jar diff --git a/OpenPGP-Keychain/res/layout/create_key.xml b/OpenPGP-Keychain/res/layout/create_key.xml index d5bf6cf9f..8014dbefc 100644 --- a/OpenPGP-Keychain/res/layout/create_key.xml +++ b/OpenPGP-Keychain/res/layout/create_key.xml @@ -58,14 +58,12 @@ android:padding="4dp" android:text="@string/label_keySize" /> - <EditText + <Spinner android:id="@+id/create_key_size" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right" - android:numeric="integer" - android:padding="4dp" - android:text="1024" /> + android:padding="4dp" /> </TableRow> </TableLayout> diff --git a/OpenPGP-Keychain/res/raw/help_nfc_beam.html b/OpenPGP-Keychain/res/raw/help_nfc_beam.html index aa510008c..301c04267 100644 --- a/OpenPGP-Keychain/res/raw/help_nfc_beam.html +++ b/OpenPGP-Keychain/res/raw/help_nfc_beam.html @@ -5,12 +5,12 @@ And don't add newlines before or after p tags because of transifex --> <head> </head> <body> -<h2>How to receive keyrings</h2> +<h2>How to receive keys</h2> <ol> -<li>Go to your partners 'Manage Public Keyrings' and long press on the keyring you want to share.</li> +<li>Go to your partners 'Manage Public Keys' and long press on the key you want to share.</li> <li>Hold the two devices back to back (they have to be almost touching) and you’ll feel a vibration.</li> <li>After it vibrates you’ll see the content on your partners device turn into a card-like object with Star Trek warp speed-looking animation in the background.</li> <li>Tap the card and the content will then load on the your device.</li> </ol> </body> -</html>
\ No newline at end of file +</html> diff --git a/OpenPGP-Keychain/res/values/arrays.xml b/OpenPGP-Keychain/res/values/arrays.xml index 05320c609..950a70821 100644 --- a/OpenPGP-Keychain/res/values/arrays.xml +++ b/OpenPGP-Keychain/res/values/arrays.xml @@ -43,5 +43,10 @@ <item>14400</item> <item>28800</item> </string-array> - + <string-array name="key_size_spinner_values"> + <item>@string/key_size_512</item> + <item>@string/key_size_1024</item> + <item>@string/key_size_2048</item> + <item>@string/key_size_4096</item> + </string-array> </resources>
\ No newline at end of file diff --git a/OpenPGP-Keychain/res/values/strings.xml b/OpenPGP-Keychain/res/values/strings.xml index bcae942aa..70f4993d7 100644 --- a/OpenPGP-Keychain/res/values/strings.xml +++ b/OpenPGP-Keychain/res/values/strings.xml @@ -20,16 +20,15 @@ <!-- title_lowerCase: capitalized words, no punctuation --> <string name="title_mailInbox">Mail Inbox</string> - <string name="title_managePublicKeys">Manage Public Keyrings</string> - <string name="title_manageSecretKeys">Manage Secret Keyrings</string> - <string name="title_selectRecipients">Select Public Keyring</string> - <string name="title_selectSignature">Select Secret Keyring</string> + <string name="title_managePublicKeys">Manage Public Keys</string> + <string name="title_manageSecretKeys">Manage Secret Keys</string> + <string name="title_selectRecipients">Select Public Key</string> + <string name="title_selectSignature">Select Secret Key</string> <string name="title_encrypt">Encrypt</string> <string name="title_decrypt">Decrypt</string> <string name="title_authentication">Passphrase</string> <string name="title_createKey">Create Key</string> - <string name="title_editKey">Edit Keyring</string> - <string name="title_createKey">Create Keyring</string> + <string name="title_editKey">Edit Key</string> <string name="title_preferences">Preferences</string> <string name="title_crypto_consumers">Registered Applications</string> <string name="title_keyServerPreference">Key Server Preference</string> @@ -38,18 +37,17 @@ <string name="title_sendEmail">"Send Mail…"</string> <string name="title_encryptToFile">Encrypt To File</string> <string name="title_decryptToFile">Decrypt To File</string> - <string name="title_importKeys">Import Keyrings</string> - <string name="title_exportKey">Export Keyring</string> - <string name="title_exportKeys">Export Keyrings</string> + <string name="title_importKeys">Import Keys</string> + <string name="title_exportKey">Export Key</string> + <string name="title_exportKeys">Export Keys</string> <string name="title_keyNotFound">Key Not Found</string> - <string name="title_help">Getting Started</string> <string name="title_keyServerQuery">Query Key Server</string> <string name="title_sendKey">Export to Key Server</string> <string name="title_unknownSignatureKey">Unknown Signature Key</string> - <string name="title_signKey">Sign Keyring</string> + <string name="title_signKey">Sign Key</string> <string name="title_about">About</string> <string name="title_help">Help</string> - <string name="title_shareByNfc">Share keyring with NFC</string> + <string name="title_shareByNfc">Share key with NFC</string> <!-- section_lowerCase: capitalized words, no punctuation --> <string name="section_userIds">User IDs</string> @@ -87,18 +85,18 @@ <!-- menu_lowerCase: capitalized words, no punctuation --> <string name="menu_about">About</string> <string name="menu_deleteAccount">Delete Account</string> - <string name="menu_managePublicKeys">Manage Public Keyrings</string> - <string name="menu_manageSecretKeys">Manage Secret Keyrings</string> + <string name="menu_managePublicKeys">Manage Public Keys</string> + <string name="menu_manageSecretKeys">Manage Secret Keys</string> <string name="menu_preferences">Settings</string> <string name="menu_apiAppSettings">Registered Apps</string> <string name="menu_importFromFile">Import from file</string> <string name="menu_importFromQrCode">Import from QR Code</string> <string name="menu_importFromNfc">Import from NFC</string> - <string name="menu_exportKeys">Export All Keyrings</string> + <string name="menu_exportKeys">Export All Keys</string> <string name="menu_exportKey">Export To File</string> - <string name="menu_deleteKey">Delete Keyring</string> - <string name="menu_createKey">Create Keyring</string> - <string name="menu_editKey">Edit Keyring</string> + <string name="menu_deleteKey">Delete Key</string> + <string name="menu_createKey">Create Key</string> + <string name="menu_editKey">Edit Key</string> <string name="menu_search">Search</string> <string name="menu_help">Help</string> <string name="menu_keyServer">Query Key Server</string> @@ -142,7 +140,7 @@ <string name="label_name">Name</string> <string name="label_comment">Comment</string> <string name="label_email">Email</string> - <string name="label_sendKey">Send Keyring to Server?</string> + <string name="label_sendKey">Send Key to Server?</string> <string name="noKeysSelected">Select</string> <string name="oneKeySelected">1 Selected</string> <string name="nKeysSelected">Selected</string> @@ -209,34 +207,34 @@ <string name="encryptionSuccessful">Successfully encrypted.</string> <string name="encryptionToClipboardSuccessful">Successfully encrypted to clipboard.</string> <string name="enterPassPhraseTwice">Enter the passphrase twice.</string> - <string name="selectEncryptionKey">Select at least one encryption keyring.</string> - <string name="selectEncryptionOrSignatureKey">Select at least one encryption keyring or a signature keyring.</string> + <string name="selectEncryptionKey">Select at least one encryption key.</string> + <string name="selectEncryptionOrSignatureKey">Select at least one encryption key or a signature key.</string> <string name="specifyFileToEncryptTo">Please specify which file to encrypt to.\nWARNING! File will be overwritten if it exists.</string> <string name="specifyFileToDecryptTo">Please specify which file to decrypt to.\nWARNING! File will be overwritten if it exists.</string> - <string name="specifyFileToImportFrom">Please specify which file to import keyrings from. (.asc or .gpg)</string> + <string name="specifyFileToImportFrom">Please specify which file to import keys from. (.asc or .gpg)</string> <string name="specifyFileToExportTo">Please specify which file to export to.\nWARNING! File will be overwritten if it exists.</string> - <string name="specifyFileToExportSecretKeysTo">Please specify which file to export to.\nWARNING! You are about to export SECRET keyrings.\nWARNING! File will be overwritten if it exists.</string> - <string name="keyDeletionConfirmation">Do you really want to delete the keyring \'%s\'?\nYou can\'t undo this!</string> - <string name="secretKeyDeletionConfirmation">Do you really want to delete the SECRET keyring \'%s\'?\nYou can\'t undo this!</string> - <string name="keysAddedAndUpdated">Successfully added %1$s keyring(s) and updated %2$s keyring(s).</string> - <string name="keysAdded">Successfully added %s keyring(s).</string> - <string name="keysUpdated">Successfully updated %s keyring(s).</string> - <string name="noKeysAddedOrUpdated">No keyrings added or updated.</string> - <string name="keyExported">Successfully exported 1 keyring.</string> - <string name="keysExported">Successfully exported %s keyrings.</string> - <string name="noKeysExported">No keyrings exported.</string> + <string name="specifyFileToExportSecretKeysTo">Please specify which file to export to.\nWARNING! You are about to export SECRET keys.\nWARNING! File will be overwritten if it exists.</string> + <string name="keyDeletionConfirmation">Do you really want to delete the key \'%s\'?\nYou can\'t undo this!</string> + <string name="secretKeyDeletionConfirmation">Do you really want to delete the SECRET key \'%s\'?\nYou can\'t undo this!</string> + <string name="keysAddedAndUpdated">Successfully added %1$s key(s) and updated %2$s key(s).</string> + <string name="keysAdded">Successfully added %s key(s).</string> + <string name="keysUpdated">Successfully updated %s key(s).</string> + <string name="noKeysAddedOrUpdated">No keys added or updated.</string> + <string name="keyExported">Successfully exported 1 key.</string> + <string name="keysExported">Successfully exported %s keys.</string> + <string name="noKeysExported">No keys exported.</string> <string name="keyCreationElGamalInfo">Note: only subkeys support ElGamal, and for ElGamal the nearest keysize of 1536, 2048, 3072, 4096, or 8192 will be used.</string> <string name="keyNotFound">Couldn\'t find key %08X.</string> <string name="keysFound">Found %s key(s).</string> <string name="unknownSignatureKeyTouchToLookUp">Unknown signature, touch to look up key.</string> <string name="badKeysEncountered">%s bad secret key(s) ignored. Perhaps you exported with the option\n --export-secret-subkeys\nMake sure you export with\n --export-secret-keys\ninstead.</string> - <string name="lookupUnknownKey">Unknown keyring %s, do you want to try finding it on a keyserver?</string> - <string name="keySendSuccess">Successfully sent keyring to server</string> - <string name="keySignSuccess">Successfully signed keyring</string> - <string name="qrScanImportSuccess">Successfully validated and imported keyring</string> + <string name="lookupUnknownKey">Unknown key %s, do you want to try finding it on a keyserver?</string> + <string name="keySendSuccess">Successfully sent key to server</string> + <string name="keySignSuccess">Successfully signed key</string> + <string name="qrScanImportSuccess">Successfully validated and imported key</string> <string name="listInformation">Long press one entry in this list to show more options!</string> <string name="listEmpty">This list is empty!</string> - <string name="nfcSuccessfull">Successfully sent keyring with NFC Beam!</string> + <string name="nfcSuccessfull">Successfully sent key with NFC Beam!</string> <!-- error_lowerCase: phrases, no punctuation, all lowercase, @@ -285,11 +283,11 @@ <string name="progress_certifyingMasterKey">certifying master key…</string> <string name="progress_buildingMasterKeyRing">building master key ring…</string> <string name="progress_addingSubKeys">adding sub keys…</string> - <string name="progress_savingKeyRing">saving key keyring…</string> - <string name="progress_importingSecretKeys">importing secret keyrings…</string> - <string name="progress_importingPublicKeys">importing public keyrings…</string> - <string name="progress_exportingKey">exporting keyring…</string> - <string name="progress_exportingKeys">exporting keyrings…</string> + <string name="progress_savingKeyRing">saving key key…</string> + <string name="progress_importingSecretKeys">importing secret keys…</string> + <string name="progress_importingPublicKeys">importing public keys…</string> + <string name="progress_exportingKey">exporting key…</string> + <string name="progress_exportingKeys">exporting keys…</string> <string name="progress_extractingSignatureKey">extracting signature key…</string> <string name="progress_extractingKey">extracting key…</string> <string name="progress_preparingStreams">preparing streams…</string> @@ -319,24 +317,30 @@ <!-- action strings --> <string name="action_encrypt">Encrypt</string> <string name="action_decrypt">Decrypt</string> - <string name="action_importPublic">Import Public Keyrings</string> - <string name="action_importSecret">Import Secret Keyrings</string> - <string name="hint_publicKeys">Search Public Keyrings</string> - <string name="hint_secretKeys">Search Secret Keyrings</string> + <string name="action_importPublic">Import Public Keys</string> + <string name="action_importSecret">Import Secret Keys</string> + <string name="hint_publicKeys">Search Public Keys</string> + <string name="hint_secretKeys">Search Secret Keys</string> <string name="filterInfo">Filter: \"%s\"</string> - <string name="shareKeyringWith">Share keyring with…</string> + <string name="shareKeyringWith">Share Key with…</string> + <!-- key bit length selections --> + <string name="key_size_512">512</string> + <string name="key_size_1024">1024</string> + <string name="key_size_2048">2048</string> + <string name="key_size_4096">4096</string> + <!-- misc --> <string name="fast">fast</string> <string name="slow">slow</string> <string name="very_slow">very slow</string> - + <!-- APG 2.0 --> <!-- Dashboard --> - <string name="dashboard_manage_keys">Manage Public Keyrings</string> - <string name="dashboard_my_keys">My Secret Keyrings</string> + <string name="dashboard_manage_keys">Manage Public Keys</string> + <string name="dashboard_my_keys">My Secret Keys</string> <string name="dashboard_encrypt">Encrypt</string> <string name="dashboard_decrypt">Decrypt</string> <string name="dashboard_help">Help</string> @@ -350,13 +354,13 @@ <string name="help_about_version">Version:</string> <!-- Import from QR Code --> - <string name="import_from_qr_code_import">Import keyring(s) (only locally)</string> - <string name="import_from_qr_code_import_sign_and_upload">Import, Sign, and upload keyring(s)</string> + <string name="import_from_qr_code_import">Import key(s) (only locally)</string> + <string name="import_from_qr_code_import_sign_and_upload">Import, Sign, and upload key(s)</string> <string name="import_from_qr_code_finish">Finish</string> <!-- Intent labels --> <string name="intent_decrypt_file">OpenPGP: Decrypt File</string> - <string name="intent_import_key">OpenPGP: Import Keyring</string> + <string name="intent_import_key">OpenPGP: Import Key</string> <string name="intent_send_encrypt">OpenPGP: Encrypt</string> <string name="intent_send_decrypt">OpenPGP: Decrypt</string> @@ -374,4 +378,4 @@ <string name="api_register_disallow">Disallow access</string> <string name="api_register_error_select_key">Please select a key!</string> -</resources>
\ No newline at end of file +</resources> diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/KeychainApplication.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/KeychainApplication.java index dbe9f6394..e63c44760 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/KeychainApplication.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/KeychainApplication.java @@ -28,7 +28,7 @@ public class KeychainApplication extends Application { static { // Define Java Security Provider to be Bouncy Castle - Security.addProvider(new BouncyCastleProvider()); + Security.insertProviderAt(new BouncyCastleProvider(), 1); } @Override diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/PgpMain.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/PgpMain.java index 142dfec01..d236f9faa 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/PgpMain.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/PgpMain.java @@ -132,7 +132,8 @@ public class PgpMain { } // Not BC due to the use of Spongy Castle for Android - public static final String BOUNCY_CASTLE_PROVIDER_NAME = "SC"; + public static final String SC = BouncyCastleProvider.PROVIDER_NAME; + public static final String BOUNCY_CASTLE_PROVIDER_NAME = SC; private static final int[] PREFERRED_SYMMETRIC_ALGORITHMS = new int[] { SymmetricKeyAlgorithmTags.AES_256, SymmetricKeyAlgorithmTags.AES_192, @@ -323,8 +324,9 @@ public class PgpMain { } PGPSecretKeyRing newKeyRing = PGPSecretKeyRing.copyWithNewPassword(keyRing, - oldPassPhrase.toCharArray(), newPassPhrase.toCharArray(), keyRing.getSecretKey().getKeyEncryptionAlgorithm(), - new SecureRandom(), BOUNCY_CASTLE_PROVIDER_NAME); + new JcePBESecretKeyDecryptorBuilder( + new JcaPGPDigestCalculatorProviderBuilder().setProvider(BOUNCY_CASTLE_PROVIDER_NAME).build()).setProvider(BOUNCY_CASTLE_PROVIDER_NAME).build(oldPassPhrase.toCharArray()), + new JcePBESecretKeyEncryptorBuilder(keyRing.getSecretKey().getKeyEncryptionAlgorithm()).build(newPassPhrase.toCharArray())); updateProgress(progress, R.string.progress_savingKeyRing, 50, 100); diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 711cdae24..bf685d725 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -65,27 +65,26 @@ public class KeychainIntentService extends IntentService implements ProgressDial /* extras that can be given by intent */ public static final String EXTRA_MESSENGER = "messenger"; - public static final String EXTRA_ACTION = "action"; public static final String EXTRA_DATA = "data"; /* possible EXTRA_ACTIONs */ - public static final int ACTION_ENCRYPT_SIGN = 10; + public static final String ACTION_ENCRYPT_SIGN = Constants.INTENT_PREFIX + "ENCRYPT_SIGN"; - public static final int ACTION_DECRYPT_VERIFY = 20; + public static final String ACTION_DECRYPT_VERIFY = Constants.INTENT_PREFIX + "DECRYPT_VERIFY"; - public static final int ACTION_SAVE_KEYRING = 30; - public static final int ACTION_GENERATE_KEY = 31; - public static final int ACTION_GENERATE_DEFAULT_RSA_KEYS = 32; + public static final String ACTION_SAVE_KEYRING = Constants.INTENT_PREFIX + "SAVE_KEYRING"; + public static final String ACTION_GENERATE_KEY = Constants.INTENT_PREFIX + "GENERATE_KEY"; + public static final String ACTION_GENERATE_DEFAULT_RSA_KEYS = Constants.INTENT_PREFIX + "GENERATE_DEFAULT_RSA_KEYS"; - public static final int ACTION_DELETE_FILE_SECURELY = 40; + public static final String ACTION_DELETE_FILE_SECURELY = Constants.INTENT_PREFIX + "DELETE_FILE_SECURELY"; - public static final int ACTION_IMPORT_KEYRING = 50; - public static final int ACTION_EXPORT_KEYRING = 51; + public static final String ACTION_IMPORT_KEYRING = Constants.INTENT_PREFIX + "IMPORT_KEYRING"; + public static final String ACTION_EXPORT_KEYRING = Constants.INTENT_PREFIX + "EXPORT_KEYRING"; - public static final int ACTION_UPLOAD_KEYRING = 60; - public static final int ACTION_QUERY_KEYRING = 61; + public static final String ACTION_UPLOAD_KEYRING = Constants.INTENT_PREFIX + "UPLOAD_KEYRING"; + public static final String ACTION_QUERY_KEYRING = Constants.INTENT_PREFIX + "QUERY_KEYRING"; - public static final int ACTION_SIGN_KEYRING = 70; + public static final String ACTION_SIGN_KEYRING = Constants.INTENT_PREFIX + "SIGN_KEYRING"; /* keys for data bundle */ @@ -216,8 +215,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial return; } - if (!(extras.containsKey(EXTRA_MESSENGER) || extras.containsKey(EXTRA_DATA) || extras - .containsKey(EXTRA_ACTION))) { + if (!(extras.containsKey(EXTRA_MESSENGER) || extras.containsKey(EXTRA_DATA) || + (intent.getAction() == null))) { Log.e(Constants.TAG, "Extra bundle must contain a messenger, a data bundle, and an action!"); return; @@ -228,12 +227,10 @@ public class KeychainIntentService extends IntentService implements ProgressDial OtherHelper.logDebugBundle(data, "EXTRA_DATA"); - int action = extras.getInt(EXTRA_ACTION); - + String action = intent.getAction(); + // execute action from extra bundle - switch (action) { - case ACTION_ENCRYPT_SIGN: - + if( ACTION_ENCRYPT_SIGN.equals(action)) { try { /* Input */ int target = data.getInt(TARGET); @@ -382,10 +379,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - - break; - - case ACTION_DECRYPT_VERIFY: + } + else if(ACTION_DECRYPT_VERIFY.equals(action)) { try { /* Input */ int target = data.getInt(TARGET); @@ -514,11 +509,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - - break; - - case ACTION_SAVE_KEYRING: - + } + else if(ACTION_SAVE_KEYRING.equals(action)) { try { /* Input */ String oldPassPhrase = data.getString(SAVE_KEYRING_CURRENT_PASSPHRASE); @@ -554,11 +546,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - - break; - - case ACTION_GENERATE_KEY: - + } + else if(ACTION_GENERATE_KEY.equals(action)) { try { /* Input */ int algorithm = data.getInt(GENERATE_KEY_ALGORITHM); @@ -585,10 +574,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - - break; - - case ACTION_GENERATE_DEFAULT_RSA_KEYS: + } + else if(ACTION_GENERATE_DEFAULT_RSA_KEYS.equals(action)) { // generate one RSA 2048 key for signing and one subkey for encrypting! try { /* Input */ @@ -614,10 +601,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - - break; - - case ACTION_DELETE_FILE_SECURELY: + } + else if(ACTION_DELETE_FILE_SECURELY.equals(action)) { try { /* Input */ String deleteFile = data.getString(DELETE_FILE); @@ -638,10 +623,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - - break; - - case ACTION_IMPORT_KEYRING: + } + else if(ACTION_IMPORT_KEYRING.equals(action)) { try { /* Input */ @@ -688,10 +671,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - - break; - - case ACTION_EXPORT_KEYRING: + } + else if(ACTION_EXPORT_KEYRING.equals(action)) { try { /* Input */ @@ -739,10 +720,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - - break; - - case ACTION_UPLOAD_KEYRING: + } + else if(ACTION_UPLOAD_KEYRING.equals(action)) { try { /* Input */ @@ -766,10 +745,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - - break; - - case ACTION_QUERY_KEYRING: + } + else if(ACTION_QUERY_KEYRING.equals(action)) { try { /* Input */ @@ -797,10 +774,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - - break; - - case ACTION_SIGN_KEYRING: + } + else if(ACTION_SIGN_KEYRING.equals(action)) { try { /* Input */ @@ -824,13 +799,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial } catch (Exception e) { sendErrorToHandler(e); } - - break; - - default: - break; } - } private void sendErrorToHandler(Exception e) { diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DecryptActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DecryptActivity.java index ed81c2aa8..8b617b92b 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DecryptActivity.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/DecryptActivity.java @@ -758,7 +758,7 @@ public class DecryptActivity extends SherlockFragmentActivity { // fill values for this action Bundle data = new Bundle(); - intent.putExtra(KeychainIntentService.EXTRA_ACTION, KeychainIntentService.ACTION_DECRYPT_VERIFY); + intent.setAction(KeychainIntentService.ACTION_DECRYPT_VERIFY); // choose action based on input: decrypt stream, file or bytes if (mContentUri != null) { diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index bc4467967..b710e69cf 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -238,8 +238,7 @@ public class EditKeyActivity extends SherlockFragmentActivity { // Send all information needed to service generate keys in other thread Intent serviceIntent = new Intent(this, KeychainIntentService.class); - serviceIntent.putExtra(KeychainIntentService.EXTRA_ACTION, - KeychainIntentService.ACTION_GENERATE_DEFAULT_RSA_KEYS); + serviceIntent.setAction(KeychainIntentService.ACTION_GENERATE_DEFAULT_RSA_KEYS); // fill values for this action Bundle data = new Bundle(); @@ -438,8 +437,7 @@ public class EditKeyActivity extends SherlockFragmentActivity { // Send all information needed to service to edit key in other thread Intent intent = new Intent(this, KeychainIntentService.class); - intent.putExtra(KeychainIntentService.EXTRA_ACTION, - KeychainIntentService.ACTION_SAVE_KEYRING); + intent.setAction(KeychainIntentService.ACTION_SAVE_KEYRING); // fill values for this action Bundle data = new Bundle(); diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EncryptActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EncryptActivity.java index c6b2d196a..e38044526 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EncryptActivity.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/EncryptActivity.java @@ -693,7 +693,7 @@ public class EncryptActivity extends SherlockFragmentActivity { signOnly = (mEncryptionKeyIds == null || mEncryptionKeyIds.length == 0); } - intent.putExtra(KeychainIntentService.EXTRA_ACTION, KeychainIntentService.ACTION_ENCRYPT_SIGN); + intent.setAction(KeychainIntentService.ACTION_ENCRYPT_SIGN); // choose default settings, target and data bundle by target if (mStreamAndReturnUri != null) { @@ -778,7 +778,11 @@ public class EncryptActivity extends SherlockFragmentActivity { Log.d(Constants.TAG, "output: " + output); Intent emailIntent = new Intent(Intent.ACTION_SEND); - emailIntent.setType("text/plain; charset=utf-8"); + + //Type is set to text/plain so that encrypted messages can + //be sent with Whatsapp, Hangouts, SMS etc... + emailIntent.setType("text/plain"); + emailIntent.putExtra(Intent.EXTRA_TEXT, output); if (mSubject != null) { emailIntent.putExtra(Intent.EXTRA_SUBJECT, mSubject); diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java index cd5a12df0..cb186ba16 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java @@ -321,7 +321,7 @@ public class ImportKeysActivity extends SherlockFragmentActivity { // Send all information needed to service to import key in other thread Intent intent = new Intent(this, KeychainIntentService.class); - intent.putExtra(KeychainIntentService.EXTRA_ACTION, KeychainIntentService.ACTION_IMPORT_KEYRING); + intent.setAction(KeychainIntentService.ACTION_IMPORT_KEYRING); // fill values for this action Bundle data = new Bundle(); diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListActivity.java index a128263c1..d96308a40 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListActivity.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListActivity.java @@ -259,7 +259,7 @@ public class KeyListActivity extends SherlockFragmentActivity { // Send all information needed to service to export key in other thread Intent intent = new Intent(this, KeychainIntentService.class); - intent.putExtra(KeychainIntentService.EXTRA_ACTION, KeychainIntentService.ACTION_EXPORT_KEYRING); + intent.setAction(KeychainIntentService.ACTION_EXPORT_KEYRING); // fill values for this action Bundle data = new Bundle(); diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java index 648b09ef7..d04cdcaad 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java @@ -116,7 +116,7 @@ public class KeyListPublicFragment extends KeyListFragment implements case Id.menu.exportToServer: Intent uploadIntent = new Intent(mKeyListActivity, KeyServerUploadActivity.class); uploadIntent.setAction(KeyServerUploadActivity.ACTION_EXPORT_KEY_TO_SERVER); - uploadIntent.putExtra(KeyServerUploadActivity.EXTRA_KEYRING_ROW_ID, keyRingRowId); + uploadIntent.putExtra(KeyServerUploadActivity.EXTRA_KEYRING_ROW_ID, (int)keyRingRowId); startActivityForResult(uploadIntent, Id.request.export_to_server); return true; diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyServerQueryActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyServerQueryActivity.java index df8b7b374..b409698b0 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyServerQueryActivity.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyServerQueryActivity.java @@ -168,7 +168,7 @@ public class KeyServerQueryActivity extends SherlockFragmentActivity { // Send all information needed to service to query keys in other thread Intent intent = new Intent(this, KeychainIntentService.class); - intent.putExtra(KeychainIntentService.EXTRA_ACTION, KeychainIntentService.ACTION_QUERY_KEYRING); + intent.setAction(KeychainIntentService.ACTION_QUERY_KEYRING); // fill values for this action Bundle data = new Bundle(); diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyServerUploadActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyServerUploadActivity.java index 657044f2b..31486937d 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyServerUploadActivity.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyServerUploadActivity.java @@ -104,7 +104,7 @@ public class KeyServerUploadActivity extends SherlockFragmentActivity { // Send all information needed to service to upload key in other thread Intent intent = new Intent(this, KeychainIntentService.class); - intent.putExtra(KeychainIntentService.EXTRA_ACTION, KeychainIntentService.ACTION_UPLOAD_KEYRING); + intent.setAction(KeychainIntentService.ACTION_UPLOAD_KEYRING); // fill values for this action Bundle data = new Bundle(); diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SignKeyActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SignKeyActivity.java index 06d59b9a2..e8f989dff 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SignKeyActivity.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/SignKeyActivity.java @@ -199,8 +199,7 @@ public class SignKeyActivity extends SherlockFragmentActivity { // Send all information needed to service to sign key in other thread Intent intent = new Intent(this, KeychainIntentService.class); - intent.putExtra(KeychainIntentService.EXTRA_ACTION, - KeychainIntentService.ACTION_SIGN_KEYRING); + intent.setAction(KeychainIntentService.ACTION_SIGN_KEYRING); // fill values for this action Bundle data = new Bundle(); @@ -251,8 +250,7 @@ public class SignKeyActivity extends SherlockFragmentActivity { // Send all information needed to service to upload key in other thread Intent intent = new Intent(this, KeychainIntentService.class); - intent.putExtra(KeychainIntentService.EXTRA_ACTION, - KeychainIntentService.ACTION_UPLOAD_KEYRING); + intent.setAction(KeychainIntentService.ACTION_UPLOAD_KEYRING); // fill values for this action Bundle data = new Bundle(); diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java index defc3bc6c..303193c9a 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java @@ -76,7 +76,7 @@ public class DeleteFileDialogFragment extends DialogFragment { // fill values for this action Bundle data = new Bundle(); - intent.putExtra(KeychainIntentService.EXTRA_ACTION, KeychainIntentService.ACTION_DELETE_FILE_SECURELY); + intent.setAction(KeychainIntentService.ACTION_DELETE_FILE_SECURELY); data.putString(KeychainIntentService.DELETE_FILE, deleteFile); intent.putExtra(KeychainIntentService.EXTRA_DATA, data); diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index e9a5674cd..45c106eb9 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -59,10 +59,14 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { Button mExpiryDateButton; GregorianCalendar mExpiryDate; + private int mDatePickerResultCount = 0; private DatePickerDialog.OnDateSetListener mExpiryDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { - GregorianCalendar date = new GregorianCalendar(year, monthOfYear, dayOfMonth); - setExpiryDate(date); + if(mDatePickerResultCount++ == 0) // Note: Ignore results after the first one - android sends multiples. + { + GregorianCalendar date = new GregorianCalendar(year, monthOfYear, dayOfMonth); + setExpiryDate(date); + } } }; @@ -111,11 +115,15 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { DatePickerDialog dialog = new DatePickerDialog(getContext(), mExpiryDateSetListener, date.get(Calendar.YEAR), date.get(Calendar.MONTH), date.get(Calendar.DAY_OF_MONTH)); + mDatePickerResultCount = 0; dialog.setCancelable(true); dialog.setButton(Dialog.BUTTON_NEGATIVE, getContext() .getString(R.string.btn_noDate), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { - setExpiryDate(null); + if(mDatePickerResultCount++ == 0) // Note: Ignore results after the first one - android sends multiples. + { + setExpiryDate(null); + } } }); dialog.show(); diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/SectionView.java index 6d94889cf..997352769 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -43,6 +43,8 @@ import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.ImageView; @@ -186,14 +188,32 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor } } - final EditText keySize = (EditText) view.findViewById(R.id.create_key_size); - + final Spinner keySize = (Spinner) view.findViewById(R.id.create_key_size); + ArrayAdapter<CharSequence> keySizeAdapter = ArrayAdapter.createFromResource(getContext(), R.array.key_size_spinner_values, android.R.layout.simple_spinner_item); + keySizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + keySize.setAdapter(keySizeAdapter); + keySize.setSelection(2); // Default to 2048 for the key length dialog.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface di, int id) { di.dismiss(); try { - mNewKeySize = Integer.parseInt("" + keySize.getText()); + int nKeyIndex = keySize.getSelectedItemPosition(); + switch(nKeyIndex) + { + case 0: + mNewKeySize = 512; + break; + case 1: + mNewKeySize = 1024; + break; + case 2: + mNewKeySize = 2048; + break; + case 3: + mNewKeySize = 4096; + break; + } } catch (NumberFormatException e) { mNewKeySize = 0; } @@ -269,8 +289,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor // Send all information needed to service to edit key in other thread Intent intent = new Intent(mActivity, KeychainIntentService.class); - intent.putExtra(KeychainIntentService.EXTRA_ACTION, - KeychainIntentService.ACTION_GENERATE_KEY); + intent.setAction(KeychainIntentService.ACTION_GENERATE_KEY); // fill values for this action Bundle data = new Bundle(); |