Use SwitchPreference more often

This commit is contained in:
Dominik Schürmann
2015-08-27 14:05:58 +02:00
parent c292b8d9c3
commit 905e738621
4 changed files with 20 additions and 20 deletions

View File

@@ -94,10 +94,10 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
} }
}); });
initializeSearchKeyserver( initializeSearchKeyserver(
(CheckBoxPreference) findPreference(Constants.Pref.SEARCH_KEYSERVER) (SwitchPreference) findPreference(Constants.Pref.SEARCH_KEYSERVER)
); );
initializeSearchKeybase( initializeSearchKeybase(
(CheckBoxPreference) findPreference(Constants.Pref.SEARCH_KEYBASE) (SwitchPreference) findPreference(Constants.Pref.SEARCH_KEYBASE)
); );
} else if (action != null && action.equals(ACTION_PREFS_ADV)) { } else if (action != null && action.equals(ACTION_PREFS_ADV)) {
@@ -195,10 +195,10 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
} }
}); });
initializeSearchKeyserver( initializeSearchKeyserver(
(CheckBoxPreference) findPreference(Constants.Pref.SEARCH_KEYSERVER) (SwitchPreference) findPreference(Constants.Pref.SEARCH_KEYSERVER)
); );
initializeSearchKeybase( initializeSearchKeybase(
(CheckBoxPreference) findPreference(Constants.Pref.SEARCH_KEYBASE) (SwitchPreference) findPreference(Constants.Pref.SEARCH_KEYBASE)
); );
} }
@@ -256,8 +256,8 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
} }
public static class Initializer { public static class Initializer {
private CheckBoxPreference mUseTor; private SwitchPreference mUseTor;
private CheckBoxPreference mUseNormalProxy; private SwitchPreference mUseNormalProxy;
private EditTextPreference mProxyHost; private EditTextPreference mProxyHost;
private EditTextPreference mProxyPort; private EditTextPreference mProxyPort;
private ListPreference mProxyType; private ListPreference mProxyType;
@@ -293,8 +293,8 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
mActivity.addPreferencesFromResource(R.xml.proxy_prefs); mActivity.addPreferencesFromResource(R.xml.proxy_prefs);
} }
mUseTor = (CheckBoxPreference) automaticallyFindPreference(Constants.Pref.USE_TOR_PROXY); mUseTor = (SwitchPreference) automaticallyFindPreference(Constants.Pref.USE_TOR_PROXY);
mUseNormalProxy = (CheckBoxPreference) automaticallyFindPreference(Constants.Pref.USE_NORMAL_PROXY); mUseNormalProxy = (SwitchPreference) automaticallyFindPreference(Constants.Pref.USE_NORMAL_PROXY);
mProxyHost = (EditTextPreference) automaticallyFindPreference(Constants.Pref.PROXY_HOST); mProxyHost = (EditTextPreference) automaticallyFindPreference(Constants.Pref.PROXY_HOST);
mProxyPort = (EditTextPreference) automaticallyFindPreference(Constants.Pref.PROXY_PORT); mProxyPort = (EditTextPreference) automaticallyFindPreference(Constants.Pref.PROXY_PORT);
mProxyType = (ListPreference) automaticallyFindPreference(Constants.Pref.PROXY_TYPE); mProxyType = (ListPreference) automaticallyFindPreference(Constants.Pref.PROXY_TYPE);
@@ -492,19 +492,19 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
final Account account = manager.getAccountsByType(Constants.ACCOUNT_TYPE)[0]; final Account account = manager.getAccountsByType(Constants.ACCOUNT_TYPE)[0];
// for keyserver sync // for keyserver sync
initializeSyncCheckBox( initializeSyncCheckBox(
(CheckBoxPreference) findPreference(Constants.Pref.SYNC_KEYSERVER), (SwitchPreference) findPreference(Constants.Pref.SYNC_KEYSERVER),
account, account,
Constants.PROVIDER_AUTHORITY Constants.PROVIDER_AUTHORITY
); );
// for contacts sync // for contacts sync
initializeSyncCheckBox( initializeSyncCheckBox(
(CheckBoxPreference) findPreference(Constants.Pref.SYNC_CONTACTS), (SwitchPreference) findPreference(Constants.Pref.SYNC_CONTACTS),
account, account,
ContactsContract.AUTHORITY ContactsContract.AUTHORITY
); );
} }
private void initializeSyncCheckBox(final CheckBoxPreference syncCheckBox, private void initializeSyncCheckBox(final SwitchPreference syncCheckBox,
final Account account, final Account account,
final String authority) { final String authority) {
boolean syncEnabled = ContentResolver.getSyncAutomatically(account, authority); boolean syncEnabled = ContentResolver.getSyncAutomatically(account, authority);
@@ -529,7 +529,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
}); });
} }
private void setSummary(CheckBoxPreference syncCheckBox, String authority, private void setSummary(SwitchPreference syncCheckBox, String authority,
boolean checked) { boolean checked) {
switch (authority) { switch (authority) {
case Constants.PROVIDER_AUTHORITY: { case Constants.PROVIDER_AUTHORITY: {
@@ -623,7 +623,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
}); });
} }
private static void initializeSearchKeyserver(final CheckBoxPreference mSearchKeyserver) { private static void initializeSearchKeyserver(final SwitchPreference mSearchKeyserver) {
Preferences.CloudSearchPrefs prefs = sPreferences.getCloudSearchPrefs(); Preferences.CloudSearchPrefs prefs = sPreferences.getCloudSearchPrefs();
mSearchKeyserver.setChecked(prefs.searchKeyserver); mSearchKeyserver.setChecked(prefs.searchKeyserver);
mSearchKeyserver.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { mSearchKeyserver.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@@ -636,7 +636,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
}); });
} }
private static void initializeSearchKeybase(final CheckBoxPreference mSearchKeybase) { private static void initializeSearchKeybase(final SwitchPreference mSearchKeybase) {
Preferences.CloudSearchPrefs prefs = sPreferences.getCloudSearchPrefs(); Preferences.CloudSearchPrefs prefs = sPreferences.getCloudSearchPrefs();
mSearchKeybase.setChecked(prefs.searchKeybase); mSearchKeybase.setChecked(prefs.searchKeybase);
mSearchKeybase.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { mSearchKeybase.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference <SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:key="search_keyserver_pref" android:key="search_keyserver_pref"
android:summary="@string/pref_keyserver_summary" android:summary="@string/pref_keyserver_summary"
@@ -12,7 +12,7 @@
android:persistent="false" android:persistent="false"
android:title="@string/label_keyservers" /> android:title="@string/label_keyservers" />
<CheckBoxPreference <SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:key="search_keybase_pref" android:key="search_keybase_pref"
android:summary="@string/pref_keybase_summary" android:summary="@string/pref_keybase_summary"

View File

@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference <SwitchPreference
android:key="useTorProxy" android:key="useTorProxy"
android:persistent="true" android:persistent="true"
android:title="@string/pref_proxy_tor_title" android:title="@string/pref_proxy_tor_title"
android:summary="@string/pref_proxy_tor_summary" /> android:summary="@string/pref_proxy_tor_summary" />
<CheckBoxPreference <SwitchPreference
android:key="useNormalProxy" android:key="useNormalProxy"
android:persistent="true" android:persistent="true"
android:title="@string/pref_proxy_normal_title" /> android:title="@string/pref_proxy_normal_title" />

View File

@@ -1,9 +1,9 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference <SwitchPreference
android:key="syncKeyserver" android:key="syncKeyserver"
android:persistent="false" android:persistent="false"
android:title="@string/label_sync_settings_keyserver_title"/> android:title="@string/label_sync_settings_keyserver_title"/>
<CheckBoxPreference <SwitchPreference
android:key="syncContacts" android:key="syncContacts"
android:persistent="false" android:persistent="false"
android:title="@string/label_sync_settings_contacts_title" /> android:title="@string/label_sync_settings_contacts_title" />