use of android.support.v7.preference.CheckBoxPreference in project Signal-Android by signalapp.
the class AdvancedPreferenceFragment method initializePushMessagingToggle.
private void initializePushMessagingToggle() {
CheckBoxPreference preference = (CheckBoxPreference) this.findPreference(PUSH_MESSAGING_PREF);
if (TextSecurePreferences.isPushRegistered(getActivity())) {
preference.setChecked(true);
preference.setSummary(TextSecurePreferences.getLocalNumber(getActivity()));
} else {
preference.setChecked(false);
preference.setSummary(R.string.preferences__free_private_messages_and_calls);
}
preference.setOnPreferenceChangeListener(new PushMessagingClickListener());
}
use of android.support.v7.preference.CheckBoxPreference in project android_packages_apps_Settings by omnirom.
the class ApplicationSettings method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.application_settings);
mToggleAdvancedSettings = (CheckBoxPreference) findPreference(KEY_TOGGLE_ADVANCED_SETTINGS);
mToggleAdvancedSettings.setChecked(isAdvancedSettingsEnabled());
getPreferenceScreen().removePreference(mToggleAdvancedSettings);
// not ready for prime time yet
if (false) {
getPreferenceScreen().removePreference(mInstallLocation);
}
mInstallLocation = (ListPreference) findPreference(KEY_APP_INSTALL_LOCATION);
// Is app default install location set?
boolean userSetInstLocation = (Settings.Global.getInt(getContentResolver(), Settings.Global.SET_INSTALL_LOCATION, 0) != 0);
if (!userSetInstLocation) {
getPreferenceScreen().removePreference(mInstallLocation);
} else {
mInstallLocation.setValue(getAppInstallLocation());
mInstallLocation.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
String value = (String) newValue;
handleUpdateAppInstallLocation(value);
return false;
}
});
}
}
use of android.support.v7.preference.CheckBoxPreference in project android_packages_apps_Settings by DirtyUnicorns.
the class ApplicationSettings method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.application_settings);
mToggleAdvancedSettings = (CheckBoxPreference) findPreference(KEY_TOGGLE_ADVANCED_SETTINGS);
mToggleAdvancedSettings.setChecked(isAdvancedSettingsEnabled());
getPreferenceScreen().removePreference(mToggleAdvancedSettings);
// not ready for prime time yet
if (false) {
getPreferenceScreen().removePreference(mInstallLocation);
}
mInstallLocation = (ListPreference) findPreference(KEY_APP_INSTALL_LOCATION);
// Is app default install location set?
boolean userSetInstLocation = (Settings.Global.getInt(getContentResolver(), Settings.Global.SET_INSTALL_LOCATION, 0) != 0);
if (!userSetInstLocation) {
getPreferenceScreen().removePreference(mInstallLocation);
} else {
mInstallLocation.setValue(getAppInstallLocation());
mInstallLocation.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
String value = (String) newValue;
handleUpdateAppInstallLocation(value);
return false;
}
});
}
}
use of android.support.v7.preference.CheckBoxPreference in project vlc-android by GeoffreyMetais.
the class PreferencesExtensionFragment method onPreferenceTreeClick.
@Override
public boolean onPreferenceTreeClick(Preference preference) {
String key = preference.getKey();
if (key == null || !key.startsWith(mExtensionKey))
return false;
if (key.equals(mExtensionKey)) {
SwitchPreferenceCompat switchPreference = (SwitchPreferenceCompat) preference;
mSettings.edit().putBoolean(key, switchPreference.isChecked()).apply();
if (switchPreference.isChecked()) {
for (Preference checkbox : preferences) checkbox.setEnabled(true);
} else {
for (Preference checkbox : preferences) {
((CheckBoxPreference) checkbox).setChecked(false);
mSettings.edit().putBoolean(checkbox.getKey(), false).apply();
checkbox.setEnabled(false);
}
}
} else if (key.endsWith("_" + ExtensionsManager.ANDROID_AUTO_SUFFIX)) {
mSettings.edit().putBoolean(preference.getKey(), ((TwoStatePreference) preference).isChecked()).apply();
}
return super.onPreferenceTreeClick(preference);
}
use of android.support.v7.preference.CheckBoxPreference in project RespawnIRC-Android by FranckRJ.
the class SettingsFragment method updatePrefDefaultValue.
/* Le but de la clef temporaire est de ne pas sauvegarder l'option par défaut si c'est celle ci
* qui est retourné par "PrefsManager.getX()". La clef temporaire n'est pas vide pour empêcher
* des possibles crash (des histoires de requireKey() etc). Elle est unique par type de pref pour
* ne pas causer de crash lors de l'assignation d'un string à ce qui était précédement un bool.
* La persistance est temporairement à false pour plus de sécurité, au cas où, dans le doute,
* mais ça reste plutôt assez moche comme solution au final. */
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);
}
Aggregations