mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-25 09:54:22 +00:00
android, desktop: gaurd crashes when item is absent in the list (#6140)
This commit is contained in:
+2
-2
@@ -159,11 +159,11 @@ fun AppearanceScope.AppearanceLayout(
|
||||
}
|
||||
}
|
||||
|
||||
private fun findEnabledIcon(): AppIcon = AppIcon.values().first { icon ->
|
||||
private fun findEnabledIcon(): AppIcon = AppIcon.values().firstOrNull { icon ->
|
||||
androidAppContext.packageManager.getComponentEnabledSetting(
|
||||
ComponentName(APPLICATION_ID, "chat.simplex.app.MainActivity_${icon.name.lowercase()}")
|
||||
).let { it == COMPONENT_ENABLED_STATE_DEFAULT || it == COMPONENT_ENABLED_STATE_ENABLED }
|
||||
}
|
||||
} ?: AppIcon.DEFAULT
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
|
||||
+5
-3
@@ -46,7 +46,7 @@ fun <T> ExposedDropDownSetting(
|
||||
horizontalArrangement = Arrangement.End
|
||||
) {
|
||||
Text(
|
||||
values.first { it.first == selection.value }.second + (if (label != null) " $label" else ""),
|
||||
(values.firstOrNull { it.first == selection.value }?.second ?: "") + (if (label != null) " $label" else ""),
|
||||
Modifier.widthIn(max = maxWidth),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
@@ -120,8 +120,10 @@ fun <T> ExposedDropDownSettingWithIcon(
|
||||
),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
val choice = values.first { it.first == selection.value }
|
||||
Icon(painterResource(choice.second), choice.third, Modifier.padding(boxSize * iconPaddingPercent).fillMaxSize(), tint = iconColor)
|
||||
val choice = values.firstOrNull { it.first == selection.value }
|
||||
if (choice != null) {
|
||||
Icon(painterResource(choice.second), choice.third, Modifier.padding(boxSize * iconPaddingPercent).fillMaxSize(), tint = iconColor)
|
||||
}
|
||||
}
|
||||
DefaultExposedDropdownMenu(
|
||||
modifier = Modifier.widthIn(min = minWidth),
|
||||
|
||||
+2
-2
@@ -91,7 +91,7 @@ fun <T> SectionViewSelectable(
|
||||
}
|
||||
}
|
||||
}
|
||||
SectionTextFooter(values.first { it.value == currentValue.value }.description)
|
||||
SectionTextFooter(values.firstOrNull { it.value == currentValue.value }?.description ?: AnnotatedString(""))
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -221,7 +221,7 @@ fun <T> SectionItemWithValue(
|
||||
horizontalArrangement = Arrangement.End
|
||||
) {
|
||||
Text(
|
||||
values.first { it.value == currentValue.value }.title + (if (label != null) " $label" else ""),
|
||||
(values.firstOrNull { it.value == currentValue.value }?.title ?: "") + (if (label != null) " $label" else ""),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
color = MaterialTheme.colors.secondary
|
||||
|
||||
+2
-2
@@ -62,7 +62,7 @@ fun NotificationsSettingsLayout(
|
||||
if (appPlatform == AppPlatform.ANDROID) {
|
||||
SettingsActionItemWithContent(null, stringResource(MR.strings.settings_notifications_mode_title), { showPage(CurrentPage.NOTIFICATIONS_MODE) }) {
|
||||
Text(
|
||||
modes.first { it.value == notificationsMode.value }.title,
|
||||
modes.firstOrNull { it.value == notificationsMode.value }?.title ?: "",
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
color = MaterialTheme.colors.secondary
|
||||
@@ -71,7 +71,7 @@ fun NotificationsSettingsLayout(
|
||||
}
|
||||
SettingsActionItemWithContent(null, stringResource(MR.strings.settings_notification_preview_mode_title), { showPage(CurrentPage.NOTIFICATION_PREVIEW_MODE) }) {
|
||||
Text(
|
||||
previewModes.first { it.value == notificationPreviewMode.value }.title,
|
||||
previewModes.firstOrNull { it.value == notificationPreviewMode.value }?.title ?: "",
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
color = MaterialTheme.colors.secondary
|
||||
|
||||
+1
-1
@@ -594,7 +594,7 @@ fun UseOnionHosts(
|
||||
onSelected = {}
|
||||
)
|
||||
}
|
||||
SectionTextFooter(values.first { it.value == onionHosts.value }.description)
|
||||
SectionTextFooter(values.firstOrNull { it.value == onionHosts.value }?.description ?: AnnotatedString(""))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -31,6 +31,7 @@ actual fun CustomTimePicker(
|
||||
mutableStateOf(res)
|
||||
}
|
||||
val values = remember(unit.value) {
|
||||
// TODO replace with firstOrNull
|
||||
val limit = timeUnitsLimits.first { it.timeUnit == unit.value }
|
||||
val res = ArrayList<Pair<Int, String>>()
|
||||
for (i in limit.minValue..limit.maxValue) {
|
||||
|
||||
Reference in New Issue
Block a user