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.
This commit is contained in:
Thialfihar 2014-04-02 01:58:31 +02:00
parent 82e5d14fb1
commit 592ab31d86
7 changed files with 61 additions and 60 deletions

View File

@ -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<PGPSignature>(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;

View File

@ -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;
}
}

View File

@ -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 {

View File

@ -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 + ")";

View File

@ -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 {

View File

@ -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<String> getOriginalIDs()
{
public ArrayList<String> getOriginalIDs() {
ArrayList<String> orig = new ArrayList<String>();
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<String> getDeletedIDs()
{
public ArrayList<String> getDeletedIDs() {
return mDeletedIDs;
}
public ArrayList<PGPSecretKey> getDeletedKeys()
{
public ArrayList<PGPSecretKey> getDeletedKeys() {
return mDeletedKeys;
}
public List<Boolean> getNeedsSavingArray()
{
public List<Boolean> getNeedsSavingArray() {
ArrayList<Boolean> mList = new ArrayList<Boolean>();
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<Boolean> getNewIDFlags()
{
public List<Boolean> getNewIDFlags() {
ArrayList<Boolean> mList = new ArrayList<Boolean>();
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<Boolean> getNewKeysArray()
{
public List<Boolean> getNewKeysArray() {
ArrayList<Boolean> mList = new ArrayList<Boolean>();
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();

View File

@ -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;
}