change when passphrase is requested in edit activity
This commit is contained in:
@@ -93,6 +93,7 @@ public class EditKeyActivity extends ActionBarActivity {
|
|||||||
private String mCurrentPassPhrase = null;
|
private String mCurrentPassPhrase = null;
|
||||||
private String mNewPassPhrase = null;
|
private String mNewPassPhrase = null;
|
||||||
private String mSavedNewPassPhrase = null;
|
private String mSavedNewPassPhrase = null;
|
||||||
|
private boolean mIsPassPhraseSet;
|
||||||
|
|
||||||
private BootstrapButton mChangePassPhrase;
|
private BootstrapButton mChangePassPhrase;
|
||||||
|
|
||||||
@@ -256,16 +257,7 @@ public class EditKeyActivity extends ActionBarActivity {
|
|||||||
long masterKeyId = ProviderHelper.getSecretMasterKeyId(this, keyRingRowId);
|
long masterKeyId = ProviderHelper.getSecretMasterKeyId(this, keyRingRowId);
|
||||||
|
|
||||||
masterCanSign = ProviderHelper.getSecretMasterKeyCanSign(this, keyRingRowId);
|
masterCanSign = ProviderHelper.getSecretMasterKeyCanSign(this, keyRingRowId);
|
||||||
|
finallyEdit(masterKeyId, masterCanSign);
|
||||||
String passphrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId);
|
|
||||||
if (passphrase == null) {
|
|
||||||
showPassphraseDialog(masterKeyId, masterCanSign);
|
|
||||||
} else {
|
|
||||||
// PgpMain.setEditPassPhrase(passPhrase);
|
|
||||||
mCurrentPassPhrase = passphrase;
|
|
||||||
|
|
||||||
finallyEdit(masterKeyId, masterCanSign);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,9 +270,7 @@ public class EditKeyActivity extends ActionBarActivity {
|
|||||||
String passPhrase = PassphraseCacheService.getCachedPassphrase(
|
String passPhrase = PassphraseCacheService.getCachedPassphrase(
|
||||||
EditKeyActivity.this, masterKeyId);
|
EditKeyActivity.this, masterKeyId);
|
||||||
mCurrentPassPhrase = passPhrase;
|
mCurrentPassPhrase = passPhrase;
|
||||||
finallyEdit(masterKeyId, masterCanSign);
|
finallySaveClicked();
|
||||||
} else {
|
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -369,14 +359,11 @@ public class EditKeyActivity extends ActionBarActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: ???
|
mCurrentPassPhrase = "";
|
||||||
if (mCurrentPassPhrase == null) {
|
|
||||||
mCurrentPassPhrase = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
buildLayout();
|
buildLayout();
|
||||||
|
mIsPassPhraseSet = PassphraseCacheService.hasPassphrase(this, masterKeyId);
|
||||||
if (mCurrentPassPhrase.equals("")) {
|
if (!mIsPassPhraseSet) {
|
||||||
// check "no passphrase" checkbox and remove button
|
// check "no passphrase" checkbox and remove button
|
||||||
mNoPassphrase.setChecked(true);
|
mNoPassphrase.setChecked(true);
|
||||||
mChangePassPhrase.setVisibility(View.GONE);
|
mChangePassPhrase.setVisibility(View.GONE);
|
||||||
@@ -482,7 +469,7 @@ public class EditKeyActivity extends ActionBarActivity {
|
|||||||
public boolean isPassphraseSet() {
|
public boolean isPassphraseSet() {
|
||||||
if (mNoPassphrase.isChecked()) {
|
if (mNoPassphrase.isChecked()) {
|
||||||
return true;
|
return true;
|
||||||
} else if ((!mCurrentPassPhrase.equals(""))
|
} else if ((mIsPassPhraseSet)
|
||||||
|| (mNewPassPhrase != null && !mNewPassPhrase.equals(""))) {
|
|| (mNewPassPhrase != null && !mNewPassPhrase.equals(""))) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@@ -491,11 +478,31 @@ public class EditKeyActivity extends ActionBarActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void saveClicked() {
|
private void saveClicked() {
|
||||||
|
long masterKeyId = getMasterKeyId();
|
||||||
try {
|
try {
|
||||||
if (!isPassphraseSet()) {
|
if (!isPassphraseSet()) {
|
||||||
throw new PgpGeneralException(this.getString(R.string.set_a_passphrase));
|
throw new PgpGeneralException(this.getString(R.string.set_a_passphrase));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String passphrase = null;
|
||||||
|
if (mIsPassPhraseSet)
|
||||||
|
passphrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId);
|
||||||
|
else
|
||||||
|
passphrase = "";
|
||||||
|
if (passphrase == null) {
|
||||||
|
showPassphraseDialog(masterKeyId, masterCanSign);
|
||||||
|
} else {
|
||||||
|
mCurrentPassPhrase = passphrase;
|
||||||
|
finallySaveClicked();
|
||||||
|
}
|
||||||
|
} catch (PgpGeneralException e) {
|
||||||
|
//Toast.makeText(this, getString(R.string.error_message, e.getMessage()),
|
||||||
|
// Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void finallySaveClicked() {
|
||||||
|
try {
|
||||||
// Send all information needed to service to edit key in other thread
|
// Send all information needed to service to edit key in other thread
|
||||||
Intent intent = new Intent(this, KeychainIntentService.class);
|
Intent intent = new Intent(this, KeychainIntentService.class);
|
||||||
|
|
||||||
@@ -552,8 +559,8 @@ public class EditKeyActivity extends ActionBarActivity {
|
|||||||
// start service with intent
|
// start service with intent
|
||||||
startService(intent);
|
startService(intent);
|
||||||
} catch (PgpGeneralException e) {
|
} catch (PgpGeneralException e) {
|
||||||
Toast.makeText(this, getString(R.string.error_message, e.getMessage()),
|
//Toast.makeText(this, getString(R.string.error_message, e.getMessage()),
|
||||||
Toast.LENGTH_SHORT).show();
|
// Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user