Don't show OAuth 2.0 option for POP3 accounts
This commit is contained in:
parent
0f6a50df73
commit
37ea82bd8f
4 changed files with 41 additions and 9 deletions
|
@ -27,13 +27,6 @@ enum class AuthenticationType(
|
|||
val DEFAULT = PasswordCleartext
|
||||
fun all() = values().toList().toImmutableList()
|
||||
|
||||
fun incoming() = listOf(
|
||||
PasswordCleartext,
|
||||
PasswordEncrypted,
|
||||
ClientCertificate,
|
||||
OAuth2,
|
||||
).toImmutableList()
|
||||
|
||||
fun outgoing() = all()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import app.k9mail.core.ui.compose.theme.K9Theme
|
|||
import app.k9mail.core.ui.compose.theme.MainTheme
|
||||
import app.k9mail.core.ui.compose.theme.ThunderbirdTheme
|
||||
import app.k9mail.feature.account.setup.R
|
||||
import app.k9mail.feature.account.setup.domain.entity.AuthenticationType
|
||||
import app.k9mail.feature.account.setup.domain.entity.ConnectionSecurity
|
||||
import app.k9mail.feature.account.setup.domain.entity.IncomingProtocolType
|
||||
import app.k9mail.feature.account.setup.ui.common.item.ErrorItem
|
||||
|
@ -136,7 +135,7 @@ internal fun AccountIncomingConfigContent(
|
|||
|
||||
item {
|
||||
SelectInput(
|
||||
options = AuthenticationType.incoming(),
|
||||
options = state.allowedAuthenticationTypes,
|
||||
optionToStringTransformation = { it.toResourceString(resources) },
|
||||
selectedOption = state.authenticationType,
|
||||
onOptionChange = { onEvent(Event.AuthenticationTypeChanged(it)) },
|
||||
|
|
|
@ -1,4 +1,36 @@
|
|||
package app.k9mail.feature.account.setup.ui.incoming
|
||||
|
||||
import app.k9mail.feature.account.setup.domain.entity.AuthenticationType
|
||||
import app.k9mail.feature.account.setup.domain.entity.AuthenticationType.ClientCertificate
|
||||
import app.k9mail.feature.account.setup.domain.entity.AuthenticationType.OAuth2
|
||||
import app.k9mail.feature.account.setup.domain.entity.AuthenticationType.PasswordCleartext
|
||||
import app.k9mail.feature.account.setup.domain.entity.AuthenticationType.PasswordEncrypted
|
||||
import app.k9mail.feature.account.setup.domain.entity.IncomingProtocolType
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
internal val AccountIncomingConfigContract.State.isPasswordFieldVisible: Boolean
|
||||
get() = authenticationType.isPasswordRequired
|
||||
|
||||
internal val AccountIncomingConfigContract.State.allowedAuthenticationTypes: ImmutableList<AuthenticationType>
|
||||
get() = protocolType.allowedAuthenticationTypes.toImmutableList()
|
||||
|
||||
internal val IncomingProtocolType.allowedAuthenticationTypes: List<AuthenticationType>
|
||||
get() = when (this) {
|
||||
IncomingProtocolType.IMAP -> {
|
||||
listOf(
|
||||
PasswordCleartext,
|
||||
PasswordEncrypted,
|
||||
ClientCertificate,
|
||||
OAuth2,
|
||||
)
|
||||
}
|
||||
|
||||
IncomingProtocolType.POP3 -> {
|
||||
listOf(
|
||||
PasswordCleartext,
|
||||
PasswordEncrypted,
|
||||
ClientCertificate,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,12 +69,20 @@ internal class AccountIncomingConfigViewModel(
|
|||
|
||||
private fun updateProtocolType(protocolType: IncomingProtocolType) {
|
||||
updateState {
|
||||
val allowedAuthenticationTypesForNewProtocol = protocolType.allowedAuthenticationTypes
|
||||
val newAuthenticationType = if (it.authenticationType in allowedAuthenticationTypesForNewProtocol) {
|
||||
it.authenticationType
|
||||
} else {
|
||||
allowedAuthenticationTypesForNewProtocol.first()
|
||||
}
|
||||
|
||||
it.copy(
|
||||
protocolType = protocolType,
|
||||
security = protocolType.defaultConnectionSecurity,
|
||||
port = it.port.updateValue(
|
||||
protocolType.toDefaultPort(protocolType.defaultConnectionSecurity),
|
||||
),
|
||||
authenticationType = newAuthenticationType,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue