From 7eb10cb5a67cd084f8badfbc261dd92b2a1a4e64 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Sat, 20 Feb 2016 22:26:50 -0500 Subject: [PATCH] Fix a bug with storing the default algorithm version. --- .../java/com/lyndir/masterpassword/EmergencyActivity.java | 2 +- .../src/main/java/com/lyndir/masterpassword/Preferences.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/MasterPassword/Java/masterpassword-android/src/main/java/com/lyndir/masterpassword/EmergencyActivity.java b/MasterPassword/Java/masterpassword-android/src/main/java/com/lyndir/masterpassword/EmergencyActivity.java index 07c59c33..43706f74 100644 --- a/MasterPassword/Java/masterpassword-android/src/main/java/com/lyndir/masterpassword/EmergencyActivity.java +++ b/MasterPassword/Java/masterpassword-android/src/main/java/com/lyndir/masterpassword/EmergencyActivity.java @@ -272,7 +272,7 @@ public class EmergencyActivity extends Activity { try { return MasterKey.create( version, fullName, masterPassword ); } - catch (RuntimeException e) { + catch (Exception e) { sitePasswordField.setText( "" ); progressView.setVisibility( View.INVISIBLE ); logger.err( e, "While generating master key." ); diff --git a/MasterPassword/Java/masterpassword-android/src/main/java/com/lyndir/masterpassword/Preferences.java b/MasterPassword/Java/masterpassword-android/src/main/java/com/lyndir/masterpassword/Preferences.java index 10c31dea..cd6e18a6 100644 --- a/MasterPassword/Java/masterpassword-android/src/main/java/com/lyndir/masterpassword/Preferences.java +++ b/MasterPassword/Java/masterpassword-android/src/main/java/com/lyndir/masterpassword/Preferences.java @@ -21,6 +21,7 @@ public class Preferences { private static final String PREF_MASK_PASSWORD = "maskPassword"; private static final String PREF_FULL_NAME = "fullName"; private static final String PREF_SITE_TYPE = "siteType"; + private static final String PREF_ALGORITHM_VERSION = "algorithmVersion"; private static Preferences instance; private Context context; @@ -136,12 +137,12 @@ public class Preferences { if (getDefaultVersion().equals( value )) return false; - prefs().edit().putInt( PREF_SITE_TYPE, value.ordinal() ).apply(); + prefs().edit().putInt( PREF_ALGORITHM_VERSION, value.ordinal() ).apply(); return true; } @Nonnull public MasterKey.Version getDefaultVersion() { - return MasterKey.Version.values()[prefs().getInt( PREF_SITE_TYPE, MasterKey.Version.CURRENT.ordinal() )]; + return MasterKey.Version.values()[prefs().getInt( PREF_ALGORITHM_VERSION, MasterKey.Version.CURRENT.ordinal() )]; } }