mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-24 01:32:16 -05:00
Add yubikey default PIN preference
This commit is contained in:
parent
2a9b083012
commit
fa9bbdd60c
@ -78,6 +78,7 @@ public final class Constants {
|
|||||||
public static final String CACHED_CONSOLIDATE = "cachedConsolidate";
|
public static final String CACHED_CONSOLIDATE = "cachedConsolidate";
|
||||||
public static final String CACHED_CONSOLIDATE_SECRETS = "cachedConsolidateSecrets";
|
public static final String CACHED_CONSOLIDATE_SECRETS = "cachedConsolidateSecrets";
|
||||||
public static final String CACHED_CONSOLIDATE_PUBLICS = "cachedConsolidatePublics";
|
public static final String CACHED_CONSOLIDATE_PUBLICS = "cachedConsolidatePublics";
|
||||||
|
public static final String USE_DEFAULT_YUBIKEY_PIN = "useDefaultYubikeyPin";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class Defaults {
|
public static final class Defaults {
|
||||||
|
@ -179,6 +179,16 @@ public class Preferences {
|
|||||||
return mSharedPreferences.getBoolean(Constants.Pref.FIRST_TIME, true);
|
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) {
|
public void setFirstTime(boolean value) {
|
||||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||||
editor.putBoolean(Constants.Pref.FIRST_TIME, value);
|
editor.putBoolean(Constants.Pref.FIRST_TIME, value);
|
||||||
@ -216,6 +226,16 @@ public class Preferences {
|
|||||||
editor.commit();
|
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() {
|
public void updatePreferences() {
|
||||||
// migrate keyserver to hkps
|
// migrate keyserver to hkps
|
||||||
if (mSharedPreferences.getInt(Constants.Pref.KEY_SERVERS_DEFAULT_VERSION, 0) !=
|
if (mSharedPreferences.getInt(Constants.Pref.KEY_SERVERS_DEFAULT_VERSION, 0) !=
|
||||||
@ -256,14 +276,4 @@ public class Preferences {
|
|||||||
setDefaultHashAlgorithm(HashAlgorithmTags.SHA512);
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -53,11 +53,6 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
sPreferences = Preferences.getPreferences(this);
|
sPreferences = Preferences.getPreferences(this);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
// final ActionBar actionBar = getSupportActionBar();
|
|
||||||
// actionBar.setDisplayShowTitleEnabled(true);
|
|
||||||
// actionBar.setDisplayHomeAsUpEnabled(false);
|
|
||||||
// actionBar.setHomeButtonEnabled(false);
|
|
||||||
|
|
||||||
String action = getIntent().getAction();
|
String action = getIntent().getAction();
|
||||||
|
|
||||||
if (action != null && action.equals(ACTION_PREFS_GEN)) {
|
if (action != null && action.equals(ACTION_PREFS_GEN)) {
|
||||||
@ -122,6 +117,9 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
initializeWriteVersionHeader(
|
initializeWriteVersionHeader(
|
||||||
(CheckBoxPreference) findPreference(Constants.Pref.WRITE_VERSION_HEADER));
|
(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) {
|
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
||||||
// Load the legacy preferences headers
|
// Load the legacy preferences headers
|
||||||
addPreferencesFromResource(R.xml.preference_headers_legacy);
|
addPreferencesFromResource(R.xml.preference_headers_legacy);
|
||||||
@ -265,6 +263,9 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
|
|
||||||
initializeWriteVersionHeader(
|
initializeWriteVersionHeader(
|
||||||
(CheckBoxPreference) findPreference(Constants.Pref.WRITE_VERSION_HEADER));
|
(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;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,8 @@
|
|||||||
<string name="label_file_ascii_armor">Files: ASCII Armor</string>
|
<string name="label_file_ascii_armor">Files: ASCII Armor</string>
|
||||||
<string name="label_write_version_header">Let others know that you\'re using OpenKeychain</string>
|
<string name="label_write_version_header">Let others know that you\'re using OpenKeychain</string>
|
||||||
<string name="label_write_version_header_summary">Writes \'OpenKeychain v2.7\' to OpenPGP signatures, ciphertext, and exported keys</string>
|
<string name="label_write_version_header_summary">Writes \'OpenKeychain v2.7\' to OpenPGP signatures, ciphertext, and exported keys</string>
|
||||||
|
<string name="label_use_default_yubikey_pin">Use default Yubikey PIN</string>
|
||||||
|
<string name="label_label_use_default_yubikey_pin_summary">Uses default PIN (123456) to access Yubikeys over NFC</string>
|
||||||
<string name="label_asymmetric_from">Signed by:</string>
|
<string name="label_asymmetric_from">Signed by:</string>
|
||||||
<string name="label_to">Encrypt to:</string>
|
<string name="label_to">Encrypt to:</string>
|
||||||
<string name="label_delete_after_encryption">Files: Delete After Encryption</string>
|
<string name="label_delete_after_encryption">Files: Delete After Encryption</string>
|
||||||
|
@ -28,4 +28,11 @@
|
|||||||
android:title="@string/label_write_version_header"
|
android:title="@string/label_write_version_header"
|
||||||
android:summary="@string/label_write_version_header_summary" />
|
android:summary="@string/label_write_version_header_summary" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="useDefaultYubikeyPin"
|
||||||
|
android:persistent="false"
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:title="@string/label_use_default_yubikey_pin"
|
||||||
|
android:summary="@string/label_label_use_default_yubikey_pin_summary" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
Loading…
Reference in New Issue
Block a user