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; return userId;
} }
public static int getKeyUsage(PGPSecretKey key) public static int getKeyUsage(PGPSecretKey key) {
{
return getKeyUsage(key.getPublicKey()); return getKeyUsage(key.getPublicKey());
} }
@ -310,13 +309,19 @@ public class PgpKeyHelper {
int usage = 0; int usage = 0;
if (key.getVersion() >= 4) { if (key.getVersion() >= 4) {
for (PGPSignature sig : new IterableIterator<PGPSignature>(key.getSignatures())) { 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(); PGPSignatureSubpacketVector hashed = sig.getHashedSubPackets();
if (hashed != null) usage |= hashed.getKeyFlags(); if (hashed != null) {
usage |= hashed.getKeyFlags();
}
PGPSignatureSubpacketVector unhashed = sig.getUnhashedSubPackets(); PGPSignatureSubpacketVector unhashed = sig.getUnhashedSubPackets();
if (unhashed != null) usage |= unhashed.getKeyFlags(); if (unhashed != null) {
usage |= unhashed.getKeyFlags();
}
} }
} }
return usage; return usage;

View File

@ -69,8 +69,7 @@ public class SaveKeyringParcel implements Parcelable {
} }
@Override @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(userIDs); //might not be the best method to store.
destination.writeSerializable(originalIDs); destination.writeSerializable(originalIDs);
destination.writeSerializable(deletedIDs); destination.writeSerializable(deletedIDs);
@ -78,8 +77,9 @@ public class SaveKeyringParcel implements Parcelable {
destination.writeByte((byte) (primaryIDChanged ? 1 : 0)); destination.writeByte((byte) (primaryIDChanged ? 1 : 0));
destination.writeBooleanArray(moddedKeys); destination.writeBooleanArray(moddedKeys);
byte[] tmp = null; byte[] tmp = null;
if (deletedKeys.size() != 0) if (deletedKeys.size() != 0) {
tmp = PgpConversionHelper.PGPSecretKeyArrayListToBytes(deletedKeys); tmp = PgpConversionHelper.PGPSecretKeyArrayListToBytes(deletedKeys);
}
destination.writeByteArray(tmp); destination.writeByteArray(tmp);
destination.writeSerializable(keysExpiryDates); destination.writeSerializable(keysExpiryDates);
destination.writeList(keysUsages); destination.writeList(keysUsages);
@ -101,8 +101,7 @@ public class SaveKeyringParcel implements Parcelable {
}; };
@Override @Override
public int describeContents() public int describeContents() {
{
return 0; return 0;
} }
} }

View File

@ -391,9 +391,10 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
if (!isSet) { if (!isSet) {
isSet = true; isSet = true;
String[] parts = PgpKeyHelper.splitUserId(userId); String[] parts = PgpKeyHelper.splitUserId(userId);
if (parts[0] != null) if (parts[0] != null) {
setTitle(parts[0]); setTitle(parts[0]);
} }
}
mUserIds.add(userId); mUserIds.add(userId);
} }
} }
@ -547,10 +548,11 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
} }
String passphrase; String passphrase;
if (mIsPassPhraseSet) if (mIsPassPhraseSet) {
passphrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId); passphrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId);
else } else {
passphrase = ""; passphrase = "";
}
if (passphrase == null) { if (passphrase == null) {
showPassphraseDialog(masterKeyId); showPassphraseDialog(masterKeyId);
} else { } else {

View File

@ -148,9 +148,10 @@ public class DeleteKeyDialogFragment extends DialogFragment {
String selectionIDs = ""; String selectionIDs = "";
for (int i = 0; i < keyRingRowIds.length; i++) { for (int i = 0; i < keyRingRowIds.length; i++) {
selectionIDs += "'" + String.valueOf(keyRingRowIds[i]) + "'"; selectionIDs += "'" + String.valueOf(keyRingRowIds[i]) + "'";
if (i + 1 < keyRingRowIds.length) if (i + 1 < keyRingRowIds.length) {
selectionIDs += ","; selectionIDs += ",";
} }
}
selection += selectionIDs + ")"; selection += selectionIDs + ")";
Cursor cursor = activity.getContentResolver().query(queryUri, projection, Cursor cursor = activity.getContentResolver().query(queryUri, projection,

View File

@ -255,8 +255,9 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
} else { } else {
mUsage = PgpKeyHelper.getKeyUsage(key); mUsage = PgpKeyHelper.getKeyUsage(key);
mOriginalUsage = mUsage; mOriginalUsage = mUsage;
if (key.isMasterKey()) if (key.isMasterKey()) {
mChkCertify.setChecked(PgpKeyHelper.isCertificationKey(key)); mChkCertify.setChecked(PgpKeyHelper.isCertificationKey(key));
}
mChkSign.setChecked(PgpKeyHelper.isSigningKey(key)); mChkSign.setChecked(PgpKeyHelper.isSigningKey(key));
mChkEncrypt.setChecked(PgpKeyHelper.isEncryptionKey(key)); mChkEncrypt.setChecked(PgpKeyHelper.isEncryptionKey(key));
mChkAuthenticate.setChecked(PgpKeyHelper.isAuthenticationKey(key)); mChkAuthenticate.setChecked(PgpKeyHelper.isAuthenticationKey(key));
@ -332,10 +333,10 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
return mUsage; return mUsage;
} }
public boolean needsSaving() public boolean needsSaving() {
{ if (mIsNewKey) {
if (mIsNewKey)
return true; return true;
}
boolean retval = (getUsage() != mOriginalUsage); boolean retval = (getUsage() != mOriginalUsage);
@ -345,21 +346,21 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
if (mOEDNull != mEDNull) { if (mOEDNull != mEDNull) {
dateChanged = true; dateChanged = true;
} else { } else {
if(mOEDNull) //both null, no change if (mOEDNull) {
//both null, no change
dateChanged = false; dateChanged = false;
else } else {
dateChanged = ((mExpiryDate.compareTo(mOriginalExpiryDate)) != 0); dateChanged = ((mExpiryDate.compareTo(mOriginalExpiryDate)) != 0);
} }
}
retval |= dateChanged; retval |= dateChanged;
return retval; return retval;
} }
public boolean getIsNewKey() public boolean getIsNewKey() {
{
return mIsNewKey; return mIsNewKey;
} }
} }
class ExpiryDatePickerDialog extends DatePickerDialog { class ExpiryDatePickerDialog extends DatePickerDialog {

View File

@ -164,32 +164,32 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
mEditors.setVisibility(hasChildren ? View.VISIBLE : View.GONE); mEditors.setVisibility(hasChildren ? View.VISIBLE : View.GONE);
} }
public boolean needsSaving() public boolean needsSaving() {
{
//check each view for needs saving, take account of deleted items //check each view for needs saving, take account of deleted items
boolean ret = mOldItemDeleted; boolean ret = mOldItemDeleted;
for (int i = 0; i < mEditors.getChildCount(); ++i) { for (int i = 0; i < mEditors.getChildCount(); ++i) {
Editor editor = (Editor) mEditors.getChildAt(i); Editor editor = (Editor) mEditors.getChildAt(i);
ret |= editor.needsSaving(); ret |= editor.needsSaving();
if (mType == Id.type.user_id) if (mType == Id.type.user_id) {
ret |= ((UserIdEditor)editor).primarySwapped(); ret |= ((UserIdEditor) editor).primarySwapped();
}
} }
return ret; return ret;
} }
public boolean primaryChanged() public boolean primaryChanged() {
{
boolean ret = false; boolean ret = false;
for (int i = 0; i < mEditors.getChildCount(); ++i) { for (int i = 0; i < mEditors.getChildCount(); ++i) {
Editor editor = (Editor) mEditors.getChildAt(i); Editor editor = (Editor) mEditors.getChildAt(i);
if (mType == Id.type.user_id) if (mType == Id.type.user_id) {
ret |= ((UserIdEditor)editor).primarySwapped(); ret |= ((UserIdEditor) editor).primarySwapped();
}
} }
return ret; return ret;
} }
public String getOriginalPrimaryID() public String getOriginalPrimaryID() {
{ //NB: this will have to change when we change how Primary IDs are chosen, and so we need to be //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 // 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 // revoked ones make this harder than the simple case we are continuing to assume here
for (int i = 0; i < mEditors.getChildCount(); ++i) { for (int i = 0; i < mEditors.getChildCount(); ++i) {
@ -203,35 +203,32 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
return null; return null;
} }
public ArrayList<String> getOriginalIDs() public ArrayList<String> getOriginalIDs() {
{
ArrayList<String> orig = new ArrayList<String>(); ArrayList<String> orig = new ArrayList<String>();
if (mType == Id.type.user_id) { if (mType == Id.type.user_id) {
for (int i = 0; i < mEditors.getChildCount(); ++i) { for (int i = 0; i < mEditors.getChildCount(); ++i) {
UserIdEditor editor = (UserIdEditor) mEditors.getChildAt(i); UserIdEditor editor = (UserIdEditor) mEditors.getChildAt(i);
if (editor.isMainUserId()) if (editor.isMainUserId()) {
orig.add(0, editor.getOriginalID()); orig.add(0, editor.getOriginalID());
else } else {
orig.add(editor.getOriginalID()); orig.add(editor.getOriginalID());
} }
}
return orig; return orig;
} else { } else {
return null; return null;
} }
} }
public ArrayList<String> getDeletedIDs() public ArrayList<String> getDeletedIDs() {
{
return mDeletedIDs; return mDeletedIDs;
} }
public ArrayList<PGPSecretKey> getDeletedKeys() public ArrayList<PGPSecretKey> getDeletedKeys() {
{
return mDeletedKeys; return mDeletedKeys;
} }
public List<Boolean> getNeedsSavingArray() public List<Boolean> getNeedsSavingArray() {
{
ArrayList<Boolean> mList = new ArrayList<Boolean>(); ArrayList<Boolean> mList = new ArrayList<Boolean>();
for (int i = 0; i < mEditors.getChildCount(); ++i) { for (int i = 0; i < mEditors.getChildCount(); ++i) {
Editor editor = (Editor) mEditors.getChildAt(i); Editor editor = (Editor) mEditors.getChildAt(i);
@ -240,21 +237,20 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
return mList; return mList;
} }
public List<Boolean> getNewIDFlags() public List<Boolean> getNewIDFlags() {
{
ArrayList<Boolean> mList = new ArrayList<Boolean>(); ArrayList<Boolean> mList = new ArrayList<Boolean>();
for (int i = 0; i < mEditors.getChildCount(); ++i) { for (int i = 0; i < mEditors.getChildCount(); ++i) {
UserIdEditor editor = (UserIdEditor) mEditors.getChildAt(i); UserIdEditor editor = (UserIdEditor) mEditors.getChildAt(i);
if (editor.isMainUserId()) if (editor.isMainUserId()) {
mList.add(0, editor.getIsNewID()); mList.add(0, editor.getIsNewID());
else } else {
mList.add(editor.getIsNewID()); mList.add(editor.getIsNewID());
} }
}
return mList; return mList;
} }
public List<Boolean> getNewKeysArray() public List<Boolean> getNewKeysArray() {
{
ArrayList<Boolean> mList = new ArrayList<Boolean>(); ArrayList<Boolean> mList = new ArrayList<Boolean>();
if (mType == Id.type.key) { if (mType == Id.type.key) {
for (int i = 0; i < mEditors.getChildCount(); ++i) { for (int i = 0; i < mEditors.getChildCount(); ++i) {
@ -420,8 +416,9 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
mEditors, false); mEditors, false);
view.setEditorListener(SectionView.this); view.setEditorListener(SectionView.this);
int usage = 0; int usage = 0;
if (mEditors.getChildCount() == 0) if (mEditors.getChildCount() == 0) {
usage = PGPKeyFlags.CAN_CERTIFY; usage = PGPKeyFlags.CAN_CERTIFY;
}
view.setValue(newKey, newKey.isMasterKey(), usage, true); view.setValue(newKey, newKey.isMasterKey(), usage, true);
mEditors.addView(view); mEditors.addView(view);
SectionView.this.updateEditorsVisible(); SectionView.this.updateEditorsVisible();

View File

@ -84,8 +84,7 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
} }
@Override @Override
public void afterTextChanged(Editable s) public void afterTextChanged(Editable s) {
{
if (mEditorListener != null) { if (mEditorListener != null) {
mEditorListener.onEdited(); mEditorListener.onEdited();
} }
@ -246,18 +245,15 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
return retval; return retval;
} }
public boolean getIsOriginallyMainUserID() public boolean getIsOriginallyMainUserID() {
{
return mOriginallyMainUserID; return mOriginallyMainUserID;
} }
public boolean primarySwapped() public boolean primarySwapped() {
{
return (mOriginallyMainUserID != isMainUserId()); return (mOriginallyMainUserID != isMainUserId());
} }
public String getOriginalID() public String getOriginalID() {
{
return mOriginalID; return mOriginalID;
} }