diff options
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain')
3 files changed, 38 insertions, 15 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java index 623991097..1563932a5 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java @@ -78,6 +78,7 @@ public final class Constants { public static final String CACHED_CONSOLIDATE = "cachedConsolidate"; public static final String CACHED_CONSOLIDATE_SECRETS = "cachedConsolidateSecrets"; public static final String CACHED_CONSOLIDATE_PUBLICS = "cachedConsolidatePublics"; + public static final String USE_DEFAULT_YUBIKEY_PIN = "useDefaultYubikeyPin"; } public static final class Defaults { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java index 866be82d2..af7bdbdd2 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java @@ -179,6 +179,16 @@ public class Preferences { return mSharedPreferences.getBoolean(Constants.Pref.FIRST_TIME, true); } + public boolean useDefaultYubikeyPin() { + return mSharedPreferences.getBoolean(Pref.USE_DEFAULT_YUBIKEY_PIN, true); + } + + public void setUseDefaultYubikeyPin(boolean useDefaultYubikeyPin) { + SharedPreferences.Editor editor = mSharedPreferences.edit(); + editor.putBoolean(Pref.USE_DEFAULT_YUBIKEY_PIN, useDefaultYubikeyPin); + editor.commit(); + } + public void setFirstTime(boolean value) { SharedPreferences.Editor editor = mSharedPreferences.edit(); editor.putBoolean(Constants.Pref.FIRST_TIME, value); @@ -216,6 +226,16 @@ public class Preferences { editor.commit(); } + public void setWriteVersionHeader(boolean conceal) { + SharedPreferences.Editor editor = mSharedPreferences.edit(); + editor.putBoolean(Constants.Pref.WRITE_VERSION_HEADER, conceal); + editor.commit(); + } + + public boolean getWriteVersionHeader() { + return mSharedPreferences.getBoolean(Constants.Pref.WRITE_VERSION_HEADER, false); + } + public void updatePreferences() { // migrate keyserver to hkps if (mSharedPreferences.getInt(Constants.Pref.KEY_SERVERS_DEFAULT_VERSION, 0) != @@ -256,14 +276,4 @@ public class Preferences { setDefaultHashAlgorithm(HashAlgorithmTags.SHA512); } } - - public void setWriteVersionHeader(boolean conceal) { - SharedPreferences.Editor editor = mSharedPreferences.edit(); - editor.putBoolean(Constants.Pref.WRITE_VERSION_HEADER, conceal); - editor.commit(); - } - - public boolean getWriteVersionHeader() { - return mSharedPreferences.getBoolean(Constants.Pref.WRITE_VERSION_HEADER, false); - } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java index 64c1e16be..1221966e1 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java @@ -53,11 +53,6 @@ public class PreferencesActivity extends PreferenceActivity { sPreferences = Preferences.getPreferences(this); super.onCreate(savedInstanceState); -// final ActionBar actionBar = getSupportActionBar(); -// actionBar.setDisplayShowTitleEnabled(true); -// actionBar.setDisplayHomeAsUpEnabled(false); -// actionBar.setHomeButtonEnabled(false); - String action = getIntent().getAction(); if (action != null && action.equals(ACTION_PREFS_GEN)) { @@ -122,6 +117,9 @@ public class PreferencesActivity extends PreferenceActivity { initializeWriteVersionHeader( (CheckBoxPreference) findPreference(Constants.Pref.WRITE_VERSION_HEADER)); + initializeUseDefaultYubikeyPin( + (CheckBoxPreference) findPreference(Constants.Pref.USE_DEFAULT_YUBIKEY_PIN)); + } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { // Load the legacy preferences headers addPreferencesFromResource(R.xml.preference_headers_legacy); @@ -265,6 +263,9 @@ public class PreferencesActivity extends PreferenceActivity { initializeWriteVersionHeader( (CheckBoxPreference) findPreference(Constants.Pref.WRITE_VERSION_HEADER)); + + initializeUseDefaultYubikeyPin( + (CheckBoxPreference) findPreference(Constants.Pref.USE_DEFAULT_YUBIKEY_PIN)); } } @@ -396,4 +397,15 @@ public class PreferencesActivity extends PreferenceActivity { } }); } + + private static void initializeUseDefaultYubikeyPin(final CheckBoxPreference mUseDefaultYubikeyPin) { + mUseDefaultYubikeyPin.setChecked(sPreferences.useDefaultYubikeyPin()); + mUseDefaultYubikeyPin.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + public boolean onPreferenceChange(Preference preference, Object newValue) { + mUseDefaultYubikeyPin.setChecked((Boolean) newValue); + sPreferences.setUseDefaultYubikeyPin((Boolean) newValue); + return false; + } + }); + } } |