From 592ab31d866c9b58ce6e831b184301f665558e11 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Wed, 2 Apr 2014 01:58:31 +0200 Subject: [PATCH] Add missing and curly brackets and fix others Style guide demands them even for single-line blocks, and opening curly brackets never appear on a line on their own. --- .../keychain/pgp/PgpKeyHelper.java | 15 +++-- .../keychain/service/SaveKeyringParcel.java | 9 ++- .../keychain/ui/EditKeyActivity.java | 8 ++- .../ui/dialog/DeleteKeyDialogFragment.java | 3 +- .../keychain/ui/widget/KeyEditor.java | 19 ++++--- .../keychain/ui/widget/SectionView.java | 55 +++++++++---------- .../keychain/ui/widget/UserIdEditor.java | 12 ++-- 7 files changed, 61 insertions(+), 60 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java index 89352ef31..f4a5b8d4e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java @@ -300,8 +300,7 @@ public class PgpKeyHelper { return userId; } - public static int getKeyUsage(PGPSecretKey key) - { + public static int getKeyUsage(PGPSecretKey key) { return getKeyUsage(key.getPublicKey()); } @@ -310,13 +309,19 @@ public class PgpKeyHelper { int usage = 0; if (key.getVersion() >= 4) { for (PGPSignature sig : new IterableIterator(key.getSignatures())) { - if (key.isMasterKey() && sig.getKeyID() != key.getKeyID()) continue; + if (key.isMasterKey() && sig.getKeyID() != key.getKeyID()) { + continue; + } PGPSignatureSubpacketVector hashed = sig.getHashedSubPackets(); - if (hashed != null) usage |= hashed.getKeyFlags(); + if (hashed != null) { + usage |= hashed.getKeyFlags(); + } PGPSignatureSubpacketVector unhashed = sig.getUnhashedSubPackets(); - if (unhashed != null) usage |= unhashed.getKeyFlags(); + if (unhashed != null) { + usage |= unhashed.getKeyFlags(); + } } } return usage; 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 cc0f94b9b..7012bfafd 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 @@ -69,8 +69,7 @@ public class SaveKeyringParcel implements Parcelable { } @Override - public void writeToParcel(Parcel destination, int flags) - { + public void writeToParcel(Parcel destination, int flags) { destination.writeSerializable(userIDs); //might not be the best method to store. destination.writeSerializable(originalIDs); destination.writeSerializable(deletedIDs); @@ -78,8 +77,9 @@ public class SaveKeyringParcel implements Parcelable { destination.writeByte((byte) (primaryIDChanged ? 1 : 0)); destination.writeBooleanArray(moddedKeys); byte[] tmp = null; - if (deletedKeys.size() != 0) + if (deletedKeys.size() != 0) { tmp = PgpConversionHelper.PGPSecretKeyArrayListToBytes(deletedKeys); + } destination.writeByteArray(tmp); destination.writeSerializable(keysExpiryDates); destination.writeList(keysUsages); @@ -101,8 +101,7 @@ public class SaveKeyringParcel implements Parcelable { }; @Override - public int describeContents() - { + public int describeContents() { return 0; } } 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 a8b3e29ed..d0a0d20ad 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 @@ -391,8 +391,9 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener if (!isSet) { isSet = true; String[] parts = PgpKeyHelper.splitUserId(userId); - if (parts[0] != null) + if (parts[0] != null) { setTitle(parts[0]); + } } mUserIds.add(userId); } @@ -547,10 +548,11 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } String passphrase; - if (mIsPassPhraseSet) + if (mIsPassPhraseSet) { passphrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId); - else + } else { passphrase = ""; + } if (passphrase == null) { showPassphraseDialog(masterKeyId); } else { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java index a467c779c..4de332d3c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java @@ -148,8 +148,9 @@ public class DeleteKeyDialogFragment extends DialogFragment { String selectionIDs = ""; for (int i = 0; i < keyRingRowIds.length; i++) { selectionIDs += "'" + String.valueOf(keyRingRowIds[i]) + "'"; - if (i + 1 < keyRingRowIds.length) + if (i + 1 < keyRingRowIds.length) { selectionIDs += ","; + } } selection += selectionIDs + ")"; 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 de26e20a3..5fd06f4fc 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 @@ -255,8 +255,9 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { } else { mUsage = PgpKeyHelper.getKeyUsage(key); mOriginalUsage = mUsage; - if (key.isMasterKey()) + if (key.isMasterKey()) { mChkCertify.setChecked(PgpKeyHelper.isCertificationKey(key)); + } mChkSign.setChecked(PgpKeyHelper.isSigningKey(key)); mChkEncrypt.setChecked(PgpKeyHelper.isEncryptionKey(key)); mChkAuthenticate.setChecked(PgpKeyHelper.isAuthenticationKey(key)); @@ -332,10 +333,10 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { return mUsage; } - public boolean needsSaving() - { - if (mIsNewKey) + public boolean needsSaving() { + if (mIsNewKey) { return true; + } boolean retval = (getUsage() != mOriginalUsage); @@ -345,21 +346,21 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { if (mOEDNull != mEDNull) { dateChanged = true; } else { - if(mOEDNull) //both null, no change + if (mOEDNull) { + //both null, no change dateChanged = false; - else + } else { dateChanged = ((mExpiryDate.compareTo(mOriginalExpiryDate)) != 0); + } } retval |= dateChanged; return retval; } - public boolean getIsNewKey() - { + public boolean getIsNewKey() { return mIsNewKey; } - } class ExpiryDatePickerDialog extends DatePickerDialog { 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 150f6e221..1f388e865 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 @@ -164,34 +164,34 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor mEditors.setVisibility(hasChildren ? View.VISIBLE : View.GONE); } - public boolean needsSaving() - { + public boolean needsSaving() { //check each view for needs saving, take account of deleted items boolean ret = mOldItemDeleted; for (int i = 0; i < mEditors.getChildCount(); ++i) { Editor editor = (Editor) mEditors.getChildAt(i); ret |= editor.needsSaving(); - if (mType == Id.type.user_id) - ret |= ((UserIdEditor)editor).primarySwapped(); + if (mType == Id.type.user_id) { + ret |= ((UserIdEditor) editor).primarySwapped(); + } } return ret; } - public boolean primaryChanged() - { + public boolean primaryChanged() { boolean ret = false; for (int i = 0; i < mEditors.getChildCount(); ++i) { Editor editor = (Editor) mEditors.getChildAt(i); - if (mType == Id.type.user_id) - ret |= ((UserIdEditor)editor).primarySwapped(); + if (mType == Id.type.user_id) { + ret |= ((UserIdEditor) editor).primarySwapped(); + } } return ret; } - public String getOriginalPrimaryID() - { //NB: this will have to change when we change how Primary IDs are chosen, and so we need to be - // careful about where Master key capabilities are stored... multiple primaries and - // revoked ones make this harder than the simple case we are continuing to assume here + public String getOriginalPrimaryID() { + //NB: this will have to change when we change how Primary IDs are chosen, and so we need to be + // careful about where Master key capabilities are stored... multiple primaries and + // revoked ones make this harder than the simple case we are continuing to assume here for (int i = 0; i < mEditors.getChildCount(); ++i) { Editor editor = (Editor) mEditors.getChildAt(i); if (mType == Id.type.user_id) { @@ -203,16 +203,16 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor return null; } - public ArrayList getOriginalIDs() - { + public ArrayList getOriginalIDs() { ArrayList orig = new ArrayList(); if (mType == Id.type.user_id) { for (int i = 0; i < mEditors.getChildCount(); ++i) { UserIdEditor editor = (UserIdEditor) mEditors.getChildAt(i); - if (editor.isMainUserId()) + if (editor.isMainUserId()) { orig.add(0, editor.getOriginalID()); - else + } else { orig.add(editor.getOriginalID()); + } } return orig; } else { @@ -220,18 +220,15 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor } } - public ArrayList getDeletedIDs() - { + public ArrayList getDeletedIDs() { return mDeletedIDs; } - public ArrayList getDeletedKeys() - { + public ArrayList getDeletedKeys() { return mDeletedKeys; } - public List getNeedsSavingArray() - { + public List getNeedsSavingArray() { ArrayList mList = new ArrayList(); for (int i = 0; i < mEditors.getChildCount(); ++i) { Editor editor = (Editor) mEditors.getChildAt(i); @@ -240,21 +237,20 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor return mList; } - public List getNewIDFlags() - { + public List getNewIDFlags() { ArrayList mList = new ArrayList(); for (int i = 0; i < mEditors.getChildCount(); ++i) { UserIdEditor editor = (UserIdEditor) mEditors.getChildAt(i); - if (editor.isMainUserId()) + if (editor.isMainUserId()) { mList.add(0, editor.getIsNewID()); - else + } else { mList.add(editor.getIsNewID()); + } } return mList; } - public List getNewKeysArray() - { + public List getNewKeysArray() { ArrayList mList = new ArrayList(); if (mType == Id.type.key) { for (int i = 0; i < mEditors.getChildCount(); ++i) { @@ -420,8 +416,9 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor mEditors, false); view.setEditorListener(SectionView.this); int usage = 0; - if (mEditors.getChildCount() == 0) + if (mEditors.getChildCount() == 0) { usage = PGPKeyFlags.CAN_CERTIFY; + } view.setValue(newKey, newKey.isMasterKey(), usage, true); mEditors.addView(view); SectionView.this.updateEditorsVisible(); 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 71f5f0d86..b21b99254 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 @@ -84,8 +84,7 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene } @Override - public void afterTextChanged(Editable s) - { + public void afterTextChanged(Editable s) { if (mEditorListener != null) { mEditorListener.onEdited(); } @@ -246,18 +245,15 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene return retval; } - public boolean getIsOriginallyMainUserID() - { + public boolean getIsOriginallyMainUserID() { return mOriginallyMainUserID; } - public boolean primarySwapped() - { + public boolean primarySwapped() { return (mOriginallyMainUserID != isMainUserId()); } - public String getOriginalID() - { + public String getOriginalID() { return mOriginalID; }