diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/data/DataAndStorageSettingsFragment.kt b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/data/DataAndStorageSettingsFragment.kt index 8082284e30..bbfa876541 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/data/DataAndStorageSettingsFragment.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/data/DataAndStorageSettingsFragment.kt @@ -142,6 +142,7 @@ private fun DataAndStorageSettingsScreen( labels = stringArrayResource(R.array.pref_media_download_entries), values = stringArrayResource(R.array.pref_media_download_values), selection = state.mobileAutoDownloadValues.toTypedArray(), + noSelectionLabel = stringResource(R.string.preferences__none), onSelectionChanged = callbacks::onMobileDataAutoDownloadSelectionChanged ) } @@ -152,6 +153,7 @@ private fun DataAndStorageSettingsScreen( labels = stringArrayResource(R.array.pref_media_download_entries), values = stringArrayResource(R.array.pref_media_download_values), selection = state.wifiAutoDownloadValues.toTypedArray(), + noSelectionLabel = stringResource(R.string.preferences__none), onSelectionChanged = callbacks::onWifiDataAutoDownloadSelectionChanged ) } @@ -162,6 +164,7 @@ private fun DataAndStorageSettingsScreen( labels = stringArrayResource(R.array.pref_media_download_entries), values = stringArrayResource(R.array.pref_media_download_values), selection = state.roamingAutoDownloadValues.toTypedArray(), + noSelectionLabel = stringResource(R.string.preferences__none), onSelectionChanged = callbacks::onRoamingDataAutoDownloadSelectionChanged ) } diff --git a/core/ui/src/main/java/org/signal/core/ui/compose/Rows.kt b/core/ui/src/main/java/org/signal/core/ui/compose/Rows.kt index 8d8470513a..6c35123e41 100644 --- a/core/ui/src/main/java/org/signal/core/ui/compose/Rows.kt +++ b/core/ui/src/main/java/org/signal/core/ui/compose/Rows.kt @@ -219,16 +219,21 @@ object Rows { labels: Array, values: Array, selection: Array, + noSelectionLabel: String, onSelectionChanged: (Array) -> Unit ) { var displayDialog by remember { mutableStateOf(false) } TextRow( text = text, - label = selection.joinToString(", ") { - val index = values.indexOf(it) - if (index == -1) error("not found: $it in ${values.joinToString(", ")}") - labels[index] + label = if (selection.isNotEmpty()) { + selection.joinToString(", ") { + val index = values.indexOf(it) + if (index == -1) error("not found: $it in ${values.joinToString(", ")}") + labels[index] + } + } else { + noSelectionLabel }, onClick = { displayDialog = true @@ -698,6 +703,7 @@ private fun MultiSelectRowPreview() { labels = arrayOf("A", "B", "C"), values = arrayOf("a", "b", "c"), selection = selectedValues, + noSelectionLabel = "None", onSelectionChanged = { selectedValues = it } diff --git a/core/ui/src/main/res/values/strings.xml b/core/ui/src/main/res/values/strings.xml index 015b9d7e43..3d337e5643 100644 --- a/core/ui/src/main/res/values/strings.xml +++ b/core/ui/src/main/res/values/strings.xml @@ -21,4 +21,5 @@ %1$s/%2$s +