Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ package ee.ria.DigiDoc.ui.component.shared.dialog

import android.content.res.Configuration
import androidx.annotation.StringRes
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.selection.selectable
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.RadioButton
Expand All @@ -48,6 +48,7 @@ import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.heading
import androidx.compose.ui.semantics.semantics
Expand Down Expand Up @@ -78,7 +79,6 @@ fun OptionChooserDialog(
var selectedOption by remember { mutableStateOf(choices[selectedChoice]) }

val optionText = stringResource(id = R.string.option)
val optionSelectedText = stringResource(id = R.string.option_selected)

LaunchedEffect(Unit) {
focusRequester.requestFocus()
Expand Down Expand Up @@ -117,10 +117,18 @@ fun OptionChooserDialog(
.fillMaxWidth()
.padding(vertical = SPadding)
.padding(start = XSPadding)
.clickable {
currentChoice = index
selectedOption = choices[currentChoice]
},
.selectable(
selected = index == currentChoice,
role = Role.RadioButton,
onClick = {
currentChoice = index
selectedOption = choices[index]
},
).semantics {
testTagsAsResourceId = true
this.contentDescription =
String.format(optionText, choices[index].lowercase())
}.testTag("optionChooser$index"),
verticalAlignment = Alignment.CenterVertically,
) {
Text(
Expand All @@ -133,28 +141,8 @@ fun OptionChooserDialog(
style = MaterialTheme.typography.bodyLarge,
)
RadioButton(
modifier =
modifier
.semantics {
testTagsAsResourceId = true
this.contentDescription =
if (index == currentChoice) {
String.format(
optionSelectedText,
choices[index].lowercase(),
)
} else {
String.format(
optionText,
choices[index].lowercase(),
)
}
}.testTag("optionChooser$index"),
selected = selectedOption == choices[index],
onClick = {
currentChoice = index
selectedOption = choices[index]
},
onClick = null,
)
}
HorizontalDivider()
Expand Down Expand Up @@ -188,8 +176,8 @@ fun OptionChooserDialogPreview() {
title = R.string.choose_server_option,
choices =
listOf(
stringResource(R.string.option),
stringResource(R.string.option),
"Server 1",
"Server 2",
),
cancelButtonClick = {},
okButtonClick = {},
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/values-et/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,7 @@
<string name="main_menu_encrypt_container_accessibility">Krüpteeri ümbrik</string>

<string name="choose_server_option">Vali server</string>
<string name="option">Valik</string>
<string name="option_selected">Valik %1$s valitud</string>
<string name="option">Valik %1$s</string>

<string name="option_ria">RIA</string>
<string name="option_key_transfer">Kasuta krüpteerimiseks võtmeedastusserverit</string>
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,7 @@
<string name="main_menu_encrypt_container_accessibility">Encrypt container</string>

<string name="choose_server_option">Choose server</string>
<string name="option">Option</string>
<string name="option_selected">Option %1$s selected</string>
<string name="option">Option %1$s</string>

<string name="option_ria">RIA</string>
<string name="option_key_transfer">Use a key transfer server for encryption</string>
Expand Down
Loading