Fix crash when a preference doesn't have a title (e.g. info preference)

This commit is contained in:
arkon 2020-11-29 15:01:13 -05:00
parent c9c0f3d014
commit 3133a63cf8

View file

@ -81,8 +81,8 @@ object SettingsSearchHelper {
pref: Preference, pref: Preference,
breadcrumbs: String = "" breadcrumbs: String = ""
) { ) {
when (pref) { when {
is PreferenceGroup -> { pref is PreferenceGroup -> {
val breadcrumbsStr = addLocalizedBreadcrumb(breadcrumbs, "${pref.title}") val breadcrumbsStr = addLocalizedBreadcrumb(breadcrumbs, "${pref.title}")
for (x in 0 until pref.preferenceCount) { for (x in 0 until pref.preferenceCount) {
@ -90,7 +90,7 @@ object SettingsSearchHelper {
getSettingSearchResult(ctrl, subPref, breadcrumbsStr) // recursion getSettingSearchResult(ctrl, subPref, breadcrumbsStr) // recursion
} }
} }
is PreferenceCategory -> { pref is PreferenceCategory -> {
val breadcrumbsStr = addLocalizedBreadcrumb(breadcrumbs, "${pref.title}") val breadcrumbsStr = addLocalizedBreadcrumb(breadcrumbs, "${pref.title}")
for (x in 0 until pref.preferenceCount) { for (x in 0 until pref.preferenceCount) {
@ -98,7 +98,7 @@ object SettingsSearchHelper {
getSettingSearchResult(ctrl, subPref, breadcrumbsStr) // recursion getSettingSearchResult(ctrl, subPref, breadcrumbsStr) // recursion
} }
} }
else -> { (pref.title != null) -> {
// Is an actual preference // Is an actual preference
val title = pref.title.toString() val title = pref.title.toString()
val summary = if (pref.summary != null) pref.summary.toString() else "" val summary = if (pref.summary != null) pref.summary.toString() else ""