From 6ac13d9f6933bf72950910b0e2831761dd8c434b Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Wed, 2 Apr 2014 15:31:03 +0200 Subject: [PATCH 1/3] Rename "pass phrase" to "passphrase" --- .../keychain/Constants.java | 2 +- .../keychain/helper/Preferences.java | 8 ++-- .../keychain/pgp/PgpKeyOperation.java | 42 +++++++++---------- .../service/KeychainIntentService.java | 18 ++++---- .../service/PassphraseCacheService.java | 2 +- .../keychain/service/SaveKeyringParcel.java | 12 +++--- .../keychain/ui/EditKeyActivity.java | 40 +++++++++--------- .../keychain/ui/EncryptFileFragment.java | 4 +- .../keychain/ui/EncryptMessageFragment.java | 4 +- .../keychain/ui/PreferencesActivity.java | 14 +++---- 10 files changed, 73 insertions(+), 73 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java index 5062800db..84c7f0f41 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java @@ -58,7 +58,7 @@ public final class Constants { public static final String DEFAULT_ASCII_ARMOUR = "defaultAsciiArmour"; public static final String DEFAULT_MESSAGE_COMPRESSION = "defaultMessageCompression"; public static final String DEFAULT_FILE_COMPRESSION = "defaultFileCompression"; - public static final String PASS_PHRASE_CACHE_TTL = "passphraseCacheTtl"; + public static final String PASSPHRASE_CACHE_TTL = "passphraseCacheTtl"; public static final String LANGUAGE = "language"; public static final String FORCE_V3_SIGNATURES = "forceV3Signatures"; public static final String KEY_SERVERS = "keyServers"; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java index 13b1df4d4..e91572ade 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java @@ -58,8 +58,8 @@ public class Preferences { editor.commit(); } - public long getPassPhraseCacheTtl() { - int ttl = mSharedPreferences.getInt(Constants.Pref.PASS_PHRASE_CACHE_TTL, 180); + public long getPassphraseCacheTtl() { + int ttl = mSharedPreferences.getInt(Constants.Pref.PASSPHRASE_CACHE_TTL, 180); // fix the value if it was set to "never" in previous versions, which currently is not // supported if (ttl == 0) { @@ -68,9 +68,9 @@ public class Preferences { return (long) ttl; } - public void setPassPhraseCacheTtl(int value) { + public void setPassphraseCacheTtl(int value) { SharedPreferences.Editor editor = mSharedPreferences.edit(); - editor.putInt(Constants.Pref.PASS_PHRASE_CACHE_TTL, value); + editor.putInt(Constants.Pref.PASSPHRASE_CACHE_TTL, value); editor.commit(); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index ceccf7a70..48b959738 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -195,25 +195,25 @@ public class PgpKeyOperation { sha1Calc, isMasterKey, keyEncryptor); } - public PGPSecretKeyRing changeSecretKeyPassphrase(PGPSecretKeyRing keyRing, String oldPassPhrase, - String newPassPhrase) + public PGPSecretKeyRing changeSecretKeyPassphrase(PGPSecretKeyRing keyRing, String oldPassphrase, + String newPassphrase) throws IOException, PGPException, NoSuchProviderException { updateProgress(R.string.progress_building_key, 0, 100); - if (oldPassPhrase == null) { - oldPassPhrase = ""; + if (oldPassphrase == null) { + oldPassphrase = ""; } - if (newPassPhrase == null) { - newPassPhrase = ""; + if (newPassphrase == null) { + newPassphrase = ""; } PGPSecretKeyRing newKeyRing = PGPSecretKeyRing.copyWithNewPassword( keyRing, new JcePBESecretKeyDecryptorBuilder(new JcaPGPDigestCalculatorProviderBuilder() .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build()).setProvider( - Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(oldPassPhrase.toCharArray()), + Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(oldPassphrase.toCharArray()), new JcePBESecretKeyEncryptorBuilder(keyRing.getSecretKey() - .getKeyEncryptionAlgorithm()).build(newPassPhrase.toCharArray())); + .getKeyEncryptionAlgorithm()).build(newPassphrase.toCharArray())); return newKeyRing; @@ -223,7 +223,7 @@ public class PgpKeyOperation { ArrayList userIds, ArrayList keys, ArrayList keysExpiryDates, ArrayList keysUsages, - String newPassPhrase, String oldPassPhrase) + String newPassphrase, String oldPassphrase) throws PgpGeneralMsgIdException, PGPException, SignatureException, IOException { int usageId = keysUsages.get(0); @@ -236,7 +236,7 @@ public class PgpKeyOperation { PGPPublicKey masterPublicKey = masterKey.getPublicKey(); PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider( - Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(oldPassPhrase.toCharArray()); + Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(oldPassphrase.toCharArray()); PGPPrivateKey masterPrivateKey = masterKey.extractPrivateKey(keyDecryptor); updateProgress(R.string.progress_certifying_master_key, 20, 100); @@ -294,7 +294,7 @@ public class PgpKeyOperation { PBESecretKeyEncryptor keyEncryptor = new JcePBESecretKeyEncryptorBuilder( PGPEncryptedData.CAST5, sha1Calc) .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( - newPassPhrase.toCharArray()); + newPassphrase.toCharArray()); PGPKeyRingGenerator keyGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, masterKeyPair, mainUserId, sha1Calc, hashedPacketsGen.generate(), @@ -310,7 +310,7 @@ public class PgpKeyOperation { PBESecretKeyDecryptor keyDecryptor2 = new JcePBESecretKeyDecryptorBuilder() .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( - oldPassPhrase.toCharArray()); + oldPassphrase.toCharArray()); PGPPrivateKey subPrivateKey = subKey.extractPrivateKey(keyDecryptor2); // TODO: now used without algorithm and creation time?! (APG 1) @@ -375,16 +375,16 @@ public class PgpKeyOperation { updateProgress(R.string.progress_building_key, 0, 100); PGPSecretKey masterKey = saveParcel.keys.get(0); - if (saveParcel.oldPassPhrase == null) { - saveParcel.oldPassPhrase = ""; + if (saveParcel.oldPassphrase == null) { + saveParcel.oldPassphrase = ""; } - if (saveParcel.newPassPhrase == null) { - saveParcel.newPassPhrase = ""; + if (saveParcel.newPassphrase == null) { + saveParcel.newPassphrase = ""; } if (mKR == null) { return buildNewSecretKey(saveParcel.userIDs, saveParcel.keys, saveParcel.keysExpiryDates, - saveParcel.keysUsages, saveParcel.newPassPhrase, saveParcel.oldPassPhrase); //new Keyring + saveParcel.keysUsages, saveParcel.newPassphrase, saveParcel.oldPassphrase); //new Keyring } /* @@ -423,7 +423,7 @@ public class PgpKeyOperation { String mainUserId = saveParcel.userIDs.get(0); PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider( - Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(saveParcel.oldPassPhrase.toCharArray()); + Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(saveParcel.oldPassphrase.toCharArray()); PGPPrivateKey masterPrivateKey = masterKey.extractPrivateKey(keyDecryptor); updateProgress(R.string.progress_certifying_master_key, 20, 100); @@ -565,7 +565,7 @@ public class PgpKeyOperation { PBESecretKeyEncryptor keyEncryptor = new JcePBESecretKeyEncryptorBuilder( PGPEncryptedData.CAST5, sha1Calc) .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( - saveParcel.oldPassPhrase.toCharArray()); + saveParcel.oldPassphrase.toCharArray()); //this generates one more signature than necessary... PGPKeyRingGenerator keyGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, @@ -586,7 +586,7 @@ public class PgpKeyOperation { } else { keyDecryptor2 = new JcePBESecretKeyDecryptorBuilder() .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( - saveParcel.oldPassPhrase.toCharArray()); + saveParcel.oldPassphrase.toCharArray()); } PGPPrivateKey subPrivateKey = subKey.extractPrivateKey(keyDecryptor2); PGPKeyPair subKeyPair = new PGPKeyPair(subPublicKey, subPrivateKey); @@ -667,7 +667,7 @@ public class PgpKeyOperation { PBESecretKeyEncryptor keyEncryptorNew = new JcePBESecretKeyEncryptorBuilder( PGPEncryptedData.CAST5, sha1Calc) .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( - saveParcel.newPassPhrase.toCharArray()); + saveParcel.newPassphrase.toCharArray()); //update the passphrase mKR = PGPSecretKeyRing.copyWithNewPassword(mKR, keyDecryptor, keyEncryptorNew); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 1c334e6d6..e9c949246 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -488,16 +488,16 @@ public class KeychainIntentService extends IntentService try { /* Input */ SaveKeyringParcel saveParams = data.getParcelable(SAVE_KEYRING_PARCEL); - String oldPassPhrase = saveParams.oldPassPhrase; - String newPassPhrase = saveParams.newPassPhrase; + String oldPassphrase = saveParams.oldPassphrase; + String newPassphrase = saveParams.newPassphrase; boolean canSign = true; if (data.containsKey(SAVE_KEYRING_CAN_SIGN)) { canSign = data.getBoolean(SAVE_KEYRING_CAN_SIGN); } - if (newPassPhrase == null) { - newPassPhrase = oldPassPhrase; + if (newPassphrase == null) { + newPassphrase = oldPassphrase; } long masterKeyId = saveParams.keys.get(0).getKeyID(); @@ -508,7 +508,7 @@ public class KeychainIntentService extends IntentService PGPSecretKeyRing keyRing = ProviderHelper .getPGPSecretKeyRingByKeyId(this, masterKeyId); keyRing = keyOperations.changeSecretKeyPassphrase(keyRing, - oldPassPhrase, newPassPhrase); + oldPassphrase, newPassphrase); setProgress(R.string.progress_saving_key_ring, 50, 100); ProviderHelper.saveKeyRing(this, keyRing); setProgress(R.string.progress_done, 100, 100); @@ -526,7 +526,7 @@ public class KeychainIntentService extends IntentService ProviderHelper.saveKeyRing(this, pair.second); setProgress(R.string.progress_done, 100, 100); } - PassphraseCacheService.addCachedPassphrase(this, masterKeyId, newPassPhrase); + PassphraseCacheService.addCachedPassphrase(this, masterKeyId, newPassphrase); /* Output */ sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY); @@ -816,9 +816,9 @@ public class KeychainIntentService extends IntentService ArrayList userIds = data.getStringArrayList(CERTIFY_KEY_UIDS); /* Operation */ - String signaturePassPhrase = PassphraseCacheService.getCachedPassphrase(this, + String signaturePassphrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId); - if (signaturePassPhrase == null) { + if (signaturePassphrase == null) { throw new PgpGeneralException("Unable to obtain passphrase"); } @@ -829,7 +829,7 @@ public class KeychainIntentService extends IntentService PGPSecretKey certificationKey = PgpKeyHelper.getCertificationKey(this, masterKeyId); publicKey = keyOperation.certifyKey(certificationKey, publicKey, - userIds, signaturePassPhrase); + userIds, signaturePassphrase); publicRing = PGPPublicKeyRing.insertPublicKey(publicRing, publicKey); // store the signed key in our local cache diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java index bdce9069e..a4b6ab6b9 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java @@ -95,7 +95,7 @@ public class PassphraseCacheService extends Service { Intent intent = new Intent(context, PassphraseCacheService.class); intent.setAction(ACTION_PASSPHRASE_CACHE_ADD); - intent.putExtra(EXTRA_TTL, Preferences.getPreferences(context).getPassPhraseCacheTtl()); + intent.putExtra(EXTRA_TTL, Preferences.getPreferences(context).getPassphraseCacheTtl()); intent.putExtra(EXTRA_PASSPHRASE, passphrase); intent.putExtra(EXTRA_KEY_ID, keyId); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java index 7012bfafd..7c2dcf2c1 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java @@ -38,8 +38,8 @@ public class SaveKeyringParcel implements Parcelable { public ArrayList deletedKeys; public ArrayList keysExpiryDates; public ArrayList keysUsages; - public String newPassPhrase; - public String oldPassPhrase; + public String newPassphrase; + public String oldPassphrase; public boolean[] newKeys; public ArrayList keys; public String originalPrimaryID; @@ -61,8 +61,8 @@ public class SaveKeyringParcel implements Parcelable { } keysExpiryDates = (ArrayList) source.readSerializable(); keysUsages = source.readArrayList(Integer.class.getClassLoader()); - newPassPhrase = source.readString(); - oldPassPhrase = source.readString(); + newPassphrase = source.readString(); + oldPassphrase = source.readString(); newKeys = source.createBooleanArray(); keys = PgpConversionHelper.BytesToPGPSecretKeyList(source.createByteArray()); originalPrimaryID = source.readString(); @@ -83,8 +83,8 @@ public class SaveKeyringParcel implements Parcelable { destination.writeByteArray(tmp); destination.writeSerializable(keysExpiryDates); destination.writeList(keysUsages); - destination.writeString(newPassPhrase); - destination.writeString(oldPassPhrase); + destination.writeString(newPassphrase); + destination.writeString(oldPassphrase); destination.writeBooleanArray(newKeys); destination.writeByteArray(PgpConversionHelper.PGPSecretKeyArrayListToBytes(keys)); destination.writeString(originalPrimaryID); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index e0286b566..30636f849 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -97,9 +97,9 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener private SectionView mKeysView; private String mCurrentPassphrase = null; - private String mNewPassPhrase = null; - private String mSavedNewPassPhrase = null; - private boolean mIsPassPhraseSet; + private String mNewPassphrase = null; + private String mSavedNewPassphrase = null; + private boolean mIsPassphraseSet; private boolean mNeedsSaving; private boolean mIsBrandNewKeyring = false; @@ -403,8 +403,8 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener mCurrentPassphrase = ""; buildLayout(false); - mIsPassPhraseSet = PassphraseCacheService.hasPassphrase(this, masterKeyId); - if (!mIsPassPhraseSet) { + mIsPassphraseSet = PassphraseCacheService.hasPassphrase(this, masterKeyId); + if (!mIsPassphraseSet) { // check "no passphrase" checkbox and remove button mNoPassphrase.setChecked(true); mChangePassphrase.setVisibility(View.GONE); @@ -423,10 +423,10 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener Bundle data = message.getData(); // set new returned passphrase! - mNewPassPhrase = data + mNewPassphrase = data .getString(SetPassphraseDialogFragment.MESSAGE_NEW_PASSPHRASE); - updatePassPhraseButtonText(); + updatePassphraseButtonText(); somethingChanged(); } } @@ -466,7 +466,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout container = (LinearLayout) findViewById(R.id.edit_key_container); - if (mIsPassPhraseSet) { + if (mIsPassphraseSet) { mChangePassphrase.setText(getString(R.string.btn_change_passphrase)); } mUserIdsView = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false); @@ -482,7 +482,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener mKeysView.setEditorListener(this); container.addView(mKeysView); - updatePassPhraseButtonText(); + updatePassphraseButtonText(); mChangePassphrase.setOnClickListener(new OnClickListener() { public void onClick(View v) { @@ -497,11 +497,11 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { // remove passphrase - mSavedNewPassPhrase = mNewPassPhrase; - mNewPassPhrase = ""; + mSavedNewPassphrase = mNewPassphrase; + mNewPassphrase = ""; mChangePassphrase.setVisibility(View.GONE); } else { - mNewPassPhrase = mSavedNewPassPhrase; + mNewPassphrase = mSavedNewPassphrase; mChangePassphrase.setVisibility(View.VISIBLE); } somethingChanged(); @@ -519,8 +519,8 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener public boolean isPassphraseSet() { if (mNoPassphrase.isChecked()) { return true; - } else if ((mIsPassPhraseSet) - || (mNewPassPhrase != null && !mNewPassPhrase.equals(""))) { + } else if ((mIsPassphraseSet) + || (mNewPassphrase != null && !mNewPassphrase.equals(""))) { return true; } else { return false; @@ -530,9 +530,9 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener public boolean hasPassphraseChanged() { if (mNoPassphrase != null) { if (mNoPassphrase.isChecked()) { - return mIsPassPhraseSet; + return mIsPassphraseSet; } else { - return (mNewPassPhrase != null && !mNewPassPhrase.equals("")); + return (mNewPassphrase != null && !mNewPassphrase.equals("")); } } else { return false; @@ -548,7 +548,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } String passphrase; - if (mIsPassPhraseSet) { + if (mIsPassphraseSet) { passphrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId); } else { passphrase = ""; @@ -638,8 +638,8 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener saveParams.deletedKeys = mKeysView.getDeletedKeys(); saveParams.keysExpiryDates = getKeysExpiryDates(mKeysView); saveParams.keysUsages = getKeysUsages(mKeysView); - saveParams.newPassPhrase = mNewPassPhrase; - saveParams.oldPassPhrase = mCurrentPassphrase; + saveParams.newPassphrase = mNewPassphrase; + saveParams.oldPassphrase = mCurrentPassphrase; saveParams.newKeys = toPrimitiveArray(mKeysView.getNewKeysArray()); saveParams.keys = getKeys(mKeysView); saveParams.originalPrimaryID = mUserIdsView.getOriginalPrimaryID(); @@ -819,7 +819,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener return keysExpiryDates; } - private void updatePassPhraseButtonText() { + private void updatePassphraseButtonText() { mChangePassphrase.setText(isPassphraseSet() ? getString(R.string.btn_change_passphrase) : getString(R.string.btn_set_passphrase)); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java index c8ea6ffb7..8b440a552 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java @@ -224,9 +224,9 @@ public class EncryptFileFragment extends Fragment { if (mEncryptInterface.isModeSymmetric()) { // symmetric encryption - boolean gotPassPhrase = (mEncryptInterface.getPassphrase() != null + boolean gotPassphrase = (mEncryptInterface.getPassphrase() != null && mEncryptInterface.getPassphrase().length() != 0); - if (!gotPassPhrase) { + if (!gotPassphrase) { AppMsg.makeText(getActivity(), R.string.passphrase_must_not_be_empty, AppMsg.STYLE_ALERT) .show(); return; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java index 4522acf4e..a7818a1d8 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java @@ -125,9 +125,9 @@ public class EncryptMessageFragment extends Fragment { if (mEncryptInterface.isModeSymmetric()) { // symmetric encryption - boolean gotPassPhrase = (mEncryptInterface.getPassphrase() != null + boolean gotPassphrase = (mEncryptInterface.getPassphrase() != null && mEncryptInterface.getPassphrase().length() != 0); - if (!gotPassPhrase) { + if (!gotPassphrase) { AppMsg.makeText(getActivity(), R.string.passphrase_must_not_be_empty, AppMsg.STYLE_ALERT) .show(); return; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java index 54d37c72f..57841edde 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java @@ -61,8 +61,8 @@ public class PreferencesActivity extends PreferenceActivity { if (action != null && action.equals(ACTION_PREFS_GEN)) { addPreferencesFromResource(R.xml.gen_preferences); - initializePassPassPhraceCacheTtl( - (IntegerListPreference) findPreference(Constants.Pref.PASS_PHRASE_CACHE_TTL)); + initializePassPassphraceCacheTtl( + (IntegerListPreference) findPreference(Constants.Pref.PASSPHRASE_CACHE_TTL)); mKeyServerPreference = (PreferenceScreen) findPreference(Constants.Pref.KEY_SERVERS); String servers[] = sPreferences.getKeyServers(); @@ -165,8 +165,8 @@ public class PreferencesActivity extends PreferenceActivity { // Load the preferences from an XML resource addPreferencesFromResource(R.xml.gen_preferences); - initializePassPassPhraceCacheTtl( - (IntegerListPreference) findPreference(Constants.Pref.PASS_PHRASE_CACHE_TTL)); + initializePassPassphraceCacheTtl( + (IntegerListPreference) findPreference(Constants.Pref.PASSPHRASE_CACHE_TTL)); mKeyServerPreference = (PreferenceScreen) findPreference(Constants.Pref.KEY_SERVERS); String servers[] = sPreferences.getKeyServers(); @@ -261,15 +261,15 @@ public class PreferencesActivity extends PreferenceActivity { || super.isValidFragment(fragmentName); } - private static void initializePassPassPhraceCacheTtl(final IntegerListPreference mPassphraseCacheTtl) { - mPassphraseCacheTtl.setValue("" + sPreferences.getPassPhraseCacheTtl()); + private static void initializePassPassphraceCacheTtl(final IntegerListPreference mPassphraseCacheTtl) { + mPassphraseCacheTtl.setValue("" + sPreferences.getPassphraseCacheTtl()); mPassphraseCacheTtl.setSummary(mPassphraseCacheTtl.getEntry()); mPassphraseCacheTtl .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { mPassphraseCacheTtl.setValue(newValue.toString()); mPassphraseCacheTtl.setSummary(mPassphraseCacheTtl.getEntry()); - sPreferences.setPassPhraseCacheTtl(Integer.parseInt(newValue.toString())); + sPreferences.setPassphraseCacheTtl(Integer.parseInt(newValue.toString())); return false; } }); From c4c9713da467d2d1f1d7d1cb50d72524d769b21b Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Wed, 2 Apr 2014 15:36:32 +0200 Subject: [PATCH 2/3] Rename "armour" to "armor" --- .../sufficientlysecure/keychain/Constants.java | 2 +- .../keychain/helper/Preferences.java | 8 ++++---- .../keychain/ui/EncryptFileFragment.java | 4 ++-- .../keychain/ui/PreferencesActivity.java | 18 +++++++++--------- .../layout/encrypt_content_adv_settings.xml | 4 ++-- .../src/main/res/xml/adv_preferences.xml | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java index 84c7f0f41..5b9f53b09 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java @@ -55,7 +55,7 @@ public final class Constants { public static final class Pref { public static final String DEFAULT_ENCRYPTION_ALGORITHM = "defaultEncryptionAlgorithm"; public static final String DEFAULT_HASH_ALGORITHM = "defaultHashAlgorithm"; - public static final String DEFAULT_ASCII_ARMOUR = "defaultAsciiArmour"; + public static final String DEFAULT_ASCII_ARMOR = "defaultAsciiArmor"; public static final String DEFAULT_MESSAGE_COMPRESSION = "defaultMessageCompression"; public static final String DEFAULT_FILE_COMPRESSION = "defaultFileCompression"; public static final String PASSPHRASE_CACHE_TTL = "passphraseCacheTtl"; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java index e91572ade..ca5555fea 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java @@ -118,13 +118,13 @@ public class Preferences { editor.commit(); } - public boolean getDefaultAsciiArmour() { - return mSharedPreferences.getBoolean(Constants.Pref.DEFAULT_ASCII_ARMOUR, false); + public boolean getDefaultAsciiArmor() { + return mSharedPreferences.getBoolean(Constants.Pref.DEFAULT_ASCII_ARMOR, false); } - public void setDefaultAsciiArmour(boolean value) { + public void setDefaultAsciiArmor(boolean value) { SharedPreferences.Editor editor = mSharedPreferences.edit(); - editor.putBoolean(Constants.Pref.DEFAULT_ASCII_ARMOUR, value); + editor.putBoolean(Constants.Pref.DEFAULT_ASCII_ARMOR, value); editor.commit(); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java index 8b440a552..01422ea13 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java @@ -138,8 +138,8 @@ public class EncryptFileFragment extends Fragment { mDeleteAfter = (CheckBox) view.findViewById(R.id.deleteAfterEncryption); mShareAfter = (CheckBox) view.findViewById(R.id.shareAfterEncryption); - mAsciiArmor = (CheckBox) view.findViewById(R.id.asciiArmour); - mAsciiArmor.setChecked(Preferences.getPreferences(getActivity()).getDefaultAsciiArmour()); + mAsciiArmor = (CheckBox) view.findViewById(R.id.asciiArmor); + mAsciiArmor.setChecked(Preferences.getPreferences(getActivity()).getDefaultAsciiArmor()); return view; } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java index 57841edde..265bb2139 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java @@ -110,8 +110,8 @@ public class PreferencesActivity extends PreferenceActivity { (IntegerListPreference) findPreference(Constants.Pref.DEFAULT_FILE_COMPRESSION), entries, values); - initializeAsciiArmour( - (CheckBoxPreference) findPreference(Constants.Pref.DEFAULT_ASCII_ARMOUR)); + initializeAsciiArmor( + (CheckBoxPreference) findPreference(Constants.Pref.DEFAULT_ASCII_ARMOR)); initializeForceV3Signatures( (CheckBoxPreference) findPreference(Constants.Pref.FORCE_V3_SIGNATURES)); @@ -247,8 +247,8 @@ public class PreferencesActivity extends PreferenceActivity { (IntegerListPreference) findPreference(Constants.Pref.DEFAULT_FILE_COMPRESSION), entries, values); - initializeAsciiArmour( - (CheckBoxPreference) findPreference(Constants.Pref.DEFAULT_ASCII_ARMOUR)); + initializeAsciiArmor( + (CheckBoxPreference) findPreference(Constants.Pref.DEFAULT_ASCII_ARMOR)); initializeForceV3Signatures( (CheckBoxPreference) findPreference(Constants.Pref.FORCE_V3_SIGNATURES)); @@ -362,12 +362,12 @@ public class PreferencesActivity extends PreferenceActivity { }); } - private static void initializeAsciiArmour(final CheckBoxPreference mAsciiArmour) { - mAsciiArmour.setChecked(sPreferences.getDefaultAsciiArmour()); - mAsciiArmour.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + private static void initializeAsciiArmor(final CheckBoxPreference mAsciiArmor) { + mAsciiArmor.setChecked(sPreferences.getDefaultAsciiArmor()); + mAsciiArmor.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { - mAsciiArmour.setChecked((Boolean) newValue); - sPreferences.setDefaultAsciiArmour((Boolean) newValue); + mAsciiArmor.setChecked((Boolean) newValue); + sPreferences.setDefaultAsciiArmor((Boolean) newValue); return false; } }); diff --git a/OpenPGP-Keychain/src/main/res/layout/encrypt_content_adv_settings.xml b/OpenPGP-Keychain/src/main/res/layout/encrypt_content_adv_settings.xml index 2281759d1..ac990653a 100644 --- a/OpenPGP-Keychain/src/main/res/layout/encrypt_content_adv_settings.xml +++ b/OpenPGP-Keychain/src/main/res/layout/encrypt_content_adv_settings.xml @@ -54,10 +54,10 @@ android:orientation="horizontal"> - \ No newline at end of file + diff --git a/OpenPGP-Keychain/src/main/res/xml/adv_preferences.xml b/OpenPGP-Keychain/src/main/res/xml/adv_preferences.xml index 2705bd22f..03f93b051 100644 --- a/OpenPGP-Keychain/src/main/res/xml/adv_preferences.xml +++ b/OpenPGP-Keychain/src/main/res/xml/adv_preferences.xml @@ -35,7 +35,7 @@ android:title="@string/label_file_compression" /> @@ -45,4 +45,4 @@ android:persistent="false" android:title="@string/label_force_v3_signature" /> - \ No newline at end of file + From 7a66ccb5ee5d3de8f3814267969139397de45e12 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Wed, 2 Apr 2014 15:43:29 +0200 Subject: [PATCH 3/3] Rename "canEdit" to "canBeEdited" --- .../keychain/ui/EditKeyActivity.java | 4 ++-- .../keychain/ui/widget/KeyEditor.java | 4 ++-- .../keychain/ui/widget/SectionView.java | 14 +++++++------- .../keychain/ui/widget/UserIdEditor.java | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 30636f849..b0cca4a7a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -471,13 +471,13 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } mUserIdsView = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false); mUserIdsView.setType(Id.type.user_id); - mUserIdsView.setCanEdit(mMasterCanSign); + mUserIdsView.setCanBeEdited(mMasterCanSign); mUserIdsView.setUserIds(mUserIds); mUserIdsView.setEditorListener(this); container.addView(mUserIdsView); mKeysView = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false); mKeysView.setType(Id.type.key); - mKeysView.setCanEdit(mMasterCanSign); + mKeysView.setCanBeEdited(mMasterCanSign); mKeysView.setKeys(mKeys, mKeysUsages, newKeys); mKeysView.setEditorListener(this); container.addView(mKeysView); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index 5fd06f4fc..c7bd1c987 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -196,8 +196,8 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { super.onFinishInflate(); } - public void setCanEdit(boolean bCanEdit) { - if (!bCanEdit) { + public void setCanBeEdited(boolean canBeEdited) { + if (!canBeEdited) { mDeleteButton.setVisibility(View.INVISIBLE); mExpiryDateButton.setEnabled(false); mChkSign.setEnabled(false); //certify is always disabled diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index 1f388e865..fb59cd3b7 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -64,7 +64,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor private boolean mOldItemDeleted = false; private ArrayList mDeletedIDs = new ArrayList(); private ArrayList mDeletedKeys = new ArrayList(); - private boolean mCanEdit = true; + private boolean mCanBeEdited = true; private ActionBarActivity mActivity; @@ -107,9 +107,9 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor } } - public void setCanEdit(boolean bCanEdit) { - mCanEdit = bCanEdit; - if (!mCanEdit) { + public void setCanBeEdited(boolean canBeEdited) { + mCanBeEdited = canBeEdited; + if (!mCanBeEdited) { mPlusButton.setVisibility(View.INVISIBLE); } } @@ -265,7 +265,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor * {@inheritDoc} */ public void onClick(View v) { - if (mCanEdit) { + if (mCanBeEdited) { switch (mType) { case Id.type.user_id: { UserIdEditor view = (UserIdEditor) mInflater.inflate( @@ -315,7 +315,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor mEditors, false); view.setEditorListener(this); view.setValue(userId, mEditors.getChildCount() == 0, false); - view.setCanEdit(mCanEdit); + view.setCanBeEdited(mCanBeEdited); mEditors.addView(view); } @@ -336,7 +336,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor view.setEditorListener(this); boolean isMasterKey = (mEditors.getChildCount() == 0); view.setValue(list.get(i), isMasterKey, usages.get(i), newKeys); - view.setCanEdit(mCanEdit); + view.setCanBeEdited(mCanBeEdited); mEditors.addView(view); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java index 4b2387afb..2253872d5 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java @@ -52,8 +52,8 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene private boolean mOriginallyMainUserID; private boolean mIsNewId; - public void setCanEdit(boolean bCanEdit) { - if (!bCanEdit) { + public void setCanBeEdited(boolean canBeEdited) { + if (!canBeEdited) { mDeleteButton.setVisibility(View.INVISIBLE); mName.setEnabled(false); mIsMainUserId.setEnabled(false);