Java Code Examples for android.preference.Preference.OnPreferenceChangeListener

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 android-voip-service, under directory /src/main/java/org/linphone/.

Source file: LinphonePreferencesActivity.java

  21 
vote

private void addTransportChecboxesListener(){
  final List<CheckBoxPreference> checkboxes=Arrays.asList(findCheckbox(R.string.pref_transport_udp_key),findCheckbox(R.string.pref_transport_tcp_key),findCheckbox(R.string.pref_transport_tls_key));
  OnPreferenceChangeListener changedListener=new OnPreferenceChangeListener(){
    public boolean onPreferenceChange(    Preference preference,    Object newValue){
      if ((Boolean)newValue) {
        for (        CheckBoxPreference p : checkboxes) {
          if (p == preference)           continue;
          p.setChecked(false);
        }
        return true;
      }
 else {
        for (        CheckBoxPreference p : checkboxes) {
          if (p == preference)           continue;
          if (p.isChecked())           return true;
        }
        return false;
      }
    }
  }
;
  OnPreferenceClickListener clickListener=new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      if (((CheckBoxPreference)preference).isChecked()) {
        for (        CheckBoxPreference p : checkboxes) {
          if (p == preference)           continue;
          if (p.isChecked())           return false;
        }
        return true;
      }
      return false;
    }
  }
;
  for (  CheckBoxPreference c : checkboxes) {
    c.setOnPreferenceChangeListener(changedListener);
    c.setOnPreferenceClickListener(clickListener);
  }
}
 

Example 2

From project lullaby, under directory /src/net/sileht/lullaby/.

Source file: SettingActivity.java

  21 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.preferences);
  findPreference("InsecureSSL").setOnPreferenceChangeListener(new OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference preference,    Object newValue){
      Utils.setSSLCheck((Boolean)newValue);
      return true;
    }
  }
);
}
 

Example 3

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

Source file: EditFunctionButtonActivity.java

  21 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  this.addPreferencesFromResource(R.xml.functionbtn);
  valuesMap.put("name","");
  valuesMap.put("keys","");
  valuesMap.put("sortnumber","0");
  btn=(FunctionButton)getIntent().getSerializableExtra("button");
  if (btn != null)   extractValues(btn);
  updatePreferenceDisplay();
  System.out.println(getPreferenceScreen().getPreferenceCount());
  OnPreferenceChangeListener listener=new OnPreferenceChangeListener(){
    public boolean onPreferenceChange(    Preference preference,    Object newValue){
      String key=preference.getKey();
      String value=newValue.toString();
      Log.i("TT","onPreferenceChange," + key + ":"+ value);
      valuesMap.put(key,value);
      updatePreferenceDisplay();
      return false;
    }
  }
;
  for (int i=0; i < getPreferenceScreen().getPreferenceCount(); i++) {
    Preference p=getPreferenceScreen().getPreference(i);
    if (p instanceof PreferenceCategory) {
      PreferenceCategory p2=(PreferenceCategory)p;
      for (int j=0; j < p2.getPreferenceCount(); j++) {
        p2.getPreference(j).setOnPreferenceChangeListener(listener);
      }
    }
 else {
      getPreferenceScreen().getPreference(i).setOnPreferenceChangeListener(listener);
    }
  }
}
 

Example 4

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

Source file: SyncSettings.java

  21 
vote

@Override public void onCreate(Bundle icicle){
  super.onCreate(icicle);
  addPreferencesFromResource(R.xml.sync_settings);
  mAutoSyncPreference=(CheckBoxPreference)getPreferenceScreen().findPreference(KEY_SYNC_SWITCH);
  mAutoSyncPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference preference,    Object newValue){
      ContentResolver.setMasterSyncAutomatically((Boolean)newValue);
      return true;
    }
  }
);
  setHasOptionsMenu(true);
}
 

Example 5

From project Racenet-for-Android, under directory /src/org/racenet/.

Source file: SettingsActivity.java

  21 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.settings);
  manager=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  db=new Database(getApplicationContext());
  OnPreferenceChangeListener listener=new OnPreferenceChangeListener(){
    public boolean onPreferenceChange(    Preference pref,    Object value){
      if (pref.getKey().equals("icon")) {
        if (value.toString() == "true") {
          if (IsServiceRunning.check("org.racenet.services.MQTTService",getApplicationContext())) {
            manager.notify(MQTTService.SERVICE_NOTIFICATION,MQTTService.getServiceNotification(getApplicationContext(),SettingsActivity.this));
          }
        }
 else {
          manager.cancel(MQTTService.SERVICE_NOTIFICATION);
        }
      }
 else       if (pref.getKey().equals("ping")) {
        if (!value.toString().matches("^[0-9]+$")) {
          new AlertDialog.Builder(SettingsActivity.this).setMessage("Must be a numeric value.").setNeutralButton("OK",null).show();
          return false;
        }
 else {
          new AlertDialog.Builder(SettingsActivity.this).setMessage("Logout and login to apply the change.").setNeutralButton("OK",null).show();
        }
      }
      db.set(pref.getKey(),value.toString());
      return true;
    }
  }
;
  findPreference("icon").setOnPreferenceChangeListener(listener);
  findPreference("sound").setOnPreferenceChangeListener(listener);
  findPreference("ping").setOnPreferenceChangeListener(listener);
}
 

Example 6

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

Source file: NotificationPreferenceActivity.java

  20 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  PreferenceManager prefMgr=getPreferenceManager();
  prefMgr.setSharedPreferencesName(Preferences.PREF);
  addPreferencesFromResource(R.xml.notification_preferences);
  ratingsPref=(CheckBoxPreference)getPreferenceScreen().findPreference(Preferences.NOTIFICATION_CHANGES_RATING);
  ratingsPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference preference,    Object newValue){
      Boolean notificationsEnabled=(Boolean)newValue || commentsPref.isChecked() || downloadsPref.isChecked();
      notificationSignalPrefCat.setEnabled(notificationsEnabled);
      return true;
    }
  }
);
  commentsPref=(CheckBoxPreference)getPreferenceScreen().findPreference(Preferences.NOTIFICATION_CHANGES_COMMENTS);
  commentsPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference preference,    Object newValue){
      Boolean notificationsEnabled=(Boolean)newValue || ratingsPref.isChecked() || downloadsPref.isChecked();
      notificationSignalPrefCat.setEnabled(notificationsEnabled);
      return true;
    }
  }
);
  downloadsPref=(CheckBoxPreference)getPreferenceScreen().findPreference(Preferences.NOTIFICATION_CHANGES_DOWNLOADS);
  downloadsPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference preference,    Object newValue){
      Boolean notificationsEnabled=(Boolean)newValue || ratingsPref.isChecked() || commentsPref.isChecked();
      notificationSignalPrefCat.setEnabled(notificationsEnabled);
      return true;
    }
  }
);
  notificationSignalPrefCat=(PreferenceCategory)getPreferenceScreen().findPreference("prefCatNotificationSignal");
  Boolean notificationsEnabled=commentsPref.isChecked() || ratingsPref.isChecked() || downloadsPref.isChecked();
  notificationSignalPrefCat.setEnabled(notificationsEnabled);
}
 

Example 7

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

Source file: ApplicationSettings.java

  20 
vote

@Override protected void onCreate(Bundle icicle){
  super.onCreate(icicle);
  addPreferencesFromResource(R.xml.application_settings);
  mToggleAppInstallation=(CheckBoxPreference)findPreference(KEY_TOGGLE_INSTALL_APPLICATIONS);
  mToggleAppInstallation.setChecked(isNonMarketAppsAllowed());
  mInstallLocation=(ListPreference)findPreference(KEY_APP_INSTALL_LOCATION);
  boolean userSetInstLocation=(Settings.System.getInt(getContentResolver(),Settings.Secure.SET_INSTALL_LOCATION,0) != 0);
  if (!userSetInstLocation) {
    getPreferenceScreen().removePreference(mInstallLocation);
  }
 else {
    mInstallLocation.setValue(getAppInstallLocation());
    mInstallLocation.setOnPreferenceChangeListener(new OnPreferenceChangeListener(){
      public boolean onPreferenceChange(      Preference preference,      Object newValue){
        String value=(String)newValue;
        handleUpdateAppInstallLocation(value);
        return false;
      }
    }
);
  }
  if (getResources().getConfiguration().keyboard == Configuration.KEYBOARD_NOKEYS) {
    Preference quickLaunchSetting=findPreference(KEY_QUICK_LAUNCH);
    getPreferenceScreen().removePreference(quickLaunchSetting);
  }
}
 

Example 8

From project Birthdays, under directory /src/com/rexmenpara/birthdays/.

Source file: AppPrefActivity.java

  20 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.preferences);
  Preference calendarName=(Preference)findPreference("calendarName");
  calendarName.setOnPreferenceChangeListener(new OnPreferenceChangeListener(){
    public boolean onPreferenceChange(    Preference preference,    Object newValue){
      SharedPreferences sharedPreferences=getSharedPreferences("birthdayPrefs",Activity.MODE_PRIVATE);
      SharedPreferences.Editor editor=sharedPreferences.edit();
      editor.putString("calendarName",newValue.toString());
      editor.commit();
      return true;
    }
  }
);
}
 

Example 9

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

Source file: ApplicationSettings.java

  20 
vote

@Override public void onCreate(Bundle icicle){
  super.onCreate(icicle);
  addPreferencesFromResource(R.xml.application_settings);
  mToggleAdvancedSettings=(CheckBoxPreference)findPreference(KEY_TOGGLE_ADVANCED_SETTINGS);
  mToggleAdvancedSettings.setChecked(isAdvancedSettingsEnabled());
  getPreferenceScreen().removePreference(mToggleAdvancedSettings);
  if (false) {
    getPreferenceScreen().removePreference(mInstallLocation);
  }
  mInstallLocation=(ListPreference)findPreference(KEY_APP_INSTALL_LOCATION);
  boolean userSetInstLocation=(Settings.System.getInt(getContentResolver(),Settings.Secure.SET_INSTALL_LOCATION,0) != 0);
  if (!userSetInstLocation) {
    getPreferenceScreen().removePreference(mInstallLocation);
  }
 else {
    mInstallLocation.setValue(getAppInstallLocation());
    mInstallLocation.setOnPreferenceChangeListener(new OnPreferenceChangeListener(){
      public boolean onPreferenceChange(      Preference preference,      Object newValue){
        String value=(String)newValue;
        handleUpdateAppInstallLocation(value);
        return false;
      }
    }
);
  }
}
 

Example 10

From project danbooru-gallery-android, under directory /src/tw/idv/palatis/danboorugallery/.

Source file: DanbooruGalleryPreferenceActivity.java

  20 
vote

@Override protected void onStart(){
  if (preferences.contains("json_hosts"))   try {
    hosts=D.HostsFromJSONArray(new JSONArray(preferences.getString("json_hosts","")));
  }
 catch (  JSONException ex) {
    D.Log.wtf(ex);
  }
 else   hosts=new ArrayList<Host>();
  try {
    PackageInfo manager=getPackageManager().getPackageInfo(getPackageName(),0);
    findPreference("preferences_about_version").setSummary(manager.versionName);
  }
 catch (  NameNotFoundException e) {
  }
  ListPreference pref_hosts=(ListPreference)findPreference("preferences_hosts_select");
  pref_hosts.setOnPreferenceChangeListener(new OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference preference,    Object newValue){
      String name=hosts.get(Integer.parseInt((String)newValue)).name;
      preference.setSummary(String.format(getString(R.string.preferences_hosts_selected_host),name));
      return true;
    }
  }
);
  CheckBoxPreference pref_aggressive=(CheckBoxPreference)findPreference("preferences_options_aggressive_prefetch");
  pref_aggressive.setChecked(preferences.getBoolean("aggressive_prefetch",false));
  CheckBoxPreference pref_hqimage=(CheckBoxPreference)findPreference("preferences_options_high_quality_image");
  pref_hqimage.setChecked(preferences.getBoolean("high_quality_image",false));
  notifyHostsChanged();
  super.onStart();
}
 

Example 11

From project keepassdroid, under directory /src/com/keepassdroid/settings/.

Source file: AppSettingsActivity.java

  20 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.preferences);
  Preference keyFile=findPreference(getString(R.string.keyfile_key));
  keyFile.setOnPreferenceChangeListener(new OnPreferenceChangeListener(){
    public boolean onPreferenceChange(    Preference preference,    Object newValue){
      Boolean value=(Boolean)newValue;
      if (!value.booleanValue()) {
        FileDbHelper helper=App.fileDbHelper;
        helper.deleteAllKeys();
      }
      return true;
    }
  }
);
  Database db=App.getDB();
  if (db.Loaded() && db.pm.appSettingsEnabled()) {
    Preference rounds=findPreference(getString(R.string.rounds_key));
    rounds.setOnPreferenceChangeListener(new OnPreferenceChangeListener(){
      public boolean onPreferenceChange(      Preference preference,      Object newValue){
        setRounds(App.getDB(),preference);
        return true;
      }
    }
);
    setRounds(db,rounds);
    Preference algorithm=findPreference(getString(R.string.algorithm_key));
    setAlgorithm(db,algorithm);
  }
 else {
    Preference dbSettings=findPreference(getString(R.string.db_key));
    dbSettings.setEnabled(false);
  }
  backupManager=new BackupManagerCompat(this);
}
 

Example 12

From project KeyboardTerm, under directory /src/tw/kenshinn/keyboardTerm/.

Source file: KeyboardsSettingsActivity.java

  20 
vote

private void updateButtonState(final PreferenceGroup group,int enableCount){
  SharedPreferences pref=PreferenceManager.getDefaultSharedPreferences(this);
  group.getPreference(0).setOnPreferenceChangeListener(new OnPreferenceChangeListener(){
    public boolean onPreferenceChange(    Preference preference,    Object newValue){
      updateButtonState(group,Integer.parseInt(newValue.toString()));
      return true;
    }
  }
);
  group.getPreference(0).setSummary(String.valueOf(enableCount));
  for (int i=1; i < group.getPreferenceCount(); i++) {
    Preference item=group.getPreference(i);
    String keyValue=pref.getString(item.getKey(),"NONE");
    item.setTitle(getResources().getString(R.string.setting_button) + " " + i);
    if (keyValue.startsWith("custom_")) {
      item.setSummary(keyValue.replaceAll("^custom_",""));
      item.setOnPreferenceChangeListener(mButtonChangeListener);
      continue;
    }
    if (mKeyValuesList.contains(keyValue)) {
      int index=mKeyValuesList.indexOf(keyValue);
      item.setSummary(mKeyDefinesList.get(index));
    }
 else {
      item.setSummary(keyValue);
    }
    item.setOnPreferenceChangeListener(mButtonChangeListener);
    if (i <= enableCount)     item.setEnabled(true);
 else     item.setEnabled(false);
  }
}
 

Example 13

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

Source file: SettingsActivity.java

  20 
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 14

From project SamyGo-Android-Remote, under directory /src/de/quist/app/samyGoRemote/.

Source file: MainPreferencesActivity.java

  20 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.main_preferences);
  portPref=findPreference(Remote.PREFS_SERVER_PORT_KEY);
  senderFactoryPref=(ListPreference)findPreference(Remote.PREFS_SENDER_FACTORY_KEY);
  senderFactoryPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener(){
    public boolean onPreferenceChange(    Preference preference,    Object newValue){
      setPortEnabledState(newValue);
      return true;
    }
  }
);
  Preference hostPrefs=findPreference(Remote.PREFS_SERVER_HOST_KEY);
  ((HostnamePreference)hostPrefs).setOnSenderFactoryChangeListener(new OnSenderFactoryChangeListener(){
    public boolean onSenderFactoryChange(    String newValue){
      senderFactoryPref.setValue(newValue);
      setPortEnabledState(newValue);
      return true;
    }
  }
);
  String value=PreferenceManager.getDefaultSharedPreferences(this).getString(Remote.PREFS_SENDER_FACTORY_KEY,Remote.PREFS_SENDER_FACTORY_DEFAULT);
  setPortEnabledState(value);
}
 

Example 15

From project SeriesGuide, under directory /SeriesGuide/src/com/battlelancer/seriesguide/ui/.

Source file: SeriesGuidePreferences.java

  20 
vote

protected static void setupAdvancedSettings(final Activity activity,Preference themePref,final Intent startIntent,Preference upcomingPref,Preference numberFormatPref,Preference offsetPref,Preference analyticsPref,Preference clearCachePref){
  themePref.setOnPreferenceChangeListener(new OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference preference,    Object newValue){
      if (preference.getKey().equals(KEY_THEME)) {
        Utils.updateTheme((String)newValue);
        NavUtils.navigateUpTo(activity,new Intent(Intent.ACTION_MAIN).setClass(activity,ShowsActivity.class));
        activity.startActivity(startIntent);
      }
      return true;
    }
  }
);
  clearCachePref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
    public boolean onPreferenceClick(    Preference preference){
      fireTrackerEvent("Clear Image Cache");
      ImageProvider.getInstance(activity).clearCache();
      ImageProvider.getInstance(activity).clearExternalStorageCache();
      Toast.makeText(activity,activity.getString(R.string.done),Toast.LENGTH_SHORT).show();
      return true;
    }
  }
);
  analyticsPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference preference,    Object newValue){
      if (preference.getKey().equals(KEY_GOOGLEANALYTICS)) {
        boolean isEnabled=(Boolean)newValue;
        GoogleAnalytics.getInstance(activity).setAppOptOut(isEnabled);
        return true;
      }
      return false;
    }
  }
);
  setListPreferenceSummary((ListPreference)themePref);
  setListPreferenceSummary((ListPreference)upcomingPref);
  setListPreferenceSummary((ListPreference)numberFormatPref);
  ListPreference offsetListPref=(ListPreference)offsetPref;
  offsetListPref.setSummary(activity.getString(R.string.pref_offsetsummary,offsetListPref.getEntry()));
}
 

Example 16

From project sms-backup-plus, under directory /src/com/zegoggles/smssync/.

Source file: SmsSync.java

  20 
vote

private void addSummaryListener(final Runnable r,String... prefs){
  for (  String p : prefs) {
    findPreference(p).setOnPreferenceChangeListener(new OnPreferenceChangeListener(){
      public boolean onPreferenceChange(      Preference preference,      final Object newValue){
        new Handler().post(new Runnable(){
          @Override public void run(){
            r.run();
            onContentChanged();
          }
        }
);
        return true;
      }
    }
);
  }
}
 

Example 17

From project SyncMyPix, under directory /src/com/nloko/android/syncmypix/.

Source file: SettingsActivity.java

  20 
vote

private void setupViews(Bundle savedInstanceState){
  addPreferencesFromResource(R.layout.preferences);
  int freq=getSharedPreferences(SettingsActivity.PREFS_NAME,0).getInt("sched_freq",0);
  ListPreference schedule=(ListPreference)findPreference("sched_freq");
  if (freq != Integer.parseInt(schedule.getValue())) {
    schedule.setValueIndex(freq);
  }
  schedule.setOnPreferenceChangeListener(new OnPreferenceChangeListener(){
    public boolean onPreferenceChange(    Preference preference,    Object newValue){
      int position=Integer.parseInt((String)newValue);
      long firstTriggerTime;
      long interval;
      Utils.setInt(getSharedPreferences(SettingsActivity.PREFS_NAME,0),"sched_freq",position);
      if ((interval=SettingsActivity.getScheduleInterval(position)) > 0) {
        firstTriggerTime=System.currentTimeMillis() + interval;
        Utils.setLong(getSharedPreferences(SettingsActivity.PREFS_NAME,0),"sched_time",firstTriggerTime);
        SyncService.updateSchedule(SettingsActivity.this,MainActivity.getSyncSource(getBaseContext()),firstTriggerTime,interval);
      }
 else {
        SyncService.cancelSchedule(SettingsActivity.this,MainActivity.getSyncSource(getBaseContext()));
      }
      return true;
    }
  }
);
  if (MainActivity.isLoggedInFromSyncSource(getBaseContext(),MainActivity.getSyncSource(getBaseContext()))) {
    setLoginStatus(R.string.preferences_loggedin);
  }
}
 

Example 18

From project Synodroid, under directory /src/com/bigpupdev/synodroid/ui/.

Source file: DownloadPreferenceActivity.java

  20 
vote

private void reloadCurrentServers(){
  serversCategory.removeAll();
  maxServerId=0;
  final ListPreferenceWithValue defSrvPref=ListPreferenceWithValue.create(DownloadPreferenceActivity.this,PREFERENCE_DEF_SRV,R.string.label_def_srv,R.string.hint_def_srv,null);
  defSrvPref.setOrder(0);
  PreferenceFacade.processLoadingServers(getPreferenceScreen().getSharedPreferences(),this,defSrvPref,getString(R.string.srv_always_ask));
  serversCategory.addPreference(defSrvPref);
  defSrvPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener(){
    public boolean onPreferenceChange(    Preference preference,    Object newValue){
      SharedPreferences preferences=getSharedPreferences(PREFERENCE_SERVER,Activity.MODE_PRIVATE);
      preferences.edit().putString(PREFERENCE_DEF_SRV,(String)newValue).commit();
      return true;
    }
  }
);
}
 

Example 19

From project UABDroid, under directory /src/org/uab/deic/uabdroid/.

Source file: AppPreferencesActivity.java

  20 
vote

@Override public void onCreate(Bundle _savedInstanceState){
  super.onCreate(_savedInstanceState);
  addPreferencesFromResource(R.xml.userpreferences);
  PreferenceManager preferenceManager=getPreferenceManager();
  final Preference alertsFrequency=preferenceManager.findPreference(PREF_NEXT_SESSION_ALERT_FREQ);
  final Preference alertsInterval=preferenceManager.findPreference(PREF_NEXT_SESSION_ALERT_INTERVAL);
  mCheckAlertsAlarms=(CheckBoxPreference)preferenceManager.findPreference(PREF_NEXT_SESSION_ALERTS_CHECK);
  mCheckAlertsAlarms.setOnPreferenceChangeListener(new OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference _preference,    Object _object){
      alertsFrequency.setEnabled(!((CheckBoxPreference)_preference).isChecked());
      alertsInterval.setEnabled(!((CheckBoxPreference)_preference).isChecked());
      return true;
    }
  }
);
  alertsFrequency.setEnabled(mCheckAlertsAlarms.isChecked());
  alertsInterval.setEnabled(mCheckAlertsAlarms.isChecked());
  final Preference updatesFrequency=preferenceManager.findPreference(PREF_AUTOMATIC_UPDATES_FREQ);
  mCheckUpdatesAlarms=(CheckBoxPreference)preferenceManager.findPreference(PREF_AUTOMATIC_UPDATES_CHECK);
  mCheckUpdatesAlarms.setOnPreferenceChangeListener(new OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference _preference,    Object _object){
      updatesFrequency.setEnabled(!((CheckBoxPreference)_preference).isChecked());
      return true;
    }
  }
);
  updatesFrequency.setEnabled(mCheckUpdatesAlarms.isChecked());
  getListView().setCacheColorHint(0);
}
 

Example 20

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

Source file: GeneralPreferences.java

  19 
vote

/** 
 * Sets up all the preference change listeners to use the specified listener.
 */
private void setPreferenceListeners(OnPreferenceChangeListener listener){
  mUseHomeTZ.setOnPreferenceChangeListener(listener);
  mHomeTZ.setOnPreferenceChangeListener(listener);
  mWeekStart.setOnPreferenceChangeListener(listener);
  mDefaultReminder.setOnPreferenceChangeListener(listener);
  mRingtone.setOnPreferenceChangeListener(listener);
  mHideDeclined.setOnPreferenceChangeListener(listener);
  mVibrateWhen.setOnPreferenceChangeListener(listener);
}
 

Example 21

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

Source file: GeneralPreferences.java

  19 
vote

/** 
 * Sets up all the preference change listeners to use the specified listener.
 */
private void setPreferenceListeners(OnPreferenceChangeListener listener){
  mUseHomeTZ.setOnPreferenceChangeListener(listener);
  mHomeTZ.setOnPreferenceChangeListener(listener);
  mWeekStart.setOnPreferenceChangeListener(listener);
  mDefaultReminder.setOnPreferenceChangeListener(listener);
  mRingtone.setOnPreferenceChangeListener(listener);
  mHideDeclined.setOnPreferenceChangeListener(listener);
  mVibrateWhen.setOnPreferenceChangeListener(listener);
}