Loading .idea/codeStyles/Project.xml +1 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ <option name="INSERT_INNER_CLASS_IMPORTS" value="true" /> <option name="IMPORT_LAYOUT_TABLE"> <value> <package name="" withSubpackages="true" static="false" module="true" /> <package name="java" withSubpackages="true" static="false" /> <emptyLine /> <package name="android" withSubpackages="true" static="false" /> Loading app-common/build.gradle.kts +2 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,8 @@ android { dependencies { api(projects.legacy.common) implementation(projects.feature.account.core) implementation(projects.legacy.core) implementation(projects.legacy.account) Loading app-common/src/main/kotlin/net/thunderbird/app/common/AppCommonModule.kt +21 −0 Original line number Diff line number Diff line package net.thunderbird.app.common import app.k9mail.legacy.account.AccountDefaultsProvider import app.k9mail.legacy.account.LegacyAccountWrapperManager import net.thunderbird.app.common.account.CommonAccountDefaultsProvider import net.thunderbird.app.common.account.data.CommonAccountProfileLocalDataSource import net.thunderbird.app.common.account.data.CommonLegacyAccountWrapperManager import net.thunderbird.feature.account.core.AccountCoreExternalContract.AccountProfileLocalDataSource import net.thunderbird.feature.account.core.featureAccountCoreModule import org.koin.core.module.Module import org.koin.dsl.module val appCommonModule: Module = module { includes( featureAccountCoreModule, ) single<LegacyAccountWrapperManager> { CommonLegacyAccountWrapperManager( accountManager = get(), ) } single<AccountProfileLocalDataSource> { CommonAccountProfileLocalDataSource( accountManager = get(), ) } single<AccountDefaultsProvider> { CommonAccountDefaultsProvider( resourceProvider = get(), Loading app-common/src/main/kotlin/net/thunderbird/app/common/account/CommonAccountDefaultsProvider.kt +8 −8 Original line number Diff line number Diff line Loading @@ -2,11 +2,6 @@ package net.thunderbird.app.common.account import app.k9mail.core.featureflag.FeatureFlagProvider import app.k9mail.core.featureflag.toFeatureFlagKey import app.k9mail.legacy.account.Account import app.k9mail.legacy.account.Account.Expunge import app.k9mail.legacy.account.Account.FolderMode import app.k9mail.legacy.account.Account.ShowPictures import app.k9mail.legacy.account.Account.SpecialFolderSelection import app.k9mail.legacy.account.AccountDefaultsProvider import app.k9mail.legacy.account.AccountDefaultsProvider.Companion.DEFAULT_MAXIMUM_AUTO_DOWNLOAD_MESSAGE_SIZE import app.k9mail.legacy.account.AccountDefaultsProvider.Companion.DEFAULT_MESSAGE_FORMAT Loading @@ -24,7 +19,12 @@ import app.k9mail.legacy.account.AccountDefaultsProvider.Companion.DEFAULT_STRIP import app.k9mail.legacy.account.AccountDefaultsProvider.Companion.DEFAULT_SYNC_INTERVAL import app.k9mail.legacy.account.AccountDefaultsProvider.Companion.NO_OPENPGP_KEY import app.k9mail.legacy.account.AccountDefaultsProvider.Companion.UNASSIGNED_ACCOUNT_NUMBER import app.k9mail.legacy.account.Expunge import app.k9mail.legacy.account.FolderMode import app.k9mail.legacy.account.Identity import app.k9mail.legacy.account.LegacyAccount import app.k9mail.legacy.account.ShowPictures import app.k9mail.legacy.account.SpecialFolderSelection import app.k9mail.legacy.notification.NotificationLight import app.k9mail.legacy.notification.NotificationSettings import app.k9mail.legacy.notification.NotificationVibration Loading @@ -37,13 +37,13 @@ class CommonAccountDefaultsProvider( private val featureFlagProvider: FeatureFlagProvider, ) : AccountDefaultsProvider { override fun applyDefaults(account: Account) = with(account) { override fun applyDefaults(account: LegacyAccount) = with(account) { applyLegacyDefaults() applyNotificationDefaults() } @Suppress("LongMethod") private fun Account.applyLegacyDefaults() { private fun LegacyAccount.applyLegacyDefaults() { automaticCheckIntervalMinutes = DEFAULT_SYNC_INTERVAL idleRefreshMinutes = 24 displayCount = K9.DEFAULT_VISIBLE_LIMIT Loading Loading @@ -116,7 +116,7 @@ class CommonAccountDefaultsProvider( resetChangeMarkers() } private fun Account.applyNotificationDefaults() { private fun LegacyAccount.applyNotificationDefaults() { isNotifyNewMail = featureFlagProvider.provide( "email_notification_default".toFeatureFlagKey(), ).whenEnabledOrNot( Loading app-common/src/main/kotlin/net/thunderbird/app/common/account/data/CommonAccountProfileLocalDataSource.kt 0 → 100644 +41 −0 Original line number Diff line number Diff line package net.thunderbird.app.common.account.data import app.k9mail.legacy.account.LegacyAccountWrapperManager import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onEach import net.thunderbird.feature.account.api.AccountId import net.thunderbird.feature.account.api.profile.AccountProfile import net.thunderbird.feature.account.core.AccountCoreExternalContract.AccountProfileLocalDataSource class CommonAccountProfileLocalDataSource( private val accountManager: LegacyAccountWrapperManager, ) : AccountProfileLocalDataSource { override fun getById(accountId: AccountId): Flow<AccountProfile?> { return accountManager.getById(accountId.value) .onEach { println("Flow emitted account: $it") } .map { account -> account?.let { AccountProfile( accountId = AccountId.from(account.uuid), name = account.displayName, color = account.chipColor, ) } } } override suspend fun update(accountProfile: AccountProfile) { val currentAccount = accountManager.getById(accountProfile.accountId.value) .firstOrNull() ?: return val updatedAccount = currentAccount.copy( displayName = accountProfile.name, chipColor = accountProfile.color, ) accountManager.update(updatedAccount) } } Loading
.idea/codeStyles/Project.xml +1 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ <option name="INSERT_INNER_CLASS_IMPORTS" value="true" /> <option name="IMPORT_LAYOUT_TABLE"> <value> <package name="" withSubpackages="true" static="false" module="true" /> <package name="java" withSubpackages="true" static="false" /> <emptyLine /> <package name="android" withSubpackages="true" static="false" /> Loading
app-common/build.gradle.kts +2 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,8 @@ android { dependencies { api(projects.legacy.common) implementation(projects.feature.account.core) implementation(projects.legacy.core) implementation(projects.legacy.account) Loading
app-common/src/main/kotlin/net/thunderbird/app/common/AppCommonModule.kt +21 −0 Original line number Diff line number Diff line package net.thunderbird.app.common import app.k9mail.legacy.account.AccountDefaultsProvider import app.k9mail.legacy.account.LegacyAccountWrapperManager import net.thunderbird.app.common.account.CommonAccountDefaultsProvider import net.thunderbird.app.common.account.data.CommonAccountProfileLocalDataSource import net.thunderbird.app.common.account.data.CommonLegacyAccountWrapperManager import net.thunderbird.feature.account.core.AccountCoreExternalContract.AccountProfileLocalDataSource import net.thunderbird.feature.account.core.featureAccountCoreModule import org.koin.core.module.Module import org.koin.dsl.module val appCommonModule: Module = module { includes( featureAccountCoreModule, ) single<LegacyAccountWrapperManager> { CommonLegacyAccountWrapperManager( accountManager = get(), ) } single<AccountProfileLocalDataSource> { CommonAccountProfileLocalDataSource( accountManager = get(), ) } single<AccountDefaultsProvider> { CommonAccountDefaultsProvider( resourceProvider = get(), Loading
app-common/src/main/kotlin/net/thunderbird/app/common/account/CommonAccountDefaultsProvider.kt +8 −8 Original line number Diff line number Diff line Loading @@ -2,11 +2,6 @@ package net.thunderbird.app.common.account import app.k9mail.core.featureflag.FeatureFlagProvider import app.k9mail.core.featureflag.toFeatureFlagKey import app.k9mail.legacy.account.Account import app.k9mail.legacy.account.Account.Expunge import app.k9mail.legacy.account.Account.FolderMode import app.k9mail.legacy.account.Account.ShowPictures import app.k9mail.legacy.account.Account.SpecialFolderSelection import app.k9mail.legacy.account.AccountDefaultsProvider import app.k9mail.legacy.account.AccountDefaultsProvider.Companion.DEFAULT_MAXIMUM_AUTO_DOWNLOAD_MESSAGE_SIZE import app.k9mail.legacy.account.AccountDefaultsProvider.Companion.DEFAULT_MESSAGE_FORMAT Loading @@ -24,7 +19,12 @@ import app.k9mail.legacy.account.AccountDefaultsProvider.Companion.DEFAULT_STRIP import app.k9mail.legacy.account.AccountDefaultsProvider.Companion.DEFAULT_SYNC_INTERVAL import app.k9mail.legacy.account.AccountDefaultsProvider.Companion.NO_OPENPGP_KEY import app.k9mail.legacy.account.AccountDefaultsProvider.Companion.UNASSIGNED_ACCOUNT_NUMBER import app.k9mail.legacy.account.Expunge import app.k9mail.legacy.account.FolderMode import app.k9mail.legacy.account.Identity import app.k9mail.legacy.account.LegacyAccount import app.k9mail.legacy.account.ShowPictures import app.k9mail.legacy.account.SpecialFolderSelection import app.k9mail.legacy.notification.NotificationLight import app.k9mail.legacy.notification.NotificationSettings import app.k9mail.legacy.notification.NotificationVibration Loading @@ -37,13 +37,13 @@ class CommonAccountDefaultsProvider( private val featureFlagProvider: FeatureFlagProvider, ) : AccountDefaultsProvider { override fun applyDefaults(account: Account) = with(account) { override fun applyDefaults(account: LegacyAccount) = with(account) { applyLegacyDefaults() applyNotificationDefaults() } @Suppress("LongMethod") private fun Account.applyLegacyDefaults() { private fun LegacyAccount.applyLegacyDefaults() { automaticCheckIntervalMinutes = DEFAULT_SYNC_INTERVAL idleRefreshMinutes = 24 displayCount = K9.DEFAULT_VISIBLE_LIMIT Loading Loading @@ -116,7 +116,7 @@ class CommonAccountDefaultsProvider( resetChangeMarkers() } private fun Account.applyNotificationDefaults() { private fun LegacyAccount.applyNotificationDefaults() { isNotifyNewMail = featureFlagProvider.provide( "email_notification_default".toFeatureFlagKey(), ).whenEnabledOrNot( Loading
app-common/src/main/kotlin/net/thunderbird/app/common/account/data/CommonAccountProfileLocalDataSource.kt 0 → 100644 +41 −0 Original line number Diff line number Diff line package net.thunderbird.app.common.account.data import app.k9mail.legacy.account.LegacyAccountWrapperManager import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onEach import net.thunderbird.feature.account.api.AccountId import net.thunderbird.feature.account.api.profile.AccountProfile import net.thunderbird.feature.account.core.AccountCoreExternalContract.AccountProfileLocalDataSource class CommonAccountProfileLocalDataSource( private val accountManager: LegacyAccountWrapperManager, ) : AccountProfileLocalDataSource { override fun getById(accountId: AccountId): Flow<AccountProfile?> { return accountManager.getById(accountId.value) .onEach { println("Flow emitted account: $it") } .map { account -> account?.let { AccountProfile( accountId = AccountId.from(account.uuid), name = account.displayName, color = account.chipColor, ) } } } override suspend fun update(accountProfile: AccountProfile) { val currentAccount = accountManager.getById(accountProfile.accountId.value) .firstOrNull() ?: return val updatedAccount = currentAccount.copy( displayName = accountProfile.name, chipColor = accountProfile.color, ) accountManager.update(updatedAccount) } }