本文整理汇总了Java中android.support.v7.preference.SwitchPreferenceCompat.setChecked方法的典型用法代码示例。如果您正苦于以下问题:Java SwitchPreferenceCompat.setChecked方法的具体用法?Java SwitchPreferenceCompat.setChecked怎么用?Java SwitchPreferenceCompat.setChecked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.preference.SwitchPreferenceCompat
的用法示例。
在下文中一共展示了SwitchPreferenceCompat.setChecked方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onViewCreated
import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);
app = (App) getContext().getApplicationContext();
view.setBackgroundColor(Color.parseColor("#FFFFFF"));
SwitchPreferenceCompat preference = (SwitchPreferenceCompat)findPreference("enableNotifications");
preference.setOnPreferenceChangeListener(onSetAlarm);
ListPreference delay = (ListPreference)findPreference("delayNotifications");
delay.setOnPreferenceChangeListener(onDelayChange);
CheckBoxPreference display = (CheckBoxPreference)findPreference("displaySilNotification");
display.setOnPreferenceChangeListener(onDisplayChange);
if (app.getPublicPreferenceB(Common.GLOBAL_SETTING_ISNOTIFON)) {
preference.setChecked(true);
delay.setEnabled(true);
delay.setValueIndex(getIdByTime(app.account.getNotificationTime()));
display.setEnabled(true);
display.setChecked(app.getPublicPreferenceB(Common.GLOBAL_SETTING_NOTIFICATIONDISPLAY));
} else {
preference.setChecked(false);
delay.setEnabled(false);
display.setEnabled(false);
display.setChecked(false);
}
}
示例2: updatePrefDefaultValue
import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
private static void updatePrefDefaultValue(Preference pref) {
String realPrefKey = pref.getKey();
pref.setPersistent(false);
if (pref instanceof CheckBoxPreference) {
pref.setKey("tmpKeyBool");
CheckBoxPreference checkBoxPref = (CheckBoxPreference) pref;
checkBoxPref.setChecked(PrefsManager.getBool(realPrefKey));
} else if (pref instanceof SwitchPreferenceCompat) {
pref.setKey("tmpKeyBool");
SwitchPreferenceCompat switchPref = (SwitchPreferenceCompat) pref;
switchPref.setChecked(PrefsManager.getBool(realPrefKey));
} else if (pref instanceof EditTextPreference) {
pref.setKey("tmpKeyString");
EditTextPreference editTextPref = (EditTextPreference) pref;
editTextPref.setText(PrefsManager.getString(realPrefKey));
} else if (pref instanceof ListPreference) {
pref.setKey("tmpKeyString");
ListPreference listPref = (ListPreference) pref;
listPref.setValue(PrefsManager.getString(realPrefKey));
}
pref.setPersistent(true);
pref.setKey(realPrefKey);
}
示例3: onCreatePreferencesFix
import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
@Override
public void onCreatePreferencesFix(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.app_preferences);
PreferenceScreen mainPreferenceScreen = (PreferenceScreen) findPreference("mainPreferenceScreen");
pushPreferenceCat = findPreference("pushCat");
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
Preference downloadNotificationCat = findPreference("downloadNotificationCat");
mainPreferenceScreen.removePreference(downloadNotificationCat);
}
crashlyticsAlwaysSendPreference = (SwitchPreferenceCompat) findPreference(getString(R.string.pref_key_crashlytics_always_send));
crashlyticsAlwaysSendPreference.setChecked(TazSettings.getInstance(getContext())
.getCrashlyticsAlwaysSend());
crashlyticsAlwaysSendPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
TazSettings.getInstance(preference.getContext())
.setCrashlyticsAlwaysSend((Boolean) newValue);
return true;
}
});
setPushPrefState(!TextUtils.isEmpty(TazSettings.getInstance(getContext())
.getFirebaseToken()));
}
示例4: onCreatePreferences
import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
@Override
public void onCreatePreferences(Bundle bundle, String s) {
addPreferencesFromResource(R.xml.pref_discogs);
SwitchPreferenceCompat sw = (SwitchPreferenceCompat) findPreference("enable_discogs");
Discogs discogs = Discogs.getInstance(getContext());
boolean loggedin = discogs.isLoggedIn();
sw.setChecked(loggedin);
if(loggedin) {
sw.setSummaryOn("Signed in as " + discogs.getUser());
}
Preference preloadButton = findPreference("discogs_preload_collection");
preloadButton.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
Discogs.getInstance(getActivity()).preloadCollection();
return true;
}
});
}
示例5: activateBackup
import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
private void activateBackup() {
final SwitchPreferenceCompat backupActivePref = (SwitchPreferenceCompat) findPreference(KEY_BACKUP_ACTIVE_BOOL);
if (!backupActivePref.isChecked()) {
backupActivePref.setChecked(true);
}
changeProgressBarVisibility(false);
}
示例6: onPreferenceChange
import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object newValue)
{
SettingsManager pref = new SettingsManager(getActivity().getApplicationContext());
if (preference instanceof SwitchPreferenceCompat) {
pref.put(preference.getKey(), (boolean) newValue);
} else if (preference.getKey().equals(getString(R.string.pref_key_port))) {
int value = TorrentEngine.Settings.DEFAULT_PORT;
if (!TextUtils.isEmpty((String) newValue)) {
value = Integer.parseInt((String) newValue);
}
pref.put(preference.getKey(), value);
preference.setSummary(Integer.toString(value));
} else if (preference.getKey().equals(getString(R.string.pref_key_enc_mode))) {
int type = Integer.parseInt((String) newValue);
pref.put(preference.getKey(), type);
String typesName[] = getResources().getStringArray(R.array.pref_enc_mode_entries);
preference.setSummary(typesName[type]);
boolean enableAdvancedEncryptSettings = type != Integer.parseInt(getString(R.string.pref_enc_mode_disable_value));
String keyEncryptInConnections = getString(R.string.pref_key_enc_in_connections);
SwitchPreferenceCompat encryptInConnections =
(SwitchPreferenceCompat) findPreference(keyEncryptInConnections);
encryptInConnections.setEnabled(enableAdvancedEncryptSettings);
encryptInConnections.setChecked(enableAdvancedEncryptSettings);
String keyEncryptOutConnections = getString(R.string.pref_key_enc_out_connections);
SwitchPreferenceCompat encryptOutConnections =
(SwitchPreferenceCompat) findPreference(keyEncryptOutConnections);
encryptOutConnections.setEnabled(enableAdvancedEncryptSettings);
encryptOutConnections.setChecked(enableAdvancedEncryptSettings);
}
return true;
}
示例7: disableBatteryControl
import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
private void disableBatteryControl(SettingsManager pref)
{
String keyBatteryControl = getString(R.string.pref_key_battery_control);
SwitchPreferenceCompat batteryControl = (SwitchPreferenceCompat) findPreference(keyBatteryControl);
batteryControl.setChecked(false);
pref.put(batteryControl.getKey(), false);
disableCustomBatteryControl(pref);
}
示例8: disableCustomBatteryControl
import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
private void disableCustomBatteryControl(SettingsManager pref)
{
String keyCustomBatteryControl = getString(R.string.pref_key_custom_battery_control);
SwitchPreferenceCompat batteryControl = (SwitchPreferenceCompat) findPreference(keyCustomBatteryControl);
batteryControl.setChecked(false);
pref.put(batteryControl.getKey(), false);
}
示例9: accountChanged
import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
@Override
public void accountChanged(Account account) {
if (account == null) {
Log.d(TAG, "accountChanged: Null account");
return;
}
setPreferenceDetails(account.getConfig());
SwitchPreferenceCompat pref = (SwitchPreferenceCompat) findPreference("Account.status");
if (account.isSip() && pref != null) {
String status;
pref.setTitle(account.getAlias());
if (account.isEnabled()) {
if (account.isTrying()) {
status = getString(R.string.account_status_connecting);
} else if (account.needsMigration()) {
status = getString(R.string.account_update_needed);
} else if (account.isInError()) {
status = getString(R.string.account_status_connection_error);
} else if (account.isRegistered()) {
status = getString(R.string.account_status_online);
} else {
status = getString(R.string.account_status_unknown);
}
} else {
status = getString(R.string.account_status_offline);
}
pref.setSummary(status);
pref.setChecked(account.isEnabled());
// An ip2ip account is always ready
pref.setEnabled(!account.isIP2IP());
pref.setOnPreferenceChangeListener(changeAccountStatusListener);
}
setPreferenceListener(account.getConfig(), changeBasicPreferenceListener);
}
示例10: PrefEGM96SetToFalse
import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
public void PrefEGM96SetToFalse() {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext());
SharedPreferences.Editor editor1 = settings.edit();
editor1.putBoolean("prefEGM96AltitudeCorrection", false);
editor1.commit();
SwitchPreferenceCompat EGM96 = (SwitchPreferenceCompat) super.findPreference("prefEGM96AltitudeCorrection");
EGM96.setChecked(false);
}
示例11: PrefEGM96SetToTrue
import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
public void PrefEGM96SetToTrue() {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext());
SharedPreferences.Editor editor1 = settings.edit();
editor1.putBoolean("prefEGM96AltitudeCorrection", true);
editor1.commit();
SwitchPreferenceCompat EGM96 = (SwitchPreferenceCompat) super.findPreference("prefEGM96AltitudeCorrection");
EGM96.setChecked(true);
}
示例12: init
import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
private void init() {
addPreferencesFromResource(R.xml.settings);
if (Utils.DONATED) {
getPreferenceScreen().removePreference(findPreference(KEY_AD_VIEW));
}
SwitchPreferenceCompat forceEnglish = (SwitchPreferenceCompat) findPreference(KEY_FORCE_ENGLISH);
if (Resources.getSystem().getConfiguration().locale.getLanguage().startsWith("en")) {
getPreferenceScreen().removePreference(forceEnglish);
} else {
forceEnglish.setOnPreferenceChangeListener(this);
}
/*
if (Utils.hideStartActivity()) {
((PreferenceCategory) findPreference(KEY_USER_INTERFACE))
.removePreference(findPreference(KEY_MATERIAL_ICON));
} else {
findPreference(KEY_MATERIAL_ICON).setOnPreferenceChangeListener(this);
}
*/
findPreference(KEY_RESET_DATA).setOnPreferenceClickListener(this);
findPreference(KEY_UPDATE_NOTIFICATION).setOnPreferenceChangeListener(this);
findPreference(KEY_CHECK_UPDATE).setOnPreferenceClickListener(this);
findPreference(KEY_DARK_THEME).setOnPreferenceChangeListener(this);
findPreference(KEY_BANNER_RESIZER).setOnPreferenceClickListener(this);
findPreference(KEY_HIDE_BANNER).setOnPreferenceChangeListener(this);
findPreference(KEY_ACCENT_COLOR).setOnPreferenceClickListener(this);
findPreference(KEY_SECTIONS_ICON).setOnPreferenceChangeListener(this);
findPreference(KEY_APPLY_ON_BOOT_TEST).setOnPreferenceClickListener(this);
findPreference(KEY_LOGCAT).setOnPreferenceClickListener(this);
if (Utils.existFile("/proc/last_kmsg") || Utils.existFile("/sys/fs/pstore/console-ramoops")) {
findPreference(KEY_LAST_KMSG).setOnPreferenceClickListener(this);
} else {
((PreferenceCategory) findPreference(KEY_DEBUGGING_CATEGORY)).removePreference(
findPreference(KEY_LAST_KMSG));
}
findPreference(KEY_DMESG).setOnPreferenceClickListener(this);
findPreference(KEY_SET_PASSWORD).setOnPreferenceClickListener(this);
findPreference(KEY_DELETE_PASSWORD).setOnPreferenceClickListener(this);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
|| !FingerprintManagerCompat.from(getActivity()).isHardwareDetected()) {
((PreferenceCategory) findPreference(KEY_SECURITY_CATEGORY)).removePreference(
findPreference(KEY_FINGERPRINT));
} else {
mFingerprint = findPreference(KEY_FINGERPRINT);
mFingerprint.setEnabled(!Prefs.getString("password", "", getActivity()).isEmpty());
}
PreferenceCategory sectionsCategory = (PreferenceCategory) findPreference(KEY_SECTIONS);
for (NavigationActivity.NavigationFragment navigationFragment : NavigationActivity.sFragments) {
Fragment fragment = navigationFragment.mFragment;
int id = navigationFragment.mId;
if (fragment != null && fragment.getClass() != SettingsFragment.class) {
SwitchPreferenceCompat switchPreference = new SwitchPreferenceCompat(
new ContextThemeWrapper(getActivity(), R.style.Preference_SwitchPreferenceCompat_Material));
switchPreference.setSummary(getString(id));
switchPreference.setKey(fragment.getClass().getSimpleName() + "_enabled");
switchPreference.setChecked(Prefs.getBoolean(fragment.getClass().getSimpleName()
+ "_enabled", true, getActivity()));
switchPreference.setOnPreferenceChangeListener(this);
switchPreference.setPersistent(false);
sectionsCategory.addPreference(switchPreference);
}
}
}
示例13: init
import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
private void init() {
addPreferencesFromResource(R.xml.settings);
if (Utils.DONATED) {
getPreferenceScreen().removePreference(findPreference(KEY_AD_VIEW));
}
SwitchPreferenceCompat forceEnglish = (SwitchPreferenceCompat) findPreference(KEY_FORCE_ENGLISH);
if (Resources.getSystem().getConfiguration().locale.getLanguage().startsWith("en")) {
getPreferenceScreen().removePreference(forceEnglish);
} else {
forceEnglish.setOnPreferenceChangeListener(this);
}
if (Utils.hideStartActivity()) {
((PreferenceCategory) findPreference(KEY_USER_INTERFACE))
.removePreference(findPreference(KEY_MATERIAL_ICON));
} else {
findPreference(KEY_MATERIAL_ICON).setOnPreferenceChangeListener(this);
}
findPreference(KEY_DARK_THEME).setOnPreferenceChangeListener(this);
findPreference(KEY_BANNER_RESIZER).setOnPreferenceClickListener(this);
findPreference(KEY_HIDE_BANNER).setOnPreferenceChangeListener(this);
findPreference(KEY_ACCENT_COLOR).setOnPreferenceClickListener(this);
findPreference(KEY_SECTIONS_ICON).setOnPreferenceChangeListener(this);
findPreference(KEY_APPLY_ON_BOOT_TEST).setOnPreferenceClickListener(this);
findPreference(KEY_LOGCAT).setOnPreferenceClickListener(this);
if (Utils.existFile("/proc/last_kmsg") || Utils.existFile("/sys/fs/pstore/console-ramoops")) {
findPreference(KEY_LAST_KMSG).setOnPreferenceClickListener(this);
} else {
((PreferenceCategory) findPreference(KEY_DEBUGGING_CATEGORY)).removePreference(
findPreference(KEY_LAST_KMSG));
}
findPreference(KEY_DMESG).setOnPreferenceClickListener(this);
findPreference(KEY_SET_PASSWORD).setOnPreferenceClickListener(this);
findPreference(KEY_DELETE_PASSWORD).setOnPreferenceClickListener(this);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
|| !FingerprintManagerCompat.from(getActivity()).isHardwareDetected()) {
((PreferenceCategory) findPreference(KEY_SECURITY_CATEGORY)).removePreference(
findPreference(KEY_FINGERPRINT));
} else {
mFingerprint = findPreference(KEY_FINGERPRINT);
mFingerprint.setEnabled(!Prefs.getString("password", "", getActivity()).isEmpty());
}
PreferenceCategory sectionsCategory = (PreferenceCategory) findPreference(KEY_SECTIONS);
for (NavigationActivity.NavigationFragment navigationFragment : NavigationActivity.sFragments) {
Fragment fragment = navigationFragment.mFragment;
int id = navigationFragment.mId;
if (fragment != null && fragment.getClass() != SettingsFragment.class) {
SwitchPreferenceCompat switchPreference = new SwitchPreferenceCompat(
new ContextThemeWrapper(getActivity(), R.style.Preference_SwitchPreferenceCompat_Material));
switchPreference.setSummary(getString(id));
switchPreference.setKey(fragment.getClass().getSimpleName() + "_enabled");
switchPreference.setChecked(Prefs.getBoolean(fragment.getClass().getSimpleName()
+ "_enabled", true, getActivity()));
switchPreference.setOnPreferenceChangeListener(this);
switchPreference.setPersistent(false);
sectionsCategory.addPreference(switchPreference);
}
}
}
示例14: onCreate
import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
SettingsManager pref = new SettingsManager(getActivity().getApplicationContext());
boolean enableAdvancedSettings;
String keyProxyType = getString(R.string.pref_key_proxy_type);
ListPreference proxyType = (ListPreference) findPreference(keyProxyType);
int type = pref.getInt(keyProxyType, SettingsManager.Default.proxyType);
proxyType.setValueIndex(type);
String typesName[] = getResources().getStringArray(R.array.pref_proxy_type_entries);
proxyType.setSummary(typesName[type]);
enableAdvancedSettings = type != Integer.parseInt(getString(R.string.pref_proxy_type_none_value));
bindOnPreferenceChangeListener(proxyType);
String keyAddress = getString(R.string.pref_key_proxy_address);
EditTextPreference address = (EditTextPreference) findPreference(keyAddress);
address.setEnabled(enableAdvancedSettings);
String addressValue = pref.getString(keyAddress, SettingsManager.Default.proxyAddress);
address.setText(addressValue);
address.setSummary(addressValue);
bindOnPreferenceChangeListener(address);
String keyPort = getString(R.string.pref_key_proxy_port);
EditTextPreference port = (EditTextPreference) findPreference(keyPort);
port.setEnabled(enableAdvancedSettings);
InputFilter[] portFilter =
new InputFilter[]{new InputFilterMinMax(0, 10000)};
int portNumber = pref.getInt(keyPort, SettingsManager.Default.proxyPort);
String portValue = Integer.toString(portNumber);
port.getEditText().setFilters(portFilter);
port.setSummary(portValue);
port.setText(portValue);
bindOnPreferenceChangeListener(port);
String keyProxyPeersToo = getString(R.string.pref_key_proxy_peers_too);
SwitchPreferenceCompat proxyPeersToo = (SwitchPreferenceCompat) findPreference(keyProxyPeersToo);
proxyPeersToo.setEnabled(enableAdvancedSettings);
proxyPeersToo.setChecked(pref.getBoolean(keyProxyPeersToo, SettingsManager.Default.proxyPeersToo));
bindOnPreferenceChangeListener(proxyPeersToo);
String keyForceProxy = getString(R.string.pref_key_force_proxy);
SwitchPreferenceCompat forceProxy = (SwitchPreferenceCompat) findPreference(keyForceProxy);
forceProxy.setEnabled(enableAdvancedSettings);
forceProxy.setChecked(pref.getBoolean(keyForceProxy, SettingsManager.Default.forceProxy));
bindOnPreferenceChangeListener(forceProxy);
String keyRequiresAuth = getString(R.string.pref_key_proxy_requires_auth);
SwitchPreferenceCompat requiresAuth = (SwitchPreferenceCompat) findPreference(keyRequiresAuth);
requiresAuth.setEnabled(enableAdvancedSettings);
requiresAuth.setChecked(pref.getBoolean(keyRequiresAuth, SettingsManager.Default.proxyRequiresAuth));
bindOnPreferenceChangeListener(requiresAuth);
String keyLogin = getString(R.string.pref_key_proxy_login);
EditTextPreference login = (EditTextPreference) findPreference(keyLogin);
String loginValue = pref.getString(keyLogin, SettingsManager.Default.proxyLogin);
login.setText(loginValue);
login.setSummary(loginValue);
bindOnPreferenceChangeListener(login);
String keyPassword = getString(R.string.pref_key_proxy_password);
EditTextPreference password = (EditTextPreference) findPreference(keyPassword);
String passwordValue = pref.getString(keyPassword, SettingsManager.Default.proxyPassword);
password.setText(passwordValue);
EditText edit = password.getEditText();
password.setSummary(edit.getTransformationMethod().getTransformation(passwordValue, edit).toString());
bindOnPreferenceChangeListener(password);
}
示例15: onCreate
import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
final SettingsManager pref = new SettingsManager(getActivity().getApplicationContext());
String keyAutostart = getString(R.string.pref_key_autostart);
SwitchPreferenceCompat autostart = (SwitchPreferenceCompat) findPreference(keyAutostart);
autostart.setChecked(pref.getBoolean(keyAutostart, SettingsManager.Default.autostart));
bindOnPreferenceChangeListener(autostart);
String keyKeepAlive = getString(R.string.pref_key_keep_alive);
SwitchPreferenceCompat keepAlive = (SwitchPreferenceCompat) findPreference(keyKeepAlive);
keepAlive.setChecked(pref.getBoolean(keyKeepAlive, SettingsManager.Default.keepAlive));
bindOnPreferenceChangeListener(keepAlive);
String keyShutdownComplete = getString(R.string.pref_key_shutdown_downloads_complete);
SwitchPreferenceCompat shutdownComplete = (SwitchPreferenceCompat) findPreference(keyShutdownComplete);
shutdownComplete.setChecked(pref.getBoolean(keyShutdownComplete, SettingsManager.Default.shutdownDownloadsComplete));
bindOnPreferenceChangeListener(shutdownComplete);
String keyCpuSleep = getString(R.string.pref_key_cpu_do_not_sleep);
SwitchPreferenceCompat cpuSleep = (SwitchPreferenceCompat) findPreference(keyCpuSleep);
cpuSleep.setChecked(pref.getBoolean(keyCpuSleep, SettingsManager.Default.cpuDoNotSleep));
bindOnPreferenceChangeListener(cpuSleep);
String keyOnlyCharging = getString(R.string.pref_key_download_and_upload_only_when_charging);
SwitchPreferenceCompat onlyCharging = (SwitchPreferenceCompat) findPreference(keyOnlyCharging);
onlyCharging.setChecked(pref.getBoolean(keyOnlyCharging, SettingsManager.Default.onlyCharging));
bindOnPreferenceChangeListener(onlyCharging);
String keyBatteryControl = getString(R.string.pref_key_battery_control);
SwitchPreferenceCompat batteryControl = (SwitchPreferenceCompat) findPreference(keyBatteryControl);
batteryControl.setSummary(String.format(getString(R.string.pref_battery_control_summary),
Utils.getDefaultBatteryLowLevel()));
batteryControl.setChecked(pref.getBoolean(keyBatteryControl, SettingsManager.Default.batteryControl));
bindOnPreferenceChangeListener(batteryControl);
String keyCustomBatteryControl = getString(R.string.pref_key_custom_battery_control);
SwitchPreferenceCompat customBatteryControl = (SwitchPreferenceCompat) findPreference(keyCustomBatteryControl);
customBatteryControl.setSummary(String.format(getString(R.string.pref_custom_battery_control_summary),
Utils.getDefaultBatteryLowLevel()));
customBatteryControl.setChecked(pref.getBoolean(keyCustomBatteryControl, SettingsManager.Default.customBatteryControl));
bindOnPreferenceChangeListener(customBatteryControl);
String keyCustomBatteryControlValue = getString(R.string.pref_key_custom_battery_control_value);
SeekBarPreference customBatteryControlValue = (SeekBarPreference) findPreference(keyCustomBatteryControlValue);
customBatteryControlValue.setValue(pref.getInt(keyCustomBatteryControlValue, Utils.getDefaultBatteryLowLevel()));
customBatteryControlValue.setMin(10);
customBatteryControlValue.setMax(90);
bindOnPreferenceChangeListener(customBatteryControlValue);
String keyWifiOnly = getString(R.string.pref_key_wifi_only);
SwitchPreferenceCompat wifiOnly = (SwitchPreferenceCompat) findPreference(keyWifiOnly);
wifiOnly.setChecked(pref.getBoolean(keyWifiOnly, SettingsManager.Default.wifiOnly));
bindOnPreferenceChangeListener(wifiOnly);
}