Java Code Examples for android.support.v7.preference.Preference#setSummary()
The following examples show how to use
android.support.v7.preference.Preference#setSummary() .
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: SettingsFragmentView.java From FastAccess with GNU General Public License v3.0 | 6 votes |
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); setDivider(ActivityCompat.getDrawable(getActivity(), R.drawable.list_divider)); setDividerHeight(1); PreferenceGroupAdapter adapter = (PreferenceGroupAdapter) getListView().getAdapter(); for (int i = 0; i < getListView().getAdapter().getItemCount(); i++) {//lazy global setOnPreferenceClickListener Preference preference = adapter.getItem(i); if (preference != null && !InputHelper.isEmpty(preference.getKey())) { if (preference.getKey().equalsIgnoreCase("version")) { preference.setSummary(BuildConfig.VERSION_NAME); } else if (!(preference instanceof SwitchPreference) && !(preference instanceof ListPreference)) { preference.setOnPreferenceClickListener(this); } } } }
Example 2
Source File: SettingsFragment.java From android-dev-challenge with Apache License 2.0 | 6 votes |
private void setPreferenceSummary(Preference preference, Object value) { String stringValue = value.toString(); if (preference instanceof ListPreference) { // For list preferences, look up the correct display value in // the preference's 'entries' list (since they have separate labels/values). ListPreference listPreference = (ListPreference) preference; int prefIndex = listPreference.findIndexOfValue(stringValue); if (prefIndex >= 0) { preference.setSummary(listPreference.getEntries()[prefIndex]); } } else { // For other preferences, set the summary to the value's simple string representation. preference.setSummary(stringValue); } }
Example 3
Source File: GcmAdvancedFragment.java From android_packages_apps_GmsCore with Apache License 2.0 | 6 votes |
private void updateContent() { GcmPrefs prefs = GcmPrefs.get(getContext()); for (String pref : HEARTBEAT_PREFS) { Preference preference = findPreference(pref); int state = prefs.getNetworkValue(pref); if (state == 0) { int heartbeat = prefs.getHeartbeatMsFor(preference.getKey(), true); if (heartbeat == 0) { preference.setSummary("ON / Automatic"); } else { preference.setSummary("ON / Automatic: " + getHeartbeatString(heartbeat)); } } else if (state == -1) { preference.setSummary("OFF"); } else { preference.setSummary("ON / Manual: " + getHeartbeatString(state * 60000)); } } }
Example 4
Source File: SettingsFragment.java From android-dev-challenge with Apache License 2.0 | 6 votes |
private void setPreferenceSummary(Preference preference, Object value) { String stringValue = value.toString(); if (preference instanceof ListPreference) { // For list preferences, look up the correct display value in // the preference's 'entries' list (since they have separate labels/values). ListPreference listPreference = (ListPreference) preference; int prefIndex = listPreference.findIndexOfValue(stringValue); if (prefIndex >= 0) { preference.setSummary(listPreference.getEntries()[prefIndex]); } } else { // For other preferences, set the summary to the value's simple string representation. preference.setSummary(stringValue); } }
Example 5
Source File: PrinterDetailsFragment.java From octoandroid with GNU General Public License v3.0 | 6 votes |
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { String stringValue = newValue.toString(); if (preference instanceof ListPreference) { // For list preferences, look up the correct display value in // the preference's 'entries' list (since they have separate labels/values). ListPreference listPreference = (ListPreference) preference; int prefIndex = listPreference.findIndexOfValue(stringValue); if (prefIndex >= 0) { preference.setSummary(listPreference.getEntries()[prefIndex]); } } else { // For other preferences, set the summary to the value's simple string representation. preference.setSummary(stringValue); } return true; }
Example 6
Source File: SettingsFragment.java From android-dev-challenge with Apache License 2.0 | 6 votes |
private void setPreferenceSummary(Preference preference, Object value) { String stringValue = value.toString(); if (preference instanceof ListPreference) { // For list preferences, look up the correct display value in // the preference's 'entries' list (since they have separate labels/values). ListPreference listPreference = (ListPreference) preference; int prefIndex = listPreference.findIndexOfValue(stringValue); if (prefIndex >= 0) { preference.setSummary(listPreference.getEntries()[prefIndex]); } } else { // For other preferences, set the summary to the value's simple string representation. preference.setSummary(stringValue); } }
Example 7
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 8
Source File: SettingsFragment.java From android-dev-challenge with Apache License 2.0 | 6 votes |
private void setPreferenceSummary(Preference preference, Object value) { String stringValue = value.toString(); if (preference instanceof ListPreference) { // For list preferences, look up the correct display value in // the preference's 'entries' list (since they have separate labels/values). ListPreference listPreference = (ListPreference) preference; int prefIndex = listPreference.findIndexOfValue(stringValue); if (prefIndex >= 0) { preference.setSummary(listPreference.getEntries()[prefIndex]); } } else { // For other preferences, set the summary to the value's simple string representation. preference.setSummary(stringValue); } }
Example 9
Source File: SettingsFragment.java From android-dev-challenge with Apache License 2.0 | 6 votes |
private void setPreferenceSummary(Preference preference, Object value) { String stringValue = value.toString(); if (preference instanceof ListPreference) { // For list preferences, look up the correct display value in // the preference's 'entries' list (since they have separate labels/values). ListPreference listPreference = (ListPreference) preference; int prefIndex = listPreference.findIndexOfValue(stringValue); if (prefIndex >= 0) { preference.setSummary(listPreference.getEntries()[prefIndex]); } } else { // For other preferences, set the summary to the value's simple string representation. preference.setSummary(stringValue); } }
Example 10
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 11
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 12
Source File: SettingsFragment.java From android-dev-challenge with Apache License 2.0 | 6 votes |
private void setPreferenceSummary(Preference preference, Object value) { String stringValue = value.toString(); if (preference instanceof ListPreference) { // For list preferences, look up the correct display value in // the preference's 'entries' list (since they have separate labels/values). ListPreference listPreference = (ListPreference) preference; int prefIndex = listPreference.findIndexOfValue(stringValue); if (prefIndex >= 0) { preference.setSummary(listPreference.getEntries()[prefIndex]); } } else { // For other preferences, set the summary to the value's simple string representation. preference.setSummary(stringValue); } }
Example 13
Source File: SettingsBehaviorFragment.java From openlauncher with Apache License 2.0 | 6 votes |
@Override public void updateSummaries() { List<Integer> gestures = new ArrayList<>(Arrays.asList( R.string.pref_key__gesture_double_tap, R.string.pref_key__gesture_swipe_up, R.string.pref_key__gesture_swipe_down, R.string.pref_key__gesture_pinch_in, R.string.pref_key__gesture_pinch_out )); for (int resId : gestures) { Preference preference = findPreference(getString(resId)); Object gesture = AppSettings.get().getGesture(resId); if (gesture instanceof Intent) { preference.setSummary(String.format(Locale.ENGLISH, "%s: %s", getString(R.string.app), AppManager.getInstance(getContext()).findApp((Intent) gesture)._label)); } else if (gesture instanceof LauncherAction.ActionDisplayItem) { preference.setSummary(String.format(Locale.ENGLISH, "%s: %s", getString(R.string.action), ((LauncherAction.ActionDisplayItem) gesture)._label)); } else { preference.setSummary(String.format(Locale.ENGLISH, "%s", getString(R.string.none))); } } }
Example 14
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 15
Source File: SettingsFragment.java From android-dev-challenge with Apache License 2.0 | 5 votes |
/** * Updates the summary for the preference * * @param preference The preference to be updated * @param value The value that the preference was updated to */ private void setPreferenceSummary(Preference preference, String value) { // COMPLETED (3) Don't forget to add code here to properly set the summary for an EditTextPreference if (preference instanceof ListPreference) { // For list preferences, figure out the label of the selected value ListPreference listPreference = (ListPreference) preference; int prefIndex = listPreference.findIndexOfValue(value); if (prefIndex >= 0) { // Set the summary to that label listPreference.setSummary(listPreference.getEntries()[prefIndex]); } } else if (preference instanceof EditTextPreference) { preference.setSummary(value); } }
Example 16
Source File: SettingsFragment.java From android-dev-challenge with Apache License 2.0 | 5 votes |
private void setPreferenceSummary(Preference preference, Object value) { if (preference instanceof ListPreference) { ListPreference listPreference = (ListPreference) preference; int prefIndex = listPreference.findIndexOfValue(value.toString()); if (prefIndex >= 0) { preference.setSummary(listPreference.getEntries()[prefIndex]); } } else { preference.setSummary(value.toString()); } }
Example 17
Source File: SettingsFragment.java From ApkTrack with GNU General Public License v3.0 | 5 votes |
/** * This function is used to set the right summary for the proxy type setting, and * disable the proxy address setting if no proxy type is selected. * @param new_type The new value for this setting (may be null if we're initializing and not * updating). */ private void render_proxy_type_preference(String new_type) { Preference proxy_type = findPreference(KEY_PREF_PROXY_TYPE); Preference proxy_address = findPreference(KEY_PREF_PROXY_ADDRESS); Preference proxy_warning = findPreference(KEY_PREF_PROXY_WARNING); if (proxy_type == null || proxy_address == null || proxy_warning == null) { Log.v(MainActivity.TAG, "The preferences are malformed!"); return; } // new_type will be set if this function is called from the PropertyChangeListener, but // will be null when called from onCreatePreferences. Get the stored value in that case. if (new_type == null) { new_type = proxy_type.getSharedPreferences().getString(KEY_PREF_PROXY_TYPE, "DIRECT"); } switch (new_type) { case "DIRECT": proxy_type.setSummary(R.string.no_proxy_summary); proxy_address.setEnabled(false); proxy_warning.setEnabled(false); break; case "HTTP": proxy_type.setSummary(R.string.http_proxy_summary); proxy_address.setEnabled(true); proxy_warning.setEnabled(true); break; case "SOCKS": proxy_type.setSummary(R.string.socks_proxy_summary); proxy_address.setEnabled(true); proxy_warning.setEnabled(true); break; } }
Example 18
Source File: SettingsActivity.java From NominatimGeocoderBackend with Apache License 2.0 | 5 votes |
private void updatePreference(Preference preference, String key) { refreshPrefs(); if (preference == null) { return; } if (preference instanceof ListPreference) { ListPreference listPreference = (ListPreference) preference; listPreference.setSummary(listPreference.getEntry()); return; } preference.setSummary(shPref.getString(key, "Default")); }
Example 19
Source File: Settings.java From isu with GNU General Public License v3.0 | 4 votes |
@Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { getPreferenceManager().setSharedPreferencesName(Constants.PREF_NAME); addPreferencesFromResource(R.xml.settings); mSettingsPref = (PreferenceCategory) findPreference("settings_pref"); mSettingsView = (Preference) findPreference("settings_view"); mSettingsForceEnglish = (SwitchPreference) findPreference("forceenglish"); mSettingsForceEnglish.setOnPreferenceChangeListener(this); mSettingsSU = (PreferenceCategory) findPreference("su_settings_pref"); mSettingsMonitor = (PreferenceCategory) findPreference("monitor_settings"); mSettingsNotifications = (PreferenceCategory) findPreference("notifications_settings_pref"); mSettingsSelinux = (PreferenceCategory) findPreference("selinux_settings_pref"); mSettingsDebug = (PreferenceCategory) findPreference("anddebug_settings_pref"); mSettingsProps = (PreferenceCategory) findPreference("props_settings_pref"); mApplySuDelay = (ListPreference) findPreference("apply_su_delay"); mApplyMonitorDelay = (ListPreference) findPreference("allow_delay"); CharSequence[] entriesSuDelay = new CharSequence[6]; CharSequence[] entryValuesSuDelay = new CharSequence[6]; for (int i = 0; i < 6; i++) { entriesSuDelay[i] = (String.format(getString(R.string.apply_su_delay_summary), ((i + 1) * 10))); entryValuesSuDelay[i] = String.valueOf((i + 1) * 10000); } mApplySuDelay.setEntries(entriesSuDelay); mApplySuDelay.setEntryValues(entryValuesSuDelay); CharSequence[] entriesMonitorDelay = new CharSequence[7]; CharSequence[] entryValuesMonitorDelay = new CharSequence[7]; for (int i = 0; i < 7; i++) { if (i == 0) { entriesMonitorDelay[i] = getString(R.string.disable); entryValuesMonitorDelay[i] = String.valueOf(i); } else { entriesMonitorDelay[i] = (String.format(getString(R.string.apply_su_delay_summary), ((i) * 5))); entryValuesMonitorDelay[i] = String.valueOf((i) * 5000); } } mApplyMonitorDelay.setEntries(entriesMonitorDelay); mApplyMonitorDelay.setEntryValues(entryValuesMonitorDelay); suVersion = Tools.SuVersion(getActivity()); isCMSU = Tools.SuVersionBool(suVersion); if (!isCMSU) { mSettingsSU.setEnabled(false); mSettingsMonitor.setEnabled(false); mSettingsNotifications.setEnabled(false); mSettingsSelinux.setEnabled(false); mSettingsDebug.setEnabled(false); if (!Tools.rootAccess(getActivity())) { mSettingsView.setSummary(getString(R.string.device_not_root)); mSettingsProps.setEnabled(false); } } else mSettingsPref.removePreference(mSettingsView); }
Example 20
Source File: USBGpsSettingsFragment.java From UsbGps4Droid with GNU General Public License v3.0 | 3 votes |
private void updatePreferenceDetails() { String mockProvider = sharedPreferences.getString(USBGpsProviderService.PREF_MOCK_GPS_NAME, getString(R.string.defaultMockGpsName)); Preference pref = findPreference(USBGpsProviderService.PREF_MOCK_GPS_NAME); pref.setSummary(getString(R.string.pref_mock_gps_name_summary, mockProvider)); pref = findPreference(USBGpsProviderService.PREF_CONNECTION_RETRIES); String maxConnRetries = sharedPreferences.getString(USBGpsProviderService.PREF_CONNECTION_RETRIES, getString(R.string.defaultConnectionRetries)); pref.setSummary(getString(R.string.pref_connection_retries_summary, maxConnRetries)); }