@Override protected Dialog onCreateDialog(int id) { super.onCreateDialog(id); switch (id) { case R.string.cache_clear_warning: return new ConfirmDialogBuilder(this, R.string.cache_clear_warning, this) .setMessage(R.string.cache_clear_warning) .create(); case R.string.security_clear_certificate_warning: return new ConfirmDialogBuilder(this, R.string.security_clear_certificate_warning, this) .setMessage(R.string.security_clear_certificate_warning) .create(); case R.string.contacts_reset_offline_warning: return new ConfirmDialogBuilder(this, R.string.contacts_reset_offline_warning, this) .setMessage(R.string.contacts_reset_offline_warning) .create(); case R.string.application_state_closing: ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.setMessage(getString(R.string.application_state_closing)); progressDialog.setCancelable(false); progressDialog.setIndeterminate(true); return progressDialog; default: return null; } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (isFinishing()) return; addPreferencesFromResource(R.xml.preference_editor); getPreferenceScreen() .findPreference(getString(R.string.preference_accounts_key)) .setIntent(AccountList.createIntent(this)); getPreferenceScreen() .findPreference(getString(R.string.events_phrases)) .setIntent(PhraseList.createIntent(this)); getPreferenceScreen() .findPreference(getString(R.string.cache_clear_key)) .setOnPreferenceClickListener(this); getPreferenceScreen() .findPreference(getString(R.string.security_clear_certificate_key)) .setOnPreferenceClickListener(this); getPreferenceScreen() .findPreference(getString(R.string.contacts_reset_offline_key)) .setOnPreferenceClickListener(this); getPreferenceScreen() .findPreference(getString(R.string.debug_log_key)) .setEnabled(LogManager.isDebugable()); // Force request sound. This will set default value if not specified. SettingsManager.eventsSound(); SettingsManager.chatsAttentionSound(); PreferenceScreen about = (PreferenceScreen) getPreferenceScreen().findPreference(getString(R.string.preference_about_key)); about.setSummary( getString(R.string.application_name) + "\n" + getString(R.string.application_version)); about.setIntent(AboutViewer.createIntent(this)); PreferenceSummaryHelper.updateSummary(getPreferenceScreen()); }
@Override protected void onPause() { super.onPause(); PreferenceManager.getDefaultSharedPreferences(this) .unregisterOnSharedPreferenceChangeListener(this); }