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