List of usage examples for android.preference EditTextPreference getEditText
public EditText getEditText()
From source file:nya.miku.wishmaster.chans.nullchan.NullchanoneModule.java
private void addDomainPreference(PreferenceGroup group) { Context context = group.getContext(); EditTextPreference domainPref = new EditTextPreference(context); domainPref.setTitle(R.string.pref_domain); domainPref.setDialogTitle(R.string.pref_domain); domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN)); domainPref.getEditText().setHint(CHAN_DOMAIN); domainPref.getEditText().setSingleLine(); domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); group.addPreference(domainPref);// ww w . j a v a 2 s .c o m }
From source file:nya.miku.wishmaster.chans.endchan.EndChanModule.java
private void addDomainPreferences(PreferenceGroup group) { Context context = group.getContext(); Preference.OnPreferenceChangeListener updateDomainListener = new Preference.OnPreferenceChangeListener() { @Override/*from w ww . ja v a 2s .c o m*/ public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference.getKey().equals(getSharedKey(PREF_KEY_DOMAIN))) { updateDomain((String) newValue); return true; } return false; } }; PreferenceCategory domainCat = new PreferenceCategory(context); domainCat.setTitle(R.string.makaba_prefs_domain_category); group.addPreference(domainCat); EditTextPreference domainPref = new EditTextPreference(context); domainPref.setTitle(R.string.pref_domain); domainPref.setDialogTitle(R.string.pref_domain); domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT)); domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN)); domainPref.getEditText().setHint(DEFAULT_DOMAIN); domainPref.getEditText().setSingleLine(); domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); domainPref.setOnPreferenceChangeListener(updateDomainListener); domainCat.addPreference(domainPref); }
From source file:org.trosnoth.serveradmin.ServerSettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); telnet = ConnectionActivity.telnet;/*w w w .ja va 2s. com*/ telnet.send("game = getGame()"); pref = new ServerSettings(); pref.registerOnSharedPreferenceChangeListener(this); addPreferencesFromResource(R.xml.server_settings); gameModes = telnet.parseJSON(telnet.readWrite("print json.dumps(getGame().listGameModes())")); ListPreference gameModesPref = (ListPreference) this.findPreference("gameMode"); String[] strArray = new String[gameModes.size()]; gameModes.toArray(strArray); gameModesPref.setEntries(strArray); gameModesPref.setEntryValues(strArray); EditTextPreference setting; EditText settingText; setting = (EditTextPreference) findPreference("playersPerTeam"); settingText = setting.getEditText(); settingText.setInputType(InputType.TYPE_CLASS_NUMBER); settingText.setFilters(InputFilters.integerFilter(255)); setting = (EditTextPreference) findPreference("playersTotal"); settingText = setting.getEditText(); settingText.setInputType(InputType.TYPE_CLASS_NUMBER); settingText.setFilters(InputFilters.integerFilter(255)); setting = (EditTextPreference) findPreference("gameSpeed"); settingText = setting.getEditText(); settingText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); // Update every 5 seconds Runnable looper = new Runnable() { public void run() { update(); mHandler.postDelayed(this, ConnectionActivity.UPDATE_FREQ); } }; if (ConnectionActivity.automaticUpdate) { mHandler.removeCallbacks(looper); mHandler.post(looper); } else { update(); } }
From source file:com.nttec.everychan.chans.nullchan.NullchanccModule.java
private void addDomainPreference(PreferenceGroup group) { Context context = group.getContext(); EditTextPreference domainPref = new EditTextPreference(context); domainPref.setTitle(R.string.pref_domain); domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT)); domainPref.setDialogTitle(R.string.pref_domain); domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN)); domainPref.getEditText().setHint(DEFAULT_DOMAIN); domainPref.getEditText().setSingleLine(); domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); group.addPreference(domainPref);//from w ww .j a v a 2s . c o m }
From source file:nya.miku.wishmaster.chans.tirech.TirechModule.java
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); EditTextPreference domainPref = new EditTextPreference(context); domainPref.setTitle(R.string.pref_domain); domainPref.setDialogTitle(R.string.pref_domain); domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT)); domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN)); domainPref.getEditText().setHint(DEFAULT_DOMAIN); domainPref.getEditText().setSingleLine(); domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); preferenceGroup.addPreference(domainPref); addPasswordPreference(preferenceGroup); addCloudflareRecaptchaFallbackPreference(preferenceGroup); addProxyPreferences(preferenceGroup); }
From source file:nya.miku.wishmaster.api.AbstractChanModule.java
/** * ( ?/ ) ? ? ? ? ?///from ww w . java2 s. co m * @param group , ??? */ protected void addPasswordPreference(PreferenceGroup group) { final Context context = group.getContext(); EditTextPreference passwordPref = new EditTextPreference(context); // ? passwordPref.setTitle(R.string.pref_password_title); passwordPref.setDialogTitle(R.string.pref_password_title); passwordPref.setSummary(R.string.pref_password_summary); passwordPref.setKey(getSharedKey(PREF_KEY_PASSWORD)); passwordPref.getEditText() .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); passwordPref.getEditText().setSingleLine(); passwordPref.getEditText().setFilters(new InputFilter[] { new InputFilter.LengthFilter(255) }); group.addPreference(passwordPref); }
From source file:nya.miku.wishmaster.chans.cirno.CirnoModule.java
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { final Context context = preferenceGroup.getContext(); EditTextPreference passwordPref = new EditTextPreference(context); passwordPref.setTitle(R.string.iichan_prefs_report_thread); passwordPref.setDialogTitle(R.string.iichan_prefs_report_thread); passwordPref.setSummary(R.string.iichan_prefs_report_thread_summary); passwordPref.setKey(getSharedKey(PREF_KEY_REPORT_THREAD)); passwordPref.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER); passwordPref.getEditText().setSingleLine(); passwordPref.getEditText().setFilters(new InputFilter[] { new InputFilter.LengthFilter(255) }); preferenceGroup.addPreference(passwordPref); super.addPreferencesOnScreen(preferenceGroup); }
From source file:com.nttec.everychan.chans.dvach.DvachModule.java
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); addPasswordPreference(preferenceGroup); CheckBoxPreference onionPref = new LazyPreferences.CheckBoxPreference(context); onionPref.setTitle(R.string.pref_use_onion); onionPref.setSummary(R.string.pref_use_onion_summary); onionPref.setKey(getSharedKey(PREF_KEY_USE_ONION)); onionPref.setDefaultValue(false);//from ww w. j a v a 2 s . co m onionPref.setDisableDependentsState(true); preferenceGroup.addPreference(onionPref); EditTextPreference domainPref = new EditTextPreference(context); domainPref.setTitle(R.string.pref_domain); domainPref.setDialogTitle(R.string.pref_domain); domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT)); domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN)); domainPref.getEditText().setHint(DEFAULT_DOMAIN); domainPref.getEditText().setSingleLine(); domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); preferenceGroup.addPreference(domainPref); domainPref.setDependency(getSharedKey(PREF_KEY_USE_ONION)); addProxyPreferences(preferenceGroup); }
From source file:nya.miku.wishmaster.api.AbstractChanModule.java
/** * ( ?/ ) ? ?-?//from www . jav a 2 s . co m * @param group , ??? */ protected void addProxyPreferences(PreferenceGroup group) { final Context context = group.getContext(); PreferenceCategory proxyCat = new PreferenceCategory(context); //? ? ? proxyCat.setTitle(R.string.pref_cat_proxy); group.addPreference(proxyCat); CheckBoxPreference useProxyPref = new CheckBoxPreference(context); //? "? ? " useProxyPref.setTitle(R.string.pref_use_proxy); useProxyPref.setSummary(R.string.pref_use_proxy_summary); useProxyPref.setKey(getSharedKey(PREF_KEY_USE_PROXY)); useProxyPref.setDefaultValue(false); useProxyPref.setOnPreferenceChangeListener(updateHttpListener); proxyCat.addPreference(useProxyPref); EditTextPreference proxyHostPref = new EditTextPreference(context); // ? ?-? proxyHostPref.setTitle(R.string.pref_proxy_host); proxyHostPref.setDialogTitle(R.string.pref_proxy_host); proxyHostPref.setSummary(R.string.pref_proxy_host_summary); proxyHostPref.setKey(getSharedKey(PREF_KEY_PROXY_HOST)); proxyHostPref.setDefaultValue(DEFAULT_PROXY_HOST); proxyHostPref.getEditText().setSingleLine(); proxyHostPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); proxyHostPref.setOnPreferenceChangeListener(updateHttpListener); proxyCat.addPreference(proxyHostPref); proxyHostPref.setDependency(getSharedKey(PREF_KEY_USE_PROXY)); EditTextPreference proxyHostPort = new EditTextPreference(context); // ?-? proxyHostPort.setTitle(R.string.pref_proxy_port); proxyHostPort.setDialogTitle(R.string.pref_proxy_port); proxyHostPort.setSummary(R.string.pref_proxy_port_summary); proxyHostPort.setKey(getSharedKey(PREF_KEY_PROXY_PORT)); proxyHostPort.setDefaultValue(DEFAULT_PROXY_PORT); proxyHostPort.getEditText().setSingleLine(); proxyHostPort.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER); proxyHostPort.setOnPreferenceChangeListener(updateHttpListener); proxyCat.addPreference(proxyHostPort); proxyHostPort.setDependency(getSharedKey(PREF_KEY_USE_PROXY)); }
From source file:com.nttec.everychan.chans.ponyach.PonyachModule.java
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { final Context context = preferenceGroup.getContext(); ListPreference captchaLevel = new LazyPreferences.ListPreference(context); captchaLevel.setTitle(R.string.ponyach_prefs_captcha); captchaLevel.setDialogTitle(R.string.ponyach_prefs_captcha); captchaLevel.setKey(getSharedKey(PREF_KEY_CAPTCHA_LEVEL)); captchaLevel.setEntryValues(new String[] { "3", "2", "1" }); captchaLevel.setEntries(new String[] { "Easy", "Easy++", "Medium" }); captchaLevel.setDefaultValue("1"); preferenceGroup.addPreference(captchaLevel); EditTextPreference passcodePref = new EditTextPreference(context); passcodePref.setTitle(R.string.ponyach_prefs_passcode); passcodePref.setDialogTitle(R.string.ponyach_prefs_passcode); passcodePref.getEditText().setFilters(new InputFilter[] { new InputFilter.LengthFilter(6) }); passcodePref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override/*ww w . j a v a 2 s .c o m*/ public boolean onPreferenceChange(Preference preference, Object newValue) { final String newPasscode = (String) newValue; final CancellableTask passAuthTask = new CancellableTask.BaseCancellableTask(); final ProgressDialog passAuthProgressDialog = new ProgressDialog(context); passAuthProgressDialog.setMessage("Logging in"); passAuthProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { passAuthTask.cancel(); } }); passAuthProgressDialog.setCanceledOnTouchOutside(false); passAuthProgressDialog.show(); Async.runAsync(new Runnable() { @Override public void run() { try { if (passAuthTask.isCancelled()) return; String url = getUsingUrl() + "passcode.php"; List<BasicNameValuePair> pairs = Collections .singletonList(new BasicNameValuePair("passcode_just_set", newPasscode)); HttpRequestModel request = HttpRequestModel.builder() .setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).build(); HttpStreamer.getInstance().getStringFromUrl(url, request, httpClient, null, passAuthTask, false); savePhpCookies(); } catch (final Exception e) { if (context instanceof Activity) { ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { String message = e.getMessage() == null ? resources.getString(R.string.error_unknown) : e.getMessage(); Toast.makeText(context, message, Toast.LENGTH_LONG).show(); } }); } } finally { passAuthProgressDialog.dismiss(); } } }); return false; } }); preferenceGroup.addPreference(passcodePref); ListPreference domainPref = new LazyPreferences.ListPreference(context); domainPref.setTitle(R.string.pref_domain); domainPref.setDialogTitle(R.string.pref_domain); domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN)); domainPref.setEntryValues(DOMAINS); domainPref.setEntries(DOMAINS); domainPref.setDefaultValue(DEFAULT_DOMAIN); domainPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { loadPhpCookies((String) newValue); return true; } }); preferenceGroup.addPreference(domainPref); addHttpsPreference(preferenceGroup, useHttpsDefaultValue()); addProxyPreferences(preferenceGroup); captchaLevel.setSummary(captchaLevel.getEntry()); domainPref.setSummary(domainPref.getEntry()); }