Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 20e5517c authored by Wolf-Martell Montwé's avatar Wolf-Martell Montwé
Browse files

Remove `Account` dependency on `K9`

parent ca3333a9
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -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 {
+2 −2
Original line number Diff line number Diff line
@@ -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) {