Skip to content

Commit 5b75f0d

Browse files
committed
refactor: rename LegacyAccountWrapper to LegacyAccount
1 parent 4ca78c9 commit 5b75f0d

10 files changed

Lines changed: 45 additions & 50 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ 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
6+
import net.thunderbird.core.android.account.LegacyAccount
77
import net.thunderbird.core.android.account.LegacyAccountWrapperManager
88
import net.thunderbird.feature.account.AccountId
99
import net.thunderbird.feature.account.storage.legacy.mapper.DefaultLegacyAccountWrapperDataMapper
@@ -13,7 +13,7 @@ internal class DefaultLegacyAccountWrapperManager(
1313
private val accountDataMapper: DefaultLegacyAccountWrapperDataMapper,
1414
) : LegacyAccountWrapperManager {
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/data/DefaultAccountProfileLocalDataSourceTest.kt

Lines changed: 4 additions & 4 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,7 +139,7 @@ class DefaultAccountProfileLocalDataSourceTest {
139139
}
140140

141141
private fun createTestSubject(
142-
legacyAccount: LegacyAccountWrapper?,
142+
legacyAccount: LegacyAccount?,
143143
): DefaultAccountProfileLocalDataSource {
144144
return DefaultAccountProfileLocalDataSource(
145145
accountManager = FakeLegacyAccountWrapperManager(

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

Lines changed: 6 additions & 6 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
8+
import net.thunderbird.core.android.account.LegacyAccount
99
import net.thunderbird.core.android.account.LegacyAccountWrapperManager
1010
import net.thunderbird.feature.account.AccountId
1111

1212
internal class FakeLegacyAccountWrapperManager(
13-
initialAccounts: List<LegacyAccountWrapper> = emptyList(),
13+
initialAccounts: List<LegacyAccount> = emptyList(),
1414
) : LegacyAccountWrapperManager {
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 }

core/android/account/src/main/kotlin/net/thunderbird/core/android/account/LegacyAccountWrapper.kt renamed to core/android/account/src/main/kotlin/net/thunderbird/core/android/account/LegacyAccount.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,9 @@ import net.thunderbird.feature.mail.folder.api.SpecialFolderSelection
1212
import net.thunderbird.feature.notification.NotificationSettings
1313

1414
/**
15-
* A immutable wrapper for the [LegacyAccountDto] class.
16-
*
1715
* This class is used to store the account data in a way that is safe to pass between threads.
18-
*
19-
* Use LegacyAccountWrapper.from(account) to create a wrapper from an account.
20-
* Use LegacyAccountWrapper.to(wrapper) to create an account from a wrapper.
2116
*/
22-
data class LegacyAccountWrapper(
17+
data class LegacyAccount(
2318
val isSensitiveDebugLoggingEnabled: () -> Boolean = { false },
2419

2520
// [Account]

core/android/account/src/main/kotlin/net/thunderbird/core/android/account/LegacyAccountWrapperManager.kt renamed to core/android/account/src/main/kotlin/net/thunderbird/core/android/account/LegacyAccountManager.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import kotlinx.coroutines.flow.Flow
44
import net.thunderbird.feature.account.AccountId
55

66
interface LegacyAccountWrapperManager {
7-
fun getAll(): Flow<List<LegacyAccountWrapper>>
7+
fun getAll(): Flow<List<LegacyAccount>>
88

9-
fun getById(id: AccountId): Flow<LegacyAccountWrapper?>
9+
fun getById(id: AccountId): Flow<LegacyAccount?>
1010

11-
suspend fun update(account: LegacyAccountWrapper)
11+
suspend fun update(account: LegacyAccount)
1212
}

core/android/account/src/test/kotlin/net/thunderbird/core/android/account/LegacyAccountWrapperTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class LegacyAccountWrapperTest {
2424
val expected = createAccountWrapper()
2525

2626
// act
27-
val result = LegacyAccountWrapper(
27+
val result = LegacyAccount(
2828
isSensitiveDebugLoggingEnabled = isSensitiveDebugLoggingEnabled,
2929
id = ACCOUNT_ID,
3030
name = PROFILE_NAME,
@@ -93,8 +93,8 @@ class LegacyAccountWrapperTest {
9393
val notificationSettings = NotificationSettings()
9494

9595
@Suppress("LongMethod")
96-
fun createAccountWrapper(): LegacyAccountWrapper {
97-
return LegacyAccountWrapper(
96+
fun createAccountWrapper(): LegacyAccount {
97+
return LegacyAccount(
9898
isSensitiveDebugLoggingEnabled = isSensitiveDebugLoggingEnabled,
9999

100100
// [Account]

feature/account/storage/legacy/src/main/kotlin/net/thunderbird/feature/account/storage/legacy/mapper/DefaultLegacyAccountWrapperDataMapper.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package net.thunderbird.feature.account.storage.legacy.mapper
22

3+
import net.thunderbird.core.android.account.LegacyAccount
34
import net.thunderbird.core.android.account.LegacyAccountDto
4-
import net.thunderbird.core.android.account.LegacyAccountWrapper
55
import net.thunderbird.core.architecture.data.DataMapper
66
import net.thunderbird.feature.account.storage.profile.ProfileDto
77

8-
class DefaultLegacyAccountWrapperDataMapper : DataMapper<LegacyAccountWrapper, LegacyAccountDto> {
8+
class DefaultLegacyAccountWrapperDataMapper : DataMapper<LegacyAccount, LegacyAccountDto> {
99

1010
@Suppress("LongMethod")
11-
override fun toDomain(dto: LegacyAccountDto): LegacyAccountWrapper {
12-
return LegacyAccountWrapper(
11+
override fun toDomain(dto: LegacyAccountDto): LegacyAccount {
12+
return LegacyAccount(
1313
isSensitiveDebugLoggingEnabled = dto.isSensitiveDebugLoggingEnabled,
1414

1515
// Account
@@ -119,7 +119,7 @@ class DefaultLegacyAccountWrapperDataMapper : DataMapper<LegacyAccountWrapper, L
119119
}
120120

121121
@Suppress("LongMethod")
122-
override fun toDto(domain: LegacyAccountWrapper): LegacyAccountDto {
122+
override fun toDto(domain: LegacyAccount): LegacyAccountDto {
123123
return LegacyAccountDto(
124124
uuid = domain.uuid,
125125
isSensitiveDebugLoggingEnabled = domain.isSensitiveDebugLoggingEnabled,

feature/account/storage/legacy/src/test/kotlin/net/thunderbird/feature/account/storage/legacy/mapper/DefaultLegacyAccountWrapperDataMapperTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import net.thunderbird.core.android.account.DeletePolicy
1111
import net.thunderbird.core.android.account.Expunge
1212
import net.thunderbird.core.android.account.FolderMode
1313
import net.thunderbird.core.android.account.Identity
14+
import net.thunderbird.core.android.account.LegacyAccount
1415
import net.thunderbird.core.android.account.LegacyAccountDto
15-
import net.thunderbird.core.android.account.LegacyAccountWrapper
1616
import net.thunderbird.core.android.account.MessageFormat
1717
import net.thunderbird.core.android.account.QuoteStyle
1818
import net.thunderbird.core.android.account.ShowPictures
@@ -293,10 +293,10 @@ class DefaultLegacyAccountWrapperDataMapperTest {
293293
}
294294

295295
@Suppress("LongMethod")
296-
fun createAccountWrapper(): LegacyAccountWrapper {
296+
fun createAccountWrapper(): LegacyAccount {
297297
val id = AccountIdFactory.of(ACCOUNT_ID_RAW)
298298

299-
return LegacyAccountWrapper(
299+
return LegacyAccount(
300300
isSensitiveDebugLoggingEnabled = defaultIsSensitiveDebugLoggingEnabled,
301301

302302
// [Account]

legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListFragment.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ import kotlinx.coroutines.flow.onEach
6969
import net.jcip.annotations.GuardedBy
7070
import net.thunderbird.core.android.account.AccountManager
7171
import net.thunderbird.core.android.account.Expunge
72+
import net.thunderbird.core.android.account.LegacyAccount
7273
import net.thunderbird.core.android.account.LegacyAccountDto
73-
import net.thunderbird.core.android.account.LegacyAccountWrapper
7474
import net.thunderbird.core.android.account.SortType
7575
import net.thunderbird.core.android.network.ConnectivityManager
7676
import net.thunderbird.core.architecture.data.DataMapper
@@ -110,8 +110,8 @@ class MessageListFragment :
110110
@OptIn(ExperimentalTime::class)
111111
private val clock: Clock by inject()
112112
private val setupArchiveFolderDialogFragmentFactory: SetupArchiveFolderDialogFragmentFactory by inject()
113-
private val legacyAccountWrapperDataMapper: DataMapper<
114-
LegacyAccountWrapper,
113+
private val legacyAccountDataMapper: DataMapper<
114+
LegacyAccount,
115115
LegacyAccountDto,
116116
> by inject<DefaultLegacyAccountWrapperDataMapper>()
117117
private val preferences: Preferences by inject()
@@ -147,7 +147,7 @@ class MessageListFragment :
147147
private lateinit var adapter: MessageListAdapter
148148

149149
private lateinit var accountUuids: Array<String>
150-
private var accounts: List<LegacyAccountWrapper> = emptyList()
150+
private var accounts: List<LegacyAccount> = emptyList()
151151
private var account: LegacyAccountDto? = null
152152
private var currentFolder: FolderInfoHolder? = null
153153
private var remoteSearchFuture: Future<*>? = null
@@ -467,7 +467,7 @@ class MessageListFragment :
467467
adapter = adapter,
468468
listener = swipeListener,
469469
accounts = accounts,
470-
legacyAccountWrapperDataMapper = legacyAccountWrapperDataMapper,
470+
legacyAccountDataMapper = legacyAccountDataMapper,
471471
).also { messageListSwipeCallback = it },
472472
)
473473
itemTouchHelper.attachToRecyclerView(recyclerView)
@@ -546,7 +546,7 @@ class MessageListFragment :
546546
}
547547

548548
private fun updateAccountList(accounts: List<LegacyAccountDto>) {
549-
this.accounts = accounts.map(legacyAccountWrapperDataMapper::toDomain)
549+
this.accounts = accounts.map(legacyAccountDataMapper::toDomain)
550550
}
551551

552552
fun folderLoading(folderId: Long, loading: Boolean) {

legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListSwipeCallback.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import com.fsck.k9.ui.messagelist.item.MessageViewHolder
1919
import com.google.android.material.color.ColorRoles
2020
import com.google.android.material.textview.MaterialTextView
2121
import kotlin.math.abs
22+
import net.thunderbird.core.android.account.LegacyAccount
2223
import net.thunderbird.core.android.account.LegacyAccountDto
23-
import net.thunderbird.core.android.account.LegacyAccountWrapper
2424
import net.thunderbird.core.architecture.data.DataMapper
2525
import net.thunderbird.core.common.action.SwipeAction
2626
import net.thunderbird.core.common.action.SwipeActions
@@ -35,8 +35,8 @@ class MessageListSwipeCallback(
3535
private val buildSwipeActions: DomainContract.UseCase.BuildSwipeActions<LegacyAccountDto>,
3636
private val adapter: MessageListAdapter,
3737
private val listener: MessageListSwipeListener,
38-
accounts: List<LegacyAccountWrapper>,
39-
private val legacyAccountWrapperDataMapper: DataMapper<LegacyAccountWrapper, LegacyAccountDto>,
38+
accounts: List<LegacyAccount>,
39+
private val legacyAccountDataMapper: DataMapper<LegacyAccount, LegacyAccountDto>,
4040
) : ItemTouchHelper.Callback() {
4141
private var swipeActions: Map<String, SwipeActions> = emptyMap()
4242
private val swipePadding = context.resources.getDimension(R.dimen.messageListSwipeIconPadding).toInt()
@@ -326,7 +326,7 @@ class MessageListSwipeCallback(
326326
return (super.getAnimationDuration(recyclerView, animationType, animateDx, animateDy) * percentage).toLong()
327327
}
328328

329-
fun invalidateSwipeActions(accounts: List<LegacyAccountWrapper>) {
329+
fun invalidateSwipeActions(accounts: List<LegacyAccount>) {
330330
swipeActions = buildSwipeActions(accounts)
331331
swipeLeftConfig.apply {
332332
clear()
@@ -338,18 +338,18 @@ class MessageListSwipeCallback(
338338
}
339339
}
340340

341-
fun buildSwipeActions(accounts: List<LegacyAccountWrapper>): Map<String, SwipeActions> {
341+
fun buildSwipeActions(accounts: List<LegacyAccount>): Map<String, SwipeActions> {
342342
return buildSwipeActions(
343343
accountUuids = accounts.map { it.uuid }.toSet(),
344344
isIncomingServerPop3 = { account ->
345-
legacyAccountWrapperDataMapper.toDomain(account).isIncomingServerPop3()
345+
legacyAccountDataMapper.toDomain(account).isIncomingServerPop3()
346346
},
347-
hasArchiveFolder = { account -> legacyAccountWrapperDataMapper.toDomain(account).hasArchiveFolder() },
347+
hasArchiveFolder = { account -> legacyAccountDataMapper.toDomain(account).hasArchiveFolder() },
348348
)
349349
}
350350

351351
private fun setupSwipeActionConfig(
352-
accounts: List<LegacyAccountWrapper>,
352+
accounts: List<LegacyAccount>,
353353
resourceProvider: SwipeResourceProvider,
354354
isLeft: Boolean,
355355
): Map<String, SwipeActionConfig> {
@@ -384,8 +384,8 @@ class MessageListSwipeCallback(
384384
private val ViewHolder.messageListItem: MessageListItem?
385385
get() = (this as? MessageViewHolder)?.uniqueId?.let { adapter.getItemById(it) }
386386

387-
private val MessageListItem.accountWrapper: LegacyAccountWrapper
388-
get() = legacyAccountWrapperDataMapper.toDomain(account)
387+
private val MessageListItem.accountWrapper: LegacyAccount
388+
get() = legacyAccountDataMapper.toDomain(account)
389389
}
390390

391391
fun interface SwipeActionSupportProvider {

0 commit comments

Comments
 (0)