Search in sources :

Example 1 with ConfigKey

use of cx.ring.model.ConfigKey in project ring-client-android by savoirfairelinux.

the class GeneralAccountFragment method setPreferenceDetails.

private void setPreferenceDetails(AccountConfig details) {
    for (ConfigKey confKey : details.getKeys()) {
        Preference pref = findPreference(confKey.key());
        if (pref == null) {
            continue;
        }
        if (!confKey.isTwoState()) {
            String val = details.get(confKey);
            ((EditTextPreference) pref).setText(val);
            if (pref instanceof PasswordPreference) {
                StringBuilder tmp = new StringBuilder();
                for (int i = 0; i < val.length(); ++i) {
                    tmp.append("*");
                }
                pref.setSummary(tmp.toString());
            } else {
                pref.setSummary(val);
            }
        } else {
            ((TwoStatePreference) pref).setChecked(details.getBool(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) EditTextPreference(android.support.v7.preference.EditTextPreference) EditTextIntegerPreference(cx.ring.views.EditTextIntegerPreference) PasswordPreference(cx.ring.views.PasswordPreference) PasswordPreference(cx.ring.views.PasswordPreference) EditTextPreference(android.support.v7.preference.EditTextPreference)

Example 2 with ConfigKey

use of cx.ring.model.ConfigKey in project ring-client-android by savoirfairelinux.

the class SecurityAccountFragment method onActivityResult.

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_CANCELED) {
        return;
    }
    Uri uri = data.getData();
    if (uri == null) {
        return;
    }
    File myFile = new File(uri.getEncodedPath());
    ConfigKey key = null;
    Preference preference;
    switch(requestCode) {
        case SELECT_CA_LIST_RC:
            preference = tlsCategory.findPreference(ConfigKey.TLS_CA_LIST_FILE.key());
            preference.setSummary(myFile.getName());
            key = ConfigKey.TLS_CA_LIST_FILE;
            setFeedbackIcon(preference);
            break;
        case SELECT_PRIVATE_KEY_RC:
            tlsCategory.findPreference(ConfigKey.TLS_PRIVATE_KEY_FILE.key()).setSummary(myFile.getName());
            key = ConfigKey.TLS_PRIVATE_KEY_FILE;
            break;
        case SELECT_CERTIFICATE_RC:
            preference = tlsCategory.findPreference(ConfigKey.TLS_CERTIFICATE_FILE.key());
            preference.setSummary(myFile.getName());
            key = ConfigKey.TLS_CERTIFICATE_FILE;
            setFeedbackIcon(preference);
            checkForRSAKey();
            break;
        default:
            break;
    }
    presenter.fileActivityResult(key, myFile.getAbsolutePath());
}
Also used : ConfigKey(cx.ring.model.ConfigKey) 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) Uri(android.net.Uri) File(java.io.File)

Example 3 with ConfigKey

use of cx.ring.model.ConfigKey in project ring-client-android by savoirfairelinux.

the class AdvancedAccountFragment method onPreferenceChange.

@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    final ConfigKey key = ConfigKey.fromString(preference.getKey());
    presenter.preferenceChanged(key, newValue);
    if (preference instanceof TwoStatePreference) {
        presenter.twoStatePreferenceChanged(key, newValue);
    } else if (preference instanceof PasswordPreference) {
        presenter.passwordPreferenceChanged(key, newValue);
        preference.setSummary(TextUtils.isEmpty(newValue.toString()) ? "" : "******");
    } else {
        presenter.preferenceChanged(key, newValue);
        preference.setSummary(newValue.toString());
    }
    return true;
}
Also used : ConfigKey(cx.ring.model.ConfigKey) TwoStatePreference(android.support.v7.preference.TwoStatePreference) PasswordPreference(cx.ring.views.PasswordPreference)

Example 4 with ConfigKey

use of cx.ring.model.ConfigKey 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 5 with ConfigKey

use of cx.ring.model.ConfigKey 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)

Aggregations

TwoStatePreference (android.support.v7.preference.TwoStatePreference)6 ConfigKey (cx.ring.model.ConfigKey)6 Preference (android.support.v7.preference.Preference)5 EditTextPreference (android.support.v7.preference.EditTextPreference)4 ListPreference (android.support.v7.preference.ListPreference)3 PasswordPreference (cx.ring.views.PasswordPreference)3 File (java.io.File)3 CredentialsPreference (cx.ring.views.CredentialsPreference)2 EditTextIntegerPreference (cx.ring.views.EditTextIntegerPreference)2 Uri (android.net.Uri)1 SwitchPreference (android.support.v14.preference.SwitchPreference)1