0
0
mirror of https://github.com/thunderbird/thunderbird-android.git synced 2024-09-19 19:52:14 +02:00

Remove Account dependency on K9

This commit is contained in:
Wolf-Martell Montwé 2024-08-01 12:54:53 +02:00
parent ca3333a91a
commit 20e5517cad
No known key found for this signature in database
GPG Key ID: 6D45B21512ACBF72
2 changed files with 11 additions and 5 deletions

View File

@ -9,10 +9,16 @@ import com.fsck.k9.mail.ServerSettings
import java.util.Calendar
import java.util.Date
// This needs to be in sync with K9.DEFAULT_VISIBLE_LIMIT
const val DEFAULT_VISIBLE_LIMIT = 25
/**
* Account stores all of the settings for a single account defined by the user. Each account is defined by a UUID.
*/
class Account(override val uuid: String) : BaseAccount {
class Account(
override val uuid: String,
private val isSensitiveDebugLoggingEnabled: () -> Boolean = { false },
) : BaseAccount {
@get:Synchronized
@set:Synchronized
var deletePolicy = DeletePolicy.NEVER
@ -71,7 +77,7 @@ class Account(override val uuid: String) : BaseAccount {
var displayCount = 0
set(value) {
if (field != value) {
field = value.takeIf { it != -1 } ?: K9.DEFAULT_VISIBLE_LIMIT
field = value.takeIf { it != -1 } ?: DEFAULT_VISIBLE_LIMIT
isChangedVisibleLimits = true
}
}
@ -587,7 +593,7 @@ class Account(override val uuid: String) : BaseAccount {
}
override fun toString(): String {
return if (K9.isSensitiveDebugLoggingEnabled) displayName else uuid
return if (isSensitiveDebugLoggingEnabled()) displayName else uuid
}
override fun equals(other: Any?): Boolean {

View File

@ -78,7 +78,7 @@ class Preferences internal constructor(
val accountUuids = storage.getString("accountUuids", null)
if (!accountUuids.isNullOrEmpty()) {
accountUuids.split(",").forEach { uuid ->
val newAccount = Account(uuid)
val newAccount = Account(uuid, K9::isSensitiveDebugLoggingEnabled)
accountPreferenceSerializer.loadAccount(newAccount, storage)
accounts[uuid] = newAccount
@ -172,7 +172,7 @@ class Preferences internal constructor(
}
fun newAccount(accountUuid: String): Account {
val account = Account(accountUuid)
val account = Account(accountUuid, K9::isSensitiveDebugLoggingEnabled)
accountPreferenceSerializer.loadDefaults(account)
synchronized(accountLock) {