From eecea12c17a1b1f5a4eba19e2dec4463049922ff Mon Sep 17 00:00:00 2001 From: andrew Date: Thu, 30 Nov 2023 09:10:06 +1030 Subject: [PATCH] Add set button contentDescription --- .../disappearingmessages/ui/DisappearingMessages.kt | 3 ++- .../java/org/thoughtcrime/securesms/ui/Components.kt | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/disappearingmessages/ui/DisappearingMessages.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/disappearingmessages/ui/DisappearingMessages.kt index fa6a67a1fe..cc35903952 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/disappearingmessages/ui/DisappearingMessages.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/disappearingmessages/ui/DisappearingMessages.kt @@ -21,6 +21,7 @@ import androidx.compose.ui.unit.sp import network.loki.messenger.R import network.loki.messenger.libsession_util.util.ExpiryMode import org.thoughtcrime.securesms.ui.Callbacks +import org.thoughtcrime.securesms.ui.GetString import org.thoughtcrime.securesms.ui.NoOpCallbacks import org.thoughtcrime.securesms.ui.OptionsCard import org.thoughtcrime.securesms.ui.OutlineButton @@ -62,7 +63,7 @@ fun DisappearingMessages( } if (state.showSetButton) OutlineButton( - stringResource(R.string.disappearing_messages_set_button_title), + GetString(R.string.disappearing_messages_set_button_title), modifier = Modifier .align(Alignment.CenterHorizontally) .padding(bottom = 20.dp), diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt index 8f4cd14f02..6c223a45f2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt @@ -186,15 +186,16 @@ fun TitledRadioButton(option: RadioOption, onClick: () -> Unit) { } @Composable -fun Modifier.contentDescription(text: GetString): Modifier { +fun Modifier.contentDescription(text: GetString?): Modifier { val context = LocalContext.current - return semantics { contentDescription = text(context) } + return text?.let { semantics { contentDescription = it(context) } } ?: this } @Composable -fun OutlineButton(text: String, modifier: Modifier = Modifier, onClick: () -> Unit) { +fun OutlineButton(text: GetString, contentDescription: GetString? = text, modifier: Modifier = Modifier, onClick: () -> Unit) { OutlinedButton( - modifier = modifier.size(108.dp, 34.dp), + modifier = modifier.size(108.dp, 34.dp) + .contentDescription(contentDescription), onClick = onClick, border = BorderStroke(1.dp, LocalExtraColors.current.prominentButtonColor), shape = RoundedCornerShape(50), // = 50% percent @@ -203,7 +204,7 @@ fun OutlineButton(text: String, modifier: Modifier = Modifier, onClick: () -> Un backgroundColor = MaterialTheme.colors.background ) ){ - Text(text = text) + Text(text = text()) } }