List of usage examples for android.preference PreferenceCategory PreferenceCategory
public PreferenceCategory(Context context)
From source file:com.reliqartz.firsttipcalc.gui.SettingsActivity.java
/** * Shows the simplified settings UI if the device configuration if the * device configuration dictates that a simplified, single-pane UI should be * shown.//from w w w . j a v a2 s .c o m */ @SuppressWarnings("deprecation") private void setupSimplePreferencesScreen() { if (!isSimplePreferences(this)) { return; } // In the simplified UI, fragments are not used at all and we instead // use the older PreferenceActivity APIs. // Add 'general' preferences. // general preference xml already has a header. no fakeheader needed. addPreferencesFromResource(R.xml.pref_general); // Add 'bill splitting' preferences. PreferenceCategory fakeHeader = new PreferenceCategory(this); fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_bill_splitting); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_bill_splitting); // Add 'notifications' preferences, and a corresponding header. /* * PreferenceCategory fakeHeader = new PreferenceCategory(this); * fakeHeader.setTitle(R.string.pref_header_notifications); * getPreferenceScreen().addPreference(fakeHeader); * addPreferencesFromResource(R.xml.pref_notification); */ // Add 'data and sync' preferences, and a corresponding header. fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_about); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_about); // Bind the summaries of EditText/List/Dialog/Ringtone preferences to // their values. When their values change, their summaries are updated // to reflect the new value, per the Android Design guidelines. bindPreferenceSummaryToValue(findPreference("pref_currency")); bindPreferenceSummaryToValue(findPreference("pref_base_tip")); // bindPreferenceSummaryToValue(findPreference("notifications_new_message_ringtone")); }
From source file:com.nikolak.weatherapp.SettingsActivity.java
/** * Shows the simplified settings UI if the device configuration if the * device configuration dictates that a simplified, single-pane UI should be * shown.//from w w w. j a v a 2 s .c o m */ private void setupSimplePreferencesScreen() { if (!isSimplePreferences(this)) { return; } // In the simplified UI, fragments are not used at all and we instead // use the older PreferenceActivity APIs. // Add 'general' preferences. addPreferencesFromResource(R.xml.pref_general); // Add 'notifications' preferences, and a corresponding header. // PreferenceCategory fakeHeader = new PreferenceCategory(this); // fakeHeader.setTitle(R.string.pref_header_notifications); // getPreferenceScreen().addPreference(fakeHeader); // addPreferencesFromResource(R.xml.pref_notification); // Add 'data and sync' preferences, and a corresponding header. PreferenceCategory fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_data_sync); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_data_sync); // Bind the summaries of EditText/List/Dialog/Ringtone preferences to // their values. When their values change, their summaries are updated // to reflect the new value, per the Android Design guidelines. bindPreferenceSummaryToValue(findPreference("custom_location")); bindPreferenceSummaryToValue(findPreference("weather_units")); bindPreferenceSummaryToValue(findPreference("sync_frequency")); }
From source file:com.airflo.preferences.ListPreferenceActivity.java
/** * Add three slider preferences to a category. * @param catTitle/* w ww. j a v a 2 s .c om*/ * @param key * @param no */ private void addManyListItems(int catTitle, String key, int no) { PreferenceCategory cat = new PreferenceCategory(this); cat.setTitle(catTitle); root.addPreference(cat); String title = getString(R.string.list_pref_hint_selector); for (int i = 1; i <= no; i++) { String akey = key + i; String atitle = title + i; addOneListItem(cat, akey, atitle); } }
From source file:com.readystatesoftware.ghostlog.GhostLogSettingsFragment.java
/** * Shows the simplified settings UI if the device configuration if the * device configuration dictates that a simplified, single-pane UI should be * shown.//from w ww.j a v a 2 s . c om */ @SuppressWarnings("deprecation") private void setupSimplePreferencesScreen() { if (!isSimplePreferences(mContext)) { return; } addPreferencesFromResource(R.xml.pref_blank); // Add 'filters' preferences. PreferenceCategory fakeHeader = new PreferenceCategory(mContext); fakeHeader.setTitle(R.string.filters); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_filters); bindPreferenceSummaryToValue(findPreference(getString(R.string.pref_log_level))); setupTagFilterPreference(mContext, findPreference(getString(R.string.pref_tag_filter))); sTagFilterPref = findPreference(getString(R.string.pref_tag_filter)); // Add 'appearance' preferences. fakeHeader = new PreferenceCategory(mContext); fakeHeader.setTitle(R.string.appearance); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_appearance); // Add 'info' preferences. fakeHeader = new PreferenceCategory(mContext); fakeHeader.setTitle(R.string.information); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_info); setupOpenSourceInfoPreference(mContext, findPreference(getString(R.string.pref_info_open_source))); setupVersionPref(mContext, findPreference(getString(R.string.pref_version))); }
From source file:pl.bcichecki.rms.client.android.activities.SettingsActivity.java
@SuppressWarnings("deprecation") private void setupSimplePreferencesScreen() { if (!isSimplePreferences(this)) { Log.d(TAG, "Will not create simple preferences."); return;/* ww w . j ava 2s .com*/ } Log.d(TAG, "Creating simple preferences."); addPreferencesFromResource(R.xml.preferences_dummy); PreferenceCategory fakeHeader; fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.activity_settings_header_user_account); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.preferences_user_account); fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.activity_settings_header_server); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.preferences_server); passwordPreference = (EditTextPreference) findPreference(SharedPreferencesWrapper.Keys.USER_PASSWORD_HASH); passwordPreference.setOnPreferenceChangeListener(onPassHashPreferenceChangeListener); passwordPreference.setOnPreferenceClickListener(onPassHashedPreferenceClickListener); }
From source file:com.readystatesoftware.ghostlog.MainActivity.java
/** * Shows the simplified settings UI if the device configuration if the * device configuration dictates that a simplified, single-pane UI should be * shown.//from w w w. j a va 2 s . c o m */ @SuppressWarnings("deprecation") private void setupSimplePreferencesScreen() { if (!isSimplePreferences(this)) { return; } addPreferencesFromResource(R.xml.pref_blank); // Add 'filters' preferences. PreferenceCategory fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.filters); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_filters); bindPreferenceSummaryToValue(findPreference(getString(R.string.pref_log_level))); setupTagFilterPreference(this, findPreference(getString(R.string.pref_tag_filter))); sTagFilterPref = findPreference(getString(R.string.pref_tag_filter)); // Add 'appearance' preferences. fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.appearance); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_appearance); // Add 'info' preferences. fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.information); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_info); setupOpenSourceInfoPreference(this, findPreference(getString(R.string.pref_info_open_source))); setupVersionPref(this, findPreference(getString(R.string.pref_version))); }
From source file:com.uoit.freeroomfinder.SettingsActivity.java
/** * setupSimplePreferencesScreen Shows the simplified settings UI if the device configuration if * the device configuration dictates that a simplified, single-pane UI should be shown. *//*from w ww.j a va 2s . c o m*/ @SuppressWarnings("deprecation") private void setupSimplePreferencesScreen() { if (!isSimplePreferences(this)) { return; } // In the simplified UI, fragments are not used at all and we instead // use the older PreferenceActivity APIs. // Add 'general' preferences. addPreferencesFromResource(R.xml.pref_general); PreferenceDialog deleteAccount = (PreferenceDialog) this.findPreference("delete_account"); DatabaseInterface dbi = new DatabaseInterface(getBaseContext()); // Disable delete account if user does not have an account if (dbi.getUser() == null) { deleteAccount.setEnabled(false); deleteAccount.setSelectable(false); } else { deleteAccount.setEnabled(true); deleteAccount.setSelectable(true); } // Contains the logic for when the preferences dialog is closed. deleteAccount.setOnPreferenceDialogClosedListener(new OnPreferenceDialogClosedListener() { /* * (non-Javadoc) * * @see com.uoit.freeroomfinder.preferences.OnPreferenceDialogClosedListener# * onPreferenceDialogClosed(boolean) */ @Override public void onPreferenceDialogClosed(boolean positiveResult) { if (positiveResult) { DatabaseInterface dbi = new DatabaseInterface(getBaseContext()); dbi.deleteAll(); } } }); // Add 'search' preferences, and a corresponding header. PreferenceCategory fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_search); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_search); // Contains the logic for setting the 24 hour clock preferences. findPreference("army_clock").setOnPreferenceChangeListener(new OnPreferenceChangeListener() { /* * (non-Javadoc) * * @see * android.preference.Preference.OnPreferenceChangeListener#onPreferenceChange(android * .preference.Preference, java.lang.Object) */ @Override public boolean onPreferenceChange(Preference preference, Object newValue) { DateTimeUtility.setArmyClock(Boolean.valueOf(newValue.toString())); return true; } }); // Add 'feedback' preferences, and a corresponding header. fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_feedback); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_feedback); findPreference("source_code").setOnPreferenceClickListener(new OnPreferenceClickListener() { /* * (non-Javadoc) * * @see * android.preference.Preference.OnPreferenceClickListener#onPreferenceClick(android * .preference.Preference) */ @Override public boolean onPreferenceClick(Preference preference) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(SettingsActivity.this.getString(R.string.source_code_site))); SettingsActivity.this.startActivity(i); return true; } }); /* Set an onclick listener for contact developers */ findPreference("contact").setOnPreferenceClickListener(new OnPreferenceClickListener() { /* * (non-Javadoc) * * @see * android.preference.Preference.OnPreferenceClickListener#onPreferenceClick(android * .preference.Preference) */ @Override public boolean onPreferenceClick(Preference preference) { /** * Create the Intent */ final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); /** * Fill it with Data */ emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, SettingsActivity.this.getResources().getStringArray(R.array.dev_emails)); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Free Room Finder"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, ""); /** * Send it off to the Activity-Chooser */ SettingsActivity.this.startActivity(Intent.createChooser(emailIntent, "Email the developers...")); return true; } }); }
From source file:com.juegoteca.actividades.Opciones.java
/** * Shows the simplified settings UI if the device configuration if the * device configuration dictates that a simplified, single-pane UI should be * shown.//from w w w . ja v a2 s . c om */ @SuppressWarnings("deprecation") private void setupSimplePreferencesScreen() { if (!isSimplePreferences(this)) { return; } final SharedPreferences settings = getSharedPreferences("UserInfo", 0); // In the simplified UI, fragments are not used at all and we instead // use the older PreferenceActivity APIs. addPreferencesFromResource(R.xml.pref_container); // Add 'general' preferences. PreferenceCategory fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_general); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_general); CheckBoxPreference preferenciaOrden = (CheckBoxPreference) findPreference("orden_ultimos_anadidos"); preferenciaOrden.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { if (newValue.toString().equals("true")) { SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("orden_ultimos_fecha_compra", true); editor.commit(); } else { SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("orden_ultimos_fecha_compra", false); editor.commit(); } return true; } }); ListPreference preferenciaModeda = (ListPreference) findPreference("currencys"); preferenciaModeda.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { SharedPreferences.Editor editor = settings.edit(); editor.putString("currency", newValue.toString()); editor.commit(); return true; } }); CheckBoxPreference preferenciaDetalle = (CheckBoxPreference) findPreference("detalle_imagen"); preferenciaDetalle.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { if (newValue.toString().equals("true")) { SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("detalle_imagen", true); editor.commit(); } else { SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("detalle_imagen", false); editor.commit(); } return true; } }); SwitchPreference preferenciaTwitter = (SwitchPreference) findPreference("twitter"); preferenciaTwitter.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (newValue instanceof Boolean) { boolean isChecked = (boolean) newValue; if (isChecked) { Intent intent = new Intent(getApplicationContext(), TwitterActivity.class); startActivity(intent); return true; } } return true; } }); // Add 'data and sync' preferences, and a corresponding header. PreferenceCategory fakeHeader2 = new PreferenceCategory(this); fakeHeader2.setTitle(R.string.pref_header_data); getPreferenceScreen().addPreference(fakeHeader2); addPreferencesFromResource(R.xml.pref_datos_seguridad); // Establece las acciones al hacer click en las preferencias Preference preferenciaCopiaExportar = findPreference("exportar_copia_seguridad"); preferenciaCopiaExportar.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { Toast t; if (!utilidades.baseDatosEsVacia()) { new CopiaSeguridadFichero().execute(); } else { t = Toast.makeText(getApplicationContext(), getString(R.string.no_data_backup), Toast.LENGTH_SHORT); t.show(); } return true; } }); Preference preferenciaCopiaImportar = findPreference("importar_restaurar_seguridad"); preferenciaCopiaImportar.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { AlertDialog.Builder builder = new AlertDialog.Builder(Opciones.this); builder.setMessage(R.string.alerta_restaurar_texto).setTitle(R.string.alerta_restaurar_titulo); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("application/zip"); intent.addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(Intent.createChooser(intent, "Escoja el fichero de copia..."), FILE_SELECT_CODE); } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog return; } }); AlertDialog dialog = builder.create(); dialog.show(); return true; } }); Preference preferenciaBorrar = findPreference("borrar_todo"); preferenciaBorrar.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { utilidades.borrarTodosDatos(true); return true; } }); // Add 'otros' preferences. PreferenceCategory fakeHeader3 = new PreferenceCategory(this); fakeHeader3.setTitle(R.string.pref_header_otros); getPreferenceScreen().addPreference(fakeHeader3); addPreferencesFromResource(R.xml.pref_otros); Resources res = getResources(); // String versionName = res.getString(R.string.app_version); String versionName = ""; try { versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName; } catch (NameNotFoundException e) { // versionName = res.getString(R.string.app_version); } String version = res.getString(R.string.pref_title_version, versionName); Preference preferenciaInicioSesion = findPreference("about"); preferenciaInicioSesion.setTitle(version); Preference preferenciaLicencia = findPreference("licenses"); preferenciaLicencia.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { Intent intent = new Intent(getApplicationContext(), AcercaDe.class); startActivity(intent); return true; } }); }
From source file:tw.idv.palatis.danboorugallery.SettingsActivity.java
/** * Shows the simplified settings UI if the device configuration if the * device configuration dictates that a simplified, single-pane UI should be * shown./*w ww.j a va 2 s . c o m*/ */ private void setupSimplePreferencesScreen() { if (!isSimplePreferences(this)) return; // Add a empty preference screen so we can insert headers... addPreferencesFromResource(R.xml.pref_empty); // In the simplified UI, fragments are not used at all and we instead // use the older PreferenceActivity APIs. PreferenceCategory fakeHeader; // Add 'screen layout' preferences, and a corresponding header. fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_screen_layout); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_screen_layout); // Add 'detail view' preference, and a corresponding header. fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_detail_view); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_detail); // Add 'network policy' preferences, and a corresponding header. fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_network_policy); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_network_policy); // Add 'debug' preferences, and a corresponding header. fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_advanced); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_advanced); // Add 'about' preferences, and a corresponding header. fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_about); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_about); // Bind the summaries of EditText/List/Dialog/Ringtone preferences to // their values. When their values change, their summaries are updated // to reflect the new value, per the Android Design guidelines. bindPreferenceSummaryToValue(findPreference(DanbooruGallerySettings.KEY_PREF_COLUMNS_PORTRAIT), 3); bindPreferenceSummaryToValue(findPreference(DanbooruGallerySettings.KEY_PREF_COLUMNS_LANDSCAPE), 5); bindPreferenceSummaryToValue(findPreference(DanbooruGallerySettings.KEY_PREF_STICKY_GRID_HEADER), true); bindPreferenceSummaryToValue(findPreference(DanbooruGallerySettings.KEY_PREF_SHOW_POST_ID), true); bindPreferenceSummaryToValue(findPreference(DanbooruGallerySettings.KEY_PREF_SHOW_IMAGE_RESOLUTION), true); bindPreferenceSummaryToValue(findPreference(DanbooruGallerySettings.KEY_PREF_DOWNLOAD_FULLSIZE), false); bindPreferenceSummaryToValue(findPreference(DanbooruGallerySettings.KEY_PREF_AUTOPLAY_DELAY), 5000); bindPreferenceSummaryToValue(findPreference(DanbooruGallerySettings.KEY_PREF_STRICT_BANDWIDTH_USAGE), true); bindPreferenceSummaryToValue(findPreference(DanbooruGallerySettings.KEY_PREF_AGGRESSIVE_PREFETCH_PREVIEW), false); bindPreferenceSummaryToValue(findPreference(DanbooruGallerySettings.KEY_PREF_ASYNC_IMAGE_LOADER_INDICATOR), false); Preference preference; preference = findPreference(DanbooruGallerySettings.KEY_PREF_CLEAR_CACHE); assert preference != null; preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(final Preference preference) { setProgressBarIndeterminate(true); setProgressBarIndeterminateVisibility(true); preference.setEnabled(false); DanbooruGalleryApplication.clearCacheWithThread(SettingsActivity.this, new DanbooruGalleryApplication.OnCacheClearedCallback() { @Override public void onCacheCleared() { mCacheSizeCalculated = false; new Thread(new CalculateDiskUsageRunnable(preference, new CalculateDiskUsageRunnable.Callbacks() { @Override public void onCalculationDone(double disk_size, double disk_size_max, double mem_size, double mem_size_max, int post_count) { mCacheSizeCalculated = true; mCacheSize = disk_size; mMaxCacheSize = disk_size_max; mMemCacheSize = mem_size; mMaxMemCacheSize = mem_size_max; mPostCount = post_count; setProgressBarIndeterminateVisibility(false); } }, getResources().getString(R.string.pref_description_clear_cache_calculating), getResources().getString(R.string.pref_description_clear_cache_done))) .start(); runOnUiThread(new Runnable() { @Override public void run() { preference.setEnabled(true); } }); } }); return true; } }); if (mCacheSizeCalculated) { preference.setSummary(getResources().getString(R.string.pref_description_clear_cache_done, mCacheSize, mMaxCacheSize, mMemCacheSize, mMaxMemCacheSize, mPostCount)); } else { new Thread(new CalculateDiskUsageRunnable(preference, new CalculateDiskUsageRunnable.Callbacks() { @Override public void onCalculationDone(double disk_size, double disk_size_max, double mem_size, double mem_size_max, int post_count) { mCacheSizeCalculated = true; mCacheSize = disk_size; mMaxCacheSize = disk_size_max; mMemCacheSize = mem_size; mMaxMemCacheSize = mem_size_max; mPostCount = post_count; } }, getResources().getString(R.string.pref_description_clear_cache_calculating), getResources().getString(R.string.pref_description_clear_cache_done))).start(); } if (getResources().getString(R.string.pref_title_translator).trim().isEmpty()) { preference = findPreference(DanbooruGallerySettings.KEY_PREF_TRANSLATOR); getPreferenceScreen().removePreference(preference); } preference = findPreference(DanbooruGallerySettings.KEY_PREF_VERSION); try { PackageInfo pinfo = getPackageManager().getPackageInfo(getPackageName(), 0); preference.setTitle( getResources().getString(R.string.pref_title_version, pinfo.versionCode, pinfo.versionName)); preference.setSummary(getResources().getString(R.string.pref_description_version, pinfo.versionCode, pinfo.versionName)); } catch (PackageManager.NameNotFoundException ignored) { preference.setTitle(getResources().getString(R.string.pref_title_version, 99999999, "????????")); preference .setSummary(getResources().getString(R.string.pref_description_version, 99999999, "????????")); } }
From source file:com.door43.translationstudio.SettingsActivity.java
/** * Shows the simplified settings UI if the device configuration if the * device configuration dictates that a simplified, single-pane UI should be * shown./*from w ww . ja v a 2 s .com*/ */ private void setupSimplePreferencesScreen() { if (!isSimplePreferences(this)) { return; } // In the simplified UI, fragments are not used at all and we instead // use the older PreferenceActivity APIs. // Add 'general' preferences. addPreferencesFromResource(R.xml.general_preferences); // NOTE: this is a copy paste from GeneralPreferenceFragment // identify all typefaces in the assets directory AssetManager am = getResources().getAssets(); String fileList[] = null; ArrayList<String> entries = new ArrayList<String>(); ArrayList<String> entryValues = new ArrayList<String>(); try { fileList = am.list("fonts"); } catch (IOException e) { Logger.e(this.getClass().getName(), "failed to load font assets", e); } if (fileList != null) { for (int i = 0; i < fileList.length; i++) { File typeface = AppContext.context().getAssetAsFile("fonts/" + fileList[i]); if (typeface != null) { TTFAnalyzer analyzer = new TTFAnalyzer(); String fontname = ""; fontname = analyzer.getTtfFontName(typeface.getAbsolutePath()); if (fontname == null) { fontname = FilenameUtils.removeExtension(typeface.getName()); } entries.add(fontname); entryValues.add(fileList[i]); } } } ListPreference pref = (ListPreference) findPreference(KEY_PREF_TRANSLATION_TYPEFACE); pref.setEntries(entries.toArray(new CharSequence[entries.size()])); pref.setEntryValues(entryValues.toArray(new CharSequence[entryValues.size()])); bindPreferenceSummaryToValue(pref); // Add 'sharing' preferences, and a corresponding header. // PreferenceCategory preferenceHeader = new PreferenceCategory(this); // preferenceHeader.setTitle(R.string.pref_header_sharing); // getPreferenceScreen().addPreference(preferenceHeader); // addPreferencesFromResource(R.xml.sharing_preferences); // Add 'server' preferences, and a corresponding header. PreferenceCategory preferenceHeader = new PreferenceCategory(this); preferenceHeader.setTitle(R.string.pref_header_synchronization); getPreferenceScreen().addPreference(preferenceHeader); addPreferencesFromResource(R.xml.server_preferences); // Add 'legal' preferences, and a corresponding header. preferenceHeader = new PreferenceCategory(this); preferenceHeader.setTitle(R.string.pref_header_legal); getPreferenceScreen().addPreference(preferenceHeader); addPreferencesFromResource(R.xml.legal_preferences); // add 'advanced' preferences and coresponding hreader preferenceHeader = new PreferenceCategory(this); preferenceHeader.setTitle(R.string.pref_header_advanced); getPreferenceScreen().addPreference(preferenceHeader); addPreferencesFromResource(R.xml.advanced_preferences); // bind the correct legal document to the preference intent bindPreferenceClickToLegalDocument(findPreference("license_agreement"), R.string.license); bindPreferenceClickToLegalDocument(findPreference("statement_of_faith"), R.string.statement_of_faith); bindPreferenceClickToLegalDocument(findPreference("translation_guidelines"), R.string.translation_guidlines); bindPreferenceClickToLegalDocument(findPreference("software_licenses"), R.string.software_licenses); // Bind the summaries of EditText/List/Dialog/Ringtone preferences to // their values. When their values change, their summaries are updated // to reflect the new value, per the Android Design guidelines. // bindPreferenceSummaryToValue(findPreference(KEY_PREF_AUTOSAVE)); bindPreferenceSummaryToValue(findPreference(KEY_PREF_AUTH_SERVER)); bindPreferenceSummaryToValue(findPreference(KEY_PREF_GIT_SERVER)); bindPreferenceSummaryToValue(findPreference(KEY_PREF_AUTH_SERVER_PORT)); bindPreferenceSummaryToValue(findPreference(KEY_PREF_GIT_SERVER_PORT)); // bindPreferenceSummaryToValue(findPreference(KEY_PREF_EXPORT_FORMAT)); bindPreferenceSummaryToValue(findPreference(KEY_PREF_MEDIA_SERVER)); bindPreferenceSummaryToValue(findPreference(KEY_PREF_LOGGING_LEVEL)); bindPreferenceSummaryToValue(findPreference(KEY_PREF_BACKUP_INTERVAL)); bindPreferenceSummaryToValue(findPreference(KEY_PREF_TYPEFACE_SIZE)); }