From cd2b493ea8d25796bf666b46597e6b6bd416f64b Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Sat, 8 Feb 2014 12:12:17 +0000 Subject: small extra check --- .../keychain/ui/EditKeyActivity.java | 38 ++++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'OpenPGP-Keychain/src/main') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 694e52f71..d53a1f836 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -326,7 +326,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: - cancelClicked(); + cancelClicked(); //TODO: why isn't this triggered on my tablet - one of many ui problems I've had with this device. A code compatibility issue or a Samsung fail? return true; case R.id.menu_key_edit_cancel: cancelClicked(); @@ -520,25 +520,27 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener private void saveClicked() { long masterKeyId = getMasterKeyId(); - try { - if (!isPassphraseSet()) { - throw new PgpGeneralException(this.getString(R.string.set_a_passphrase)); - } + if (needsSaving()) { //make sure, as some versions don't support invalidateOptionsMenu + try { + if (!isPassphraseSet()) { + 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(); + 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(); } - } catch (PgpGeneralException e) { - //Toast.makeText(this, getString(R.string.error_message, e.getMessage()), - // Toast.LENGTH_SHORT).show(); } } -- cgit v1.2.3