From 4f2fe9f6e56a946ee5ccdb824433559abf8041f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montw=C3=A9?= Date: Wed, 6 Sep 2023 13:41:03 +0200 Subject: [PATCH] Move server config to its own module --- .../account/server/config/build.gradle.kts | 29 +++++++++ .../server/config/ServerConfigModule.kt | 30 ++++++++++ .../domain/ServerConfigDomainContract.kt | 33 ++++++++++ .../domain/usecase/ValidateEmailAddress.kt | 6 +- .../domain/usecase/ValidateImapPrefix.kt | 6 +- .../domain/usecase/ValidatePassword.kt | 6 +- .../config}/domain/usecase/ValidatePort.kt | 6 +- .../config}/domain/usecase/ValidateServer.kt | 6 +- .../domain/usecase/ValidateUsername.kt | 6 +- .../ui/common}/ClientCertificateInput.kt | 6 +- .../mapper/AuthenticationTypeStringMapper.kt | 29 +++++++++ .../mapper/ConnectionSecurityStringMapper.kt | 13 ++++ .../mapper/ValidationErrorStringMapper.kt} | 43 ++++++------- .../incoming/AccountIncomingConfigContent.kt | 37 ++++++------ .../incoming/AccountIncomingConfigContract.kt | 2 +- .../incoming/AccountIncomingConfigScreen.kt | 14 ++--- .../AccountIncomingConfigStateExtensions.kt | 2 +- .../AccountIncomingConfigStateMapper.kt | 4 +- .../AccountIncomingConfigValidator.kt | 14 ++--- .../AccountIncomingConfigViewModel.kt | 14 ++--- .../FakeAccountIncomingConfigValidator.kt | 3 +- .../FakeAccountIncomingConfigViewModel.kt | 22 +++++++ .../outgoing/AccountOutgoingConfigContent.kt | 25 ++++---- .../outgoing/AccountOutgoingConfigContract.kt | 2 +- .../outgoing/AccountOutgoingConfigScreen.kt | 14 ++--- .../AccountOutgoingConfigStateExtensions.kt | 2 +- .../AccountOutgoingConfigStateMapper.kt | 4 +- .../AccountOutgoingConfigValidator.kt | 10 ++-- .../AccountOutgoingConfigViewModel.kt | 14 ++--- .../FakeAccountOutgoingConfigValidator.kt | 3 +- .../FakeAccountOutgoingConfigViewModel.kt | 22 +++++++ .../config/src/main/res/values/strings.xml | 40 +++++++++++++ .../usecase/ValidateEmailAddressTest.kt | 4 +- .../domain/usecase/ValidateImapPrefixTest.kt | 2 +- .../domain/usecase/ValidatePasswordTest.kt | 2 +- .../domain/usecase/ValidatePortTest.kt | 4 +- .../domain/usecase/ValidateServerTest.kt | 2 +- .../domain/usecase/ValidateUsernameTest.kt | 2 +- .../AccountIncomingConfigScreenKtTest.kt | 7 ++- .../AccountIncomingConfigStateMapperKtTest.kt | 4 +- .../AccountIncomingConfigStateTest.kt | 4 +- .../AccountIncomingConfigViewModelTest.kt | 9 +-- .../AccountOutgoingConfigScreenKtTest.kt | 7 ++- .../AccountOutgoingConfigStateMapperKtTest.kt | 4 +- .../AccountOutgoingConfigStateTest.kt | 4 +- .../AccountOutgoingConfigViewModelTest.kt | 9 +-- feature/account/setup/build.gradle.kts | 1 + .../account/setup/AccountSetupModule.kt | 23 +------ .../account/setup/domain/DomainContract.kt | 29 --------- .../account/setup/ui/AccountSetupScreen.kt | 12 ++-- .../AccountAutoDiscoveryContent.kt | 4 +- .../AccountAutoDiscoveryStateMapper.kt | 4 +- .../AccountAutoDiscoveryValidator.kt | 9 +-- .../AutoDiscoveryStringMapper.kt | 6 +- .../ui/autodiscovery/item/EmailAddressItem.kt | 2 +- .../ui/autodiscovery/item/PasswordItem.kt | 2 +- .../view/AutoDiscoveryServerSettingsView.kt | 1 - .../view/AutoDiscoveryStatusBodyView.kt | 4 +- .../view/AutoDiscoveryStatusHeaderState.kt | 12 ++-- .../view/ConfigurationApprovalView.kt | 2 +- .../mapper/AuthenticationTypeStringMapper.kt | 25 -------- .../setup/src/main/res/values/strings.xml | 60 ++++--------------- .../account/setup/AccountSetupModuleKtTest.kt | 4 +- .../setup/ui/AccountSetupScreenKtTest.kt | 4 +- .../AccountAutoDiscoveryStateMapperKtTest.kt | 4 +- .../FakeAccountIncomingConfigViewModel.kt | 22 ------- .../FakeAccountOutgoingConfigViewModel.kt | 22 ------- settings.gradle.kts | 1 + 68 files changed, 424 insertions(+), 360 deletions(-) create mode 100644 feature/account/server/config/build.gradle.kts create mode 100644 feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ServerConfigModule.kt create mode 100644 feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/ServerConfigDomainContract.kt rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup => server/config/src/main/kotlin/app/k9mail/feature/account/server/config}/domain/usecase/ValidateEmailAddress.kt (82%) rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup => server/config/src/main/kotlin/app/k9mail/feature/account/server/config}/domain/usecase/ValidateImapPrefix.kt (72%) rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup => server/config/src/main/kotlin/app/k9mail/feature/account/server/config}/domain/usecase/ValidatePassword.kt (74%) rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup => server/config/src/main/kotlin/app/k9mail/feature/account/server/config}/domain/usecase/ValidatePort.kt (78%) rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup => server/config/src/main/kotlin/app/k9mail/feature/account/server/config}/domain/usecase/ValidateServer.kt (71%) rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup => server/config/src/main/kotlin/app/k9mail/feature/account/server/config}/domain/usecase/ValidateUsername.kt (70%) rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/clientcertificate => server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/common}/ClientCertificateInput.kt (85%) create mode 100644 feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/common/mapper/AuthenticationTypeStringMapper.kt create mode 100644 feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/common/mapper/ConnectionSecurityStringMapper.kt rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/common/AccountSetupStringMapper.kt => server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/common/mapper/ValidationErrorStringMapper.kt} (52%) rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup => server/config/src/main/kotlin/app/k9mail/feature/account/server/config}/ui/incoming/AccountIncomingConfigContent.kt (89%) rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup => server/config/src/main/kotlin/app/k9mail/feature/account/server/config}/ui/incoming/AccountIncomingConfigContract.kt (98%) rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup => server/config/src/main/kotlin/app/k9mail/feature/account/server/config}/ui/incoming/AccountIncomingConfigScreen.kt (82%) rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup => server/config/src/main/kotlin/app/k9mail/feature/account/server/config}/ui/incoming/AccountIncomingConfigStateExtensions.kt (95%) rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup => server/config/src/main/kotlin/app/k9mail/feature/account/server/config}/ui/incoming/AccountIncomingConfigStateMapper.kt (94%) rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup => server/config/src/main/kotlin/app/k9mail/feature/account/server/config}/ui/incoming/AccountIncomingConfigValidator.kt (68%) rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup => server/config/src/main/kotlin/app/k9mail/feature/account/server/config}/ui/incoming/AccountIncomingConfigViewModel.kt (89%) rename feature/account/{setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/incoming => server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/fake}/FakeAccountIncomingConfigValidator.kt (86%) create mode 100644 feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/fake/FakeAccountIncomingConfigViewModel.kt rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup => server/config/src/main/kotlin/app/k9mail/feature/account/server/config}/ui/outgoing/AccountOutgoingConfigContent.kt (89%) rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup => server/config/src/main/kotlin/app/k9mail/feature/account/server/config}/ui/outgoing/AccountOutgoingConfigContract.kt (97%) rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup => server/config/src/main/kotlin/app/k9mail/feature/account/server/config}/ui/outgoing/AccountOutgoingConfigScreen.kt (82%) rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup => server/config/src/main/kotlin/app/k9mail/feature/account/server/config}/ui/outgoing/AccountOutgoingConfigStateExtensions.kt (81%) rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup => server/config/src/main/kotlin/app/k9mail/feature/account/server/config}/ui/outgoing/AccountOutgoingConfigStateMapper.kt (92%) rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup => server/config/src/main/kotlin/app/k9mail/feature/account/server/config}/ui/outgoing/AccountOutgoingConfigValidator.kt (71%) rename feature/account/{setup/src/main/kotlin/app/k9mail/feature/account/setup => server/config/src/main/kotlin/app/k9mail/feature/account/server/config}/ui/outgoing/AccountOutgoingConfigViewModel.kt (85%) rename feature/account/{setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/outgoing => server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/fake}/FakeAccountOutgoingConfigValidator.kt (83%) create mode 100644 feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/fake/FakeAccountOutgoingConfigViewModel.kt create mode 100644 feature/account/server/config/src/main/res/values/strings.xml rename feature/account/{setup/src/test/kotlin/app/k9mail/feature/account/setup => server/config/src/test/kotlin/app/k9mail/feature/account/server/config}/domain/usecase/ValidateEmailAddressTest.kt (86%) rename feature/account/{setup/src/test/kotlin/app/k9mail/feature/account/setup => server/config/src/test/kotlin/app/k9mail/feature/account/server/config}/domain/usecase/ValidateImapPrefixTest.kt (93%) rename feature/account/{setup/src/test/kotlin/app/k9mail/feature/account/setup => server/config/src/test/kotlin/app/k9mail/feature/account/server/config}/domain/usecase/ValidatePasswordTest.kt (94%) rename feature/account/{setup/src/test/kotlin/app/k9mail/feature/account/setup => server/config/src/test/kotlin/app/k9mail/feature/account/server/config}/domain/usecase/ValidatePortTest.kt (91%) rename feature/account/{setup/src/test/kotlin/app/k9mail/feature/account/setup => server/config/src/test/kotlin/app/k9mail/feature/account/server/config}/domain/usecase/ValidateServerTest.kt (94%) rename feature/account/{setup/src/test/kotlin/app/k9mail/feature/account/setup => server/config/src/test/kotlin/app/k9mail/feature/account/server/config}/domain/usecase/ValidateUsernameTest.kt (94%) rename feature/account/{setup/src/test/kotlin/app/k9mail/feature/account/setup => server/config/src/test/kotlin/app/k9mail/feature/account/server/config}/ui/incoming/AccountIncomingConfigScreenKtTest.kt (76%) rename feature/account/{setup/src/test/kotlin/app/k9mail/feature/account/setup => server/config/src/test/kotlin/app/k9mail/feature/account/server/config}/ui/incoming/AccountIncomingConfigStateMapperKtTest.kt (95%) rename feature/account/{setup/src/test/kotlin/app/k9mail/feature/account/setup => server/config/src/test/kotlin/app/k9mail/feature/account/server/config}/ui/incoming/AccountIncomingConfigStateTest.kt (89%) rename feature/account/{setup/src/test/kotlin/app/k9mail/feature/account/setup => server/config/src/test/kotlin/app/k9mail/feature/account/server/config}/ui/incoming/AccountIncomingConfigViewModelTest.kt (97%) rename feature/account/{setup/src/test/kotlin/app/k9mail/feature/account/setup => server/config/src/test/kotlin/app/k9mail/feature/account/server/config}/ui/outgoing/AccountOutgoingConfigScreenKtTest.kt (76%) rename feature/account/{setup/src/test/kotlin/app/k9mail/feature/account/setup => server/config/src/test/kotlin/app/k9mail/feature/account/server/config}/ui/outgoing/AccountOutgoingConfigStateMapperKtTest.kt (90%) rename feature/account/{setup/src/test/kotlin/app/k9mail/feature/account/setup => server/config/src/test/kotlin/app/k9mail/feature/account/server/config}/ui/outgoing/AccountOutgoingConfigStateTest.kt (87%) rename feature/account/{setup/src/test/kotlin/app/k9mail/feature/account/setup => server/config/src/test/kotlin/app/k9mail/feature/account/server/config}/ui/outgoing/AccountOutgoingConfigViewModelTest.kt (96%) delete mode 100644 feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/common/mapper/AuthenticationTypeStringMapper.kt delete mode 100644 feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/incoming/FakeAccountIncomingConfigViewModel.kt delete mode 100644 feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/outgoing/FakeAccountOutgoingConfigViewModel.kt diff --git a/feature/account/server/config/build.gradle.kts b/feature/account/server/config/build.gradle.kts new file mode 100644 index 000000000..1adbc030a --- /dev/null +++ b/feature/account/server/config/build.gradle.kts @@ -0,0 +1,29 @@ +plugins { + id(ThunderbirdPlugins.Library.androidCompose) +} + +android { + namespace = "app.k9mail.feature.account.server.config" + resourcePrefix = "account_server_config_" + + buildTypes { + debug { + manifestPlaceholders["appAuthRedirectScheme"] = "FIXME: override this in your app project" + } + release { + manifestPlaceholders["appAuthRedirectScheme"] = "FIXME: override this in your app project" + } + } +} + +dependencies { + implementation(projects.core.ui.compose.designsystem) + implementation(projects.core.common) + + implementation(projects.mail.common) + implementation(projects.mail.protocols.imap) + + implementation(projects.feature.account.common) + + testImplementation(projects.core.ui.compose.testing) +} diff --git a/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ServerConfigModule.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ServerConfigModule.kt new file mode 100644 index 000000000..5b3ed5345 --- /dev/null +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ServerConfigModule.kt @@ -0,0 +1,30 @@ +package app.k9mail.feature.account.server.config + +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigValidator +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigViewModel +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigValidator +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigViewModel +import org.koin.androidx.viewmodel.dsl.viewModel +import org.koin.core.module.Module +import org.koin.dsl.module + +val featureAccountServerConfigModule: Module = module { + factory { AccountIncomingConfigValidator() } + factory { AccountOutgoingConfigValidator() } + + viewModel { + AccountIncomingConfigViewModel( + validator = get(), + accountStateRepository = get(), + ) + } + + viewModel { + AccountOutgoingConfigViewModel( + validator = get(), + accountStateRepository = get(), + ) + } +} diff --git a/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/ServerConfigDomainContract.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/ServerConfigDomainContract.kt new file mode 100644 index 000000000..ce9dc8bfb --- /dev/null +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/ServerConfigDomainContract.kt @@ -0,0 +1,33 @@ +package app.k9mail.feature.account.server.config.domain + +import app.k9mail.core.common.domain.usecase.validation.ValidationResult + +interface ServerConfigDomainContract { + + interface UseCase { + + fun interface ValidateEmailAddress { + fun execute(emailAddress: String): ValidationResult + } + + fun interface ValidatePassword { + fun execute(password: String): ValidationResult + } + + fun interface ValidateServer { + fun execute(server: String): ValidationResult + } + + fun interface ValidatePort { + fun execute(port: Long?): ValidationResult + } + + fun interface ValidateUsername { + fun execute(username: String): ValidationResult + } + + fun interface ValidateImapPrefix { + fun execute(imapPrefix: String): ValidationResult + } + } +} diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateEmailAddress.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateEmailAddress.kt similarity index 82% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateEmailAddress.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateEmailAddress.kt index b53451a62..c33f224e1 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateEmailAddress.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateEmailAddress.kt @@ -1,10 +1,10 @@ -package app.k9mail.feature.account.setup.domain.usecase +package app.k9mail.feature.account.server.config.domain.usecase import app.k9mail.core.common.domain.usecase.validation.ValidationError import app.k9mail.core.common.domain.usecase.validation.ValidationResult -import app.k9mail.feature.account.setup.domain.DomainContract +import app.k9mail.feature.account.server.config.domain.ServerConfigDomainContract.UseCase -internal class ValidateEmailAddress : DomainContract.UseCase.ValidateEmailAddress { +class ValidateEmailAddress : UseCase.ValidateEmailAddress { // TODO replace by new email validation override fun execute(emailAddress: String): ValidationResult { diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateImapPrefix.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateImapPrefix.kt similarity index 72% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateImapPrefix.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateImapPrefix.kt index 486d07258..43845b089 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateImapPrefix.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateImapPrefix.kt @@ -1,10 +1,10 @@ -package app.k9mail.feature.account.setup.domain.usecase +package app.k9mail.feature.account.server.config.domain.usecase import app.k9mail.core.common.domain.usecase.validation.ValidationError import app.k9mail.core.common.domain.usecase.validation.ValidationResult -import app.k9mail.feature.account.setup.domain.DomainContract +import app.k9mail.feature.account.server.config.domain.ServerConfigDomainContract.UseCase -internal class ValidateImapPrefix : DomainContract.UseCase.ValidateImapPrefix { +internal class ValidateImapPrefix : UseCase.ValidateImapPrefix { override fun execute(imapPrefix: String): ValidationResult { return when { diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidatePassword.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidatePassword.kt similarity index 74% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidatePassword.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidatePassword.kt index f7c254832..b0a95b4c8 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidatePassword.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidatePassword.kt @@ -1,10 +1,10 @@ -package app.k9mail.feature.account.setup.domain.usecase +package app.k9mail.feature.account.server.config.domain.usecase import app.k9mail.core.common.domain.usecase.validation.ValidationError import app.k9mail.core.common.domain.usecase.validation.ValidationResult -import app.k9mail.feature.account.setup.domain.DomainContract +import app.k9mail.feature.account.server.config.domain.ServerConfigDomainContract.UseCase -internal class ValidatePassword : DomainContract.UseCase.ValidatePassword { +class ValidatePassword : UseCase.ValidatePassword { // TODO change behavior to allow empty password when no password is required based on auth type override fun execute(password: String): ValidationResult { diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidatePort.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidatePort.kt similarity index 78% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidatePort.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidatePort.kt index f0e31b67b..30288f24c 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidatePort.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidatePort.kt @@ -1,10 +1,10 @@ -package app.k9mail.feature.account.setup.domain.usecase +package app.k9mail.feature.account.server.config.domain.usecase import app.k9mail.core.common.domain.usecase.validation.ValidationError import app.k9mail.core.common.domain.usecase.validation.ValidationResult -import app.k9mail.feature.account.setup.domain.DomainContract +import app.k9mail.feature.account.server.config.domain.ServerConfigDomainContract.UseCase -internal class ValidatePort : DomainContract.UseCase.ValidatePort { +internal class ValidatePort : UseCase.ValidatePort { override fun execute(port: Long?): ValidationResult { return when (port) { diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateServer.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateServer.kt similarity index 71% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateServer.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateServer.kt index 31fcfb63d..7fbe43c7a 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateServer.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateServer.kt @@ -1,10 +1,10 @@ -package app.k9mail.feature.account.setup.domain.usecase +package app.k9mail.feature.account.server.config.domain.usecase import app.k9mail.core.common.domain.usecase.validation.ValidationError import app.k9mail.core.common.domain.usecase.validation.ValidationResult -import app.k9mail.feature.account.setup.domain.DomainContract +import app.k9mail.feature.account.server.config.domain.ServerConfigDomainContract.UseCase -internal class ValidateServer : DomainContract.UseCase.ValidateServer { +internal class ValidateServer : UseCase.ValidateServer { // TODO validate domain, ip4 or ip6 override fun execute(server: String): ValidationResult { diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateUsername.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateUsername.kt similarity index 70% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateUsername.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateUsername.kt index 7399330bb..c83482cbd 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateUsername.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateUsername.kt @@ -1,10 +1,10 @@ -package app.k9mail.feature.account.setup.domain.usecase +package app.k9mail.feature.account.server.config.domain.usecase import app.k9mail.core.common.domain.usecase.validation.ValidationError import app.k9mail.core.common.domain.usecase.validation.ValidationResult -import app.k9mail.feature.account.setup.domain.DomainContract +import app.k9mail.feature.account.server.config.domain.ServerConfigDomainContract.UseCase -internal class ValidateUsername : DomainContract.UseCase.ValidateUsername { +internal class ValidateUsername : UseCase.ValidateUsername { override fun execute(username: String): ValidationResult { return when { diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/clientcertificate/ClientCertificateInput.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/common/ClientCertificateInput.kt similarity index 85% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/clientcertificate/ClientCertificateInput.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/common/ClientCertificateInput.kt index 694b0421b..9cbbd3b8c 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/clientcertificate/ClientCertificateInput.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/common/ClientCertificateInput.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.setup.ui.clientcertificate +package app.k9mail.feature.account.server.config.ui.common import android.security.KeyChain import androidx.compose.foundation.layout.Column @@ -11,7 +11,7 @@ import androidx.compose.ui.res.stringResource import app.k9mail.core.ui.compose.common.activity.LocalActivity import app.k9mail.core.ui.compose.designsystem.atom.textfield.TextFieldOutlinedFakeSelect import app.k9mail.core.ui.compose.designsystem.molecule.input.inputContentPadding -import app.k9mail.feature.account.setup.R +import app.k9mail.feature.account.server.config.R @Composable fun ClientCertificateInput( @@ -29,7 +29,7 @@ fun ClientCertificateInput( ) { val activity = LocalActivity.current TextFieldOutlinedFakeSelect( - text = alias ?: stringResource(R.string.account_setup_client_certificate_none_selected), + text = alias ?: stringResource(R.string.account_server_config_client_certificate_none_selected), onClick = { KeyChain.choosePrivateKeyAlias(activity, onValueChange, null, null, null, -1, alias) }, diff --git a/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/common/mapper/AuthenticationTypeStringMapper.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/common/mapper/AuthenticationTypeStringMapper.kt new file mode 100644 index 000000000..59d1b221e --- /dev/null +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/common/mapper/AuthenticationTypeStringMapper.kt @@ -0,0 +1,29 @@ +package app.k9mail.feature.account.server.config.ui.common.mapper + +import android.content.res.Resources +import app.k9mail.feature.account.common.domain.entity.AuthenticationType +import app.k9mail.feature.account.server.config.R + +internal fun AuthenticationType.toResourceString(resources: Resources): String { + return when (this) { + AuthenticationType.None -> { + resources.getString(R.string.account_server_config_authentication_none) + } + + AuthenticationType.PasswordCleartext -> { + resources.getString(R.string.account_server_config_authentication_password_cleartext) + } + + AuthenticationType.PasswordEncrypted -> { + resources.getString(R.string.account_server_config_authentication_password_encrypted) + } + + AuthenticationType.ClientCertificate -> { + resources.getString(R.string.account_server_config_authentication_client_certificate) + } + + AuthenticationType.OAuth2 -> { + resources.getString(R.string.account_server_config_authentication_client_oauth) + } + } +} diff --git a/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/common/mapper/ConnectionSecurityStringMapper.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/common/mapper/ConnectionSecurityStringMapper.kt new file mode 100644 index 000000000..d232a961a --- /dev/null +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/common/mapper/ConnectionSecurityStringMapper.kt @@ -0,0 +1,13 @@ +package app.k9mail.feature.account.server.config.ui.common.mapper + +import android.content.res.Resources +import app.k9mail.feature.account.common.domain.entity.ConnectionSecurity +import app.k9mail.feature.account.server.config.R + +internal fun ConnectionSecurity.toResourceString(resources: Resources): String { + return when (this) { + ConnectionSecurity.None -> resources.getString(R.string.account_server_config_connection_security_none) + ConnectionSecurity.StartTLS -> resources.getString(R.string.account_server_config_connection_security_start_tls) + ConnectionSecurity.TLS -> resources.getString(R.string.account_server_config_connection_security_ssl) + } +} diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/common/AccountSetupStringMapper.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/common/mapper/ValidationErrorStringMapper.kt similarity index 52% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/common/AccountSetupStringMapper.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/common/mapper/ValidationErrorStringMapper.kt index 3632e43d1..949dee84d 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/common/AccountSetupStringMapper.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/common/mapper/ValidationErrorStringMapper.kt @@ -1,25 +1,16 @@ -package app.k9mail.feature.account.setup.ui.common +package app.k9mail.feature.account.server.config.ui.common.mapper import android.content.res.Resources import app.k9mail.core.common.domain.usecase.validation.ValidationError -import app.k9mail.feature.account.common.domain.entity.ConnectionSecurity -import app.k9mail.feature.account.setup.R -import app.k9mail.feature.account.setup.domain.usecase.ValidateEmailAddress.ValidateEmailAddressError -import app.k9mail.feature.account.setup.domain.usecase.ValidateImapPrefix.ValidateImapPrefixError -import app.k9mail.feature.account.setup.domain.usecase.ValidatePassword.ValidatePasswordError -import app.k9mail.feature.account.setup.domain.usecase.ValidatePort.ValidatePortError -import app.k9mail.feature.account.setup.domain.usecase.ValidateServer.ValidateServerError -import app.k9mail.feature.account.setup.domain.usecase.ValidateUsername.ValidateUsernameError +import app.k9mail.feature.account.server.config.R +import app.k9mail.feature.account.server.config.domain.usecase.ValidateEmailAddress.ValidateEmailAddressError +import app.k9mail.feature.account.server.config.domain.usecase.ValidateImapPrefix.ValidateImapPrefixError +import app.k9mail.feature.account.server.config.domain.usecase.ValidatePassword.ValidatePasswordError +import app.k9mail.feature.account.server.config.domain.usecase.ValidatePort.ValidatePortError +import app.k9mail.feature.account.server.config.domain.usecase.ValidateServer.ValidateServerError +import app.k9mail.feature.account.server.config.domain.usecase.ValidateUsername.ValidateUsernameError -internal fun ConnectionSecurity.toResourceString(resources: Resources): String { - return when (this) { - ConnectionSecurity.None -> resources.getString(R.string.account_setup_connection_security_none) - ConnectionSecurity.StartTLS -> resources.getString(R.string.account_setup_connection_security_start_tls) - ConnectionSecurity.TLS -> resources.getString(R.string.account_setup_connection_security_ssl) - } -} - -internal fun ValidationError.toResourceString(resources: Resources): String { +fun ValidationError.toResourceString(resources: Resources): String { return when (this) { is ValidateEmailAddressError -> toEmailAddressErrorString(resources) is ValidateServerError -> toServerErrorString(resources) @@ -34,11 +25,11 @@ internal fun ValidationError.toResourceString(resources: Resources): String { private fun ValidateEmailAddressError.toEmailAddressErrorString(resources: Resources): String { return when (this) { is ValidateEmailAddressError.EmptyEmailAddress -> resources.getString( - R.string.account_setup_validation_error_email_address_required, + R.string.account_server_config_validation_error_email_address_required, ) is ValidateEmailAddressError.InvalidEmailAddress -> resources.getString( - R.string.account_setup_validation_error_email_address_invalid, + R.string.account_server_config_validation_error_email_address_invalid, ) } } @@ -46,7 +37,7 @@ private fun ValidateEmailAddressError.toEmailAddressErrorString(resources: Resou private fun ValidateServerError.toServerErrorString(resources: Resources): String { return when (this) { is ValidateServerError.EmptyServer -> resources.getString( - R.string.account_setup_validation_error_server_required, + R.string.account_server_config_validation_error_server_required, ) } } @@ -54,11 +45,11 @@ private fun ValidateServerError.toServerErrorString(resources: Resources): Strin private fun ValidatePortError.toPortErrorString(resources: Resources): String { return when (this) { is ValidatePortError.EmptyPort -> resources.getString( - R.string.account_setup_validation_error_port_required, + R.string.account_server_config_validation_error_port_required, ) is ValidatePortError.InvalidPort -> resources.getString( - R.string.account_setup_validation_error_port_invalid, + R.string.account_server_config_validation_error_port_invalid, ) } } @@ -66,7 +57,7 @@ private fun ValidatePortError.toPortErrorString(resources: Resources): String { private fun ValidateUsernameError.toUsernameErrorString(resources: Resources): String { return when (this) { ValidateUsernameError.EmptyUsername -> resources.getString( - R.string.account_setup_validation_error_username_required, + R.string.account_server_config_validation_error_username_required, ) } } @@ -74,7 +65,7 @@ private fun ValidateUsernameError.toUsernameErrorString(resources: Resources): S private fun ValidatePasswordError.toPasswordErrorString(resources: Resources): String { return when (this) { ValidatePasswordError.EmptyPassword -> resources.getString( - R.string.account_setup_validation_error_password_required, + R.string.account_server_config_validation_error_password_required, ) } } @@ -82,7 +73,7 @@ private fun ValidatePasswordError.toPasswordErrorString(resources: Resources): S private fun ValidateImapPrefixError.toImapPrefixErrorString(resources: Resources): String { return when (this) { ValidateImapPrefixError.BlankImapPrefix -> resources.getString( - R.string.account_setup_validation_error_imap_prefix_blank, + R.string.account_server_config_validation_error_imap_prefix_blank, ) } } diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigContent.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigContent.kt similarity index 89% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigContent.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigContent.kt index 2cd1a405c..83aec7853 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigContent.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigContent.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.setup.ui.incoming +package app.k9mail.feature.account.server.config.ui.incoming import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.PaddingValues @@ -28,12 +28,11 @@ import app.k9mail.core.ui.compose.theme.ThunderbirdTheme import app.k9mail.feature.account.common.domain.entity.ConnectionSecurity import app.k9mail.feature.account.common.domain.entity.IncomingProtocolType import app.k9mail.feature.account.common.ui.item.defaultItemPadding -import app.k9mail.feature.account.setup.R -import app.k9mail.feature.account.setup.ui.clientcertificate.ClientCertificateInput -import app.k9mail.feature.account.setup.ui.common.mapper.toResourceString -import app.k9mail.feature.account.setup.ui.common.toResourceString -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.Event -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.State +import app.k9mail.feature.account.server.config.R +import app.k9mail.feature.account.server.config.ui.common.ClientCertificateInput +import app.k9mail.feature.account.server.config.ui.common.mapper.toResourceString +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.Event +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.State @Suppress("LongMethod") @Composable @@ -68,7 +67,7 @@ internal fun AccountIncomingConfigContent( options = IncomingProtocolType.all(), selectedOption = state.protocolType, onOptionChange = { onEvent(Event.ProtocolTypeChanged(it)) }, - label = stringResource(id = R.string.account_setup_incoming_config_protocol_type_label), + label = stringResource(id = R.string.account_server_config_protocol_type_label), contentPadding = defaultItemPadding(), ) } @@ -78,7 +77,7 @@ internal fun AccountIncomingConfigContent( text = state.server.value, errorMessage = state.server.error?.toResourceString(resources), onTextChange = { onEvent(Event.ServerChanged(it)) }, - label = stringResource(id = R.string.account_setup_incoming_config_server_label), + label = stringResource(id = R.string.account_server_config_server_label), contentPadding = defaultItemPadding(), ) } @@ -89,7 +88,7 @@ internal fun AccountIncomingConfigContent( optionToStringTransformation = { it.toResourceString(resources) }, selectedOption = state.security, onOptionChange = { onEvent(Event.SecurityChanged(it)) }, - label = stringResource(id = R.string.account_setup_incoming_config_security_label), + label = stringResource(id = R.string.account_server_config_security_label), contentPadding = defaultItemPadding(), ) } @@ -99,7 +98,7 @@ internal fun AccountIncomingConfigContent( value = state.port.value, errorMessage = state.port.error?.toResourceString(resources), onValueChange = { onEvent(Event.PortChanged(it)) }, - label = stringResource(id = R.string.account_setup_outgoing_config_port_label), + label = stringResource(id = R.string.account_server_config_port_label), contentPadding = defaultItemPadding(), ) } @@ -110,7 +109,7 @@ internal fun AccountIncomingConfigContent( optionToStringTransformation = { it.toResourceString(resources) }, selectedOption = state.authenticationType, onOptionChange = { onEvent(Event.AuthenticationTypeChanged(it)) }, - label = stringResource(id = R.string.account_setup_incoming_config_authentication_label), + label = stringResource(id = R.string.account_server_config_authentication_label), contentPadding = defaultItemPadding(), ) } @@ -120,7 +119,7 @@ internal fun AccountIncomingConfigContent( text = state.username.value, errorMessage = state.username.error?.toResourceString(resources), onTextChange = { onEvent(Event.UsernameChanged(it)) }, - label = stringResource(id = R.string.account_setup_outgoing_config_username_label), + label = stringResource(id = R.string.account_server_config_username_label), contentPadding = defaultItemPadding(), ) } @@ -140,7 +139,7 @@ internal fun AccountIncomingConfigContent( ClientCertificateInput( alias = state.clientCertificateAlias, onValueChange = { onEvent(Event.ClientCertificateChanged(it)) }, - label = stringResource(id = R.string.account_setup_client_certificate_label), + label = stringResource(id = R.string.account_server_config_client_certificate_label), contentPadding = defaultItemPadding(), ) } @@ -148,7 +147,7 @@ internal fun AccountIncomingConfigContent( if (state.protocolType == IncomingProtocolType.IMAP) { item { CheckboxInput( - text = stringResource(id = R.string.account_setup_incoming_config_imap_namespace_label), + text = stringResource(id = R.string.account_server_config_incoming_imap_namespace_label), checked = state.imapAutodetectNamespaceEnabled, onCheckedChange = { onEvent(Event.ImapAutoDetectNamespaceChanged(it)) }, contentPadding = defaultItemPadding(), @@ -159,7 +158,7 @@ internal fun AccountIncomingConfigContent( if (state.imapAutodetectNamespaceEnabled) { TextInput( onTextChange = {}, - label = stringResource(id = R.string.account_setup_incoming_config_imap_prefix_label), + label = stringResource(id = R.string.account_server_config_incoming_imap_prefix_label), contentPadding = defaultItemPadding(), isEnabled = false, ) @@ -168,7 +167,7 @@ internal fun AccountIncomingConfigContent( text = state.imapPrefix.value, errorMessage = state.imapPrefix.error?.toResourceString(resources), onTextChange = { onEvent(Event.ImapPrefixChanged(it)) }, - label = stringResource(id = R.string.account_setup_incoming_config_imap_prefix_label), + label = stringResource(id = R.string.account_server_config_incoming_imap_prefix_label), contentPadding = defaultItemPadding(), ) } @@ -176,7 +175,7 @@ internal fun AccountIncomingConfigContent( item { CheckboxInput( - text = stringResource(id = R.string.account_setup_incoming_config_imap_compression_label), + text = stringResource(id = R.string.account_server_config_incoming_imap_compression_label), checked = state.imapUseCompression, onCheckedChange = { onEvent(Event.ImapUseCompressionChanged(it)) }, contentPadding = defaultItemPadding(), @@ -185,7 +184,7 @@ internal fun AccountIncomingConfigContent( item { CheckboxInput( - text = stringResource(R.string.account_setup_incoming_config_imap_send_client_id_label), + text = stringResource(R.string.account_server_config_incoming_imap_send_client_id_label), checked = state.imapSendClientId, onCheckedChange = { onEvent(Event.ImapSendClientIdChanged(it)) }, contentPadding = defaultItemPadding(), diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigContract.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigContract.kt similarity index 98% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigContract.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigContract.kt index 4be0fdc55..e361477ff 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigContract.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigContract.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.setup.ui.incoming +package app.k9mail.feature.account.server.config.ui.incoming import app.k9mail.core.common.domain.usecase.validation.ValidationResult import app.k9mail.core.ui.compose.common.mvi.UnidirectionalViewModel diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigScreen.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigScreen.kt similarity index 82% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigScreen.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigScreen.kt index aba49a064..56dc8a36c 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigScreen.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigScreen.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.setup.ui.incoming +package app.k9mail.feature.account.server.config.ui.incoming import androidx.activity.compose.BackHandler import androidx.compose.runtime.Composable @@ -13,13 +13,13 @@ import app.k9mail.core.ui.compose.theme.ThunderbirdTheme import app.k9mail.feature.account.common.ui.AccountTopAppBar import app.k9mail.feature.account.common.ui.WizardNavigationBar import app.k9mail.feature.account.common.ui.preview.PreviewAccountStateRepository -import app.k9mail.feature.account.setup.R -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.Effect -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.Event -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.ViewModel +import app.k9mail.feature.account.server.config.R +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.Effect +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.Event +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.ViewModel @Composable -internal fun AccountIncomingConfigScreen( +fun AccountIncomingConfigScreen( onNext: (AccountIncomingConfigContract.State) -> Unit, onBack: () -> Unit, viewModel: ViewModel, @@ -43,7 +43,7 @@ internal fun AccountIncomingConfigScreen( Scaffold( topBar = { AccountTopAppBar( - title = stringResource(id = R.string.account_setup_incoming_config_top_bar_title), + title = stringResource(id = R.string.account_server_config_incoming_top_bar_title), ) }, bottomBar = { diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigStateExtensions.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigStateExtensions.kt similarity index 95% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigStateExtensions.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigStateExtensions.kt index d586bcc80..5826868e4 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigStateExtensions.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigStateExtensions.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.setup.ui.incoming +package app.k9mail.feature.account.server.config.ui.incoming import app.k9mail.feature.account.common.domain.entity.AuthenticationType import app.k9mail.feature.account.common.domain.entity.IncomingProtocolType diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigStateMapper.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigStateMapper.kt similarity index 94% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigStateMapper.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigStateMapper.kt index 95f5f5fda..ed0e1bb96 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigStateMapper.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigStateMapper.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.setup.ui.incoming +package app.k9mail.feature.account.server.config.ui.incoming import app.k9mail.feature.account.common.domain.entity.AccountState import app.k9mail.feature.account.common.domain.entity.IncomingProtocolType @@ -8,7 +8,7 @@ import app.k9mail.feature.account.common.domain.entity.toConnectionSecurity import app.k9mail.feature.account.common.domain.entity.toMailConnectionSecurity import app.k9mail.feature.account.common.domain.input.NumberInputField import app.k9mail.feature.account.common.domain.input.StringInputField -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.State +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.State import com.fsck.k9.mail.ServerSettings import com.fsck.k9.mail.store.imap.ImapStoreSettings diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigValidator.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigValidator.kt similarity index 68% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigValidator.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigValidator.kt index 662e605db..478990047 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigValidator.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigValidator.kt @@ -1,12 +1,12 @@ -package app.k9mail.feature.account.setup.ui.incoming +package app.k9mail.feature.account.server.config.ui.incoming import app.k9mail.core.common.domain.usecase.validation.ValidationResult -import app.k9mail.feature.account.setup.domain.DomainContract.UseCase -import app.k9mail.feature.account.setup.domain.usecase.ValidateImapPrefix -import app.k9mail.feature.account.setup.domain.usecase.ValidatePassword -import app.k9mail.feature.account.setup.domain.usecase.ValidatePort -import app.k9mail.feature.account.setup.domain.usecase.ValidateServer -import app.k9mail.feature.account.setup.domain.usecase.ValidateUsername +import app.k9mail.feature.account.server.config.domain.ServerConfigDomainContract.UseCase +import app.k9mail.feature.account.server.config.domain.usecase.ValidateImapPrefix +import app.k9mail.feature.account.server.config.domain.usecase.ValidatePassword +import app.k9mail.feature.account.server.config.domain.usecase.ValidatePort +import app.k9mail.feature.account.server.config.domain.usecase.ValidateServer +import app.k9mail.feature.account.server.config.domain.usecase.ValidateUsername internal class AccountIncomingConfigValidator( private val serverValidator: UseCase.ValidateServer = ValidateServer(), diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigViewModel.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigViewModel.kt similarity index 89% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigViewModel.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigViewModel.kt index 647faf351..4ea05db56 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigViewModel.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigViewModel.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.setup.ui.incoming +package app.k9mail.feature.account.server.config.ui.incoming import app.k9mail.core.common.domain.usecase.validation.ValidationResult import app.k9mail.core.ui.compose.common.mvi.BaseViewModel @@ -6,13 +6,13 @@ import app.k9mail.feature.account.common.domain.AccountDomainContract import app.k9mail.feature.account.common.domain.entity.ConnectionSecurity import app.k9mail.feature.account.common.domain.entity.IncomingProtocolType import app.k9mail.feature.account.common.domain.entity.toDefaultPort -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.Effect -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.Event -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.State -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.Validator -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.ViewModel +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.Effect +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.Event +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.State +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.Validator +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.ViewModel -internal class AccountIncomingConfigViewModel( +class AccountIncomingConfigViewModel( private val validator: Validator, private val accountStateRepository: AccountDomainContract.AccountStateRepository, initialState: State? = null, diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/incoming/FakeAccountIncomingConfigValidator.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/fake/FakeAccountIncomingConfigValidator.kt similarity index 86% rename from feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/incoming/FakeAccountIncomingConfigValidator.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/fake/FakeAccountIncomingConfigValidator.kt index 983531448..e9d21564f 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/incoming/FakeAccountIncomingConfigValidator.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/fake/FakeAccountIncomingConfigValidator.kt @@ -1,6 +1,7 @@ -package app.k9mail.feature.account.setup.ui.incoming +package app.k9mail.feature.account.server.config.ui.incoming.fake import app.k9mail.core.common.domain.usecase.validation.ValidationResult +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract class FakeAccountIncomingConfigValidator( private val serverAnswer: ValidationResult = ValidationResult.Success, diff --git a/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/fake/FakeAccountIncomingConfigViewModel.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/fake/FakeAccountIncomingConfigViewModel.kt new file mode 100644 index 000000000..6613f9abd --- /dev/null +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/incoming/fake/FakeAccountIncomingConfigViewModel.kt @@ -0,0 +1,22 @@ +package app.k9mail.feature.account.server.config.ui.incoming.fake + +import app.k9mail.core.ui.compose.common.mvi.BaseViewModel +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.Effect +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.Event +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.State +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.ViewModel + +class FakeAccountIncomingConfigViewModel( + initialState: State = State(), +) : BaseViewModel(initialState), ViewModel { + + val events = mutableListOf() + + override fun event(event: Event) { + events.add(event) + } + + fun effect(effect: Effect) { + emitEffect(effect) + } +} diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigContent.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigContent.kt similarity index 89% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigContent.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigContent.kt index 1debb3fe3..71b923678 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigContent.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigContent.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.setup.ui.outgoing +package app.k9mail.feature.account.server.config.ui.outgoing import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.PaddingValues @@ -27,12 +27,11 @@ import app.k9mail.core.ui.compose.theme.ThunderbirdTheme import app.k9mail.feature.account.common.domain.entity.AuthenticationType import app.k9mail.feature.account.common.domain.entity.ConnectionSecurity import app.k9mail.feature.account.common.ui.item.defaultItemPadding -import app.k9mail.feature.account.setup.R -import app.k9mail.feature.account.setup.ui.clientcertificate.ClientCertificateInput -import app.k9mail.feature.account.setup.ui.common.mapper.toResourceString -import app.k9mail.feature.account.setup.ui.common.toResourceString -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.Event -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.State +import app.k9mail.feature.account.server.config.R +import app.k9mail.feature.account.server.config.ui.common.ClientCertificateInput +import app.k9mail.feature.account.server.config.ui.common.mapper.toResourceString +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.Event +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.State @Suppress("LongMethod") @Composable @@ -67,7 +66,7 @@ internal fun AccountOutgoingConfigContent( text = state.server.value, errorMessage = state.server.error?.toResourceString(resources), onTextChange = { onEvent(Event.ServerChanged(it)) }, - label = stringResource(id = R.string.account_setup_outgoing_config_server_label), + label = stringResource(id = R.string.account_server_config_server_label), isRequired = true, contentPadding = defaultItemPadding(), ) @@ -79,7 +78,7 @@ internal fun AccountOutgoingConfigContent( optionToStringTransformation = { it.toResourceString(resources) }, selectedOption = state.security, onOptionChange = { onEvent(Event.SecurityChanged(it)) }, - label = stringResource(id = R.string.account_setup_outgoing_config_security_label), + label = stringResource(id = R.string.account_server_config_security_label), contentPadding = defaultItemPadding(), ) } @@ -89,7 +88,7 @@ internal fun AccountOutgoingConfigContent( value = state.port.value, errorMessage = state.port.error?.toResourceString(resources), onValueChange = { onEvent(Event.PortChanged(it)) }, - label = stringResource(id = R.string.account_setup_outgoing_config_port_label), + label = stringResource(id = R.string.account_server_config_port_label), isRequired = true, contentPadding = defaultItemPadding(), ) @@ -101,7 +100,7 @@ internal fun AccountOutgoingConfigContent( optionToStringTransformation = { it.toResourceString(resources) }, selectedOption = state.authenticationType, onOptionChange = { onEvent(Event.AuthenticationTypeChanged(it)) }, - label = stringResource(id = R.string.account_setup_outgoing_config_authentication_label), + label = stringResource(id = R.string.account_server_config_authentication_label), contentPadding = defaultItemPadding(), ) } @@ -112,7 +111,7 @@ internal fun AccountOutgoingConfigContent( text = state.username.value, errorMessage = state.username.error?.toResourceString(resources), onTextChange = { onEvent(Event.UsernameChanged(it)) }, - label = stringResource(id = R.string.account_setup_outgoing_config_username_label), + label = stringResource(id = R.string.account_server_config_username_label), isRequired = true, contentPadding = defaultItemPadding(), ) @@ -135,7 +134,7 @@ internal fun AccountOutgoingConfigContent( ClientCertificateInput( alias = state.clientCertificateAlias, onValueChange = { onEvent(Event.ClientCertificateChanged(it)) }, - label = stringResource(id = R.string.account_setup_client_certificate_label), + label = stringResource(id = R.string.account_server_config_client_certificate_label), contentPadding = defaultItemPadding(), ) } diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigContract.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigContract.kt similarity index 97% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigContract.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigContract.kt index 29b50f318..51cc1dd87 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigContract.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigContract.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.setup.ui.outgoing +package app.k9mail.feature.account.server.config.ui.outgoing import app.k9mail.core.common.domain.usecase.validation.ValidationResult import app.k9mail.core.ui.compose.common.mvi.UnidirectionalViewModel diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigScreen.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigScreen.kt similarity index 82% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigScreen.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigScreen.kt index e1c184633..82a50f150 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigScreen.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigScreen.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.setup.ui.outgoing +package app.k9mail.feature.account.server.config.ui.outgoing import androidx.activity.compose.BackHandler import androidx.compose.runtime.Composable @@ -13,13 +13,13 @@ import app.k9mail.core.ui.compose.theme.ThunderbirdTheme import app.k9mail.feature.account.common.ui.AccountTopAppBar import app.k9mail.feature.account.common.ui.WizardNavigationBar import app.k9mail.feature.account.common.ui.preview.PreviewAccountStateRepository -import app.k9mail.feature.account.setup.R -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.Effect -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.Event -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.ViewModel +import app.k9mail.feature.account.server.config.R +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.Effect +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.Event +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.ViewModel @Composable -internal fun AccountOutgoingConfigScreen( +fun AccountOutgoingConfigScreen( onNext: () -> Unit, onBack: () -> Unit, viewModel: ViewModel, @@ -43,7 +43,7 @@ internal fun AccountOutgoingConfigScreen( Scaffold( topBar = { AccountTopAppBar( - title = stringResource(id = R.string.account_setup_outgoing_config_top_bar_title), + title = stringResource(id = R.string.account_server_config_outgoing_top_bar_title), ) }, bottomBar = { diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigStateExtensions.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigStateExtensions.kt similarity index 81% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigStateExtensions.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigStateExtensions.kt index d80ffca57..a5b4544b0 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigStateExtensions.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigStateExtensions.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.setup.ui.outgoing +package app.k9mail.feature.account.server.config.ui.outgoing internal val AccountOutgoingConfigContract.State.isUsernameFieldVisible: Boolean get() = authenticationType.isUsernameRequired diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigStateMapper.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigStateMapper.kt similarity index 92% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigStateMapper.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigStateMapper.kt index 1a4ac9745..5ff993d0d 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigStateMapper.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigStateMapper.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.setup.ui.outgoing +package app.k9mail.feature.account.server.config.ui.outgoing import app.k9mail.feature.account.common.domain.entity.AccountState import app.k9mail.feature.account.common.domain.entity.toAuthType @@ -7,7 +7,7 @@ import app.k9mail.feature.account.common.domain.entity.toConnectionSecurity import app.k9mail.feature.account.common.domain.entity.toMailConnectionSecurity import app.k9mail.feature.account.common.domain.input.NumberInputField import app.k9mail.feature.account.common.domain.input.StringInputField -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.State +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.State import com.fsck.k9.mail.ServerSettings internal fun AccountState.toOutgoingConfigState(): State { diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigValidator.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigValidator.kt similarity index 71% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigValidator.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigValidator.kt index a4c71d35e..db073d78f 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigValidator.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigValidator.kt @@ -1,10 +1,10 @@ -package app.k9mail.feature.account.setup.ui.outgoing +package app.k9mail.feature.account.server.config.ui.outgoing import app.k9mail.core.common.domain.usecase.validation.ValidationResult -import app.k9mail.feature.account.setup.domain.usecase.ValidatePassword -import app.k9mail.feature.account.setup.domain.usecase.ValidatePort -import app.k9mail.feature.account.setup.domain.usecase.ValidateServer -import app.k9mail.feature.account.setup.domain.usecase.ValidateUsername +import app.k9mail.feature.account.server.config.domain.usecase.ValidatePassword +import app.k9mail.feature.account.server.config.domain.usecase.ValidatePort +import app.k9mail.feature.account.server.config.domain.usecase.ValidateServer +import app.k9mail.feature.account.server.config.domain.usecase.ValidateUsername internal class AccountOutgoingConfigValidator( private val serverValidator: ValidateServer = ValidateServer(), diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigViewModel.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigViewModel.kt similarity index 85% rename from feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigViewModel.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigViewModel.kt index a01369ec5..b706474c0 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigViewModel.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigViewModel.kt @@ -1,17 +1,17 @@ -package app.k9mail.feature.account.setup.ui.outgoing +package app.k9mail.feature.account.server.config.ui.outgoing import app.k9mail.core.common.domain.usecase.validation.ValidationResult import app.k9mail.core.ui.compose.common.mvi.BaseViewModel import app.k9mail.feature.account.common.domain.AccountDomainContract import app.k9mail.feature.account.common.domain.entity.ConnectionSecurity import app.k9mail.feature.account.common.domain.entity.toSmtpDefaultPort -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.Effect -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.Event -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.State -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.Validator -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.ViewModel +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.Effect +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.Event +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.State +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.Validator +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.ViewModel -internal class AccountOutgoingConfigViewModel( +class AccountOutgoingConfigViewModel( private val validator: Validator, private val accountStateRepository: AccountDomainContract.AccountStateRepository, initialState: State? = State(), diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/outgoing/FakeAccountOutgoingConfigValidator.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/fake/FakeAccountOutgoingConfigValidator.kt similarity index 83% rename from feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/outgoing/FakeAccountOutgoingConfigValidator.kt rename to feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/fake/FakeAccountOutgoingConfigValidator.kt index 5c342e995..4589ad714 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/outgoing/FakeAccountOutgoingConfigValidator.kt +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/fake/FakeAccountOutgoingConfigValidator.kt @@ -1,6 +1,7 @@ -package app.k9mail.feature.account.setup.ui.outgoing +package app.k9mail.feature.account.server.config.ui.outgoing.fake import app.k9mail.core.common.domain.usecase.validation.ValidationResult +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract class FakeAccountOutgoingConfigValidator( private val serverAnswer: ValidationResult = ValidationResult.Success, diff --git a/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/fake/FakeAccountOutgoingConfigViewModel.kt b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/fake/FakeAccountOutgoingConfigViewModel.kt new file mode 100644 index 000000000..583043854 --- /dev/null +++ b/feature/account/server/config/src/main/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/fake/FakeAccountOutgoingConfigViewModel.kt @@ -0,0 +1,22 @@ +package app.k9mail.feature.account.server.config.ui.outgoing.fake + +import app.k9mail.core.ui.compose.common.mvi.BaseViewModel +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.Effect +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.Event +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.State +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.ViewModel + +class FakeAccountOutgoingConfigViewModel( + initialState: State = State(), +) : BaseViewModel(initialState), ViewModel { + + val events = mutableListOf() + + override fun event(event: Event) { + events.add(event) + } + + fun effect(effect: Effect) { + emitEffect(effect) + } +} diff --git a/feature/account/server/config/src/main/res/values/strings.xml b/feature/account/server/config/src/main/res/values/strings.xml new file mode 100644 index 000000000..a32a430c6 --- /dev/null +++ b/feature/account/server/config/src/main/res/values/strings.xml @@ -0,0 +1,40 @@ + + + Protocol + Server + Security + Port + Authentication + Username + + None + StartTLS + SSL/TLS + + None + Normal password + Encrypted password + Client certificate + OAuth 2.0 + + None + Client certificate + + Incoming server settings + + Auto-detect IMAP namespace + IMAP path prefix + Use compression + Send client ID + + Outgoing server settings + + Email address is required. + Email address is invalid. + Server name is required. + Port is required. + Port is invalid (must be 1–65535). + Username is required. + Password is required. + Imap prefix can\'t be blank. + diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateEmailAddressTest.kt b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateEmailAddressTest.kt similarity index 86% rename from feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateEmailAddressTest.kt rename to feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateEmailAddressTest.kt index c00d35ed7..2549d11d1 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateEmailAddressTest.kt +++ b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateEmailAddressTest.kt @@ -1,7 +1,7 @@ -package app.k9mail.feature.account.setup.domain.usecase +package app.k9mail.feature.account.server.config.domain.usecase import app.k9mail.core.common.domain.usecase.validation.ValidationResult -import app.k9mail.feature.account.setup.domain.usecase.ValidateEmailAddress.ValidateEmailAddressError +import app.k9mail.feature.account.server.config.domain.usecase.ValidateEmailAddress.ValidateEmailAddressError import assertk.assertThat import assertk.assertions.isInstanceOf import assertk.assertions.prop diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateImapPrefixTest.kt b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateImapPrefixTest.kt similarity index 93% rename from feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateImapPrefixTest.kt rename to feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateImapPrefixTest.kt index 02cef9f34..7b209f526 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateImapPrefixTest.kt +++ b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateImapPrefixTest.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.setup.domain.usecase +package app.k9mail.feature.account.server.config.domain.usecase import app.k9mail.core.common.domain.usecase.validation.ValidationResult import assertk.assertThat diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidatePasswordTest.kt b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidatePasswordTest.kt similarity index 94% rename from feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidatePasswordTest.kt rename to feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidatePasswordTest.kt index 5f6b85e10..18f5fb6a2 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidatePasswordTest.kt +++ b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidatePasswordTest.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.setup.domain.usecase +package app.k9mail.feature.account.server.config.domain.usecase import app.k9mail.core.common.domain.usecase.validation.ValidationResult import assertk.assertThat diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidatePortTest.kt b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidatePortTest.kt similarity index 91% rename from feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidatePortTest.kt rename to feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidatePortTest.kt index ea3600dcf..450667556 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidatePortTest.kt +++ b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidatePortTest.kt @@ -1,7 +1,7 @@ -package app.k9mail.feature.account.setup.domain.usecase +package app.k9mail.feature.account.server.config.domain.usecase import app.k9mail.core.common.domain.usecase.validation.ValidationResult -import app.k9mail.feature.account.setup.domain.usecase.ValidatePort.ValidatePortError +import app.k9mail.feature.account.server.config.domain.usecase.ValidatePort.ValidatePortError import assertk.assertThat import assertk.assertions.isInstanceOf import assertk.assertions.prop diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateServerTest.kt b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateServerTest.kt similarity index 94% rename from feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateServerTest.kt rename to feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateServerTest.kt index c0278d489..ac51fc7d5 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateServerTest.kt +++ b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateServerTest.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.setup.domain.usecase +package app.k9mail.feature.account.server.config.domain.usecase import app.k9mail.core.common.domain.usecase.validation.ValidationResult import assertk.assertThat diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateUsernameTest.kt b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateUsernameTest.kt similarity index 94% rename from feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateUsernameTest.kt rename to feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateUsernameTest.kt index d9a26c467..4ac73fda0 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/domain/usecase/ValidateUsernameTest.kt +++ b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/domain/usecase/ValidateUsernameTest.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.setup.domain.usecase +package app.k9mail.feature.account.server.config.domain.usecase import app.k9mail.core.common.domain.usecase.validation.ValidationResult import assertk.assertThat diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigScreenKtTest.kt b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigScreenKtTest.kt similarity index 76% rename from feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigScreenKtTest.kt rename to feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigScreenKtTest.kt index 4525f2534..ac708f544 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigScreenKtTest.kt +++ b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigScreenKtTest.kt @@ -1,9 +1,10 @@ -package app.k9mail.feature.account.setup.ui.incoming +package app.k9mail.feature.account.server.config.ui.incoming import app.k9mail.core.ui.compose.testing.ComposeTest import app.k9mail.core.ui.compose.testing.setContent -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.Effect -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.State +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.Effect +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.State +import app.k9mail.feature.account.server.config.ui.incoming.fake.FakeAccountIncomingConfigViewModel import assertk.assertThat import assertk.assertions.isEqualTo import kotlinx.coroutines.test.runTest diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigStateMapperKtTest.kt b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigStateMapperKtTest.kt similarity index 95% rename from feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigStateMapperKtTest.kt rename to feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigStateMapperKtTest.kt index f56740d48..5d146b07d 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigStateMapperKtTest.kt +++ b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigStateMapperKtTest.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.setup.ui.incoming +package app.k9mail.feature.account.server.config.ui.incoming import app.k9mail.feature.account.common.domain.entity.AuthenticationType import app.k9mail.feature.account.common.domain.entity.ConnectionSecurity @@ -6,7 +6,7 @@ import app.k9mail.feature.account.common.domain.entity.IncomingProtocolType import app.k9mail.feature.account.common.domain.entity.MailConnectionSecurity import app.k9mail.feature.account.common.domain.input.NumberInputField import app.k9mail.feature.account.common.domain.input.StringInputField -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.State +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.State import assertk.assertThat import assertk.assertions.isEqualTo import com.fsck.k9.mail.AuthType diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigStateTest.kt b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigStateTest.kt similarity index 89% rename from feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigStateTest.kt rename to feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigStateTest.kt index 6a0519153..93d446045 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigStateTest.kt +++ b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigStateTest.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.setup.ui.incoming +package app.k9mail.feature.account.server.config.ui.incoming import app.k9mail.feature.account.common.domain.entity.AuthenticationType import app.k9mail.feature.account.common.domain.entity.ConnectionSecurity @@ -6,7 +6,7 @@ import app.k9mail.feature.account.common.domain.entity.IncomingProtocolType import app.k9mail.feature.account.common.domain.entity.toImapDefaultPort import app.k9mail.feature.account.common.domain.input.NumberInputField import app.k9mail.feature.account.common.domain.input.StringInputField -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.State +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.State import assertk.assertThat import assertk.assertions.isEqualTo import org.junit.Test diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigViewModelTest.kt b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigViewModelTest.kt similarity index 97% rename from feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigViewModelTest.kt rename to feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigViewModelTest.kt index d470f1284..74ec97317 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/incoming/AccountIncomingConfigViewModelTest.kt +++ b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/incoming/AccountIncomingConfigViewModelTest.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.setup.ui.incoming +package app.k9mail.feature.account.server.config.ui.incoming import app.k9mail.core.common.domain.usecase.validation.ValidationError import app.k9mail.core.common.domain.usecase.validation.ValidationResult @@ -18,9 +18,10 @@ import app.k9mail.feature.account.common.domain.entity.toImapDefaultPort import app.k9mail.feature.account.common.domain.entity.toPop3DefaultPort import app.k9mail.feature.account.common.domain.input.NumberInputField import app.k9mail.feature.account.common.domain.input.StringInputField -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.Effect -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.Event -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.State +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.Effect +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.Event +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract.State +import app.k9mail.feature.account.server.config.ui.incoming.fake.FakeAccountIncomingConfigValidator import assertk.assertThat import assertk.assertions.isEqualTo import com.fsck.k9.mail.AuthType diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigScreenKtTest.kt b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigScreenKtTest.kt similarity index 76% rename from feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigScreenKtTest.kt rename to feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigScreenKtTest.kt index 0de96e850..b2bf06990 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigScreenKtTest.kt +++ b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigScreenKtTest.kt @@ -1,9 +1,10 @@ -package app.k9mail.feature.account.setup.ui.outgoing +package app.k9mail.feature.account.server.config.ui.outgoing import app.k9mail.core.ui.compose.testing.ComposeTest import app.k9mail.core.ui.compose.testing.setContent -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.Effect -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.State +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.Effect +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.State +import app.k9mail.feature.account.server.config.ui.outgoing.fake.FakeAccountOutgoingConfigViewModel import assertk.assertThat import assertk.assertions.isEqualTo import kotlinx.coroutines.test.runTest diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigStateMapperKtTest.kt b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigStateMapperKtTest.kt similarity index 90% rename from feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigStateMapperKtTest.kt rename to feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigStateMapperKtTest.kt index a6394e6f8..f16773c9d 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigStateMapperKtTest.kt +++ b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigStateMapperKtTest.kt @@ -1,11 +1,11 @@ -package app.k9mail.feature.account.setup.ui.outgoing +package app.k9mail.feature.account.server.config.ui.outgoing import app.k9mail.feature.account.common.domain.entity.AuthenticationType import app.k9mail.feature.account.common.domain.entity.ConnectionSecurity import app.k9mail.feature.account.common.domain.entity.MailConnectionSecurity import app.k9mail.feature.account.common.domain.input.NumberInputField import app.k9mail.feature.account.common.domain.input.StringInputField -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.State +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.State import assertk.assertThat import assertk.assertions.isEqualTo import com.fsck.k9.mail.AuthType diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigStateTest.kt b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigStateTest.kt similarity index 87% rename from feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigStateTest.kt rename to feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigStateTest.kt index 0ae7ac7fa..6205639bf 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigStateTest.kt +++ b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigStateTest.kt @@ -1,11 +1,11 @@ -package app.k9mail.feature.account.setup.ui.outgoing +package app.k9mail.feature.account.server.config.ui.outgoing import app.k9mail.feature.account.common.domain.entity.AuthenticationType import app.k9mail.feature.account.common.domain.entity.ConnectionSecurity import app.k9mail.feature.account.common.domain.entity.toSmtpDefaultPort import app.k9mail.feature.account.common.domain.input.NumberInputField import app.k9mail.feature.account.common.domain.input.StringInputField -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.State +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.State import assertk.assertThat import assertk.assertions.isEqualTo import org.junit.Test diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigViewModelTest.kt b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigViewModelTest.kt similarity index 96% rename from feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigViewModelTest.kt rename to feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigViewModelTest.kt index 31c3f8fc4..4a38c3c31 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/outgoing/AccountOutgoingConfigViewModelTest.kt +++ b/feature/account/server/config/src/test/kotlin/app/k9mail/feature/account/server/config/ui/outgoing/AccountOutgoingConfigViewModelTest.kt @@ -1,4 +1,4 @@ -package app.k9mail.feature.account.setup.ui.outgoing +package app.k9mail.feature.account.server.config.ui.outgoing import app.k9mail.core.common.domain.usecase.validation.ValidationError import app.k9mail.core.common.domain.usecase.validation.ValidationResult @@ -16,9 +16,10 @@ import app.k9mail.feature.account.common.domain.entity.MailConnectionSecurity import app.k9mail.feature.account.common.domain.entity.toSmtpDefaultPort import app.k9mail.feature.account.common.domain.input.NumberInputField import app.k9mail.feature.account.common.domain.input.StringInputField -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.Effect -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.Event -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.State +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.Effect +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.Event +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract.State +import app.k9mail.feature.account.server.config.ui.outgoing.fake.FakeAccountOutgoingConfigValidator import assertk.assertThat import assertk.assertions.isEqualTo import com.fsck.k9.mail.AuthType diff --git a/feature/account/setup/build.gradle.kts b/feature/account/setup/build.gradle.kts index 697507561..659472c30 100644 --- a/feature/account/setup/build.gradle.kts +++ b/feature/account/setup/build.gradle.kts @@ -29,6 +29,7 @@ dependencies { api(projects.feature.account.common) implementation(projects.feature.account.oauth) + implementation(projects.feature.account.server.config) implementation(projects.feature.account.server.certificate) api(projects.feature.account.server.validation) diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/AccountSetupModule.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/AccountSetupModule.kt index 7dfbce699..6a2aee0c0 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/AccountSetupModule.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/AccountSetupModule.kt @@ -4,6 +4,7 @@ import app.k9mail.autodiscovery.api.AutoDiscoveryService import app.k9mail.autodiscovery.service.RealAutoDiscoveryService import app.k9mail.feature.account.common.featureAccountCommonModule import app.k9mail.feature.account.oauth.featureAccountOAuthModule +import app.k9mail.feature.account.server.config.featureAccountServerConfigModule import app.k9mail.feature.account.server.validation.featureAccountServerValidationModule import app.k9mail.feature.account.setup.domain.DomainContract import app.k9mail.feature.account.setup.domain.usecase.CreateAccount @@ -12,15 +13,9 @@ import app.k9mail.feature.account.setup.ui.AccountSetupViewModel import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryValidator import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryViewModel -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigValidator -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigViewModel import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract import app.k9mail.feature.account.setup.ui.options.AccountOptionsValidator import app.k9mail.feature.account.setup.ui.options.AccountOptionsViewModel -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigValidator -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigViewModel import okhttp3.OkHttpClient import org.koin.androidx.viewmodel.dsl.viewModel import org.koin.core.module.Module @@ -31,6 +26,7 @@ val featureAccountSetupModule: Module = module { featureAccountCommonModule, featureAccountOAuthModule, featureAccountServerValidationModule, + featureAccountServerConfigModule, ) single { @@ -57,8 +53,6 @@ val featureAccountSetupModule: Module = module { } factory { AccountAutoDiscoveryValidator() } - factory { AccountIncomingConfigValidator() } - factory { AccountOutgoingConfigValidator() } factory { AccountOptionsValidator() } viewModel { @@ -75,19 +69,6 @@ val featureAccountSetupModule: Module = module { oAuthViewModel = get(), ) } - viewModel { - AccountIncomingConfigViewModel( - validator = get(), - accountStateRepository = get(), - ) - } - - viewModel { - AccountOutgoingConfigViewModel( - validator = get(), - accountStateRepository = get(), - ) - } viewModel { AccountOptionsViewModel( diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/DomainContract.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/DomainContract.kt index f7d06c3bc..1e49c57d7 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/DomainContract.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/DomainContract.kt @@ -4,7 +4,6 @@ import app.k9mail.autodiscovery.api.AutoDiscoveryResult import app.k9mail.core.common.domain.usecase.validation.ValidationResult import app.k9mail.feature.account.common.domain.entity.AccountOptions import com.fsck.k9.mail.ServerSettings -import java.security.cert.X509Certificate interface DomainContract { @@ -13,10 +12,6 @@ interface DomainContract { suspend fun execute(emailAddress: String): AutoDiscoveryResult } - fun interface AddServerCertificateException { - suspend fun addCertificate(hostname: String, port: Int, certificate: X509Certificate?) - } - fun interface CreateAccount { suspend fun execute( emailAddress: String, @@ -27,34 +22,10 @@ interface DomainContract { ): String } - fun interface ValidateEmailAddress { - fun execute(emailAddress: String): ValidationResult - } - - fun interface ValidatePassword { - fun execute(password: String): ValidationResult - } - fun interface ValidateConfigurationApproval { fun execute(isApproved: Boolean?, isAutoDiscoveryTrusted: Boolean?): ValidationResult } - fun interface ValidateServer { - fun execute(server: String): ValidationResult - } - - fun interface ValidatePort { - fun execute(port: Long?): ValidationResult - } - - fun interface ValidateUsername { - fun execute(username: String): ValidationResult - } - - fun interface ValidateImapPrefix { - fun execute(imapPrefix: String): ValidationResult - } - fun interface ValidateAccountName { fun execute(accountName: String): ValidationResult } diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/AccountSetupScreen.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/AccountSetupScreen.kt index b9dd2513d..d2f9cc155 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/AccountSetupScreen.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/AccountSetupScreen.kt @@ -3,6 +3,12 @@ package app.k9mail.feature.account.setup.ui import androidx.compose.runtime.Composable import androidx.compose.ui.tooling.preview.Preview import app.k9mail.core.ui.compose.common.mvi.observe +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigScreen +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigViewModel +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigScreen +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigViewModel import app.k9mail.feature.account.server.validation.KOIN_NAME_INCOMING_SERVER_VALIDATION import app.k9mail.feature.account.server.validation.KOIN_NAME_OUTGOING_SERVER_VALIDATION import app.k9mail.feature.account.server.validation.ui.ServerValidationContract @@ -15,15 +21,9 @@ import app.k9mail.feature.account.setup.ui.AccountSetupContract.ViewModel import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryScreen import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryViewModel -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigScreen -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigViewModel import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract import app.k9mail.feature.account.setup.ui.options.AccountOptionsScreen import app.k9mail.feature.account.setup.ui.options.AccountOptionsViewModel -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigScreen -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigViewModel import org.koin.androidx.compose.koinViewModel import org.koin.core.qualifier.named diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryContent.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryContent.kt index a0dd9b217..0b515289f 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryContent.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryContent.kt @@ -53,13 +53,13 @@ internal fun AccountAutoDiscoveryContent( if (state.isLoading) { item(key = "loading") { LoadingItem( - message = stringResource(id = R.string.account_setup_auto_config_loading_message), + message = stringResource(id = R.string.account_setup_auto_discovery_loading_message), ) } } else if (state.error != null) { item(key = "error") { ErrorItem( - title = stringResource(id = R.string.account_setup_auto_config_loading_error), + title = stringResource(id = R.string.account_setup_auto_discovery_loading_error), message = state.error.toResourceString(resources), onRetry = { onEvent(Event.OnRetryClicked) }, ) diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryStateMapper.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryStateMapper.kt index 5cea5b8cd..76f159984 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryStateMapper.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryStateMapper.kt @@ -5,13 +5,13 @@ import app.k9mail.autodiscovery.api.SmtpServerSettings import app.k9mail.feature.account.common.domain.entity.AccountState import app.k9mail.feature.account.common.domain.input.NumberInputField import app.k9mail.feature.account.common.domain.input.StringInputField +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract import app.k9mail.feature.account.setup.domain.entity.toAuthenticationType import app.k9mail.feature.account.setup.domain.entity.toConnectionSecurity import app.k9mail.feature.account.setup.domain.entity.toIncomingProtocolType import app.k9mail.feature.account.setup.domain.toServerSettings -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract internal fun AccountAutoDiscoveryContract.State.toAccountState(): AccountState { return AccountState( diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryValidator.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryValidator.kt index 2ae80059e..a6b8ca3e6 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryValidator.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryValidator.kt @@ -1,14 +1,15 @@ package app.k9mail.feature.account.setup.ui.autodiscovery import app.k9mail.core.common.domain.usecase.validation.ValidationResult +import app.k9mail.feature.account.server.config.domain.ServerConfigDomainContract +import app.k9mail.feature.account.server.config.domain.usecase.ValidateEmailAddress +import app.k9mail.feature.account.server.config.domain.usecase.ValidatePassword import app.k9mail.feature.account.setup.domain.DomainContract.UseCase import app.k9mail.feature.account.setup.domain.usecase.ValidateConfigurationApproval -import app.k9mail.feature.account.setup.domain.usecase.ValidateEmailAddress -import app.k9mail.feature.account.setup.domain.usecase.ValidatePassword internal class AccountAutoDiscoveryValidator( - private val emailAddressValidator: UseCase.ValidateEmailAddress = ValidateEmailAddress(), - private val passwordValidator: UseCase.ValidatePassword = ValidatePassword(), + private val emailAddressValidator: ServerConfigDomainContract.UseCase.ValidateEmailAddress = ValidateEmailAddress(), + private val passwordValidator: ServerConfigDomainContract.UseCase.ValidatePassword = ValidatePassword(), private val configurationApprovalValidator: UseCase.ValidateConfigurationApproval = ValidateConfigurationApproval(), ) : AccountAutoDiscoveryContract.Validator { diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AutoDiscoveryStringMapper.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AutoDiscoveryStringMapper.kt index 19d8749ce..33823b6c4 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AutoDiscoveryStringMapper.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AutoDiscoveryStringMapper.kt @@ -9,11 +9,11 @@ import app.k9mail.feature.account.setup.domain.usecase.ValidateConfigurationAppr internal fun AutoDiscoveryConnectionSecurity.toResourceString(resources: Resources): String { return when (this) { AutoDiscoveryConnectionSecurity.StartTLS -> resources.getString( - R.string.account_setup_connection_security_start_tls, + R.string.account_setup_auto_discovery_connection_security_start_tls, ) AutoDiscoveryConnectionSecurity.TLS -> resources.getString( - R.string.account_setup_connection_security_ssl, + R.string.account_setup_auto_discovery_connection_security_ssl, ) } } @@ -40,7 +40,7 @@ private fun ValidateConfigurationApproval.ValidateConfigurationApprovalError.toC ): String { return when (this) { ValidateConfigurationApproval.ValidateConfigurationApprovalError.ApprovalRequired -> resources.getString( - R.string.account_setup_error_configuration_approval_required, + R.string.account_setup_auto_discovery_error_configuration_approval_required, ) } } diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/item/EmailAddressItem.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/item/EmailAddressItem.kt index 6e4d13b58..de73de106 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/item/EmailAddressItem.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/item/EmailAddressItem.kt @@ -8,7 +8,7 @@ import androidx.compose.ui.platform.LocalContext import app.k9mail.core.common.domain.usecase.validation.ValidationError import app.k9mail.core.ui.compose.designsystem.molecule.input.EmailAddressInput import app.k9mail.feature.account.common.ui.item.ListItem -import app.k9mail.feature.account.setup.ui.common.toResourceString +import app.k9mail.feature.account.server.config.ui.common.mapper.toResourceString @Composable internal fun LazyItemScope.EmailAddressItem( diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/item/PasswordItem.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/item/PasswordItem.kt index a606f9d48..6e613e2f3 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/item/PasswordItem.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/item/PasswordItem.kt @@ -8,7 +8,7 @@ import androidx.compose.ui.platform.LocalContext import app.k9mail.core.common.domain.usecase.validation.ValidationError import app.k9mail.core.ui.compose.designsystem.molecule.input.PasswordInput import app.k9mail.feature.account.common.ui.item.ListItem -import app.k9mail.feature.account.setup.ui.common.toResourceString +import app.k9mail.feature.account.server.config.ui.common.mapper.toResourceString @Composable internal fun LazyItemScope.PasswordItem( diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryServerSettingsView.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryServerSettingsView.kt index d20b0748f..9a86dc34d 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryServerSettingsView.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryServerSettingsView.kt @@ -27,7 +27,6 @@ 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.common.toResourceString @Composable internal fun AutoDiscoveryServerSettingsView( diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryStatusBodyView.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryStatusBodyView.kt index a037618f5..9f9377ee2 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryStatusBodyView.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryStatusBodyView.kt @@ -42,7 +42,7 @@ internal fun AutoDiscoveryStatusBodyView( Spacer(modifier = Modifier.height(MainTheme.sizes.smaller)) TextBody2( text = stringResource( - id = R.string.account_setup_auto_config_status_disclaimer_untrusted_configuration, + id = R.string.account_setup_auto_discovery_status_disclaimer_untrusted_configuration, ), modifier = Modifier.fillMaxWidth(), ) @@ -94,7 +94,7 @@ internal fun EditConfigurationButton( .then(modifier), ) { ButtonText( - text = stringResource(id = R.string.account_setup_auto_config_status_edit_configuration_button_label), + text = stringResource(id = R.string.account_setup_auto_discovery_status_edit_configuration_button_label), onClick = onEditConfigurationClick, color = MainTheme.colors.warning, contentPadding = buttonContentPadding( diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryStatusHeaderState.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryStatusHeaderState.kt index de36f44fc..54a727234 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryStatusHeaderState.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/AutoDiscoveryStatusHeaderState.kt @@ -13,22 +13,22 @@ enum class AutoDiscoveryStatusHeaderState( ) { NoSettings( icon = Icons.Outlined.info, - titleResourceId = R.string.account_setup_auto_config_status_header_title_configuration_not_found, - subtitleResourceId = R.string.account_setup_auto_config_status_header_subtitle_configuration_not_found, + titleResourceId = R.string.account_setup_auto_discovery_status_header_title_configuration_not_found, + subtitleResourceId = R.string.account_setup_auto_discovery_status_header_subtitle_configuration_not_found, isExpandable = false, ), Trusted( icon = Icons.Outlined.check, - titleResourceId = R.string.account_setup_auto_config_status_header_title_configuration_found, - subtitleResourceId = R.string.account_setup_auto_config_status_header_subtitle_configuration_trusted, + titleResourceId = R.string.account_setup_auto_discovery_status_header_title_configuration_found, + subtitleResourceId = R.string.account_setup_auto_discovery_status_header_subtitle_configuration_trusted, isExpandable = true, ), Untrusted( icon = Icons.Outlined.info, - titleResourceId = R.string.account_setup_auto_config_status_header_title_configuration_found, - subtitleResourceId = R.string.account_setup_auto_config_status_header_subtitle_configuration_untrusted, + titleResourceId = R.string.account_setup_auto_discovery_status_header_title_configuration_found, + subtitleResourceId = R.string.account_setup_auto_discovery_status_header_subtitle_configuration_untrusted, isExpandable = true, ), } diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/ConfigurationApprovalView.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/ConfigurationApprovalView.kt index 26e0ad170..1857ea4c4 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/ConfigurationApprovalView.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/view/ConfigurationApprovalView.kt @@ -24,7 +24,7 @@ internal fun ConfigurationApprovalView( CheckboxInput( text = stringResource( - id = R.string.account_setup_auto_config_status_checkbox_configuration_untrusted_confirmation_label, + id = R.string.account_setup_auto_discovery_status_checkbox_configuration_untrusted_confirmation_label, ), checked = approvalState.value ?: false, onCheckedChange = onConfigurationApprovalChange, diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/common/mapper/AuthenticationTypeStringMapper.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/common/mapper/AuthenticationTypeStringMapper.kt deleted file mode 100644 index 5ec5ebebe..000000000 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/common/mapper/AuthenticationTypeStringMapper.kt +++ /dev/null @@ -1,25 +0,0 @@ -package app.k9mail.feature.account.setup.ui.common.mapper - -import android.content.res.Resources -import app.k9mail.feature.account.common.domain.entity.AuthenticationType -import app.k9mail.feature.account.setup.R - -internal fun AuthenticationType.toResourceString(resources: Resources): String { - return when (this) { - AuthenticationType.None -> { - resources.getString(R.string.account_setup_authentication_none) - } - AuthenticationType.PasswordCleartext -> { - resources.getString(R.string.account_setup_authentication_password_cleartext) - } - AuthenticationType.PasswordEncrypted -> { - resources.getString(R.string.account_setup_authentication_password_encrypted) - } - AuthenticationType.ClientCertificate -> { - resources.getString(R.string.account_setup_authentication_client_certificate) - } - AuthenticationType.OAuth2 -> { - resources.getString(R.string.account_setup_authentication_client_oauth) - } - } -} diff --git a/feature/account/setup/src/main/res/values/strings.xml b/feature/account/setup/src/main/res/values/strings.xml index 19e84d79c..21cc78004 100644 --- a/feature/account/setup/src/main/res/values/strings.xml +++ b/feature/account/setup/src/main/res/values/strings.xml @@ -2,57 +2,23 @@ K-9 Mail Finish - None - SSL/TLS - StartTLS - None - Normal password - Encrypted password - Client certificate - OAuth 2.0 - Client certificate - None Network Unknown error - Email address is required. - Email address is invalid. - Server name is required. - Port is required. - Port is invalid (must be 1–65535). - Username is required. - Password is required. - Imap prefix can\'t be blank. - - Finding email details - Failed to load email configuration - Configuration Found - Configuration Not Found - Configure automatically - This configuration is not trusted - We received the configuration for your email server over a connection that isn\'t as secure as we\'d like. This means that there is a tiny chance that someone could have altered it. Could you please double-check the provided configuration to make sure it\'s as it should be? - Configure manually - Edit configuration - I trust this configuration - It is required to approve the configuration. - - Incoming server settings - Protocol - Server - Security - Authentication - Auto-detect IMAP namespace - IMAP path prefix - Use compression - Send client ID - - Outgoing server settings - Server - Security - Port - Authentication - Username + StartTLS + SSL/TLS + Finding email details + Failed to load email configuration + Configuration Found + Configuration Not Found + Configure automatically + This configuration is not trusted + We received the configuration for your email server over a connection that isn\'t as secure as we\'d like. This means that there is a tiny chance that someone could have altered it. Could you please double-check the provided configuration to make sure it\'s as it should be? + Configure manually + Edit configuration + I trust this configuration + It is required to approve the configuration. Account options Display options diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/AccountSetupModuleKtTest.kt b/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/AccountSetupModuleKtTest.kt index da60b4251..c568c561f 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/AccountSetupModuleKtTest.kt +++ b/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/AccountSetupModuleKtTest.kt @@ -5,14 +5,14 @@ import app.k9mail.core.common.oauth.OAuthConfigurationFactory import app.k9mail.feature.account.common.domain.entity.AccountState import app.k9mail.feature.account.oauth.ui.AccountOAuthContract import app.k9mail.feature.account.server.certificate.ui.ServerCertificateErrorContract +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract import app.k9mail.feature.account.server.validation.ui.ServerValidationContract import app.k9mail.feature.account.setup.AccountSetupExternalContract.AccountCreator import app.k9mail.feature.account.setup.AccountSetupExternalContract.AccountCreator.AccountCreatorResult import app.k9mail.feature.account.setup.ui.AccountSetupContract import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract import com.fsck.k9.mail.oauth.AuthStateStorage import com.fsck.k9.mail.oauth.OAuth2TokenProvider import com.fsck.k9.mail.oauth.OAuth2TokenProviderFactory diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/AccountSetupScreenKtTest.kt b/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/AccountSetupScreenKtTest.kt index 2226f350d..0c1ddb272 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/AccountSetupScreenKtTest.kt +++ b/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/AccountSetupScreenKtTest.kt @@ -4,14 +4,14 @@ import app.k9mail.core.ui.compose.testing.ComposeTest import app.k9mail.core.ui.compose.testing.onNodeWithTag import app.k9mail.core.ui.compose.testing.setContent import app.k9mail.core.ui.compose.theme.ThunderbirdTheme +import app.k9mail.feature.account.server.config.ui.incoming.fake.FakeAccountIncomingConfigViewModel +import app.k9mail.feature.account.server.config.ui.outgoing.fake.FakeAccountOutgoingConfigViewModel import app.k9mail.feature.account.server.validation.ui.fake.FakeServerValidationViewModel import app.k9mail.feature.account.setup.ui.AccountSetupContract.Effect import app.k9mail.feature.account.setup.ui.AccountSetupContract.SetupStep import app.k9mail.feature.account.setup.ui.AccountSetupContract.State import app.k9mail.feature.account.setup.ui.autodiscovery.FakeAccountAutoDiscoveryViewModel -import app.k9mail.feature.account.setup.ui.incoming.FakeAccountIncomingConfigViewModel import app.k9mail.feature.account.setup.ui.options.FakeAccountOptionsViewModel -import app.k9mail.feature.account.setup.ui.outgoing.FakeAccountOutgoingConfigViewModel import assertk.assertThat import assertk.assertions.isEqualTo import kotlinx.coroutines.test.runTest diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryStateMapperKtTest.kt b/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryStateMapperKtTest.kt index 0f144be8a..4e668b736 100644 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryStateMapperKtTest.kt +++ b/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/autodiscovery/AccountAutoDiscoveryStateMapperKtTest.kt @@ -10,12 +10,12 @@ import app.k9mail.feature.account.common.domain.entity.AuthenticationType import app.k9mail.feature.account.common.domain.entity.IncomingProtocolType import app.k9mail.feature.account.common.domain.input.NumberInputField import app.k9mail.feature.account.common.domain.input.StringInputField +import app.k9mail.feature.account.server.config.ui.incoming.AccountIncomingConfigContract +import app.k9mail.feature.account.server.config.ui.outgoing.AccountOutgoingConfigContract import app.k9mail.feature.account.setup.domain.entity.AutoDiscoveryAuthenticationType import app.k9mail.feature.account.setup.domain.entity.AutoDiscoveryConnectionSecurity import app.k9mail.feature.account.setup.domain.entity.toConnectionSecurity -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract import assertk.assertThat import assertk.assertions.isEqualTo import org.junit.Test diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/incoming/FakeAccountIncomingConfigViewModel.kt b/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/incoming/FakeAccountIncomingConfigViewModel.kt deleted file mode 100644 index 3fda4d2e7..000000000 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/incoming/FakeAccountIncomingConfigViewModel.kt +++ /dev/null @@ -1,22 +0,0 @@ -package app.k9mail.feature.account.setup.ui.incoming - -import app.k9mail.core.ui.compose.common.mvi.BaseViewModel -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.Effect -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.Event -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.State -import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.ViewModel - -class FakeAccountIncomingConfigViewModel( - initialState: State = State(), -) : BaseViewModel(initialState), ViewModel { - - val events = mutableListOf() - - override fun event(event: Event) { - events.add(event) - } - - fun effect(effect: Effect) { - emitEffect(effect) - } -} diff --git a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/outgoing/FakeAccountOutgoingConfigViewModel.kt b/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/outgoing/FakeAccountOutgoingConfigViewModel.kt deleted file mode 100644 index 0c2838600..000000000 --- a/feature/account/setup/src/test/kotlin/app/k9mail/feature/account/setup/ui/outgoing/FakeAccountOutgoingConfigViewModel.kt +++ /dev/null @@ -1,22 +0,0 @@ -package app.k9mail.feature.account.setup.ui.outgoing - -import app.k9mail.core.ui.compose.common.mvi.BaseViewModel -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.Effect -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.Event -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.State -import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.ViewModel - -class FakeAccountOutgoingConfigViewModel( - initialState: State = State(), -) : BaseViewModel(initialState), ViewModel { - - val events = mutableListOf() - - override fun event(event: Event) { - events.add(event) - } - - fun effect(effect: Effect) { - emitEffect(effect) - } -} diff --git a/settings.gradle.kts b/settings.gradle.kts index 4c7e49384..63a7f0fb6 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -48,6 +48,7 @@ include( ":feature:account:oauth", ":feature:account:setup", ":feature:account:server:certificate", + ":feature:account:server:config", ":feature:account:server:validation", )