Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions app/src/main/java/net/osmtracker/activity/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,15 @@ private void setupListPreference(String preferenceKey, String staticSummary) {
listPref.setSummaryProvider(preference -> {
ListPreference lp = (ListPreference) preference;
CharSequence entry = lp.getEntry();
// Null check: entry might be null if no value is selected
String displayValue = Objects.requireNonNull(entry).toString();

// Handle cases where no value has been selected yet. (backwards compatibility)
String displayValue;
if (entry == null || TextUtils.isEmpty(entry)) {
// Fallback text if no value is set.
displayValue = getString(R.string.prefs_not_set);
} else {
displayValue = entry.toString();
}
return displayValue + ".\n" + staticSummary;
});
}
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings-preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,6 @@
<string name="prefs_compass_heading">Export compass heading</string>
<string name="prefs_compass_heading_summary">Defines if and how the compass data should be exported to the GPX file</string>
<string name="prefs_reset_default_value">Reset default value</string>
<string name="prefs_not_set">Not set</string>

</resources>