Search in sources :

Example 11 with CheckBoxPreference

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());
}
Also used : CheckBoxPreference(android.support.v7.preference.CheckBoxPreference)

Example 12 with CheckBoxPreference

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;
            }
        });
    }
}
Also used : Preference(android.support.v7.preference.Preference) CheckBoxPreference(android.support.v7.preference.CheckBoxPreference) ListPreference(android.support.v7.preference.ListPreference) OnPreferenceChangeListener(android.support.v7.preference.Preference.OnPreferenceChangeListener)

Example 13 with CheckBoxPreference

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;
            }
        });
    }
}
Also used : Preference(android.support.v7.preference.Preference) CheckBoxPreference(android.support.v7.preference.CheckBoxPreference) ListPreference(android.support.v7.preference.ListPreference) OnPreferenceChangeListener(android.support.v7.preference.Preference.OnPreferenceChangeListener)

Example 14 with CheckBoxPreference

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);
}
Also used : SwitchPreferenceCompat(android.support.v7.preference.SwitchPreferenceCompat) CheckBoxPreference(android.support.v7.preference.CheckBoxPreference) TwoStatePreference(android.support.v7.preference.TwoStatePreference) Preference(android.support.v7.preference.Preference) CheckBoxPreference(android.support.v7.preference.CheckBoxPreference)

Example 15 with CheckBoxPreference

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);
}
Also used : CheckBoxPreference(android.support.v7.preference.CheckBoxPreference) SwitchPreferenceCompat(android.support.v7.preference.SwitchPreferenceCompat) EditTextPreference(com.takisoft.fix.support.v7.preference.EditTextPreference) ListPreference(android.support.v7.preference.ListPreference)

Aggregations

CheckBoxPreference (android.support.v7.preference.CheckBoxPreference)31 Preference (android.support.v7.preference.Preference)17 ListPreference (android.support.v7.preference.ListPreference)13 Intent (android.content.Intent)10 CheckBoxPreference (android.preference.CheckBoxPreference)8 Context (android.content.Context)7 SharedPreferences (android.content.SharedPreferences)7 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)7 Preference (android.preference.Preference)6 AlertDialog (android.support.v7.app.AlertDialog)6 PreferenceScreen (android.support.v7.preference.PreferenceScreen)5 SwitchPreferenceCompat (android.support.v7.preference.SwitchPreferenceCompat)5 Uri (android.net.Uri)4 Build (android.os.Build)4 PreferenceScreen (android.preference.PreferenceScreen)4 View (android.view.View)4 ArrayList (java.util.ArrayList)4 PackageManager (android.content.pm.PackageManager)3 Bundle (android.os.Bundle)3 ListPreference (android.preference.ListPreference)3