Experimental features settings reworked
This commit is contained in:
@@ -109,7 +109,8 @@ public final class Constants {
|
||||
public static final String SYNC_CONTACTS = "syncContacts";
|
||||
public static final String SYNC_KEYSERVER = "syncKeyserver";
|
||||
// other settings
|
||||
public static final String ENABLE_EXPERIMENTAL_FEATURES = "enableExperimentalFeatures";
|
||||
public static final String EXPERIMENTAL_ENABLE_WORD_CONFIRM = "experimentalEnableWordConfirm";
|
||||
public static final String EXPERIMENTAL_ENABLE_LINKED_IDENTITIES = "experimentalEnableLinkedIdentities";
|
||||
|
||||
public static final class Theme {
|
||||
public static final String LIGHT = "light";
|
||||
|
||||
@@ -553,19 +553,22 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||
}
|
||||
|
||||
/**
|
||||
* This fragment shows other preferences
|
||||
* This fragment shows experimental features
|
||||
*/
|
||||
public static class OtherPrefsFragment extends PreferenceFragment {
|
||||
public static class ExperimentalPrefsFragment extends PreferenceFragment {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Load the preferences from an XML resource
|
||||
addPreferencesFromResource(R.xml.other_preferences);
|
||||
addPreferencesFromResource(R.xml.experimental_preferences);
|
||||
|
||||
initializeEnableExperimentalFeatures(
|
||||
(SwitchPreference) findPreference(Constants.Pref.ENABLE_EXPERIMENTAL_FEATURES));
|
||||
initializeExperimentalEnableWordConfirm(
|
||||
(SwitchPreference) findPreference(Constants.Pref.EXPERIMENTAL_ENABLE_WORD_CONFIRM));
|
||||
|
||||
initializeExperimentalEnableLinkedIdentities(
|
||||
(SwitchPreference) findPreference(Constants.Pref.EXPERIMENTAL_ENABLE_LINKED_IDENTITIES));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -575,7 +578,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||
|| ProxyPrefsFragment.class.getName().equals(fragmentName)
|
||||
|| GuiPrefsFragment.class.getName().equals(fragmentName)
|
||||
|| SyncPrefsFragment.class.getName().equals(fragmentName)
|
||||
|| OtherPrefsFragment.class.getName().equals(fragmentName)
|
||||
|| ExperimentalPrefsFragment.class.getName().equals(fragmentName)
|
||||
|| super.isValidFragment(fragmentName);
|
||||
}
|
||||
|
||||
@@ -676,12 +679,23 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||
});
|
||||
}
|
||||
|
||||
private static void initializeEnableExperimentalFeatures(final SwitchPreference mEnableExperimentalFeatures) {
|
||||
mEnableExperimentalFeatures.setChecked(sPreferences.getEnableExperimentalFeatures());
|
||||
mEnableExperimentalFeatures.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
private static void initializeExperimentalEnableWordConfirm(final SwitchPreference mExperimentalEnableWordConfirm) {
|
||||
mExperimentalEnableWordConfirm.setChecked(sPreferences.getExperimentalEnableWordConfirm());
|
||||
mExperimentalEnableWordConfirm.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
mEnableExperimentalFeatures.setChecked((Boolean) newValue);
|
||||
sPreferences.setEnableExperimentalFeatures((Boolean) newValue);
|
||||
mExperimentalEnableWordConfirm.setChecked((Boolean) newValue);
|
||||
sPreferences.setExperimentalEnableWordConfirm((Boolean) newValue);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void initializeExperimentalEnableLinkedIdentities(final SwitchPreference mExperimentalEnableLinkedIdentities) {
|
||||
mExperimentalEnableLinkedIdentities.setChecked(sPreferences.getExperimentalEnableLinkedIdentities());
|
||||
mExperimentalEnableLinkedIdentities.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
mExperimentalEnableLinkedIdentities.setChecked((Boolean) newValue);
|
||||
sPreferences.setExperimentalEnableLinkedIdentities((Boolean) newValue);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -25,7 +25,6 @@ import android.content.res.Resources;
|
||||
import android.preference.PreferenceManager;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Constants.Pref;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.service.KeyserverSyncAdapterService;
|
||||
|
||||
import java.net.Proxy;
|
||||
@@ -360,16 +359,26 @@ public class Preferences {
|
||||
}
|
||||
}
|
||||
|
||||
// other prefs
|
||||
// experimental prefs
|
||||
|
||||
public void setEnableExperimentalFeatures(boolean enableExperimentalFeatures) {
|
||||
public void setExperimentalEnableWordConfirm(boolean enableWordConfirm) {
|
||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||
editor.putBoolean(Pref.ENABLE_EXPERIMENTAL_FEATURES, enableExperimentalFeatures);
|
||||
editor.putBoolean(Pref.EXPERIMENTAL_ENABLE_WORD_CONFIRM, enableWordConfirm);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public boolean getEnableExperimentalFeatures() {
|
||||
return mSharedPreferences.getBoolean(Pref.ENABLE_EXPERIMENTAL_FEATURES, false);
|
||||
public boolean getExperimentalEnableWordConfirm() {
|
||||
return mSharedPreferences.getBoolean(Pref.EXPERIMENTAL_ENABLE_WORD_CONFIRM, false);
|
||||
}
|
||||
|
||||
public void setExperimentalEnableLinkedIdentities(boolean enableLinkedIdentities) {
|
||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||
editor.putBoolean(Pref.EXPERIMENTAL_ENABLE_LINKED_IDENTITIES, enableLinkedIdentities);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public boolean getExperimentalEnableLinkedIdentities() {
|
||||
return mSharedPreferences.getBoolean(Pref.EXPERIMENTAL_ENABLE_LINKED_IDENTITIES, false);
|
||||
}
|
||||
|
||||
public void upgradePreferences(Context context) {
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
<string name="section_proxy_settings">"Proxy Settings"</string>
|
||||
<string name="section_gui">"Interface"</string>
|
||||
<string name="section_sync_settings">"Sync Settings"</string>
|
||||
<string name="section_other_settings">"Other Settings"</string>
|
||||
<string name="section_experimental_features">"Experimental Features"</string>
|
||||
<string name="section_certify">"Confirm"</string>
|
||||
<string name="section_actions">"Actions"</string>
|
||||
<string name="section_share_key">"Key"</string>
|
||||
@@ -186,8 +186,12 @@
|
||||
<!-- label shown in Android settings under the OpenKeychain account -->
|
||||
<string name="keyserver_sync_settings_title">"Automatically update keys"</string>
|
||||
|
||||
<string name="label_other_settings_experimental_title">"Enable experimental features"</string>
|
||||
<string name="label_other_settings_experimental_summary">"Enable experimental features, mostly results of security/UX research. Don't rely on their security!"</string>
|
||||
<string name="label_experimental_settings_desc_summary">"These features are mostly results of security/UX research. Don't rely on their security!"</string>
|
||||
|
||||
<string name="label_experimental_settings_word_confirm_title">"Word Confirm"</string>
|
||||
<string name="label_experimental_settings_word_confirm_summary">"Allows to compare fingerprints with words instead of hexadecimal representation."</string>
|
||||
<string name="label_experimental_settings_linked_identities_title">"Linked Identities"</string>
|
||||
<string name="label_experimental_settings_linked_identities_summary">"Linked Identities"</string>
|
||||
|
||||
<!-- Proxy Preferences -->
|
||||
<string name="pref_proxy_tor_title">"Enable Tor"</string>
|
||||
|
||||
20
OpenKeychain/src/main/res/xml/experimental_preferences.xml
Normal file
20
OpenKeychain/src/main/res/xml/experimental_preferences.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<Preference
|
||||
android:persistent="false"
|
||||
android:selectable="false"
|
||||
android:summary="@string/label_experimental_settings_desc_summary" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="experimentalEnableWordConfirm"
|
||||
android:persistent="false"
|
||||
android:summary="@string/label_experimental_settings_word_confirm_summary"
|
||||
android:title="@string/label_experimental_settings_word_confirm_title" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="experimentalEnableLinkedIdentities"
|
||||
android:persistent="false"
|
||||
android:summary="@string/label_experimental_settings_linked_identities_summary"
|
||||
android:title="@string/label_experimental_settings_linked_identities_title" />
|
||||
</PreferenceScreen>
|
||||
@@ -15,6 +15,6 @@
|
||||
android:fragment="org.sufficientlysecure.keychain.ui.SettingsActivity$SyncPrefsFragment"
|
||||
android:title="@string/section_sync_settings" />
|
||||
<header
|
||||
android:fragment="org.sufficientlysecure.keychain.ui.SettingsActivity$OtherPrefsFragment"
|
||||
android:title="@string/section_other_settings" />
|
||||
android:fragment="org.sufficientlysecure.keychain.ui.SettingsActivity$ExperimentalPrefsFragment"
|
||||
android:title="@string/section_experimental_features" />
|
||||
</preference-headers>
|
||||
|
||||
Reference in New Issue
Block a user