Search in sources :

Example 41 with EditTextPreference

use of android.preference.EditTextPreference in project zxingfragmentlib by mitoyarzun.

the class PreferencesFragment method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.preferences);
    PreferenceScreen preferences = getPreferenceScreen();
    preferences.getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
    checkBoxPrefs = findDecodePrefs(preferences, PreferencesActivity.KEY_DECODE_1D_PRODUCT, PreferencesActivity.KEY_DECODE_1D_INDUSTRIAL, PreferencesActivity.KEY_DECODE_QR, PreferencesActivity.KEY_DECODE_DATA_MATRIX, PreferencesActivity.KEY_DECODE_AZTEC, PreferencesActivity.KEY_DECODE_PDF417);
    disableLastCheckedPref();
    EditTextPreference customProductSearch = (EditTextPreference) preferences.findPreference(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH);
    customProductSearch.setOnPreferenceChangeListener(new CustomSearchURLValidator());
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) EditTextPreference(android.preference.EditTextPreference)

Example 42 with EditTextPreference

use of android.preference.EditTextPreference in project physical-web by google.

the class SettingsFragment method updateSettingSummary.

private void updateSettingSummary(String key) {
    Preference pref = findPreference(key);
    if (pref instanceof ListPreference) {
        ListPreference listPref = (ListPreference) pref;
        listPref.setSummary(listPref.getEntry());
    } else if (pref instanceof EditTextPreference) {
        EditTextPreference editTextPref = (EditTextPreference) pref;
        editTextPref.setSummary(editTextPref.getText());
    }
}
Also used : EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) ListPreference(android.preference.ListPreference) EditTextPreference(android.preference.EditTextPreference)

Example 43 with EditTextPreference

use of android.preference.EditTextPreference in project physical-web by google.

the class SettingsFragment method updatePwsPreference.

private void updatePwsPreference() {
    ListPreference listPreference = (ListPreference) findPreference(getString(R.string.pws_endpoint_setting_key));
    String entry = (String) listPreference.getEntry();
    if (entry == null) {
        return;
    }
    if (entry.equals(getString(R.string.custom_pws))) {
        // User selected custom PWS therefore need to update it accordingly
        EditTextPreference customPwsUrlPreference = (EditTextPreference) mCustomEndpointCategory.findPreference(getString(R.string.custom_pws_url_key));
        ListPreference customPwsVersionPreference = (ListPreference) mCustomEndpointCategory.findPreference(getString(R.string.custom_pws_version_key));
        EditTextPreference customPwsApiKeyPreference = (EditTextPreference) mCustomEndpointCategory.findPreference(getString(R.string.custom_pws_api_key_key));
        String customPwsUrl = customPwsUrlPreference.getText();
        int customPwsVersion = Integer.parseInt(customPwsVersionPreference.getValue());
        String customPwsApiKey = customPwsApiKeyPreference.getText();
        customPwsUrl = customPwsUrl == null ? "" : customPwsUrl;
        customPwsApiKey = customPwsApiKey == null ? "" : customPwsApiKey;
        listPreference.setValue(Utils.formatEndpointForSharedPrefernces(customPwsUrl, customPwsVersion, customPwsApiKey));
        getPreferenceScreen().addPreference(mCustomEndpointCategory);
    } else {
        getPreferenceScreen().removePreference(mCustomEndpointCategory);
    }
}
Also used : ListPreference(android.preference.ListPreference) EditTextPreference(android.preference.EditTextPreference)

Example 44 with EditTextPreference

use of android.preference.EditTextPreference in project AndroidSDK-RecipeBook by gabu.

the class MyPreferenceActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.pref);
    mContext = this;
    Resources r = getResources();
    mInputPasswordKey = r.getString(R.string.input_password_key);
    mRealPasswordKey = r.getString(R.string.real_password_key);
    // パスワード入力用のプリファレンスを取得
    Preference password = findPreference(mInputPasswordKey);
    // 変更を検知するリスナーをセット
    password.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        public boolean onPreferenceChange(Preference preference, Object newValue) {
            // 本来のパスワードには空文字をセット
            ((EditTextPreference) preference).setText("");
            // SharedPreferencesを取得
            SharedPreferences sp;
            sp = PreferenceManager.getDefaultSharedPreferences(mContext);
            // 編集のためEditorを取得
            Editor editor = sp.edit();
            // key: real_password_key
            // value: SHA-1値
            // newValueに入力された値が入っています。
            editor.putString(mRealPasswordKey, sha256(newValue.toString()));
            // 保存
            editor.commit();
            return false;
        }
    });
}
Also used : EditTextPreference(android.preference.EditTextPreference) Preference(android.preference.Preference) SharedPreferences(android.content.SharedPreferences) Resources(android.content.res.Resources) OnPreferenceChangeListener(android.preference.Preference.OnPreferenceChangeListener) Editor(android.content.SharedPreferences.Editor)

Example 45 with EditTextPreference

use of android.preference.EditTextPreference in project AndroidSDK-RecipeBook by gabu.

the class MyPreferenceActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.pref);
    mContext = this;
    Resources r = getResources();
    mInputPasswordKey = r.getString(R.string.input_password_key);
    mRealPasswordKey = r.getString(R.string.real_password_key);
    // パスワード入力用のプリファレンスを取得
    Preference password = findPreference(mInputPasswordKey);
    // 変更を検知するリスナーをセット
    password.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        public boolean onPreferenceChange(Preference preference, Object newValue) {
            // 本来のパスワードには空文字をセット
            ((EditTextPreference) preference).setText("");
            // SharedPreferencesを取得
            SharedPreferences sp;
            sp = PreferenceManager.getDefaultSharedPreferences(mContext);
            // 編集のためEditorを取得
            Editor editor = sp.edit();
            // key: real_password_key
            // value: SHA-1値
            // newValueに入力された値が入っています。
            editor.putString(mRealPasswordKey, sha256(newValue.toString()));
            // 保存
            editor.commit();
            return false;
        }
    });
}
Also used : EditTextPreference(android.preference.EditTextPreference) Preference(android.preference.Preference) SharedPreferences(android.content.SharedPreferences) Resources(android.content.res.Resources) OnPreferenceChangeListener(android.preference.Preference.OnPreferenceChangeListener) Editor(android.content.SharedPreferences.Editor)

Aggregations

EditTextPreference (android.preference.EditTextPreference)77 ListPreference (android.preference.ListPreference)32 Preference (android.preference.Preference)32 CheckBoxPreference (android.preference.CheckBoxPreference)17 SharedPreferences (android.content.SharedPreferences)11 PreferenceScreen (android.preference.PreferenceScreen)11 Test (org.junit.Test)9 MultiSelectListPreference (android.preference.MultiSelectListPreference)8 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)8 Intent (android.content.Intent)7 ArrayList (java.util.ArrayList)7 DialogInterface (android.content.DialogInterface)6 Bundle (android.os.Bundle)6 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)5 View (android.view.View)5 SwitchPreference (android.preference.SwitchPreference)4 EditText (android.widget.EditText)4 File (java.io.File)4 Activity (android.app.Activity)3 AlertDialog (android.app.AlertDialog)3