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(
(CheckBoxPreference) findPreference(Constants.Pref.SEARCH_KEYSERVER)
(SwitchPreference) findPreference(Constants.Pref.SEARCH_KEYSERVER)
);
initializeSearchKeybase(
(CheckBoxPreference) findPreference(Constants.Pref.SEARCH_KEYBASE)
(SwitchPreference) findPreference(Constants.Pref.SEARCH_KEYBASE)
);
} else if (action != null && action.equals(ACTION_PREFS_ADV)) {
@@ -195,10 +195,10 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
}
});
initializeSearchKeyserver(
(CheckBoxPreference) findPreference(Constants.Pref.SEARCH_KEYSERVER)
(SwitchPreference) findPreference(Constants.Pref.SEARCH_KEYSERVER)
);
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 {
private CheckBoxPreference mUseTor;
private CheckBoxPreference mUseNormalProxy;
private SwitchPreference mUseTor;
private SwitchPreference mUseNormalProxy;
private EditTextPreference mProxyHost;
private EditTextPreference mProxyPort;
private ListPreference mProxyType;
@@ -293,8 +293,8 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
mActivity.addPreferencesFromResource(R.xml.proxy_prefs);
}
mUseTor = (CheckBoxPreference) automaticallyFindPreference(Constants.Pref.USE_TOR_PROXY);
mUseNormalProxy = (CheckBoxPreference) automaticallyFindPreference(Constants.Pref.USE_NORMAL_PROXY);
mUseTor = (SwitchPreference) automaticallyFindPreference(Constants.Pref.USE_TOR_PROXY);
mUseNormalProxy = (SwitchPreference) automaticallyFindPreference(Constants.Pref.USE_NORMAL_PROXY);
mProxyHost = (EditTextPreference) automaticallyFindPreference(Constants.Pref.PROXY_HOST);
mProxyPort = (EditTextPreference) automaticallyFindPreference(Constants.Pref.PROXY_PORT);
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];
// for keyserver sync
initializeSyncCheckBox(
(CheckBoxPreference) findPreference(Constants.Pref.SYNC_KEYSERVER),
(SwitchPreference) findPreference(Constants.Pref.SYNC_KEYSERVER),
account,
Constants.PROVIDER_AUTHORITY
);
// for contacts sync
initializeSyncCheckBox(
(CheckBoxPreference) findPreference(Constants.Pref.SYNC_CONTACTS),
(SwitchPreference) findPreference(Constants.Pref.SYNC_CONTACTS),
account,
ContactsContract.AUTHORITY
);
}
private void initializeSyncCheckBox(final CheckBoxPreference syncCheckBox,
private void initializeSyncCheckBox(final SwitchPreference syncCheckBox,
final Account account,
final String 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) {
switch (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();
mSearchKeyserver.setChecked(prefs.searchKeyserver);
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();
mSearchKeybase.setChecked(prefs.searchKeybase);
mSearchKeybase.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

View File

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

View File

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

View File

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