Search in sources :

Example 66 with TwoStatePreference

use of android.support.v7.preference.TwoStatePreference in project ring-client-android by savoirfairelinux.

the class MediaPreferenceFragment method setPreferenceDetails.

private void setPreferenceDetails(AccountConfig details) {
    for (ConfigKey confKey : details.getKeys()) {
        Preference pref = findPreference(confKey.key());
        if (pref != null) {
            if (pref instanceof TwoStatePreference) {
                ((TwoStatePreference) pref).setChecked(details.getBool(confKey));
            } else if (confKey == ConfigKey.ACCOUNT_DTMF_TYPE) {
                pref.setDefaultValue(details.get(confKey).contentEquals("overrtp") ? "RTP" : "SIP");
                pref.setSummary(details.get(confKey).contentEquals("overrtp") ? "RTP" : "SIP");
            } else if (confKey == ConfigKey.RINGTONE_PATH) {
                File tmp = new File(details.get(confKey));
                pref.setSummary(tmp.getName());
            } else {
                pref.setSummary(details.get(confKey));
            }
        }
    }
}
Also used : ConfigKey(cx.ring.model.ConfigKey) TwoStatePreference(android.support.v7.preference.TwoStatePreference) TwoStatePreference(android.support.v7.preference.TwoStatePreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) File(java.io.File)

Example 67 with TwoStatePreference

use of android.support.v7.preference.TwoStatePreference in project ring-client-android by savoirfairelinux.

the class SecurityAccountFragment method setDetails.

@Override
public void setDetails(AccountConfig config, String[] tlsMethods) {
    for (int i = 0; i < tlsCategory.getPreferenceCount(); ++i) {
        final Preference current = tlsCategory.getPreference(i);
        final ConfigKey key = ConfigKey.fromString(current.getKey());
        if (current instanceof TwoStatePreference) {
            ((TwoStatePreference) current).setChecked(config.getBool(key));
        } else {
            if (key == ConfigKey.TLS_CA_LIST_FILE) {
                File crt = new File(config.get(ConfigKey.TLS_CA_LIST_FILE));
                current.setSummary(crt.getName());
                setFeedbackIcon(current);
                current.setOnPreferenceClickListener(filePickerListener);
            } else if (key == ConfigKey.TLS_PRIVATE_KEY_FILE) {
                current.setSummary(new File(config.get(ConfigKey.TLS_PRIVATE_KEY_FILE)).getName());
                current.setOnPreferenceClickListener(filePickerListener);
            } else if (key == ConfigKey.TLS_CERTIFICATE_FILE) {
                File pem = new File(config.get(ConfigKey.TLS_CERTIFICATE_FILE));
                current.setSummary(pem.getName());
                setFeedbackIcon(current);
                checkForRSAKey();
                current.setOnPreferenceClickListener(filePickerListener);
            } else if (key == ConfigKey.TLS_METHOD) {
                ListPreference listPref = (ListPreference) current;
                String curVal = config.get(key);
                listPref.setEntries(tlsMethods);
                listPref.setEntryValues(tlsMethods);
                listPref.setValue(curVal);
                current.setSummary(curVal);
            } else if (current instanceof EditTextPreference) {
                String val = config.get(key);
                ((EditTextPreference) current).setText(val);
                current.setSummary(val);
            } else {
                current.setSummary(config.get(key));
            }
        }
        current.setOnPreferenceChangeListener(tlsListener);
    }
}
Also used : ConfigKey(cx.ring.model.ConfigKey) TwoStatePreference(android.support.v7.preference.TwoStatePreference) CredentialsPreference(cx.ring.views.CredentialsPreference) ListPreference(android.support.v7.preference.ListPreference) TwoStatePreference(android.support.v7.preference.TwoStatePreference) Preference(android.support.v7.preference.Preference) EditTextPreference(android.support.v7.preference.EditTextPreference) ListPreference(android.support.v7.preference.ListPreference) EditTextPreference(android.support.v7.preference.EditTextPreference) File(java.io.File)

Example 68 with TwoStatePreference

use of android.support.v7.preference.TwoStatePreference in project ring-client-android by savoirfairelinux.

the class AdvancedAccountFragment method initView.

@Override
public void initView(AccountConfig config, ArrayList<CharSequence> networkInterfaces) {
    for (ConfigKey confKey : config.getKeys()) {
        Preference pref = findPreference(confKey.key());
        if (pref != null) {
            pref.setOnPreferenceChangeListener(this);
            if (confKey == ConfigKey.LOCAL_INTERFACE) {
                String val = config.get(confKey);
                CharSequence[] display = networkInterfaces.toArray(new CharSequence[networkInterfaces.size()]);
                ListPreference listPref = (ListPreference) pref;
                listPref.setEntries(display);
                listPref.setEntryValues(display);
                listPref.setSummary(val);
                listPref.setValue(val);
            } else if (!confKey.isTwoState()) {
                String val = config.get(confKey);
                pref.setSummary(val);
                if (pref instanceof EditTextPreference) {
                    ((EditTextPreference) pref).setText(val);
                }
            } else {
                ((TwoStatePreference) pref).setChecked(config.getBool(confKey));
            }
        }
    }
}
Also used : ConfigKey(cx.ring.model.ConfigKey) ListPreference(android.support.v7.preference.ListPreference) TwoStatePreference(android.support.v7.preference.TwoStatePreference) Preference(android.support.v7.preference.Preference) EditTextPreference(android.support.v7.preference.EditTextPreference) EditTextIntegerPreference(cx.ring.views.EditTextIntegerPreference) PasswordPreference(cx.ring.views.PasswordPreference) ListPreference(android.support.v7.preference.ListPreference) EditTextPreference(android.support.v7.preference.EditTextPreference)

Example 69 with TwoStatePreference

use of android.support.v7.preference.TwoStatePreference in project android_packages_apps_Settings by omnirom.

the class AssistFlashScreenPreferenceController method updatePreference.

private void updatePreference() {
    if (mPreference == null || !(mPreference instanceof TwoStatePreference)) {
        return;
    }
    if (isAvailable()) {
        if (mScreen.findPreference(getPreferenceKey()) == null) {
            // add it if it's not on scree
            mScreen.addPreference(mPreference);
        }
    } else {
        mScreen.removePreference(mPreference);
    }
    ComponentName assistant = getCurrentAssist();
    boolean isContextChecked = AssistContextPreferenceController.isChecked(mContext);
    mPreference.setEnabled(isContextChecked && isPreInstalledAssistant(assistant));
    ((TwoStatePreference) mPreference).setChecked(willShowFlash(assistant));
}
Also used : TwoStatePreference(android.support.v7.preference.TwoStatePreference) ComponentName(android.content.ComponentName)

Example 70 with TwoStatePreference

use of android.support.v7.preference.TwoStatePreference in project android_packages_apps_Settings by omnirom.

the class VibrateWhenRingPreferenceControllerTest method updateState_settingIsOff_preferenceShouldNotBeChecked.

@Test
public void updateState_settingIsOff_preferenceShouldNotBeChecked() {
    final TwoStatePreference preference = mock(TwoStatePreference.class);
    final Context context = ShadowApplication.getInstance().getApplicationContext();
    Settings.System.putInt(context.getContentResolver(), VIBRATE_WHEN_RINGING, 0);
    mController = new VibrateWhenRingPreferenceController(context);
    mController.updateState(preference);
    verify(preference).setChecked(false);
}
Also used : Context(android.content.Context) TwoStatePreference(android.support.v7.preference.TwoStatePreference) Test(org.junit.Test)

Aggregations

TwoStatePreference (android.support.v7.preference.TwoStatePreference)94 Context (android.content.Context)50 Test (org.junit.Test)48 Preference (android.support.v7.preference.Preference)26 ComponentName (android.content.ComponentName)7 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)7 DropDownPreference (android.support.v7.preference.DropDownPreference)6 DefaultRingtonePreference (com.android.settings.DefaultRingtonePreference)6 Calendar (java.util.Calendar)6 Date (java.util.Date)6 InputMethodInfo (android.view.inputmethod.InputMethodInfo)5 ConfigKey (cx.ring.model.ConfigKey)5 InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)4 EditTextPreference (android.support.v7.preference.EditTextPreference)3 PreferenceScreen (android.support.v7.preference.PreferenceScreen)3 File (java.io.File)3 PackageManager (android.content.pm.PackageManager)2 CheckBoxPreference (android.support.v7.preference.CheckBoxPreference)2 ListPreference (android.support.v7.preference.ListPreference)2 SwitchPreferenceCompat (android.support.v7.preference.SwitchPreferenceCompat)2