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

Commit 26ed6f95 authored by shamim-emon's avatar shamim-emon
Browse files

Refactor: Provided abstraction for com.fsck.k9.preferences.Storage -

1. Added an Interface Storage and put all the method definition there.
2. Renamed concrete Storage class to DefaultStorage and made it implement the Storage interface.
3. Updated all relevant reference of DefaultStorage with Storage interface reference.
parent a8fb859a
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
package net.thunderbird.core.android.preferences

import com.fsck.k9.preferences.Storage
import com.fsck.k9.preferences.DefaultStorage
import com.fsck.k9.preferences.StorageEditor
import com.fsck.k9.preferences.StoragePersister
import com.fsck.k9.preferences.StorageUpdater
import net.thunderbird.core.preferences.Storage

class InMemoryStoragePersister : StoragePersister {
    private val values = mutableMapOf<String, Any?>()

    override fun loadValues(): Storage {
        return Storage(values.mapValues { (_, value) -> value?.toString() ?: "" })
        return DefaultStorage(
            values.mapValues { (_, value) ->
                value?.toString() ?: ""
            },
        )
    }

    override fun createStorageEditor(storageUpdater: StorageUpdater): StorageEditor {
@@ -60,7 +65,7 @@ class InMemoryStoragePersister : StoragePersister {
        }

        private fun writeValues(currentStorage: Storage): Storage {
            return Storage(currentStorage.all - removals + changes)
            return DefaultStorage(currentStorage.getAll() - removals + changes)
        }
    }
}
+17 −0
Original line number Diff line number Diff line
package net.thunderbird.core.preferences

interface Storage {
    fun isEmpty(): Boolean

    fun contains(key: String): Boolean

    fun getAll(): Map<String, String>

    fun getBoolean(key: String, defValue: Boolean): Boolean

    fun getInt(key: String, defValue: Int): Int

    fun getLong(key: String, defValue: Long): Long

    fun getString(key: String?, defValue: String?): String
}
+1 −1
Original line number Diff line number Diff line
@@ -24,9 +24,9 @@ import app.k9mail.legacy.account.QuoteStyle
import app.k9mail.legacy.account.ShowPictures
import app.k9mail.legacy.account.SortType
import com.fsck.k9.helper.Utility
import com.fsck.k9.preferences.Storage
import com.fsck.k9.preferences.StorageEditor
import net.thunderbird.core.mail.folder.api.SpecialFolderSelection
import net.thunderbird.core.preferences.Storage
import net.thunderbird.feature.notification.NotificationLight
import net.thunderbird.feature.notification.NotificationSettings
import net.thunderbird.feature.notification.NotificationVibration
+1 −1
Original line number Diff line number Diff line
@@ -2,8 +2,8 @@ package com.fsck.k9

import android.util.TypedValue
import android.widget.TextView
import com.fsck.k9.preferences.Storage
import com.fsck.k9.preferences.StorageEditor
import net.thunderbird.core.preferences.Storage

/**
 * Manage font size of the information displayed in the message list and in the message view.
+1 −1
Original line number Diff line number Diff line
@@ -13,9 +13,9 @@ import com.fsck.k9.logging.Logger
import com.fsck.k9.mail.K9MailLib
import com.fsck.k9.mailstore.LocalStore
import com.fsck.k9.preferences.RealGeneralSettingsManager
import com.fsck.k9.preferences.Storage
import com.fsck.k9.preferences.StorageEditor
import kotlinx.datetime.Clock
import net.thunderbird.core.preferences.Storage
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import timber.log.Timber
Loading