Loading legacy/common/src/main/java/com/fsck/k9/account/AccountCreator.kt +2 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ class AccountCreator( private val preferences: Preferences, private val context: Context, private val messagingController: MessagingController, private val deletePolicyProvider: DeletePolicyProvider, private val coroutineDispatcher: CoroutineDispatcher = Dispatchers.IO, ) : AccountSetupExternalContract.AccountCreator { Loading Loading @@ -67,7 +68,7 @@ class AccountCreator( newAccount.automaticCheckIntervalMinutes = account.options.checkFrequencyInMinutes newAccount.displayCount = account.options.messageDisplayCount newAccount.deletePolicy = DeletePolicyHelper.getDefaultDeletePolicy(newAccount.incomingServerSettings.type) newAccount.deletePolicy = deletePolicyProvider.getDeletePolicy(newAccount.incomingServerSettings.type) newAccount.chipColor = accountColorPicker.pickColor() localFoldersCreator.createSpecialLocalFolders(newAccount) Loading legacy/common/src/main/java/com/fsck/k9/account/AccountModule.kt +3 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ val newAccountModule = module { localFoldersCreator = get(), preferences = get(), context = androidApplication(), deletePolicyProvider = get(), messagingController = get(), ) } Loading @@ -50,4 +51,6 @@ val newAccountModule = module { messagingController = get(), ) } factory<DeletePolicyProvider> { DefaultDeletePolicyProvider() } } legacy/common/src/main/java/com/fsck/k9/account/DefaultDeletePolicyProvider.kt 0 → 100644 +15 −0 Original line number Diff line number Diff line package com.fsck.k9.account import app.k9mail.core.common.mail.Protocols import app.k9mail.legacy.account.Account.DeletePolicy class DefaultDeletePolicyProvider : DeletePolicyProvider { override fun getDeletePolicy(accountType: String): DeletePolicy { return when (accountType) { Protocols.IMAP -> DeletePolicy.ON_DELETE Protocols.POP3 -> DeletePolicy.NEVER "demo" -> DeletePolicy.ON_DELETE else -> throw AssertionError("Unhandled case: $accountType") } } } legacy/common/src/main/java/com/fsck/k9/account/DeletePolicyHelper.ktdeleted 100644 → 0 +0 −15 Original line number Diff line number Diff line package com.fsck.k9.account import app.k9mail.core.common.mail.Protocols import app.k9mail.legacy.account.Account object DeletePolicyHelper { fun getDefaultDeletePolicy(type: String): Account.DeletePolicy { return when (type) { Protocols.IMAP -> Account.DeletePolicy.ON_DELETE Protocols.POP3 -> Account.DeletePolicy.NEVER "demo" -> Account.DeletePolicy.ON_DELETE else -> throw AssertionError("Unhandled case: $type") } } } legacy/common/src/main/java/com/fsck/k9/account/DeletePolicyProvider.kt 0 → 100644 +16 −0 Original line number Diff line number Diff line package com.fsck.k9.account import app.k9mail.core.common.mail.Protocols import app.k9mail.legacy.account.Account.DeletePolicy /** * Decides which [DeletePolicy] an account uses by default. */ interface DeletePolicyProvider { /** * Returns the [DeletePolicy] an account of type [accountType] should use by default. * * @param accountType The protocol identifier of the incoming server of an account. See [Protocols]. */ fun getDeletePolicy(accountType: String): DeletePolicy } Loading
legacy/common/src/main/java/com/fsck/k9/account/AccountCreator.kt +2 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ class AccountCreator( private val preferences: Preferences, private val context: Context, private val messagingController: MessagingController, private val deletePolicyProvider: DeletePolicyProvider, private val coroutineDispatcher: CoroutineDispatcher = Dispatchers.IO, ) : AccountSetupExternalContract.AccountCreator { Loading Loading @@ -67,7 +68,7 @@ class AccountCreator( newAccount.automaticCheckIntervalMinutes = account.options.checkFrequencyInMinutes newAccount.displayCount = account.options.messageDisplayCount newAccount.deletePolicy = DeletePolicyHelper.getDefaultDeletePolicy(newAccount.incomingServerSettings.type) newAccount.deletePolicy = deletePolicyProvider.getDeletePolicy(newAccount.incomingServerSettings.type) newAccount.chipColor = accountColorPicker.pickColor() localFoldersCreator.createSpecialLocalFolders(newAccount) Loading
legacy/common/src/main/java/com/fsck/k9/account/AccountModule.kt +3 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ val newAccountModule = module { localFoldersCreator = get(), preferences = get(), context = androidApplication(), deletePolicyProvider = get(), messagingController = get(), ) } Loading @@ -50,4 +51,6 @@ val newAccountModule = module { messagingController = get(), ) } factory<DeletePolicyProvider> { DefaultDeletePolicyProvider() } }
legacy/common/src/main/java/com/fsck/k9/account/DefaultDeletePolicyProvider.kt 0 → 100644 +15 −0 Original line number Diff line number Diff line package com.fsck.k9.account import app.k9mail.core.common.mail.Protocols import app.k9mail.legacy.account.Account.DeletePolicy class DefaultDeletePolicyProvider : DeletePolicyProvider { override fun getDeletePolicy(accountType: String): DeletePolicy { return when (accountType) { Protocols.IMAP -> DeletePolicy.ON_DELETE Protocols.POP3 -> DeletePolicy.NEVER "demo" -> DeletePolicy.ON_DELETE else -> throw AssertionError("Unhandled case: $accountType") } } }
legacy/common/src/main/java/com/fsck/k9/account/DeletePolicyHelper.ktdeleted 100644 → 0 +0 −15 Original line number Diff line number Diff line package com.fsck.k9.account import app.k9mail.core.common.mail.Protocols import app.k9mail.legacy.account.Account object DeletePolicyHelper { fun getDefaultDeletePolicy(type: String): Account.DeletePolicy { return when (type) { Protocols.IMAP -> Account.DeletePolicy.ON_DELETE Protocols.POP3 -> Account.DeletePolicy.NEVER "demo" -> Account.DeletePolicy.ON_DELETE else -> throw AssertionError("Unhandled case: $type") } } }
legacy/common/src/main/java/com/fsck/k9/account/DeletePolicyProvider.kt 0 → 100644 +16 −0 Original line number Diff line number Diff line package com.fsck.k9.account import app.k9mail.core.common.mail.Protocols import app.k9mail.legacy.account.Account.DeletePolicy /** * Decides which [DeletePolicy] an account uses by default. */ interface DeletePolicyProvider { /** * Returns the [DeletePolicy] an account of type [accountType] should use by default. * * @param accountType The protocol identifier of the incoming server of an account. See [Protocols]. */ fun getDeletePolicy(accountType: String): DeletePolicy }