Fix edit key intent, api improvements
This commit is contained in:
@@ -74,7 +74,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
||||
public static final String EXTRA_USER_IDS = "userIds";
|
||||
public static final String EXTRA_NO_PASSPHRASE = "noPassphrase";
|
||||
public static final String EXTRA_GENERATE_DEFAULT_KEYS = "generateDefaultKeys";
|
||||
public static final String EXTRA_KEY_ID = "keyId";
|
||||
public static final String EXTRA_MASTER_KEY_ID = "masterKeyId";
|
||||
|
||||
// results when saving key
|
||||
public static final String RESULT_EXTRA_MASTER_KEY_ID = "masterKeyId";
|
||||
@@ -317,8 +317,8 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
||||
}
|
||||
|
||||
if (extras != null) {
|
||||
if (extras.containsKey(EXTRA_KEY_ID)) {
|
||||
long keyId = extras.getLong(EXTRA_KEY_ID);
|
||||
if (extras.containsKey(EXTRA_MASTER_KEY_ID)) {
|
||||
long keyId = extras.getLong(EXTRA_MASTER_KEY_ID);
|
||||
|
||||
if (keyId != 0) {
|
||||
PGPSecretKey masterKey = null;
|
||||
|
||||
@@ -70,26 +70,26 @@ public class KeyListSecretActivity extends KeyListActivity {
|
||||
}
|
||||
}
|
||||
|
||||
public void checkPassPhraseAndEdit(long keyId) {
|
||||
String passPhrase = PassphraseCacheService.getCachedPassphrase(this, keyId);
|
||||
public void checkPassPhraseAndEdit(long masterKeyId) {
|
||||
String passPhrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId);
|
||||
if (passPhrase == null) {
|
||||
showPassphraseDialog(keyId);
|
||||
showPassphraseDialog(masterKeyId);
|
||||
} else {
|
||||
PgpMain.setEditPassPhrase(passPhrase);
|
||||
editKey(keyId);
|
||||
editKey(masterKeyId);
|
||||
}
|
||||
}
|
||||
|
||||
private void showPassphraseDialog(final long secretKeyId) {
|
||||
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(
|
||||
KeyListSecretActivity.this, secretKeyId);
|
||||
KeyListSecretActivity.this, masterKeyId);
|
||||
PgpMain.setEditPassPhrase(passPhrase);
|
||||
editKey(secretKeyId);
|
||||
editKey(masterKeyId);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -99,7 +99,7 @@ public class KeyListSecretActivity extends KeyListActivity {
|
||||
|
||||
try {
|
||||
PassphraseDialogFragment passphraseDialog = PassphraseDialogFragment.newInstance(
|
||||
KeyListSecretActivity.this, messenger, secretKeyId);
|
||||
KeyListSecretActivity.this, messenger, masterKeyId);
|
||||
|
||||
passphraseDialog.show(getSupportFragmentManager(), "passphraseDialog");
|
||||
} catch (PgpMain.PgpGeneralException e) {
|
||||
@@ -115,9 +115,9 @@ public class KeyListSecretActivity extends KeyListActivity {
|
||||
startActivityForResult(intent, 0);
|
||||
}
|
||||
|
||||
private void editKey(long keyId) {
|
||||
private void editKey(long masterKeyId) {
|
||||
Intent intent = new Intent(EditKeyActivity.ACTION_EDIT_KEY);
|
||||
intent.putExtra(EditKeyActivity.EXTRA_KEY_ID, keyId);
|
||||
intent.putExtra(EditKeyActivity.EXTRA_MASTER_KEY_ID, masterKeyId);
|
||||
startActivityForResult(intent, 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user