Java Code Examples for android.support.v7.preference.Preference#setTitle()
The following examples show how to use
android.support.v7.preference.Preference#setTitle() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GsPreferenceFragmentCompat.java From memetastic with GNU General Public License v3.0 | 6 votes |
@Nullable @SuppressWarnings("SameParameterValue") protected Preference updatePreference(@StringRes int keyResId, @DrawableRes Integer iconRes, CharSequence title, CharSequence summary, Boolean visible) { Preference pref = findPreference(getString(keyResId)); if (pref != null) { if (summary != null) { pref.setSummary(summary); } if (title != null) { pref.setTitle(title); } if (iconRes != null && iconRes != 0) { if (isAllowedToTint(pref)) { pref.setIcon(_cu.tintDrawable(iconRes, getIconTintColor())); } else { pref.setIcon(iconRes); } } if (visible != null) { pref.setVisible(visible); } } return pref; }
Example 2
Source File: GsPreferenceFragmentCompat.java From openlauncher with Apache License 2.0 | 6 votes |
@Nullable @SuppressWarnings("SameParameterValue") protected Preference updatePreference(@StringRes int keyResId, @DrawableRes Integer iconRes, CharSequence title, CharSequence summary, Boolean visible) { Preference pref = findPreference(getString(keyResId)); if (pref != null) { if (summary != null) { pref.setSummary(summary); } if (title != null) { pref.setTitle(title); } if (iconRes != null && iconRes != 0) { if (isAllowedToTint(pref)) { pref.setIcon(_cu.tintDrawable(iconRes, getIconTintColor())); } else { pref.setIcon(iconRes); } } if (visible != null) { pref.setVisible(visible); } } return pref; }
Example 3
Source File: GsPreferenceFragmentCompat.java From Stringlate with MIT License | 6 votes |
@Nullable @SuppressWarnings("SameParameterValue") protected Preference updatePreference(@StringRes int keyResId, @DrawableRes Integer iconRes, CharSequence title, CharSequence summary, Boolean visible) { Preference pref = findPreference(getString(keyResId)); if (pref != null) { if (summary != null) { pref.setSummary(summary); } if (title != null) { pref.setTitle(title); } if (iconRes != null && iconRes != 0) { if (isAllowedToTint(pref)) { pref.setIcon(_cu.tintDrawable(iconRes, getIconTintColor())); } else { pref.setIcon(iconRes); } } if (visible != null) { pref.setVisible(visible); } } return pref; }
Example 4
Source File: NGWSettingsFragment.java From android_maplibui with GNU Lesser General Public License v3.0 | 6 votes |
protected void addEditAccountAction( final IGISApplication application, final Account account, PreferenceGroup actionCategory) { Preference preferenceEdit = new Preference(mStyledContext); preferenceEdit.setTitle(R.string.edit_account); preferenceEdit.setSummary(R.string.edit_account_summary); String url = application.getAccountUrl(account); String login = application.getAccountLogin(account); Intent intent = new Intent(mStyledContext, NGWLoginActivity.class); intent.putExtra(NGWLoginActivity.FOR_NEW_ACCOUNT, false); intent.putExtra(NGWLoginActivity.ACCOUNT_URL_TEXT, url); intent.putExtra(NGWLoginActivity.ACCOUNT_LOGIN_TEXT, login); intent.putExtra(NGWLoginActivity.CHANGE_ACCOUNT_URL, false); intent.putExtra(NGWLoginActivity.CHANGE_ACCOUNT_LOGIN, true); preferenceEdit.setIntent(intent); actionCategory.addPreference(preferenceEdit); }
Example 5
Source File: GsPreferenceFragmentCompat.java From kimai-android with MIT License | 6 votes |
@Nullable @SuppressWarnings("SameParameterValue") protected Preference updatePreference(@StringRes int keyResId, @DrawableRes Integer iconRes, CharSequence title, CharSequence summary, Boolean visible) { Preference pref = findPreference(getString(keyResId)); if (pref != null) { if (summary != null) { pref.setSummary(summary); } if (title != null) { pref.setTitle(title); } if (iconRes != null && iconRes != 0) { if (isAllowedToTint(pref)) { pref.setIcon(_cu.tintDrawable(iconRes, getIconTintColor())); } else { pref.setIcon(iconRes); } } if (visible != null) { pref.setVisible(visible); } } return pref; }
Example 6
Source File: PreferencesChannelsSystemFragment.java From notification-channel-compat with Apache License 2.0 | 5 votes |
@Override public void onCreatePreferences(Bundle savedInstance, String rootPreferenceKey) { Context activityContext = getActivity(); PreferenceManager preferenceManager = getPreferenceManager(); preferenceManager.setSharedPreferencesName(NotificationChannelManagerHelper.SHARED_PREFERENCE_NAME); PreferenceScreen preferenceScreen = preferenceManager.createPreferenceScreen(activityContext); setPreferenceScreen(preferenceScreen); ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(activityContext, R.style.PreferenceThemeOverlay); // We instance each Preference using our ContextThemeWrapper object PreferenceCategory preferenceCategory = new PreferenceCategory(contextThemeWrapper); getPreferenceScreen().addPreference(preferenceCategory); Preference systemPref = new Preference(contextThemeWrapper); systemPref.setTitle(R.string.notification_importance_blocked); systemPref.setSummary(R.string.write_settings); systemPref.setLayoutResource(R.layout.preference_goto_target); systemPref.setIcon(R.drawable.ic_error_outline); systemPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { NotificationChannelPreference.launchSystemNotificationsSettings(getContext(), null); return true; } }); preferenceCategory.addPreference(systemPref); }
Example 7
Source File: SmsMmsPreferenceFragment.java From Silence with GNU General Public License v3.0 | 5 votes |
private void initializePlatformSpecificOptions() { PreferenceScreen preferenceScreen = getPreferenceScreen(); Preference defaultPreference = findPreference(KITKAT_DEFAULT_PREF); Preference allSmsPreference = findPreference(SilencePreferences.ALL_SMS_PREF); Preference allMmsPreference = findPreference(SilencePreferences.ALL_MMS_PREF); Preference manualMmsPreference = findPreference(MMS_PREF); if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) { if (allSmsPreference != null) preferenceScreen.removePreference(allSmsPreference); if (allMmsPreference != null) preferenceScreen.removePreference(allMmsPreference); if (Util.isDefaultSmsProvider(getActivity())) { defaultPreference.setIntent(new Intent(Settings.ACTION_WIRELESS_SETTINGS)); defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_enabled)); defaultPreference.setSummary(getString(R.string.ApplicationPreferencesActivity_tap_to_change_your_default_sms_app)); } else { Intent intent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT); intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, getActivity().getPackageName()); defaultPreference.setIntent(intent); defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_disabled)); defaultPreference.setSummary(getString(R.string.ApplicationPreferencesActivity_tap_to_make_silence_your_default_sms_app)); } } else if (defaultPreference != null) { preferenceScreen.removePreference(defaultPreference); } if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP && manualMmsPreference != null) { preferenceScreen.removePreference(manualMmsPreference); } }
Example 8
Source File: GcmFragment.java From android_packages_apps_GmsCore with Apache License 2.0 | 5 votes |
private void updateContent() { PreferenceScreen root = getPreferenceScreen(); if (McsService.isConnected()) { root.findPreference(PREF_GCM_STATUS).setSummary(getString(R.string.gcm_state_connected, DateUtils.getRelativeTimeSpanString(McsService.getStartTimestamp(), System.currentTimeMillis(), 0))); } else { root.findPreference(PREF_GCM_STATUS).setSummary(getString(R.string.gcm_state_disconnected)); } PreferenceCategory appList = (PreferenceCategory) root.findPreference(PREF_GCM_APPS); appList.removeAll(); List<GcmDatabase.App> list = database.getAppList(); if (!list.isEmpty()) { List<Preference> appListPrefs = new ArrayList<>(); PackageManager pm = getContext().getPackageManager(); for (GcmDatabase.App app : list) { try { pm.getApplicationInfo(app.packageName, 0); appListPrefs.add(new GcmAppPreference(getPreferenceManager().getContext(), app)); } catch (PackageManager.NameNotFoundException e) { final List<GcmDatabase.Registration> registrations = database.getRegistrationsByApp(app.packageName); if (registrations.isEmpty()) { database.removeApp(app.packageName); } else { appListPrefs.add(new GcmAppPreference(getPreferenceManager().getContext(), app)); } } } addPreferencesSorted(appListPrefs, appList); } else { // If there's no item to display, add a "None" item. Preference banner = new Preference(getPreferenceManager().getContext()); banner.setLayoutResource(R.layout.list_no_item); banner.setTitle(R.string.list_no_item_none); banner.setSelectable(false); appList.addPreference(banner); } }
Example 9
Source File: MoreInfoFragment.java From memetastic with GNU General Public License v3.0 | 4 votes |
@Override public synchronized void doUpdatePreferences() { super.doUpdatePreferences(); Context context = getContext(); if (context == null) { return; } Locale locale = Locale.getDefault(); String tmp; Preference pref; updateSummary(R.string.pref_key__more_info__project_license, getString(R.string.app_license_name)); // Basic app info if ((pref = findPreference(R.string.pref_key__more_info__app)) != null && pref.getSummary() == null) { pref.setIcon(R.drawable.ic_launcher); pref.setSummary(String.format(locale, "%s\nVersion v%s (%d)", _cu.getPackageIdReal(), _cu.getAppVersionName(), _cu.bcint("VERSION_CODE", 0))); } // Extract some build information and publish in summary if ((pref = findPreference(R.string.pref_key__more_info__copy_build_information)) != null && pref.getSummary() == null) { String summary = String.format(locale, "\n<b>Package:</b> %s\n<b>Version:</b> v%s (%d)", _cu.getPackageIdReal(), _cu.getAppVersionName(), _cu.bcint("VERSION_CODE", 0)); summary += (tmp = _cu.bcstr("FLAVOR", "")).isEmpty() ? "" : ("\n<b>Flavor:</b> " + tmp.replace("flavor", "")); summary += (tmp = _cu.bcstr("BUILD_TYPE", "")).isEmpty() ? "" : (" (" + tmp + ")"); summary += (tmp = _cu.bcstr("BUILD_DATE", "")).isEmpty() ? "" : ("\n<b>Build date:</b> " + tmp); summary += (tmp = _cu.getAppInstallationSource()).isEmpty() ? "" : ("\n<b>ISource:</b> " + tmp); summary += (tmp = _cu.bcstr("GITHASH", "")).isEmpty() ? "" : ("\n<b>VCS Hash:</b> " + tmp); pref.setSummary(_cu.htmlToSpanned(summary.trim().replace("\n", "<br/>"))); } // Extract project team from raw ressource, where 1 person = 4 lines // 1) Name/Title, 2) Description/Summary, 3) Link/View-Intent, 4) Empty line if ((pref = findPreference(R.string.pref_key__more_info__project_team)) != null && ((PreferenceGroup) pref).getPreferenceCount() == 0) { String[] data = (_cu.readTextfileFromRawRes(R.raw.project_team, "", "").trim() + "\n\n").split("\n"); for (int i = 0; i + 2 < data.length; i += 4) { Preference person = new Preference(context); person.setTitle(data[i]); person.setSummary(data[i + 1]); person.setIcon(R.drawable.ic_person_black_24dp); try { Uri uri = Uri.parse(data[i + 2]); Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); person.setIntent(intent); } catch (Exception ignored) { } appendPreference(person, (PreferenceGroup) pref); } } if ((pref = findPreference(R.string.pref_key__more_info__help)) != null) { pref.setTitle(getString(R.string.help) + " / FAQ"); } }
Example 10
Source File: SettingsAboutFragment.java From openlauncher with Apache License 2.0 | 4 votes |
@Override public synchronized void doUpdatePreferences() { super.doUpdatePreferences(); Context context = getContext(); if (context == null) { return; } Locale locale = Locale.getDefault(); String tmp; Preference pref; updateSummary(R.string.pref_key__more_info__project_license, getString(R.string.app_license_name)); // Basic app info if ((pref = findPreference(R.string.pref_key__more_info__app)) != null && pref.getSummary() == null) { pref.setIcon(R.mipmap.ic_launcher); pref.setSummary(String.format(locale, "%s\nVersion v%s (%d)", _cu.getPackageIdReal(), _cu.getAppVersionName(), _cu.bcint("VERSION_CODE", 0))); } // Extract some build information and publish in summary if ((pref = findPreference(R.string.pref_key__more_info__copy_build_information)) != null && pref.getSummary() == null) { String summary = String.format(locale, "\n<b>Package:</b> %s\n<b>Version:</b> v%s (%d)", _cu.getPackageIdReal(), _cu.getAppVersionName(), _cu.bcint("VERSION_CODE", 0)); summary += (tmp = _cu.bcstr("FLAVOR", "")).isEmpty() ? "" : ("\n<b>Flavor:</b> " + tmp.replace("flavor", "")); summary += (tmp = _cu.bcstr("BUILD_TYPE", "")).isEmpty() ? "" : (" (" + tmp + ")"); summary += (tmp = _cu.bcstr("BUILD_DATE", "")).isEmpty() ? "" : ("\n<b>Build date:</b> " + tmp); summary += (tmp = _cu.getAppInstallationSource()).isEmpty() ? "" : ("\n<b>ISource:</b> " + tmp); summary += (tmp = _cu.bcstr("GITHASH", "")).isEmpty() ? "" : ("\n<b>VCS Hash:</b> " + tmp); pref.setSummary(_cu.htmlToSpanned(summary.trim().replace("\n", "<br/>"))); } // Extract project team from raw resource, where 1 person = 4 lines // 1) Name/Title, 2) Description/Summary, 3) Link/View-Intent, 4) Empty line if ((pref = findPreference(R.string.pref_key__more_info__project_team)) != null && ((PreferenceGroup) pref).getPreferenceCount() == 0) { String[] data = (_cu.readTextfileFromRawRes(R.raw.project, "", "").trim() + "\n\n").split("\n"); for (int i = 0; i + 2 < data.length; i += 4) { Preference person = new Preference(context); person.setTitle(data[i]); person.setSummary(data[i + 1]); person.setIcon(R.drawable.ic_person); try { Uri uri = Uri.parse(data[i + 2]); Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); person.setIntent(intent); } catch (Exception ignored) { } appendPreference(person, (PreferenceGroup) pref); } } }
Example 11
Source File: MoreInfoFragment.java From Stringlate with MIT License | 4 votes |
@Override public synchronized void doUpdatePreferences() { super.doUpdatePreferences(); Context context = getContext(); if (context == null) { return; } Locale locale = Locale.getDefault(); String tmp; Preference pref; updateSummary(R.string.pref_key__more_info__project_license, getString(R.string.app_license_name)); // Basic app info if ((pref = findPreference(R.string.pref_key__more_info__app)) != null && pref.getSummary() == null) { pref.setIcon(R.drawable.ic_launcher); pref.setSummary(String.format(locale, "%s\nVersion v%s (%d)", _cu.getPackageName(), _cu.getAppVersionName(), _cu.bcint("VERSION_CODE", 0))); } // Extract some build information and publish in summary if ((pref = findPreference(R.string.pref_key__more_info__copy_build_information)) != null && pref.getSummary() == null) { String summary = String.format(locale, "\n<b>Package:</b> %s\n<b>Version:</b> v%s (%d)", _cu.getPackageName(), _cu.getAppVersionName(), _cu.bcint("VERSION_CODE", 0)); summary += (tmp = _cu.bcstr("FLAVOR", "")).isEmpty() ? "" : ("\n<b>Flavor:</b> " + tmp.replace("flavor", "")); summary += (tmp = _cu.bcstr("BUILD_TYPE", "")).isEmpty() ? "" : (" (" + tmp + ")"); summary += (tmp = _cu.bcstr("BUILD_DATE", "")).isEmpty() ? "" : ("\n<b>Build date:</b> " + tmp); summary += (tmp = _cu.getAppInstallationSource()).isEmpty() ? "" : ("\n<b>ISource:</b> " + tmp); summary += (tmp = _cu.bcstr("GITHASH", "")).isEmpty() ? "" : ("\n<b>VCS Hash:</b> " + tmp); pref.setSummary(_cu.htmlToSpanned(summary.trim().replace("\n", "<br/>"))); } // Extract project team from raw ressource, where 1 person = 4 lines // 1) Name/Title, 2) Description/Summary, 3) Link/View-Intent, 4) Empty line if ((pref = findPreference(R.string.pref_key__more_info__project_team)) != null && ((PreferenceGroup) pref).getPreferenceCount() == 0) { String[] data = (_cu.readTextfileFromRawRes(R.raw.project_team, "", "").trim() + "\n\n").split("\n"); for (int i = 0; i + 2 < data.length; i += 4) { Preference person = new Preference(context); person.setTitle(data[i]); person.setSummary(data[i + 1]); person.setIcon(R.drawable.ic_person_black_24dp); try { Uri uri = Uri.parse(data[i + 2]); Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); person.setIntent(intent); } catch (Exception ignored) { } appendPreference(person, (PreferenceGroup) pref); } } }
Example 12
Source File: RecipientPreferenceActivity.java From Silence with GNU General Public License v3.0 | 4 votes |
private void setSummaries(Recipients recipients) { CheckBoxPreference mutePreference = (CheckBoxPreference) this.findPreference(PREFERENCE_MUTED); AdvancedRingtonePreference ringtonePreference = (AdvancedRingtonePreference) this.findPreference(PREFERENCE_TONE); ListPreference vibratePreference = (ListPreference) this.findPreference(PREFERENCE_VIBRATE); ColorPickerPreference colorPreference = (ColorPickerPreference) this.findPreference(PREFERENCE_COLOR); Preference blockPreference = this.findPreference(PREFERENCE_BLOCK); mutePreference.setChecked(recipients.isMuted()); final Uri toneUri = recipients.getRingtone(); if (toneUri == null) { ringtonePreference.setSummary(R.string.preferences__default); ringtonePreference.setCurrentRingtone(Settings.System.DEFAULT_NOTIFICATION_URI); } else if (toneUri.toString().isEmpty()) { ringtonePreference.setSummary(R.string.preferences__silent); ringtonePreference.setCurrentRingtone(null); } else { Ringtone tone = RingtoneManager.getRingtone(getActivity(), toneUri); if (tone != null) { ringtonePreference.setSummary(tone.getTitle(getActivity())); ringtonePreference.setCurrentRingtone(toneUri); } } if (recipients.getVibrate() == VibrateState.DEFAULT) { vibratePreference.setSummary(R.string.preferences__default); vibratePreference.setValueIndex(0); } else if (recipients.getVibrate() == VibrateState.ENABLED) { vibratePreference.setSummary(R.string.RecipientPreferenceActivity_enabled); vibratePreference.setValueIndex(1); } else { vibratePreference.setSummary(R.string.RecipientPreferenceActivity_disabled); vibratePreference.setValueIndex(2); } if (!recipients.isSingleRecipient() || recipients.isGroupRecipient()) { if (colorPreference != null) getPreferenceScreen().removePreference(colorPreference); if (blockPreference != null) getPreferenceScreen().removePreference(blockPreference); } else { colorPreference.setColors(MaterialColors.CONVERSATION_PALETTE.asConversationColorArray(getActivity())); colorPreference.setColor(recipients.getColor().toActionBarColor(getActivity())); if (recipients.isBlocked()) blockPreference.setTitle(R.string.RecipientPreferenceActivity_unblock); else blockPreference.setTitle(R.string.RecipientPreferenceActivity_block); } }