Example usage for android.preference ListPreference getValue

List of usage examples for android.preference ListPreference getValue

Introduction

In this page you can find the example usage for android.preference ListPreference getValue.

Prototype

public String getValue() 

Source Link

Document

Returns the value of the key.

Usage

From source file:com.almalence.opencam.Fragment.java

private void initExportName(Preference preference, Object newValue) {
    EditTextPreference prefix = (EditTextPreference) this
            .findPreference(getResources().getString(R.string.Preference_SavePathPrefixValue));
    String prefixValue = "";
    if (prefix != null) {
        if (preference != null && prefix.getKey().equals(preference.getKey())) {
            prefixValue = newValue.toString();
        } else {/*from   w w  w .  j a  v a2 s.c  o  m*/
            prefixValue = prefix.getText();
        }

        if (!prefixValue.equals("")) {
            prefixValue = prefixValue + "_";
        }
    }

    EditTextPreference postfix = (EditTextPreference) this
            .findPreference(getResources().getString(R.string.Preference_SavePathPostfixValue));
    String postfixValue = "";
    if (postfix != null) {
        if (preference != null && postfix.getKey().equals(preference.getKey())) {
            postfixValue = newValue.toString();
        } else {
            postfixValue = postfix.getText();
        }

        if (!postfixValue.equals("")) {
            postfixValue = "_" + postfixValue;
        }
    }

    ListPreference exportNameList = (ListPreference) this
            .findPreference(getResources().getString(R.string.Preference_ExportNameValue));
    if (exportNameList != null) {
        String[] names = MainScreen.getAppResources().getStringArray(R.array.exportNameArray);
        CharSequence[] newNames = new CharSequence[names.length];
        int i = 0;
        for (String name : names) {
            newNames[i] = prefixValue + name + postfixValue;
            i++;
        }
        exportNameList.setEntries(newNames);
        exportNameList.setSummary(exportNameList.getEntries()[Integer.parseInt(exportNameList.getValue()) - 1]);
    }
}

From source file:com.nttec.everychan.chans.allchan.AllchanModule.java

@Override
public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) {
    Context context = preferenceGroup.getContext();
    addOnlyNewPostsPreference(preferenceGroup, true);
    final ListPreference captchaPreference = new LazyPreferences.ListPreference(context); //captcha_type
    captchaPreference.setTitle(R.string.pref_captcha_type);
    captchaPreference.setDialogTitle(R.string.pref_captcha_type);
    captchaPreference.setKey(getSharedKey(PREF_KEY_CAPTCHA_TYPE));
    captchaPreference.setEntryValues(CAPTCHA_TYPES_KEYS);
    captchaPreference.setEntries(CAPTCHA_TYPES);
    captchaPreference.setDefaultValue(CAPTCHA_TYPE_DEFAULT);
    int i = Arrays.asList(CAPTCHA_TYPES_KEYS)
            .indexOf(preferences.getString(getSharedKey(PREF_KEY_CAPTCHA_TYPE), CAPTCHA_TYPE_DEFAULT));
    if (i >= 0)
        captchaPreference.setSummary(CAPTCHA_TYPES[i]);
    preferenceGroup.addPreference(captchaPreference);
    addHttpsPreference(preferenceGroup, true);
    addCloudflareRecaptchaFallbackPreference(preferenceGroup);
    addProxyPreferences(preferenceGroup);

    final CheckBoxPreference proxyPreference = (CheckBoxPreference) preferenceGroup
            .findPreference(getSharedKey(PREF_KEY_USE_PROXY));
    proxyPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override/*from   w w  w.  ja v  a 2  s  .  co  m*/
        public boolean onPreferenceClick(Preference preference) {
            if (proxyPreference.isChecked() && captchaPreference.getValue().equals("recaptcha")) {
                captchaPreference.setValue("recaptcha-fallback");
            }
            return false;
        }
    });
    captchaPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (proxyPreference.isChecked() && newValue.equals("recaptcha")) {
                captchaPreference.setValue("recaptcha-fallback");
                return false;
            }
            return true;
        }
    });
}

From source file:nya.miku.wishmaster.chans.tumbach.TumbachModule.java

@Override
public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) {
    Context context = preferenceGroup.getContext();
    addOnlyNewPostsPreference(preferenceGroup, true);
    final ListPreference captchaPreference = new LazyPreferences.ListPreference(context); //captcha_type
    captchaPreference.setTitle(R.string.pref_captcha_type);
    captchaPreference.setDialogTitle(R.string.pref_captcha_type);
    captchaPreference.setKey(getSharedKey(PREF_KEY_CAPTCHA_TYPE));
    captchaPreference.setEntryValues(CAPTCHA_TYPES_KEYS);
    captchaPreference.setEntries(CAPTCHA_TYPES);
    captchaPreference.setDefaultValue(CAPTCHA_TYPE_DEFAULT);
    int i = Arrays.asList(CAPTCHA_TYPES_KEYS)
            .indexOf(preferences.getString(getSharedKey(PREF_KEY_CAPTCHA_TYPE), CAPTCHA_TYPE_DEFAULT));
    if (i >= 0)
        captchaPreference.setSummary(CAPTCHA_TYPES[i]);
    preferenceGroup.addPreference(captchaPreference);
    addPasswordPreference(preferenceGroup);
    addHttpsPreference(preferenceGroup, true);
    addCloudflareRecaptchaFallbackPreference(preferenceGroup);
    addProxyPreferences(preferenceGroup);

    final CheckBoxPreference proxyPreference = (CheckBoxPreference) preferenceGroup
            .findPreference(getSharedKey(PREF_KEY_USE_PROXY));
    proxyPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override//from w w  w.ja v  a2  s.  c o m
        public boolean onPreferenceClick(Preference preference) {
            if (proxyPreference.isChecked() && captchaPreference.getValue().equals("recaptcha")) {
                captchaPreference.setValue("recaptcha-fallback");
            }
            return false;
        }
    });
    captchaPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (proxyPreference.isChecked() && newValue.equals("recaptcha")) {
                captchaPreference.setValue("recaptcha-fallback");
                return false;
            }
            return true;
        }
    });
}