private void setDefaultValues() { settings = getSharedPreferences(sharedPrefsFile, MODE_PRIVATE); for (int i = 0; i < SipdroidEngine.LINES; i++) { String j = (i != 0 ? "" + i : ""); if (settings.getString(PREF_SERVER + j, "").equals("")) { CheckBoxPreference cb = (CheckBoxPreference) getPreferenceScreen().findPreference(PREF_WLAN + j); cb.setChecked(true); Editor edit = settings.edit(); edit.putString(PREF_PORT + j, "5061"); edit.putString(PREF_SERVER + j, DEFAULT_SERVER); edit.putString(PREF_PREF + j, DEFAULT_PREF); edit.putString(PREF_PROTOCOL + j, DEFAULT_PROTOCOL); edit.commit(); Receiver.engine(this).updateDNS(); reload(); } } if (settings.getString(PREF_STUN_SERVER, "").equals("")) { Editor edit = settings.edit(); edit.putString(PREF_STUN_SERVER, DEFAULT_STUN_SERVER); edit.putString(PREF_STUN_SERVER_PORT, DEFAULT_STUN_SERVER_PORT); edit.commit(); reload(); } if (!settings.contains(PREF_MWI_ENABLED)) { CheckBoxPreference cb = (CheckBoxPreference) getPreferenceScreen().findPreference(PREF_MWI_ENABLED); cb.setChecked(true); } if (!settings.contains(PREF_REGISTRATION)) { CheckBoxPreference cb = (CheckBoxPreference) getPreferenceScreen().findPreference(PREF_REGISTRATION); cb.setChecked(true); } if (Sipdroid.market) { CheckBoxPreference cb = (CheckBoxPreference) getPreferenceScreen().findPreference(PREF_3G); cb.setChecked(false); CheckBoxPreference cb2 = (CheckBoxPreference) getPreferenceScreen().findPreference(PREF_EDGE); cb2.setChecked(false); getPreferenceScreen().findPreference(PREF_3G).setEnabled(false); getPreferenceScreen().findPreference(PREF_EDGE).setEnabled(false); } settings.registerOnSharedPreferenceChangeListener(this); updateSummaries(); }
public void onClick(DialogInterface dialog, int whichItem) { int set = updateSleepPolicy(); boolean message = settings.getBoolean(PREF_MESSAGE, DEFAULT_MESSAGE); try { copyFile( new File(profilePath + profileFiles[whichItem]), new File(sharedPrefsPath + sharedPrefsFile + ".xml")); } catch (Exception e) { Toast.makeText( context, getString(R.string.settings_profile_import_error), Toast.LENGTH_SHORT) .show(); return; } settings.unregisterOnSharedPreferenceChangeListener(context); setDefaultValues(); // Restart the engine Receiver.engine(context).halt(); Receiver.engine(context).StartEngine(); reload(); settings.registerOnSharedPreferenceChangeListener(context); updateSummaries(); if (set != updateSleepPolicy()) updateSleep(); if (message) { Editor edit = settings.edit(); edit.putBoolean(PREF_MESSAGE, true); edit.commit(); } }