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());
}
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());
}
}
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);
}
}
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;
}
});
}
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;
}
});
}
Aggregations