some AS Inspect Code fixes

This commit is contained in:
Ashley Hughes 2014-02-08 16:33:37 +00:00
parent 33f41e66a0
commit adc6a3ea64

View File

@ -26,7 +26,6 @@ import org.spongycastle.openpgp.PGPSecretKeyRing;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Id;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.helper.ActionBarHelper;
import org.sufficientlysecure.keychain.helper.ExportHelper;
import org.sufficientlysecure.keychain.pgp.PgpConversionHelper;
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
@ -218,10 +217,10 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
// get new key from data bundle returned from service
Bundle data = message.getData();
PGPSecretKey masterKey = (PGPSecretKey) PgpConversionHelper
PGPSecretKey masterKey = PgpConversionHelper
.BytesToPGPSecretKey(data
.getByteArray(KeychainIntentService.RESULT_NEW_KEY));
PGPSecretKey subKey = (PGPSecretKey) PgpConversionHelper
PGPSecretKey subKey = PgpConversionHelper
.BytesToPGPSecretKey(data
.getByteArray(KeychainIntentService.RESULT_NEW_KEY2));
@ -235,7 +234,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
buildLayout();
}
};
}
};
// Create a new Messenger for the communication back
@ -263,7 +262,6 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
if (mDataUri == null) {
Log.e(Constants.TAG, "Intent data missing. Should be Uri of key!");
finish();
return;
} else {
Log.d(Constants.TAG, "uri: " + mDataUri);
@ -273,19 +271,18 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
long masterKeyId = ProviderHelper.getSecretMasterKeyId(this, keyRingRowId);
masterCanSign = ProviderHelper.getSecretMasterKeyCanCertify(this, keyRingRowId);
finallyEdit(masterKeyId, masterCanSign);
finallyEdit(masterKeyId);
}
}
private void showPassphraseDialog(final long masterKeyId, final boolean masterCanSign) {
private void showPassphraseDialog(final long masterKeyId) {
// Message is received after passphrase is cached
Handler returnHandler = new Handler() {
@Override
public void handleMessage(Message message) {
if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) {
String passPhrase = PassphraseCacheService.getCachedPassphrase(
mCurrentPassPhrase = PassphraseCacheService.getCachedPassphrase(
EditKeyActivity.this, masterKeyId);
mCurrentPassPhrase = passPhrase;
finallySaveClicked();
}
}
@ -310,13 +307,13 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.key_edit, menu);
mSaveButton = (MenuItem) menu.findItem(R.id.menu_key_edit_save);
mSaveButton = menu.findItem(R.id.menu_key_edit_save);
mSaveButton.setEnabled(needsSaving());
//totally get rid of some actions for new keys
if (mDataUri == null) {
MenuItem mButton = (MenuItem) menu.findItem(R.id.menu_key_edit_export_file);
MenuItem mButton = menu.findItem(R.id.menu_key_edit_export_file);
mButton.setVisible(false);
mButton = (MenuItem) menu.findItem(R.id.menu_key_edit_delete);
mButton = menu.findItem(R.id.menu_key_edit_delete);
mButton.setVisible(false);
}
return true;
@ -362,7 +359,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
}
@SuppressWarnings("unchecked")
private void finallyEdit(final long masterKeyId, final boolean masterCanSign) {
private void finallyEdit(final long masterKeyId) {
if (masterKeyId != 0) {
PGPSecretKey masterKey = null;
mKeyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(this, masterKeyId);
@ -427,7 +424,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
Messenger messenger = new Messenger(returnHandler);
// set title based on isPassphraseSet()
int title = -1;
int title;
if (isPassphraseSet()) {
title = R.string.title_change_pass_phrase;
} else {
@ -534,13 +531,13 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
throw new PgpGeneralException(this.getString(R.string.set_a_passphrase));
}
String passphrase = null;
String passphrase;
if (mIsPassPhraseSet)
passphrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId);
else
passphrase = "";
if (passphrase == null) {
showPassphraseDialog(masterKeyId, masterCanSign);
showPassphraseDialog(masterKeyId);
} else {
mCurrentPassPhrase = passphrase;
finallySaveClicked();
@ -598,7 +595,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
setResult(RESULT_OK, data);
finish();
}
};
}
};
// Create a new Messenger for the communication back
@ -661,7 +658,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
boolean gotMainUserId = false;
for (int i = 0; i < userIdEditors.getChildCount(); ++i) {
UserIdEditor editor = (UserIdEditor) userIdEditors.getChildAt(i);
String userId = null;
String userId;
try {
userId = editor.getValue();
} catch (UserIdEditor.InvalidEmailException e) {