Fix confusable string mapper extensions
This commit is contained in:
parent
9e2e146dac
commit
b82121ecbf
5 changed files with 22 additions and 10 deletions
|
@ -106,7 +106,7 @@ internal fun AutoDiscoveryContent(
|
|||
error = {
|
||||
ErrorView(
|
||||
title = stringResource(id = R.string.account_setup_auto_discovery_loading_error),
|
||||
message = state.error?.toResourceString(resources),
|
||||
message = state.error?.toAutoDiscoveryErrorString(resources),
|
||||
onRetry = { onEvent(Event.OnRetryClicked) },
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
)
|
||||
|
@ -155,7 +155,7 @@ internal fun ContentView(
|
|||
|
||||
EmailAddressInput(
|
||||
emailAddress = state.emailAddress.value,
|
||||
errorMessage = state.emailAddress.error?.toResourceString(resources),
|
||||
errorMessage = state.emailAddress.error?.toAutoDiscoveryValidationErrorString(resources),
|
||||
onEmailAddressChange = { onEvent(Event.EmailAddressChanged(it)) },
|
||||
contentPadding = PaddingValues(),
|
||||
)
|
||||
|
@ -164,7 +164,7 @@ internal fun ContentView(
|
|||
Spacer(modifier = Modifier.height(MainTheme.spacings.double))
|
||||
PasswordInput(
|
||||
password = state.password.value,
|
||||
errorMessage = state.password.error?.toResourceString(resources),
|
||||
errorMessage = state.password.error?.toAutoDiscoveryValidationErrorString(resources),
|
||||
onPasswordChange = { onEvent(Event.PasswordChanged(it)) },
|
||||
contentPadding = PaddingValues(),
|
||||
)
|
||||
|
|
|
@ -2,12 +2,13 @@ package app.k9mail.feature.account.setup.ui.autodiscovery
|
|||
|
||||
import android.content.res.Resources
|
||||
import app.k9mail.core.common.domain.usecase.validation.ValidationError
|
||||
import app.k9mail.feature.account.server.settings.domain.usecase.ValidatePassword
|
||||
import app.k9mail.feature.account.setup.R
|
||||
import app.k9mail.feature.account.setup.domain.entity.AutoDiscoveryConnectionSecurity
|
||||
import app.k9mail.feature.account.setup.domain.usecase.ValidateConfigurationApproval
|
||||
import app.k9mail.feature.account.setup.domain.usecase.ValidateEmailAddress
|
||||
|
||||
internal fun AutoDiscoveryConnectionSecurity.toResourceString(resources: Resources): String {
|
||||
internal fun AutoDiscoveryConnectionSecurity.toAutoDiscoveryConnectionSecurityString(resources: Resources): String {
|
||||
return when (this) {
|
||||
AutoDiscoveryConnectionSecurity.StartTLS -> resources.getString(
|
||||
R.string.account_setup_auto_discovery_connection_security_start_tls,
|
||||
|
@ -19,16 +20,18 @@ internal fun AutoDiscoveryConnectionSecurity.toResourceString(resources: Resourc
|
|||
}
|
||||
}
|
||||
|
||||
internal fun AccountAutoDiscoveryContract.Error.toResourceString(resources: Resources): String {
|
||||
internal fun AccountAutoDiscoveryContract.Error.toAutoDiscoveryErrorString(resources: Resources): String {
|
||||
return when (this) {
|
||||
AccountAutoDiscoveryContract.Error.NetworkError -> resources.getString(R.string.account_setup_error_network)
|
||||
AccountAutoDiscoveryContract.Error.UnknownError -> resources.getString(R.string.account_setup_error_unknown)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun ValidationError.toResourceString(resources: Resources): String {
|
||||
internal fun ValidationError.toAutoDiscoveryValidationErrorString(resources: Resources): String {
|
||||
return when (this) {
|
||||
is ValidateEmailAddress.ValidateEmailAddressError -> toEmailAddressErrorString(resources)
|
||||
is ValidatePassword.ValidatePasswordError -> toPasswordErrorString(resources)
|
||||
|
||||
is ValidateConfigurationApproval.ValidateConfigurationApprovalError -> toConfigurationApprovalErrorString(
|
||||
resources,
|
||||
)
|
||||
|
@ -57,6 +60,14 @@ private fun ValidateEmailAddress.ValidateEmailAddressError.toEmailAddressErrorSt
|
|||
}
|
||||
}
|
||||
|
||||
private fun ValidatePassword.ValidatePasswordError.toPasswordErrorString(resources: Resources): String {
|
||||
return when (this) {
|
||||
ValidatePassword.ValidatePasswordError.EmptyPassword -> resources.getString(
|
||||
R.string.account_setup_auto_discovery_validation_error_password_required,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun ValidateConfigurationApproval.ValidateConfigurationApprovalError.toConfigurationApprovalErrorString(
|
||||
resources: Resources,
|
||||
): String {
|
||||
|
|
|
@ -13,7 +13,7 @@ import app.k9mail.core.ui.compose.theme.MainTheme
|
|||
import app.k9mail.core.ui.compose.theme.PreviewWithThemes
|
||||
import app.k9mail.feature.account.common.domain.input.BooleanInputField
|
||||
import app.k9mail.feature.account.setup.R
|
||||
import app.k9mail.feature.account.setup.ui.autodiscovery.toResourceString
|
||||
import app.k9mail.feature.account.setup.ui.autodiscovery.toAutoDiscoveryValidationErrorString
|
||||
|
||||
@Composable
|
||||
internal fun AutoDiscoveryResultApprovalView(
|
||||
|
@ -30,7 +30,7 @@ internal fun AutoDiscoveryResultApprovalView(
|
|||
),
|
||||
checked = approvalState.value ?: false,
|
||||
onCheckedChange = onApprovalChange,
|
||||
errorMessage = approvalState.error?.toResourceString(resources),
|
||||
errorMessage = approvalState.error?.toAutoDiscoveryValidationErrorString(resources),
|
||||
contentPadding = PaddingValues(),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import app.k9mail.core.ui.compose.designsystem.atom.text.TextBody2
|
|||
import app.k9mail.core.ui.compose.theme.Icons
|
||||
import app.k9mail.core.ui.compose.theme.MainTheme
|
||||
import app.k9mail.core.ui.compose.theme.PreviewWithThemes
|
||||
import app.k9mail.feature.account.setup.ui.autodiscovery.toResourceString
|
||||
import app.k9mail.feature.account.setup.ui.autodiscovery.toAutoDiscoveryConnectionSecurityString
|
||||
|
||||
@Composable
|
||||
internal fun AutoDiscoveryServerSettingsView(
|
||||
|
@ -76,7 +76,7 @@ internal fun AutoDiscoveryServerSettingsView(
|
|||
icon = Icons.Filled.security,
|
||||
text = buildAnnotatedString {
|
||||
append("Security: ")
|
||||
append(connectionSecurity.toResourceString(resources))
|
||||
append(connectionSecurity.toAutoDiscoveryConnectionSecurityString(resources))
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<string name="account_setup_auto_discovery_validation_error_email_address_not_allowed">This email address is not allowed.</string>
|
||||
<string name="account_setup_auto_discovery_validation_error_email_address_not_supported">This email address is not supported.</string>
|
||||
<string name="account_setup_auto_discovery_validation_error_email_address_invalid">This is not recognized as a valid email address.</string>
|
||||
<string name="account_setup_auto_discovery_validation_error_password_required">Password is required.</string>
|
||||
|
||||
<string name="account_setup_auto_discovery_connection_security_start_tls">StartTLS</string>
|
||||
<string name="account_setup_auto_discovery_connection_security_ssl">SSL/TLS</string>
|
||||
|
|
Loading…
Reference in a new issue