Skip to content

Commit 789c1bc

Browse files
Merge pull request thunderbird#9763 from wmontwe/refactor-rename-legacy-account
refactor: rename legacy account
2 parents 21a1e2c + c70dce7 commit 789c1bc

230 files changed

Lines changed: 1846 additions & 1830 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app-common/src/main/kotlin/net/thunderbird/app/common/account/AccountCreator.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import com.fsck.k9.preferences.UnifiedInboxConfigurator
2121
import kotlinx.coroutines.CoroutineDispatcher
2222
import kotlinx.coroutines.Dispatchers
2323
import kotlinx.coroutines.withContext
24-
import net.thunderbird.core.android.account.LegacyAccount
24+
import net.thunderbird.core.android.account.LegacyAccountDto
2525
import net.thunderbird.core.common.mail.Protocols
2626
import net.thunderbird.core.logging.legacy.Log
2727
import net.thunderbird.feature.account.avatar.AvatarMonogramCreator
@@ -113,7 +113,7 @@ internal class AccountCreator(
113113
* Since the folder list hasn't been synced yet, we don't have database IDs for the folders. So we use the same
114114
* mechanism that is used when importing settings. See [com.fsck.k9.mailstore.SpecialFolderUpdater] for details.
115115
*/
116-
private fun LegacyAccount.setSpecialFolders(specialFolders: SpecialFolderSettings) {
116+
private fun LegacyAccountDto.setSpecialFolders(specialFolders: SpecialFolderSettings) {
117117
importedArchiveFolder = specialFolders.archiveSpecialFolderOption.toFolderServerId()
118118
archiveFolderSelection = specialFolders.archiveSpecialFolderOption.toFolderSelection()
119119

@@ -153,7 +153,7 @@ internal class AccountCreator(
153153
}
154154
}
155155

156-
private fun LegacyAccount.setIncomingServerSettings(serverSettings: ServerSettings) {
156+
private fun LegacyAccountDto.setIncomingServerSettings(serverSettings: ServerSettings) {
157157
if (serverSettings.type == Protocols.IMAP) {
158158
useCompression = serverSettings.isUseCompression
159159
isSendClientInfoEnabled = serverSettings.isSendClientInfo

app-common/src/main/kotlin/net/thunderbird/app/common/account/AppCommonAccountModule.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package net.thunderbird.app.common.account
22

33
import app.k9mail.feature.account.setup.AccountSetupExternalContract
44
import net.thunderbird.app.common.account.data.DefaultAccountProfileLocalDataSource
5-
import net.thunderbird.app.common.account.data.DefaultLegacyAccountWrapperManager
5+
import net.thunderbird.app.common.account.data.DefaultLegacyAccountManager
66
import net.thunderbird.core.android.account.AccountDefaultsProvider
7-
import net.thunderbird.core.android.account.LegacyAccountWrapperManager
7+
import net.thunderbird.core.android.account.LegacyAccountManager
88
import net.thunderbird.feature.account.avatar.AvatarMonogramCreator
99
import net.thunderbird.feature.account.avatar.DefaultAvatarMonogramCreator
1010
import net.thunderbird.feature.account.core.AccountCoreExternalContract.AccountProfileLocalDataSource
@@ -19,8 +19,8 @@ internal val appCommonAccountModule = module {
1919
featureAccountStorageLegacyModule,
2020
)
2121

22-
single<LegacyAccountWrapperManager> {
23-
DefaultLegacyAccountWrapperManager(
22+
single<LegacyAccountManager> {
23+
DefaultLegacyAccountManager(
2424
accountManager = get(),
2525
accountDataMapper = get(),
2626
)

app-common/src/main/kotlin/net/thunderbird/app/common/account/DefaultAccountDefaultsProvider.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import net.thunderbird.core.android.account.AccountDefaultsProvider.Companion.UN
2222
import net.thunderbird.core.android.account.Expunge
2323
import net.thunderbird.core.android.account.FolderMode
2424
import net.thunderbird.core.android.account.Identity
25-
import net.thunderbird.core.android.account.LegacyAccount
25+
import net.thunderbird.core.android.account.LegacyAccountDto
2626
import net.thunderbird.core.android.account.ShowPictures
2727
import net.thunderbird.core.featureflag.FeatureFlagProvider
2828
import net.thunderbird.core.featureflag.toFeatureFlagKey
@@ -38,11 +38,11 @@ internal class DefaultAccountDefaultsProvider(
3838
private val featureFlagProvider: FeatureFlagProvider,
3939
) : AccountDefaultsProvider {
4040

41-
override fun applyDefaults(account: LegacyAccount) = with(account) {
41+
override fun applyDefaults(account: LegacyAccountDto) = with(account) {
4242
applyLegacyDefaults()
4343
}
4444

45-
override fun applyOverwrites(account: LegacyAccount, storage: Storage) = with(account) {
45+
override fun applyOverwrites(account: LegacyAccountDto, storage: Storage) = with(account) {
4646
if (storage.contains("${account.uuid}.notifyNewMail")) {
4747
isNotifyNewMail = storage.getBoolean("${account.uuid}.notifyNewMail", false)
4848
isNotifySelfNewMail = storage.getBoolean("${account.uuid}.notifySelfNewMail", true)
@@ -64,7 +64,7 @@ internal class DefaultAccountDefaultsProvider(
6464
}
6565

6666
@Suppress("LongMethod")
67-
private fun LegacyAccount.applyLegacyDefaults() {
67+
private fun LegacyAccountDto.applyLegacyDefaults() {
6868
automaticCheckIntervalMinutes = DEFAULT_SYNC_INTERVAL
6969
idleRefreshMinutes = 24
7070
displayCount = DEFAULT_VISIBLE_LIMIT

app-common/src/main/kotlin/net/thunderbird/app/common/account/data/DefaultAccountProfileLocalDataSource.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ package net.thunderbird.app.common.account.data
33
import kotlinx.coroutines.flow.Flow
44
import kotlinx.coroutines.flow.firstOrNull
55
import kotlinx.coroutines.flow.map
6-
import net.thunderbird.core.android.account.LegacyAccountWrapperManager
6+
import net.thunderbird.core.android.account.LegacyAccountManager
77
import net.thunderbird.feature.account.AccountId
88
import net.thunderbird.feature.account.core.AccountCoreExternalContract.AccountProfileLocalDataSource
99
import net.thunderbird.feature.account.profile.AccountProfile
1010
import net.thunderbird.feature.account.storage.mapper.AccountProfileDataMapper
1111

1212
internal class DefaultAccountProfileLocalDataSource(
13-
private val accountManager: LegacyAccountWrapperManager,
13+
private val accountManager: LegacyAccountManager,
1414
private val dataMapper: AccountProfileDataMapper,
1515
) : AccountProfileLocalDataSource {
1616

app-common/src/main/kotlin/net/thunderbird/app/common/account/data/DefaultLegacyAccountWrapperManager.kt renamed to app-common/src/main/kotlin/net/thunderbird/app/common/account/data/DefaultLegacyAccountManager.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ package net.thunderbird.app.common.account.data
33
import kotlinx.coroutines.flow.Flow
44
import kotlinx.coroutines.flow.map
55
import net.thunderbird.core.android.account.AccountManager
6-
import net.thunderbird.core.android.account.LegacyAccountWrapper
7-
import net.thunderbird.core.android.account.LegacyAccountWrapperManager
6+
import net.thunderbird.core.android.account.LegacyAccount
7+
import net.thunderbird.core.android.account.LegacyAccountManager
88
import net.thunderbird.feature.account.AccountId
99
import net.thunderbird.feature.account.storage.legacy.mapper.DefaultLegacyAccountWrapperDataMapper
1010

11-
internal class DefaultLegacyAccountWrapperManager(
11+
internal class DefaultLegacyAccountManager(
1212
private val accountManager: AccountManager,
1313
private val accountDataMapper: DefaultLegacyAccountWrapperDataMapper,
14-
) : LegacyAccountWrapperManager {
14+
) : LegacyAccountManager {
1515

16-
override fun getAll(): Flow<List<LegacyAccountWrapper>> {
16+
override fun getAll(): Flow<List<LegacyAccount>> {
1717
return accountManager.getAccountsFlow()
1818
.map { list ->
1919
list.map { account ->
@@ -22,15 +22,15 @@ internal class DefaultLegacyAccountWrapperManager(
2222
}
2323
}
2424

25-
override fun getById(id: AccountId): Flow<LegacyAccountWrapper?> {
25+
override fun getById(id: AccountId): Flow<LegacyAccount?> {
2626
return accountManager.getAccountFlow(id.asRaw()).map { account ->
2727
account?.let {
2828
accountDataMapper.toDomain(it)
2929
}
3030
}
3131
}
3232

33-
override suspend fun update(account: LegacyAccountWrapper) {
33+
override suspend fun update(account: LegacyAccount) {
3434
accountManager.saveAccount(
3535
accountDataMapper.toDto(account),
3636
)

app-common/src/test/kotlin/net/thunderbird/app/common/account/DefaultAccountDefaultsProviderTest.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import net.thunderbird.core.android.account.AccountDefaultsProvider.Companion.UN
2626
import net.thunderbird.core.android.account.Expunge
2727
import net.thunderbird.core.android.account.FolderMode
2828
import net.thunderbird.core.android.account.Identity
29-
import net.thunderbird.core.android.account.LegacyAccount
29+
import net.thunderbird.core.android.account.LegacyAccountDto
3030
import net.thunderbird.core.android.account.ShowPictures
3131
import net.thunderbird.core.featureflag.FeatureFlagResult
3232
import net.thunderbird.core.preference.storage.Storage
@@ -47,7 +47,7 @@ class DefaultAccountDefaultsProviderTest {
4747
val resourceProvider = mock<CoreResourceProvider> {
4848
on { defaultIdentityDescription() } doReturn "Default Identity"
4949
}
50-
val account = LegacyAccount(
50+
val account = LegacyAccountDto(
5151
uuid = "cf728064-077d-4369-a0c7-7c2b21693d9b",
5252
isSensitiveDebugLoggingEnabled = { false },
5353
)
@@ -144,7 +144,7 @@ class DefaultAccountDefaultsProviderTest {
144144
val resourceProvider = mock<CoreResourceProvider> {
145145
on { defaultIdentityDescription() } doReturn "Default Identity"
146146
}
147-
val account = LegacyAccount(
147+
val account = LegacyAccountDto(
148148
uuid = "cf728064-077d-4369-a0c7-7c2b21693d9b",
149149
isSensitiveDebugLoggingEnabled = { false },
150150
)
@@ -174,7 +174,7 @@ class DefaultAccountDefaultsProviderTest {
174174
val resourceProvider = mock<CoreResourceProvider> {
175175
on { defaultIdentityDescription() } doReturn "Default Identity"
176176
}
177-
val account = LegacyAccount(
177+
val account = LegacyAccountDto(
178178
uuid = "cf728064-077d-4369-a0c7-7c2b21693d9b",
179179
isSensitiveDebugLoggingEnabled = { false },
180180
)
@@ -205,7 +205,7 @@ class DefaultAccountDefaultsProviderTest {
205205
val resourceProvider = mock<CoreResourceProvider> {
206206
on { defaultIdentityDescription() } doReturn "Default Identity"
207207
}
208-
val account = LegacyAccount(
208+
val account = LegacyAccountDto(
209209
uuid = "cf728064-077d-4369-a0c7-7c2b21693d9b",
210210
isSensitiveDebugLoggingEnabled = { false },
211211
)
@@ -236,7 +236,7 @@ class DefaultAccountDefaultsProviderTest {
236236
val resourceProvider = mock<CoreResourceProvider> {
237237
on { defaultIdentityDescription() } doReturn "Default Identity"
238238
}
239-
val account = LegacyAccount(
239+
val account = LegacyAccountDto(
240240
uuid = "cf728064-077d-4369-a0c7-7c2b21693d9b",
241241
isSensitiveDebugLoggingEnabled = { false },
242242
)

app-common/src/test/kotlin/net/thunderbird/app/common/account/data/DefaultAccountProfileLocalDataSourceTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import kotlinx.coroutines.test.runTest
1010
import net.thunderbird.account.fake.FakeAccountProfileData.PROFILE_COLOR
1111
import net.thunderbird.account.fake.FakeAccountProfileData.PROFILE_NAME
1212
import net.thunderbird.core.android.account.Identity
13-
import net.thunderbird.core.android.account.LegacyAccountWrapper
13+
import net.thunderbird.core.android.account.LegacyAccount
1414
import net.thunderbird.feature.account.AccountId
1515
import net.thunderbird.feature.account.AccountIdFactory
1616
import net.thunderbird.feature.account.profile.AccountAvatar
@@ -77,8 +77,8 @@ class DefaultAccountProfileLocalDataSourceTest {
7777
id: AccountId,
7878
displayName: String = PROFILE_NAME,
7979
color: Int = PROFILE_COLOR,
80-
): LegacyAccountWrapper {
81-
return LegacyAccountWrapper(
80+
): LegacyAccount {
81+
return LegacyAccount(
8282
isSensitiveDebugLoggingEnabled = { true },
8383
id = id,
8484
name = displayName,
@@ -139,10 +139,10 @@ class DefaultAccountProfileLocalDataSourceTest {
139139
}
140140

141141
private fun createTestSubject(
142-
legacyAccount: LegacyAccountWrapper?,
142+
legacyAccount: LegacyAccount?,
143143
): DefaultAccountProfileLocalDataSource {
144144
return DefaultAccountProfileLocalDataSource(
145-
accountManager = FakeLegacyAccountWrapperManager(
145+
accountManager = FakeLegacyAccountManager(
146146
initialAccounts = if (legacyAccount != null) {
147147
listOf(legacyAccount)
148148
} else {

app-common/src/test/kotlin/net/thunderbird/app/common/account/data/FakeLegacyAccountWrapperManager.kt renamed to app-common/src/test/kotlin/net/thunderbird/app/common/account/data/FakeLegacyAccountManager.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@ import kotlinx.coroutines.flow.MutableStateFlow
55
import kotlinx.coroutines.flow.StateFlow
66
import kotlinx.coroutines.flow.map
77
import kotlinx.coroutines.flow.update
8-
import net.thunderbird.core.android.account.LegacyAccountWrapper
9-
import net.thunderbird.core.android.account.LegacyAccountWrapperManager
8+
import net.thunderbird.core.android.account.LegacyAccount
9+
import net.thunderbird.core.android.account.LegacyAccountManager
1010
import net.thunderbird.feature.account.AccountId
1111

12-
internal class FakeLegacyAccountWrapperManager(
13-
initialAccounts: List<LegacyAccountWrapper> = emptyList(),
14-
) : LegacyAccountWrapperManager {
12+
internal class FakeLegacyAccountManager(
13+
initialAccounts: List<LegacyAccount> = emptyList(),
14+
) : LegacyAccountManager {
1515

1616
private val accountsState = MutableStateFlow(
1717
initialAccounts,
1818
)
19-
private val accounts: StateFlow<List<LegacyAccountWrapper>> = accountsState
19+
private val accounts: StateFlow<List<LegacyAccount>> = accountsState
2020

21-
override fun getAll(): Flow<List<LegacyAccountWrapper>> = accounts
21+
override fun getAll(): Flow<List<LegacyAccount>> = accounts
2222

23-
override fun getById(id: AccountId): Flow<LegacyAccountWrapper?> = accounts
23+
override fun getById(id: AccountId): Flow<LegacyAccount?> = accounts
2424
.map { list ->
2525
list.find { it.id == id }
2626
}
2727

28-
override suspend fun update(account: LegacyAccountWrapper) {
28+
override suspend fun update(account: LegacyAccount) {
2929
accountsState.update { currentList ->
3030
currentList.toMutableList().apply {
3131
removeIf { it.uuid == account.uuid }

app-k9mail/src/debug/kotlin/app/k9mail/dev/DemoBackendFactory.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import app.k9mail.backend.demo.DemoBackend
44
import com.fsck.k9.backend.BackendFactory
55
import com.fsck.k9.backend.api.Backend
66
import com.fsck.k9.mailstore.K9BackendStorageFactory
7-
import net.thunderbird.core.android.account.LegacyAccount
7+
import net.thunderbird.core.android.account.LegacyAccountDto
88

99
class DemoBackendFactory(private val backendStorageFactory: K9BackendStorageFactory) : BackendFactory {
10-
override fun createBackend(account: LegacyAccount): Backend {
10+
override fun createBackend(account: LegacyAccountDto): Backend {
1111
val backendStorage = backendStorageFactory.createBackendStorage(account)
1212
return DemoBackend(backendStorage)
1313
}

app-thunderbird/src/daily/kotlin/net/thunderbird/android/dev/DemoBackendFactory.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import app.k9mail.backend.demo.DemoBackend
44
import com.fsck.k9.backend.BackendFactory
55
import com.fsck.k9.backend.api.Backend
66
import com.fsck.k9.mailstore.K9BackendStorageFactory
7-
import net.thunderbird.core.android.account.LegacyAccount
7+
import net.thunderbird.core.android.account.LegacyAccountDto
88

99
class DemoBackendFactory(private val backendStorageFactory: K9BackendStorageFactory) : BackendFactory {
10-
override fun createBackend(account: LegacyAccount): Backend {
10+
override fun createBackend(account: LegacyAccountDto): Backend {
1111
val backendStorage = backendStorageFactory.createBackendStorage(account)
1212
return DemoBackend(backendStorage)
1313
}

0 commit comments

Comments
 (0)