Search in sources :

Example 1 with PasswordPreference

use of cx.ring.views.PasswordPreference 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 PasswordPreference

use of cx.ring.views.PasswordPreference in project ring-client-android by savoirfairelinux.

the class GeneralAccountFragment method onDisplayPreferenceDialog.

@Override
public void onDisplayPreferenceDialog(Preference preference) {
    if (getFragmentManager().findFragmentByTag(DIALOG_FRAGMENT_TAG) != null) {
        return;
    }
    if (preference instanceof EditTextIntegerPreference) {
        EditTextPreferenceDialog f = EditTextPreferenceDialog.newInstance(preference.getKey(), EditorInfo.TYPE_CLASS_NUMBER);
        f.setTargetFragment(this, 0);
        f.show(getFragmentManager(), DIALOG_FRAGMENT_TAG);
    } else if (preference instanceof PasswordPreference) {
        EditTextPreferenceDialog f = EditTextPreferenceDialog.newInstance(preference.getKey(), EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD);
        f.setTargetFragment(this, 0);
        f.show(getFragmentManager(), DIALOG_FRAGMENT_TAG);
    } else {
        super.onDisplayPreferenceDialog(preference);
    }
}
Also used : EditTextIntegerPreference(cx.ring.views.EditTextIntegerPreference) EditTextPreferenceDialog(cx.ring.views.EditTextPreferenceDialog) PasswordPreference(cx.ring.views.PasswordPreference)

Example 3 with PasswordPreference

use of cx.ring.views.PasswordPreference in project ring-client-android by savoirfairelinux.

the class AdvancedAccountFragment method onDisplayPreferenceDialog.

@Override
public void onDisplayPreferenceDialog(Preference preference) {
    if (getFragmentManager().findFragmentByTag(DIALOG_FRAGMENT_TAG) != null) {
        return;
    }
    if (preference instanceof EditTextIntegerPreference) {
        EditTextPreferenceDialog f = EditTextPreferenceDialog.newInstance(preference.getKey(), EditorInfo.TYPE_CLASS_NUMBER);
        f.setTargetFragment(this, 0);
        f.show(getFragmentManager(), DIALOG_FRAGMENT_TAG);
    } else if (preference instanceof PasswordPreference) {
        EditTextPreferenceDialog f = EditTextPreferenceDialog.newInstance(preference.getKey(), EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD);
        f.setTargetFragment(this, 0);
        f.show(getFragmentManager(), DIALOG_FRAGMENT_TAG);
    } else {
        super.onDisplayPreferenceDialog(preference);
    }
}
Also used : EditTextIntegerPreference(cx.ring.views.EditTextIntegerPreference) EditTextPreferenceDialog(cx.ring.views.EditTextPreferenceDialog) PasswordPreference(cx.ring.views.PasswordPreference)

Example 4 with PasswordPreference

use of cx.ring.views.PasswordPreference 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)

Aggregations

PasswordPreference (cx.ring.views.PasswordPreference)4 EditTextIntegerPreference (cx.ring.views.EditTextIntegerPreference)3 TwoStatePreference (android.support.v7.preference.TwoStatePreference)2 ConfigKey (cx.ring.model.ConfigKey)2 EditTextPreferenceDialog (cx.ring.views.EditTextPreferenceDialog)2 EditTextPreference (android.support.v7.preference.EditTextPreference)1 Preference (android.support.v7.preference.Preference)1