Java Code Examples for android.preference.MultiSelectListPreference#setSummary()

The following examples show how to use android.preference.MultiSelectListPreference#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: SettingsActivity.java    From android with MIT License 6 votes vote down vote up
private void updateReminderDaysSummary(MultiSelectListPreference daysPreference,
                                       Set<String> savedValues) {
    if (savedValues == null || savedValues.size() == 0) {
        daysPreference.setSummary(getActivity().getResources().getString(
                R.string.no_days_selected));
        return;
    }
    List<String> daysEntries = Arrays.asList(getActivity().getResources()
            .getStringArray(R.array.reminder_days_titles));
    List<String> daysEntriesValues = Arrays.asList(getActivity().getResources()
            .getStringArray(R.array.reminder_days_values));
    String summary = "";
    for (int i = 0; i < daysEntriesValues.size(); i++) {
        if (savedValues.contains(daysEntriesValues.get(i))) {
            if (!TextUtils.isEmpty(summary)) {
                summary += ", ";
            }
            summary += daysEntries.get(i);
        }
    }
    daysPreference.setSummary(summary);
}
 
Example 2
Source File: GroupPreferenceFragment.java    From tickmate with GNU General Public License v3.0 6 votes vote down vote up
private void loadGroup() {
    // Consider adding more features here, such as those in Track and TrackPreferenceFragment
    name = (EditTextPreference) findPreference("name");
    name.setText(group.getName());
    name.setSummary(group.getName());

    description = (EditTextPreference) findPreference("description");
    description.setText(group.getDescription());
    description.setSummary(group.getDescription());

    mTracksPref = (MultiSelectListPreference) findPreference("tracks");
    mTracksPref.setValues(getTrackIdsForGroupAsSet(group.getId()));

    mTracksPref.setEntries(getAllTrackNamesAsCharSeq());
    mTracksPref.setEntryValues(getAllTrackIdsAsCharSeq());
    mTracksPref.setSummary(getTrackNamesForSummary());

}
 
Example 3
Source File: SettingsActivity.java    From Equate with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Helper Class to setup the default Unit Type preference list in code
 */
private void setUpUnitTypePrefs() {
   PreferenceScreen screen = getPreferenceScreen();
   MultiSelectListPreference listPref = new MultiSelectListPreference(super.getActivity());
   listPref.setOrder(0);
   listPref.setDialogTitle(R.string.unit_select_title);
   listPref.setKey(UNIT_TYPE_PREF_KEY);
   listPref.setSummary(R.string.unit_select_summary);
   listPref.setTitle(R.string.unit_select_title);
   listPref.setEntries(getUnitTypeNameArray(getResources()));

   String[] keyArray = getUnitTypeKeyArray(getResources());
   listPref.setEntryValues(keyArray);

   final Set<String> result = new HashSet<>();
   Collections.addAll(result, keyArray);

   listPref.setDefaultValue(result);

   screen.addPreference(listPref);
}
 
Example 4
Source File: PBPreferenceFragment.java    From client-android with GNU General Public License v2.0 4 votes vote down vote up
private void setSummaries() {
    final String wifiOnly = preferences.getString(PBConstants.PREF_WIFI_ONLY,
            getResources().getString(R.string.only_wifi_default)); // default
    final ListPreference wifiPreference = (ListPreference) findPreference(PBConstants.PREF_WIFI_ONLY);
    wifiPreference.setSummary(wifiOnly);

    final String recentUploadOnly = preferences.getString(PBConstants.PREF_RECENT_UPLOAD_ONLY,
            getResources().getString(R.string.only_recent_upload_default)); // default
    final ListPreference recentUploadPreference = (ListPreference) findPreference(PBConstants.PREF_RECENT_UPLOAD_ONLY);
    recentUploadPreference.setSummary(recentUploadOnly);

    final String serverUrl = preferences.getString(PBServerPreferenceFragment.PREF_SERVER_URL, null);
    if (serverUrl != null) {
        final String serverName = preferences.getString(PBConstants.PREF_SERVER, null);
        if (serverName != null) {
            final PBServerListPreference serverPreference = (PBServerListPreference) findPreference(PBConstants.PREF_SERVER);
            serverPreference.setSummary(serverName + " @ " + serverUrl);

            // bonus: left icon of the server
            final int serverNamesId = getResources().getIdentifier("pref_server_names", "array", getActivity().getPackageName());
            final String[] serverNames = getResources().getStringArray(serverNamesId);
            final int serverPosition = Arrays.asList(serverNames).indexOf(serverName);
            final int serverIconsId = getResources().getIdentifier("pref_server_icons", "array", getActivity().getPackageName());
            final String[] serverIcons = getResources().getStringArray(serverIconsId);
            final String serverIcon = serverIcons[serverPosition];
            final String[] parts = serverIcon.split("\\.");
            final String drawableName = parts[parts.length - 1];
            final int id = getResources().getIdentifier(drawableName, "drawable", getActivity().getPackageName());
            if (id != 0) {
                serverPreference.setIcon(id);
            }
        }
    }

    String bucketSummary = "";
    final Set<String> selectedBuckets = preferences.getStringSet(PBConstants.PREF_PICTURE_FOLDER_LIST, null);
    if (selectedBuckets != null && bucketNames != null) {
        final ArrayList<String> selectedBucketNames = new ArrayList<>();
        for (String entry : selectedBuckets) {
            String oneName = bucketNames.get(entry);
            if (oneName != null) {
                oneName = oneName.substring(0, oneName.lastIndexOf('(') - 1);
                selectedBucketNames.add(oneName);
            }
        }
        bucketSummary = TextUtils.join(", ", selectedBucketNames);
    }
    final MultiSelectListPreference bucketListPreference = (MultiSelectListPreference) findPreference(PBConstants.PREF_PICTURE_FOLDER_LIST);
    bucketListPreference.setSummary(bucketSummary);
}
 
Example 5
Source File: SettingsActivityFragment.java    From geopaparazzi with GNU General Public License v3.0 4 votes vote down vote up
private void updateSummary(MultiSelectListPreference pref) {
    pref.setSummary(Arrays.toString(pref.getValues().toArray()));
}