Java Code Examples for android.preference.EditTextPreference

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project platform_packages_apps_phone, under directory /src/com/android/phone/.

Source file: RespondViaSmsManager.java

  30 
vote

@Override public boolean onPreferenceChange(Preference preference,Object newValue){
  if (DBG)   log("onPreferenceChange: key = " + preference.getKey());
  if (VDBG)   log("  preference = '" + preference + "'");
  if (VDBG)   log("  newValue = '" + newValue + "'");
  EditTextPreference pref=(EditTextPreference)preference;
  pref.setTitle((String)newValue);
  return true;
}
 

Example 2

From project packages_apps_Phone_1, under directory /src/com/android/phone/.

Source file: RespondViaSmsManager.java

  26 
vote

public boolean onPreferenceChange(Preference preference,Object newValue){
  if (DBG)   log("onPreferenceChange: key = " + preference.getKey());
  if (VDBG)   log("  preference = '" + preference + "'");
  if (VDBG)   log("  newValue = '" + newValue + "'");
  EditTextPreference pref=(EditTextPreference)preference;
  pref.setTitle((String)newValue);
  return true;
}
 

Example 3

From project mWater-Android-App, under directory /android/src/co/mwater/clientapp/ui/.

Source file: PrefActivity.java

  23 
vote

private void updatePrefSummary(Preference p){
  if (p instanceof ListPreference) {
    ListPreference listPref=(ListPreference)p;
    p.setSummary(listPref.getEntry());
  }
  if (p instanceof EditTextPreference) {
    EditTextPreference editTextPref=(EditTextPreference)p;
    p.setSummary(editTextPref.getText());
  }
}
 

Example 4

From project 2Degrees-Toolbox, under directory /Toolbox/src/biz/shadowservices/DegreesToolbox/Preferences/.

Source file: BalancePreferencesActivity.java

  22 
vote

public boolean onPreferenceClick(Preference preference){
  if (preference.getKey().equals("password")) {
    EditTextPreference pref=(EditTextPreference)preference;
    EditText field=pref.getEditText();
    field.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
    field.setTransformationMethod(new PasswordTransformationMethod());
  }
  return false;
}
 

Example 5

From project andlytics, under directory /src/com/github/andlyticsproject/.

Source file: PreferenceActivity.java

  22 
vote

private void updatePrefSummary(Preference p){
  if (p instanceof ListPreference) {
    ListPreference listPref=(ListPreference)p;
    p.setSummary(listPref.getEntry());
  }
 else   if (p instanceof EditTextPreference) {
    EditTextPreference editTextPref=(EditTextPreference)p;
    p.setSummary(editTextPref.getText());
  }
}
 

Example 6

From project android-vpn-settings, under directory /src/com/android/settings/vpn/.

Source file: VpnProfileEditor.java

  22 
vote

/** 
 * Creates a preference for users to input domain suffices.
 */
protected EditTextPreference createDomainSufficesPreference(Context c){
  EditTextPreference pref=mDomainSuffices=createEditTextPreference(c,R.string.vpn_dns_search_list_title,R.string.vpn_dns_search_list,mProfile.getDomainSuffices(),new Preference.OnPreferenceChangeListener(){
    public boolean onPreferenceChange(    Preference pref,    Object newValue){
      String v=((String)newValue).trim();
      mProfile.setDomainSuffices(v);
      setSummary(pref,R.string.vpn_dns_search_list,v,false);
      return true;
    }
  }
);
  pref.getEditText().setInputType(InputType.TYPE_TEXT_VARIATION_URI);
  return pref;
}
 

Example 7

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/vpn/.

Source file: VpnProfileEditor.java

  22 
vote

/** 
 * Creates a preference for users to input domain suffices.
 */
protected EditTextPreference createDomainSufficesPreference(Context c){
  EditTextPreference pref=mDomainSuffices=createEditTextPreference(c,R.string.vpn_dns_search_list_title,R.string.vpn_dns_search_list,mProfile.getDomainSuffices(),new Preference.OnPreferenceChangeListener(){
    public boolean onPreferenceChange(    Preference pref,    Object newValue){
      String v=((String)newValue).trim();
      mProfile.setDomainSuffices(v);
      setSummary(pref,R.string.vpn_dns_search_list,v,false);
      return true;
    }
  }
);
  pref.getEditText().setInputType(InputType.TYPE_TEXT_VARIATION_URI);
  return pref;
}
 

Example 8

From project dmix, under directory /MPDroid/src/com/namelessdev/mpdroid/.

Source file: ConnectionSettings.java

  22 
vote

private void createDynamicSettings(String keyPrefix,PreferenceCategory toCategory){
  EditTextPreference prefHost=new EditTextPreference(this);
  prefHost.setDialogTitle(R.string.host);
  prefHost.setTitle(R.string.host);
  prefHost.setSummary(R.string.hostDescription);
  prefHost.setDefaultValue("");
  prefHost.setKey(keyPrefix + "hostname");
  toCategory.addPreference(prefHost);
  EditTextPreference prefPort=new EditTextPreference(this);
  prefPort.setDialogTitle(R.string.port);
  prefPort.setTitle(R.string.port);
  prefPort.setSummary(R.string.portDescription);
  prefPort.setDefaultValue("6600");
  prefPort.setKey(keyPrefix + "port");
  toCategory.addPreference(prefPort);
  EditTextPreference prefPassword=new EditTextPreference(this);
  prefPassword.setDialogTitle(R.string.password);
  prefPassword.setTitle(R.string.password);
  prefPassword.setSummary(R.string.passwordDescription);
  prefPassword.setDefaultValue("");
  prefPassword.setKey(keyPrefix + "password");
  toCategory.addPreference(prefPassword);
  EditTextPreference prefHostStreaming=new EditTextPreference(this);
  prefHostStreaming.setDialogTitle(R.string.hostStreaming);
  prefHostStreaming.setTitle(R.string.hostStreaming);
  prefHostStreaming.setSummary(R.string.hostStreamingDescription);
  prefHostStreaming.setDefaultValue("");
  prefHostStreaming.setKey(keyPrefix + "hostnameStreaming");
  toCategory.addPreference(prefHostStreaming);
  EditTextPreference prefStreamingPort=new EditTextPreference(this);
  prefStreamingPort.setDialogTitle(R.string.portStreaming);
  prefStreamingPort.setTitle(R.string.portStreaming);
  prefStreamingPort.setSummary(R.string.portStreamingDescription);
  prefStreamingPort.setDefaultValue("8000");
  prefStreamingPort.setKey(keyPrefix + "portStreaming");
  toCategory.addPreference(prefStreamingPort);
  onContentChanged();
}
 

Example 9

From project friendica-for-android, under directory /mw-android-friendica-01/src/de/wikilab/android/friendica01/.

Source file: PreferencesActivity.java

  22 
vote

private void updatePrefSummary(Preference p){
  if (p instanceof ListPreference) {
    ListPreference listPref=(ListPreference)p;
    p.setSummary(listPref.getEntry());
  }
  if (p instanceof EditTextPreference) {
    EditTextPreference editTextPref=(EditTextPreference)p;
    String txt=editTextPref.getText();
    if (p.getKey().equals("login_password") && txt != null)     txt=repeatChar('*',txt.length());
    p.setSummary(txt);
  }
}
 

Example 10

From project gast-lib, under directory /app/src/root/gast/playground/pref/.

Source file: SummarizingEditPreferences.java

  22 
vote

private void updatePrefSummary(Preference p){
  if (p instanceof ListPreference) {
    ListPreference listPref=(ListPreference)p;
    p.setSummary(listPref.getEntry());
  }
  if (p instanceof EditTextPreference) {
    EditTextPreference editTextPref=(EditTextPreference)p;
    p.setSummary(editTextPref.getText());
  }
}
 

Example 11

From project javaee-tutorial, under directory /jaxrs/android/src/org/jboss/ee/tutorial/jaxrs/android/.

Source file: LibraryPreferences.java

  22 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.preferences);
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
  prefs.registerOnSharedPreferenceChangeListener(this);
  String hostKey=getString(R.string.pref_host_key);
  String host=prefs.getString(hostKey,getString(R.string.pref_host_default));
  EditTextPreference hostPref=(EditTextPreference)findPreference(hostKey);
  hostPref.setSummary(host);
  String portKey=getString(R.string.pref_port_key);
  String port=prefs.getString(portKey,getString(R.string.pref_port_default));
  EditTextPreference portPref=(EditTextPreference)findPreference(portKey);
  portPref.setSummary(port);
}
 

Example 12

From project K6nele, under directory /app/src/ee/ioc/phon/android/speak/.

Source file: Preferences.java

  21 
vote

public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,String key){
  Preference pref=findPreference(key);
  if (pref instanceof EditTextPreference) {
    EditTextPreference etp=(EditTextPreference)pref;
    pref.setSummary(etp.getText());
  }
 else   if (pref instanceof ListPreference) {
    ListPreference lp=(ListPreference)pref;
    if (lp.getTitle().equals(getString(R.string.titleAutoStopAfterTime))) {
      setSummary(pref,getString(R.string.summaryAutoStopAfterTime),lp.getValue());
    }
 else     if (lp.getTitle().equals(getString(R.string.titleRecordingRate))) {
      setSummary(pref,getString(R.string.summaryRecordingRate),lp.getValue());
    }
  }
}
 

Example 13

From project KeyboardTerm, under directory /src/com/roiding/rterm/.

Source file: EditFunctionButtonActivity.java

  21 
vote

private void updatePreferenceDisplay(){
  for (  String key : valuesMap.keySet()) {
    Preference pref=this.findPreference(key);
    if (pref != null) {
      String value=valuesMap.get(key);
      if (pref instanceof EditTextPreference) {
        EditTextPreference textPref=(EditTextPreference)pref;
        if (value != null && value.length() > 0)         textPref.setTitle(value);
        textPref.setText(value);
      }
 else       if (pref instanceof ListPreference) {
        ListPreference listPref=(ListPreference)pref;
        if (value != null && value.length() > 0)         listPref.setTitle(value);
        listPref.setValue(value);
      }
 else       if (pref instanceof CheckBoxPreference) {
        CheckBoxPreference checkPref=(CheckBoxPreference)pref;
        if (value != null && value.length() > 0)         checkPref.setChecked(value.toString().equals("1"));
      }
    }
  }
}
 

Example 14

From project LunaTerm, under directory /src/com/roiding/rterm/.

Source file: EditFunctionButtonActivity.java

  21 
vote

private void updatePreferenceDisplay(){
  for (  String key : valuesMap.keySet()) {
    Preference pref=this.findPreference(key);
    if (pref != null) {
      String value=valuesMap.get(key);
      if (pref instanceof EditTextPreference) {
        EditTextPreference textPref=(EditTextPreference)pref;
        if (value != null && value.length() > 0)         textPref.setTitle(value);
        textPref.setText(value);
      }
 else       if (pref instanceof ListPreference) {
        ListPreference listPref=(ListPreference)pref;
        if (value != null && value.length() > 0)         listPref.setTitle(value);
        listPref.setValue(value);
      }
    }
  }
}
 

Example 15

From project platform_packages_apps_calendar, under directory /src/com/android/calendar/.

Source file: QuickResponseSettings.java

  21 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  PreferenceScreen ps=getPreferenceManager().createPreferenceScreen(getActivity());
  ps.setTitle(R.string.quick_response_settings_title);
  mResponses=Utils.getQuickResponses(getActivity());
  if (mResponses != null) {
    mEditTextPrefs=new EditTextPreference[mResponses.length];
    Arrays.sort(mResponses);
    int i=0;
    for (    String response : mResponses) {
      EditTextPreference et=new EditTextPreference(getActivity());
      et.setDialogTitle(R.string.quick_response_settings_edit_title);
      et.setTitle(response);
      et.setText(response);
      et.setOnPreferenceChangeListener(this);
      mEditTextPrefs[i++]=et;
      ps.addPreference(et);
    }
  }
 else {
    Log.wtf(TAG,"No responses found");
  }
  setPreferenceScreen(ps);
}
 

Example 16

From project Ushahidi_Android, under directory /Core/src/com/ushahidi/android/app/.

Source file: Settings.java

  21 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.preferences);
  firstNamePref=new EditTextPreference(this);
  lastNamePref=new EditTextPreference(this);
  emailAddressPref=new EditTextPreference(this);
  phoneNumberPref=new EditTextPreference(this);
  photoSizePref=(SeekBarPreference)getPreferenceScreen().findPreference(PHOTO_SIZE_PREFERENCE);
  recentReports=getString(R.string.recent_reports);
  totalReportsPref=new ListPreference(this);
  new ListPreference(this);
  setPreferenceScreen(createPreferenceHierarchy());
  this.saveSettings();
}
 

Example 17

From project SVQCOM, under directory /Core/src/com/ushahidi/android/app/.

Source file: Settings.java

  20 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.preferences);
  firstNamePref=new EditTextPreference(this);
  lastNamePref=new EditTextPreference(this);
  emailAddressPref=new EditTextPreference(this);
  phoneNumberPref=new EditTextPreference(this);
  autoFetchCheckBoxPref=new CheckBoxPreference(this);
  vibrateCheckBoxPref=new CheckBoxPreference(this);
  ringtoneCheckBoxPref=new CheckBoxPreference(this);
  flashLedCheckBoxPref=new CheckBoxPreference(this);
  photoSizePref=(SeekBarPreference)getPreferenceScreen().findPreference(PHOTO_SIZE_PREFERENCE);
  photoSizePref.setOnPreferenceChangeListener(this);
  recentReports=getString(R.string.recent_reports);
  onPhone=getString(R.string.on_phone);
  onSdCard=getString(R.string.on_sd_card);
  minutes=getString(R.string.minutes);
  clearCacheCheckBoxPref=(DialogPreference)getPreferenceScreen().findPreference("clear_cache_preference");
  autoUpdateTimePref=new ListPreference(this);
  saveItemsPref=new ListPreference(this);
  totalReportsPref=new ListPreference(this);
  gpsTimeoutPref=new EditTextPreference(this);
  new ListPreference(this);
  setPreferenceScreen(createPreferenceHierarchy());
  this.saveSettings();
}
 

Example 18

From project 4308Cirrus, under directory /tendril-cirrus/src/main/java/edu/colorado/cs/cirrus/cirrus/.

Source file: CirrusPreferenceActivity.java

  19 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.preferences);
  myPreferenceClickListener=new simplePreferenceClickListener();
  setHomeLocPref=(Preference)findPreference("setHomeLocPref");
  gpsFreqPref=(Preference)findPreference("gpsFrequency");
  smartHeatPref=(Preference)findPreference("smartHeat");
  homeTempPref=(EditTextPreference)findPreference("homeTemp");
  awayTempPref=(EditTextPreference)findPreference("awayTemp");
  radiusPref=(EditTextPreference)findPreference("gpsRadius");
  logoutPref=(Preference)findPreference("logout");
  setHomeLocPref.setOnPreferenceClickListener(myPreferenceClickListener);
  gpsFreqPref.setOnPreferenceClickListener(myPreferenceClickListener);
  smartHeatPref.setOnPreferenceClickListener(myPreferenceClickListener);
  homeTempPref.setOnPreferenceClickListener(myPreferenceClickListener);
  awayTempPref.setOnPreferenceClickListener(myPreferenceClickListener);
  logoutPref.setOnPreferenceClickListener(myPreferenceClickListener);
  radiusPref.setOnPreferenceClickListener(myPreferenceClickListener);
  EditText homeTempEditText=(EditText)homeTempPref.getEditText();
  homeTempEditText.setKeyListener(DigitsKeyListener.getInstance(false,true));
  EditText awayTempEditText=(EditText)awayTempPref.getEditText();
  awayTempEditText.setKeyListener(DigitsKeyListener.getInstance(false,true));
  EditText radiusEditText=(EditText)radiusPref.getEditText();
  radiusEditText.setKeyListener(DigitsKeyListener.getInstance(false,true));
  cirrusPrefs=new PreferenceUtils(this);
  startLocationStuff();
}
 

Example 19

From project android-ocr, under directory /android/src/edu/sfsu/cs/orange/ocr/.

Source file: PreferencesActivity.java

  19 
vote

/** 
 * Set the default preference values.
 * @param Bundle savedInstanceState the current Activity's state, as passed by Android
 */
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.preferences);
  sharedPreferences=PreferenceManager.getDefaultSharedPreferences(this);
  listPreferenceSourceLanguage=(ListPreference)getPreferenceScreen().findPreference(KEY_SOURCE_LANGUAGE_PREFERENCE);
  listPreferenceTargetLanguage=(ListPreference)getPreferenceScreen().findPreference(KEY_TARGET_LANGUAGE_PREFERENCE);
  listPreferenceTranslator=(ListPreference)getPreferenceScreen().findPreference(KEY_TRANSLATOR);
  listPreferenceOcrEngineMode=(ListPreference)getPreferenceScreen().findPreference(KEY_OCR_ENGINE_MODE);
  editTextPreferenceCharacterBlacklist=(EditTextPreference)getPreferenceScreen().findPreference(KEY_CHARACTER_BLACKLIST);
  editTextPreferenceCharacterWhitelist=(EditTextPreference)getPreferenceScreen().findPreference(KEY_CHARACTER_WHITELIST);
  listPreferencePageSegmentationMode=(ListPreference)getPreferenceScreen().findPreference(KEY_PAGE_SEGMENTATION_MODE);
  initTranslationTargetList();
}
 

Example 20

From project android_packages_apps_phone, under directory /src/com/android/phone/sip/.

Source file: SipEditor.java

  19 
vote

String getValue(){
  if (preference instanceof EditTextPreference) {
    return ((EditTextPreference)preference).getText();
  }
 else   if (preference instanceof ListPreference) {
    return ((ListPreference)preference).getValue();
  }
  throw new RuntimeException("getValue() for the preference " + this);
}
 

Example 21

From project andstatus, under directory /src/org/andstatus/app/account/.

Source file: AccountSettings.java

  19 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  MyPreferences.initialize(this,this);
  addPreferencesFromResource(R.xml.account_settings);
  mOriginName=(ListPreference)findPreference(MyAccount.KEY_ORIGIN_NAME);
  mOAuth=(CheckBoxPreference)findPreference(MyAccount.KEY_OAUTH);
  mEditTextUsername=(EditTextPreference)findPreference(MyAccount.KEY_USERNAME_NEW);
  mEditTextPassword=(EditTextPreference)findPreference(MyAccount.KEY_PASSWORD);
  mVerifyCredentials=(Preference)findPreference(MyPreferences.KEY_VERIFY_CREDENTIALS);
  setState(getIntent(),"onCreate");
}
 

Example 22

From project andtweet, under directory /src/com/xorcode/andtweet/.

Source file: PreferencesActivity.java

  19 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.preferences);
  AndTweetPreferences.setDefaultValues(R.xml.preferences,false);
  if (!AndTweetPreferences.getSharedPreferences(PreferenceManager.KEY_HAS_SET_DEFAULT_VALUES,MODE_PRIVATE).getBoolean(PreferenceManager.KEY_HAS_SET_DEFAULT_VALUES,false)) {
    Log.e(TAG,"Default values were not set?!");
  }
  mHistorySizePreference=(ListPreference)findPreference(KEY_HISTORY_SIZE);
  mHistoryTimePreference=(ListPreference)findPreference(KEY_HISTORY_TIME);
  mFetchFrequencyPreference=(ListPreference)findPreference(KEY_FETCH_FREQUENCY);
  mNotificationRingtone=(RingtonePreference)findPreference(KEY_RINGTONE_PREFERENCE);
  mOAuth=(CheckBoxPreference)findPreference(KEY_OAUTH);
  mEditTextUsername=(EditTextPreference)findPreference(KEY_TWITTER_USERNAME_NEW);
  mEditTextPassword=(EditTextPreference)findPreference(KEY_TWITTER_PASSWORD);
  mVerifyCredentials=(Preference)findPreference(KEY_VERIFY_CREDENTIALS);
  mNotificationRingtone.setOnPreferenceChangeListener(this);
}
 

Example 23

From project creamed_glacier_app_settings, under directory /src/com/android/settings/bluetooth/.

Source file: DeviceProfilesSettings.java

  19 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  BluetoothDevice device;
  if (savedInstanceState != null) {
    device=savedInstanceState.getParcelable(EXTRA_DEVICE);
  }
 else {
    Bundle args=getArguments();
    device=args.getParcelable(EXTRA_DEVICE);
  }
  addPreferencesFromResource(R.xml.bluetooth_device_advanced);
  getPreferenceScreen().setOrderingAsAdded(false);
  mProfileContainer=(PreferenceGroup)findPreference(KEY_PROFILE_CONTAINER);
  mDeviceNamePref=(EditTextPreference)findPreference(KEY_RENAME_DEVICE);
  if (device == null) {
    Log.w(TAG,"Activity started without a remote Bluetooth device");
    finish();
    return;
  }
  mRenameDeviceNamePref=new RenameEditTextPreference();
  mManager=LocalBluetoothManager.getInstance(getActivity());
  CachedBluetoothDeviceManager deviceManager=mManager.getCachedDeviceManager();
  mProfileManager=mManager.getProfileManager();
  mCachedDevice=deviceManager.findDevice(device);
  if (mCachedDevice == null) {
    Log.w(TAG,"Device not found, cannot connect to it");
    finish();
    return;
  }
  String deviceName=mCachedDevice.getName();
  mDeviceNamePref.setSummary(deviceName);
  mDeviceNamePref.setText(deviceName);
  mDeviceNamePref.setOnPreferenceChangeListener(this);
  addPreferencesForProfiles();
}
 

Example 24

From project Gibberbot, under directory /src/info/guardianproject/otr/app/im/app/.

Source file: AccountSettingsActivity.java

  19 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getPreferenceManager().setSharedPreferencesName("account");
  addPreferencesFromResource(R.xml.account_settings);
  Intent intent=getIntent();
  mProviderId=intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_PROVIDER_ID,-1);
  if (mProviderId < 0) {
    Log.e(ImApp.LOG_TAG,"AccountSettingsActivity intent requires provider id extra");
    throw new RuntimeException("AccountSettingsActivity must be created with an provider id");
  }
  mXmppResource=(EditTextPreference)findPreference(getString(R.string.pref_account_xmpp_resource));
  mXmppResourcePrio=(EditTextPreference)findPreference(getString(R.string.pref_account_xmpp_resource_prio));
  mPort=(EditTextPreference)findPreference(getString(R.string.pref_account_port));
  mServer=(EditTextPreference)findPreference(getString(R.string.pref_account_server));
  mAllowPlainAuth=(CheckBoxPreference)findPreference(getString(R.string.pref_security_allow_plain_auth));
  mRequireTls=(CheckBoxPreference)findPreference(getString(R.string.pref_security_require_tls));
  mTlsCertVerify=(CheckBoxPreference)findPreference(getString(R.string.pref_security_tls_cert_verify));
  mDoDnsSrv=(CheckBoxPreference)findPreference(getString(R.string.pref_security_do_dns_srv));
}
 

Example 25

From project GSM-Signal-Tracking-, under directory /gpstracker/src/nl/sogeti/android/gpstracker/logger/.

Source file: ApplicationPreferenceActivity.java

  19 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.layout.settings);
  ListPreference precision=(ListPreference)findPreference("precision");
  time=(EditTextPreference)findPreference("customprecisiontime");
  distance=(EditTextPreference)findPreference("customprecisiondistance");
  setEnabledCustomValues(precision.getValue());
  precision.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
    public boolean onPreferenceChange(    Preference preference,    Object newValue){
      setEnabledCustomValues(newValue);
      return true;
    }
  }
);
}
 

Example 26

From project Hawksword, under directory /src/com/bw/hawksword/ocr/.

Source file: PreferencesActivity.java

  19 
vote

/** 
 * Set the default preference values.
 * @param Bundle savedInstanceState the current Activity's state, as passed by Android
 */
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.preferences);
  sharedPreferences=PreferenceManager.getDefaultSharedPreferences(this);
  listPreferenceDictionaryMode=(ListPreference)getPreferenceScreen().findPreference(KEY_DICTIONARY_MODE);
  listPreferenceFocusMode=(ListPreference)getPreferenceScreen().findPreference(KEY_FOCUS_MODE);
  listPreferenceSourceLanguage=(ListPreference)getPreferenceScreen().findPreference(KEY_SOURCE_LANGUAGE_PREFERENCE);
  listPreferenceTranslator=(ListPreference)getPreferenceScreen().findPreference(KEY_TRANSLATOR);
  listPreferenceOcrEngineMode=(ListPreference)getPreferenceScreen().findPreference(KEY_OCR_ENGINE_MODE);
  editTextPreferenceCharacterBlacklist=(EditTextPreference)getPreferenceScreen().findPreference(KEY_CHARACTER_BLACKLIST);
  editTextPreferenceCharacterWhitelist=(EditTextPreference)getPreferenceScreen().findPreference(KEY_CHARACTER_WHITELIST);
  listPreferencePageSegmentationMode=(ListPreference)getPreferenceScreen().findPreference(KEY_PAGE_SEGMENTATION_MODE);
}
 

Example 27

From project kumvandroid, under directory /src/com/ijuru/kumva/activity/.

Source file: PreferencesActivity.java

  19 
vote

/** 
 * @see android.preference.PreferenceActivity#onCreate(android.os.Bundle)
 */
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.preferences);
  maxResultsPref=(EditTextPreference)getPreferenceScreen().findPreference("max_results");
  maxResultsPref.setOnPreferenceChangeListener(this);
  maxResultsPref.setSummary(maxResultsPref.getText());
}
 

Example 28

From project liquidroid, under directory /src/liqui/droid/activity/.

Source file: Preferences.java

  19 
vote

@Override public void onCreate(Bundle bundle){
  super.onCreate(bundle);
  addPreferencesFromResource(R.xml.prefs_account);
  Bundle extras=null;
  if (getArguments() != null) {
    extras=getArguments();
  }
 else   if (getActivity() != null && getActivity().getIntent() != null) {
    extras=getActivity().getIntent().getExtras();
  }
  mAccount=(Account)extras.getParcelable("account");
  mObserver=new LQFBContentObserver(new Handler());
  getActivity().getContentResolver().registerContentObserver(DBSystemProvider.ACCOUNT_CONTENT_URI,true,mObserver);
  mApiKey=(EditTextPreference)findPreference("api_key");
  mApiKey.setOnPreferenceChangeListener(this);
  fillData();
}
 

Example 29

From project mobilis, under directory /MobilisXHunt/MobilisXHunt_Android/src/de/tudresden/inf/rn/mobilis/android/xhunt/activity/.

Source file: CreateGameActivity.java

  19 
vote

/** 
 * Initialize all UI elements from resources.
 */
private void initComponents(){
  mRemoteLoadingDialog=new DialogRemoteLoading(this,Const.CONNECTION_TIMEOUT_DELAY);
  mEditRounds=(EditTextPreference)getPreferenceScreen().findPreference(getKeyRounds());
  mEditMinPlayers=(EditTextPreference)getPreferenceScreen().findPreference(getKeyMinPlayers());
  mEditMaxPlayers=(EditTextPreference)getPreferenceScreen().findPreference(getKeyMaxPlayers());
  mEditStartTimer=(EditTextPreference)getPreferenceScreen().findPreference(getKeyStartTimer());
  updateSummaries();
  Button btn_Create=(Button)findViewById(R.id.creategame_btn_create);
  btn_Create.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      createGame();
    }
  }
);
}
 

Example 30

From project MWM-for-Android, under directory /src/org/metawatch/manager/.

Source file: Settings.java

  19 
vote

@Override protected void onStart(){
  Log.d(MetaWatch.TAG,"set onstart");
  editTextMac=(EditTextPreference)preferenceScreen.findPreference("MAC");
  editTextMac.setText(MetaWatchService.Preferences.watchMacAddress);
  discovery=preferenceScreen.findPreference("Discovery");
  discovery.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference arg0){
      Log.d(MetaWatch.TAG,"discovery click");
      startActivity(new Intent(context,DeviceSelection.class));
      return false;
    }
  }
);
  super.onStart();
}
 

Example 31

From project MyExpenses, under directory /src/org/totschnig/myexpenses/.

Source file: MyPreferenceActivity.java

  19 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setTitle(getString(R.string.app_name) + " " + getString(R.string.menu_settings));
  addPreferencesFromResource(R.layout.preferences);
  PreferenceScreen prefs=getPreferenceScreen();
  mCurrencyInputFormat=(ListPreference)prefs.findPreference(MyApplication.PREFKEY_CURRENCY_DECIMAL_SEPARATOR);
  if (mCurrencyInputFormat.getValue() == null) {
    String sep=Utils.getDefaultDecimalSeparator();
    mCurrencyInputFormat.setValue(sep);
  }
  mShareTarget=(EditTextPreference)prefs.findPreference(MyApplication.PREFKEY_SHARE_TARGET);
  mShareTarget.setSummary(getString(R.string.pref_share_target_summary) + ":\n" + "ftp: \"ftp://login:[email protected]:port/my/directory/\"\n"+ "mailto: \"mailto:[email protected]\"");
  mShareTarget.setOnPreferenceChangeListener(this);
}
 

Example 32

From project OpenTripPlanner-for-Android, under directory /src/org/opentripplanner/android/.

Source file: SettingsActivity.java

  19 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.preferences);
  mapTileProvider=(ListPreference)findPreference("map_tile_source");
  routingOptions=(PreferenceCategory)findPreference("routing_options");
  autoDetectServer=(CheckBoxPreference)findPreference("auto_detect_server");
  customServerURL=(EditTextPreference)findPreference("custom_server_url");
  ArrayList<CharSequence> names=new ArrayList<CharSequence>();
  ArrayList<ITileSource> tiles=TileSourceFactory.getTileSources();
  for (  ITileSource iTileSource : tiles) {
    names.add(iTileSource.name());
  }
  mapTileProvider.setEntries(names.toArray(new CharSequence[names.size()]));
  mapTileProvider.setEntryValues(names.toArray(new CharSequence[names.size()]));
  mapTileProvider.setDefaultValue("Mapnik");
  hideCustomURLPref(autoDetectServer.isChecked());
  autoDetectServer.setOnPreferenceChangeListener(new OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference preference,    Object newValue){
      Boolean value=(Boolean)newValue;
      hideCustomURLPref(value);
      return true;
    }
  }
);
}
 

Example 33

From project packages_apps_BlackICEControl, under directory /src/com/blackice/control/fragments/.

Source file: Weather.java

  19 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.prefs_weather);
  prefs=getActivity().getSharedPreferences("weather",Context.MODE_WORLD_WRITEABLE);
  mPicker=new ShortcutPickerHelper(this,this);
  mWeatherSyncInterval=(ListPreference)findPreference("refresh_interval");
  mWeatherSyncInterval.setOnPreferenceChangeListener(this);
  mWeatherSyncInterval.setSummary(Integer.toString(WeatherPrefs.getRefreshInterval(mContext)) + " minutes");
  mStatusBarLocation=(ListPreference)findPreference("statusbar_location");
  mStatusBarLocation.setOnPreferenceChangeListener(this);
  mStatusBarLocation.setValue(Settings.System.getInt(getContentResolver(),Settings.System.WEATHER_STATUSBAR_STYLE,1) + "");
  mCustomWeatherLoc=(EditTextPreference)findPreference("custom_location");
  mCustomWeatherLoc.setOnPreferenceChangeListener(this);
  mCustomWeatherLoc.setSummary(WeatherPrefs.getCustomLocation(mContext));
  mEnableWeather=(CheckBoxPreference)findPreference("enable_weather");
  mEnableWeather.setChecked(Settings.System.getInt(getContentResolver(),Settings.System.USE_WEATHER,0) == 1);
  mUseCustomLoc=(CheckBoxPreference)findPreference(WeatherPrefs.KEY_USE_CUSTOM_LOCATION);
  mUseCustomLoc.setChecked(WeatherPrefs.getUseCustomLocation(mContext));
  mShowLoc=(CheckBoxPreference)findPreference("show_location");
  mShowLoc.setChecked(Settings.System.getInt(getContentResolver(),Settings.System.WEATHER_SHOW_LOCATION,0) == 1);
  mUseCelcius=(CheckBoxPreference)findPreference(WeatherPrefs.KEY_USE_CELCIUS);
  mUseCelcius.setChecked(WeatherPrefs.getUseCelcius(mContext));
  mUseCustomApp=(CheckBoxPreference)findPreference(WeatherPrefs.KEY_USE_CUSTOM_APP);
  mUseCustomApp.setChecked(WeatherPrefs.getUseCustomApp(mContext));
  mCustomWeatherApp=(Preference)findPreference(WeatherPrefs.KEY_CUSTOM_APP);
  mCustomWeatherApp.setOnPreferenceChangeListener(this);
  mCustomWeatherApp.setSummary(mPicker.getFriendlyNameForUri(WeatherPrefs.getCustomApp(mContext)));
  setHasOptionsMenu(true);
  if (!Settings.Secure.isLocationProviderEnabled(getContentResolver(),LocationManager.NETWORK_PROVIDER) && !mUseCustomLoc.isChecked()) {
    showDialog(LOC_WARNING);
  }
}
 

Example 34

From project packages_apps_ROMControl, under directory /src/com/aokp/romcontrol/fragments/.

Source file: Weather.java

  19 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setTitle(R.string.title_weather);
  addPreferencesFromResource(R.xml.prefs_weather);
  prefs=getActivity().getSharedPreferences("weather",Context.MODE_WORLD_WRITEABLE);
  mPicker=new ShortcutPickerHelper(this,this);
  mWeatherSyncInterval=(ListPreference)findPreference("refresh_interval");
  mWeatherSyncInterval.setOnPreferenceChangeListener(this);
  mWeatherSyncInterval.setSummary(Integer.toString(WeatherPrefs.getRefreshInterval(mContext)) + getResources().getString(R.string.weather_refresh_interval_minutes));
  mStatusBarLocation=(ListPreference)findPreference("statusbar_location");
  mStatusBarLocation.setOnPreferenceChangeListener(this);
  mStatusBarLocation.setValue(Settings.System.getInt(getContentResolver(),Settings.System.STATUSBAR_WEATHER_STYLE,2) + "");
  mCustomWeatherLoc=(EditTextPreference)findPreference("custom_location");
  mCustomWeatherLoc.setOnPreferenceChangeListener(this);
  mCustomWeatherLoc.setSummary(WeatherPrefs.getCustomLocation(mContext));
  mEnableWeather=(CheckBoxPreference)findPreference("enable_weather");
  mEnableWeather.setChecked(Settings.System.getInt(getContentResolver(),Settings.System.USE_WEATHER,0) == 1);
  mUseCustomLoc=(CheckBoxPreference)findPreference(WeatherPrefs.KEY_USE_CUSTOM_LOCATION);
  mUseCustomLoc.setChecked(WeatherPrefs.getUseCustomLocation(mContext));
  mShowLoc=(CheckBoxPreference)findPreference("show_location");
  mShowLoc.setChecked(Settings.System.getInt(getContentResolver(),Settings.System.WEATHER_SHOW_LOCATION,0) == 1);
  mUseCelcius=(CheckBoxPreference)findPreference(WeatherPrefs.KEY_USE_CELCIUS);
  mUseCelcius.setChecked(WeatherPrefs.getUseCelcius(mContext));
  mUseCustomApp=(CheckBoxPreference)findPreference(WeatherPrefs.KEY_USE_CUSTOM_APP);
  mUseCustomApp.setChecked(WeatherPrefs.getUseCustomApp(mContext));
  mCustomWeatherApp=(Preference)findPreference(WeatherPrefs.KEY_CUSTOM_APP);
  mCustomWeatherApp.setOnPreferenceChangeListener(this);
  Pattern r=Pattern.compile("^#Intent");
  Matcher m=r.matcher(mPicker.getFriendlyNameForUri(WeatherPrefs.getCustomApp(mContext)));
  if (m.find()) {
    mCustomWeatherApp.setSummary("");
  }
 else {
    mCustomWeatherApp.setSummary(mPicker.getFriendlyNameForUri(WeatherPrefs.getCustomApp(mContext)));
  }
  setHasOptionsMenu(true);
  if (!Settings.Secure.isLocationProviderEnabled(getContentResolver(),LocationManager.NETWORK_PROVIDER) && !mUseCustomLoc.isChecked()) {
    showDialog(LOC_WARNING);
  }
}
 

Example 35

From project persistence, under directory /src/main/java/com/codeslap/persistence/pref/.

Source file: SmartEditTextPreference.java

  19 
vote

@Override public boolean onPreferenceClick(android.preference.Preference preference){
  String persistedString=mSmartEditTextPreference.getPersistedString(mSmartEditTextPreference.mDefVal);
  try {
    Field internal=EditTextPreference.class.getDeclaredField("mEditText");
    internal.setAccessible(true);
    Object editText=internal.get(preference);
    Method setText=TextView.class.getDeclaredMethod("setText",CharSequence.class);
    setText.invoke(editText,persistedString);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  if (clickListener != null) {
    return clickListener.onPreferenceClick(preference);
  }
  return true;
}
 

Example 36

From project platform_packages_apps_CytownPhone, under directory /src/com/android/phone/sip/.

Source file: SipEditor.java

  19 
vote

String getValue(){
  if (preference instanceof EditTextPreference) {
    return ((EditTextPreference)preference).getText();
  }
 else   if (preference instanceof ListPreference) {
    return ((ListPreference)preference).getValue();
  }
  throw new RuntimeException("getValue() for the preference " + this);
}
 

Example 37

From project platform_packages_apps_settings, under directory /src/com/android/settings/bluetooth/.

Source file: DeviceProfilesSettings.java

  19 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  BluetoothDevice device;
  if (savedInstanceState != null) {
    device=savedInstanceState.getParcelable(EXTRA_DEVICE);
  }
 else {
    Bundle args=getArguments();
    device=args.getParcelable(EXTRA_DEVICE);
  }
  addPreferencesFromResource(R.xml.bluetooth_device_advanced);
  getPreferenceScreen().setOrderingAsAdded(false);
  mProfileContainer=(PreferenceGroup)findPreference(KEY_PROFILE_CONTAINER);
  mDeviceNamePref=(EditTextPreference)findPreference(KEY_RENAME_DEVICE);
  if (device == null) {
    Log.w(TAG,"Activity started without a remote Bluetooth device");
    finish();
    return;
  }
  mRenameDeviceNamePref=new RenameEditTextPreference();
  mManager=LocalBluetoothManager.getInstance(getActivity());
  CachedBluetoothDeviceManager deviceManager=mManager.getCachedDeviceManager();
  mProfileManager=mManager.getProfileManager();
  mCachedDevice=deviceManager.findDevice(device);
  if (mCachedDevice == null) {
    Log.w(TAG,"Device not found, cannot connect to it");
    finish();
    return;
  }
  String deviceName=mCachedDevice.getName();
  mDeviceNamePref.setSummary(deviceName);
  mDeviceNamePref.setText(deviceName);
  mDeviceNamePref.setOnPreferenceChangeListener(this);
  addPreferencesForProfiles();
}
 

Example 38

From project rozkladpkp-android, under directory /src/org/tyszecki/rozkladpkp/.

Source file: PreferencesActivity.java

  19 
vote

protected void onCreate(Bundle savedInstanceState){
  setTheme(RozkladPKPApplication.getThemeId());
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.preferences);
  EditText myEditText=(EditText)((EditTextPreference)findPreference("discountValue")).getEditText();
  myEditText.setKeyListener(DigitsKeyListener.getInstance(false,true));
}
 

Example 39

From project subsonic, under directory /subsonic-android/src/github/daneren2005/dsub/activity/.

Source file: SettingsActivity.java

  19 
vote

private ServerSettings(String instance){
  screen=(PreferenceScreen)findPreference("server" + instance);
  serverName=(EditTextPreference)findPreference(Constants.PREFERENCES_KEY_SERVER_NAME + instance);
  serverUrl=(EditTextPreference)findPreference(Constants.PREFERENCES_KEY_SERVER_URL + instance);
  username=(EditTextPreference)findPreference(Constants.PREFERENCES_KEY_USERNAME + instance);
  serverUrl.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference preference,    Object value){
      try {
        String url=(String)value;
        new URL(url);
        if (!url.equals(url.trim()) || url.contains("@") || url.contains("_")) {
          throw new Exception();
        }
      }
 catch (      Exception x) {
        new ErrorDialog(SettingsActivity.this,R.string.settings_invalid_url,false);
        return false;
      }
      return true;
    }
  }
);
  username.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference preference,    Object value){
      String username=(String)value;
      if (username == null || !username.equals(username.trim())) {
        new ErrorDialog(SettingsActivity.this,R.string.settings_invalid_username,false);
        return false;
      }
      return true;
    }
  }
);
}
 

Example 40

From project Subsonic-Android, under directory /src/net/sourceforge/subsonic/androidapp/activity/.

Source file: SettingsActivity.java

  19 
vote

private ServerSettings(String instance){
  screen=(PreferenceScreen)findPreference("server" + instance);
  serverName=(EditTextPreference)findPreference(Constants.PREFERENCES_KEY_SERVER_NAME + instance);
  serverUrl=(EditTextPreference)findPreference(Constants.PREFERENCES_KEY_SERVER_URL + instance);
  username=(EditTextPreference)findPreference(Constants.PREFERENCES_KEY_USERNAME + instance);
  serverUrl.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference preference,    Object value){
      try {
        String url=(String)value;
        new URL(url);
        if (!url.equals(url.trim()) || url.contains("@")) {
          throw new Exception();
        }
      }
 catch (      Exception x) {
        new ErrorDialog(SettingsActivity.this,R.string.settings_invalid_url,false);
        return false;
      }
      return true;
    }
  }
);
  username.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference preference,    Object value){
      String username=(String)value;
      if (username == null || !username.equals(username.trim())) {
        new ErrorDialog(SettingsActivity.this,R.string.settings_invalid_username,false);
        return false;
      }
      return true;
    }
  }
);
}
 

Example 41

From project subsonic_1, under directory /subsonic-android/src/net/sourceforge/subsonic/androidapp/activity/.

Source file: SettingsActivity.java

  19 
vote

private ServerSettings(String instance){
  screen=(PreferenceScreen)findPreference("server" + instance);
  serverName=(EditTextPreference)findPreference(Constants.PREFERENCES_KEY_SERVER_NAME + instance);
  serverUrl=(EditTextPreference)findPreference(Constants.PREFERENCES_KEY_SERVER_URL + instance);
  username=(EditTextPreference)findPreference(Constants.PREFERENCES_KEY_USERNAME + instance);
  serverUrl.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference preference,    Object value){
      try {
        String url=(String)value;
        new URL(url);
        if (!url.equals(url.trim()) || url.contains("@")) {
          throw new Exception();
        }
      }
 catch (      Exception x) {
        new ErrorDialog(SettingsActivity.this,R.string.settings_invalid_url,false);
        return false;
      }
      return true;
    }
  }
);
  username.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference preference,    Object value){
      String username=(String)value;
      if (username == null || !username.equals(username.trim())) {
        new ErrorDialog(SettingsActivity.this,R.string.settings_invalid_username,false);
        return false;
      }
      return true;
    }
  }
);
}
 

Example 42

From project subsonic_2, under directory /subsonic-android/src/net/sourceforge/subsonic/androidapp/activity/.

Source file: SettingsActivity.java

  19 
vote

private ServerSettings(String instance){
  screen=(PreferenceScreen)findPreference("server" + instance);
  serverName=(EditTextPreference)findPreference(Constants.PREFERENCES_KEY_SERVER_NAME + instance);
  serverUrl=(EditTextPreference)findPreference(Constants.PREFERENCES_KEY_SERVER_URL + instance);
  username=(EditTextPreference)findPreference(Constants.PREFERENCES_KEY_USERNAME + instance);
  serverUrl.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference preference,    Object value){
      try {
        String url=(String)value;
        new URL(url);
        if (!url.equals(url.trim())) {
          throw new Exception();
        }
      }
 catch (      Exception x) {
        new ErrorDialog(SettingsActivity.this,R.string.settings_invalid_url,false);
        return false;
      }
      return true;
    }
  }
);
  username.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference preference,    Object value){
      String username=(String)value;
      if (username == null || !username.equals(username.trim())) {
        new ErrorDialog(SettingsActivity.this,R.string.settings_invalid_username,false);
        return false;
      }
      return true;
    }
  }
);
}
 

Example 43

From project Supersonic, under directory /subsonic-android/src/net/sourceforge/subsonic/androidapp/activity/.

Source file: SettingsActivity.java

  19 
vote

private ServerSettings(String instance){
  screen=(PreferenceScreen)findPreference("server" + instance);
  serverName=(EditTextPreference)findPreference(Constants.PREFERENCES_KEY_SERVER_NAME + instance);
  serverUrl=(EditTextPreference)findPreference(Constants.PREFERENCES_KEY_SERVER_URL + instance);
  username=(EditTextPreference)findPreference(Constants.PREFERENCES_KEY_USERNAME + instance);
  serverUrl.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference preference,    Object value){
      try {
        String url=(String)value;
        new URL(url);
        if (!url.equals(url.trim()) || url.contains("@")) {
          throw new Exception();
        }
      }
 catch (      Exception x) {
        new ErrorDialog(SettingsActivity.this,R.string.settings_invalid_url,false);
        return false;
      }
      return true;
    }
  }
);
  username.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference preference,    Object value){
      String username=(String)value;
      if (username == null || !username.equals(username.trim())) {
        new ErrorDialog(SettingsActivity.this,R.string.settings_invalid_username,false);
        return false;
      }
      return true;
    }
  }
);
}
 

Example 44

From project weechat-android, under directory /weechat-android/src/com/ubergeek42/WeechatAndroid/.

Source file: WeechatPreferencesActivity.java

  19 
vote

/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.preferences);
  sharedPreferences=getPreferenceScreen().getSharedPreferences();
  hostPref=(EditTextPreference)getPreferenceScreen().findPreference("host");
  portPref=(EditTextPreference)getPreferenceScreen().findPreference("port");
  passPref=(EditTextPreference)getPreferenceScreen().findPreference("password");
  textSizePref=(EditTextPreference)getPreferenceScreen().findPreference("text_size");
  timestampformatPref=(EditTextPreference)getPreferenceScreen().findPreference("timestamp_format");
  stunnelCert=(EditTextPreference)getPreferenceScreen().findPreference("stunnel_cert");
  stunnelPass=(EditTextPreference)getPreferenceScreen().findPreference("stunnel_pass");
  sshHostPref=(EditTextPreference)getPreferenceScreen().findPreference("ssh_host");
  sshUserPref=(EditTextPreference)getPreferenceScreen().findPreference("ssh_user");
  sshPortPref=(EditTextPreference)getPreferenceScreen().findPreference("ssh_port");
  sshPassPref=(EditTextPreference)getPreferenceScreen().findPreference("ssh_pass");
  prefixPref=(ListPreference)getPreferenceScreen().findPreference("prefix_align");
  connectionTypePref=(ListPreference)getPreferenceScreen().findPreference("connection_type");
  setTitle(R.string.preferences);
}