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

Unverified Commit 48ce9477 authored by Wolf-Martell Montwé's avatar Wolf-Martell Montwé Committed by GitHub
Browse files

Merge pull request #9367 from shamim-emon/fix-issue-9345

Replace Direct Calls to K9.isUseBackgroundAsUnreadIndicator with PreferenceDataStore integration
parents 2098a2de 120f25cc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ data class GeneralSettings(
    val isShowContactPicture: Boolean,
    val isChangeContactNameColor: Boolean,
    val isColorizeMissingContactPictures: Boolean,
    val isUseBackgroundAsUnreadIndicator: Boolean,
)

enum class BackgroundSync {
+1 −0
Original line number Diff line number Diff line
@@ -27,4 +27,5 @@ interface GeneralSettingsManager {
    fun setIsShowContactPicture(isShowContactPicture: Boolean)
    fun setIsChangeContactNameColor(isChangeContactNameColor: Boolean)
    fun setIsColorizeMissingContactPictures(isColorizeMissingContactPictures: Boolean)
    fun setIsUseBackgroundAsUnreadIndicator(isUseBackgroundAsUnreadIndicator: Boolean)
}
+4 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ class BuildSwipeActionsTest {
            isShowContactPicture = false,
            isChangeContactNameColor = false,
            isColorizeMissingContactPictures = false,
            isUseBackgroundAsUnreadIndicator = false,
        )

    @Test
@@ -406,6 +407,9 @@ private class FakeGeneralSettingsManager(
    override fun setIsColorizeMissingContactPictures(isColorizeMissingContactPictures: Boolean) = error(
        "not implemented",
    )
    override fun setIsUseBackgroundAsUnreadIndicator(
        isUseBackgroundAsUnreadIndicator: Boolean,
    ) = error("not implemented")
}

private class FakeStorage(
+0 −5
Original line number Diff line number Diff line
@@ -220,9 +220,6 @@ object K9 : KoinComponent {
    var sortType: SortType = AccountDefaultsProvider.DEFAULT_SORT_TYPE
    private val sortAscending = mutableMapOf<SortType, Boolean>()

    @JvmStatic
    var isUseBackgroundAsUnreadIndicator = false

    @get:Synchronized
    @set:Synchronized
    var isShowComposeButtonOnMessageList = true
@@ -363,7 +360,6 @@ object K9 : KoinComponent {

        splitViewMode = storage.getEnum("splitViewMode", SplitViewMode.NEVER)

        isUseBackgroundAsUnreadIndicator = storage.getBoolean("useBackgroundAsUnreadIndicator", false)
        isShowComposeButtonOnMessageList = storage.getBoolean("showComposeButtonOnMessageList", true)
        isThreadedViewEnabled = storage.getBoolean("threadedView", true)

@@ -441,7 +437,6 @@ object K9 : KoinComponent {
        editor.putString("notificationQuickDelete", notificationQuickDeleteBehaviour.toString())
        editor.putString("lockScreenNotificationVisibility", lockScreenNotificationVisibility.toString())

        editor.putBoolean("useBackgroundAsUnreadIndicator", isUseBackgroundAsUnreadIndicator)
        editor.putBoolean("showComposeButtonOnMessageList", isShowComposeButtonOnMessageList)
        editor.putBoolean("threadedView", isThreadedViewEnabled)
        editor.putEnum("splitViewMode", splitViewMode)
+7 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import net.thunderbird.core.preference.storage.putEnum
internal const val KEY_SHOULD_SHOW_SETUP_ARCHIVE_FOLDER_DIALOG = "shouldShowSetupArchiveFolderDialog"
internal const val KEY_CHANGE_REGISTERED_NAME_COLOR = "changeRegisteredNameColor"
internal const val KEY_COLORIZE_MISSING_CONTACT_PICTURE = "colorizeMissingContactPictures"
internal const val KEY_USE_BACKGROUND_AS_UNREAD_INDICATOR = "isUseBackgroundAsUnreadIndicator"

/**
 * Retrieve and modify general settings.
@@ -185,6 +186,10 @@ internal class RealGeneralSettingsManager(
        getSettings().copy(isColorizeMissingContactPictures = isColorizeMissingContactPictures).persist()
    }

    override fun setIsUseBackgroundAsUnreadIndicator(isUseBackgroundAsUnreadIndicator: Boolean) {
        getSettings().copy(isUseBackgroundAsUnreadIndicator = isUseBackgroundAsUnreadIndicator).persist()
    }

    private fun writeSettings(editor: StorageEditor, settings: GeneralSettings) {
        editor.putBoolean("showRecentChanges", settings.showRecentChanges)
        editor.putEnum("theme", settings.appTheme)
@@ -202,6 +207,7 @@ internal class RealGeneralSettingsManager(
        editor.putBoolean("showContactPicture", settings.isShowContactPicture)
        editor.putBoolean(KEY_CHANGE_REGISTERED_NAME_COLOR, settings.isChangeContactNameColor)
        editor.putBoolean(KEY_COLORIZE_MISSING_CONTACT_PICTURE, settings.isColorizeMissingContactPictures)
        editor.putBoolean(KEY_USE_BACKGROUND_AS_UNREAD_INDICATOR, settings.isUseBackgroundAsUnreadIndicator)
    }

    private fun loadGeneralSettings(): GeneralSettings {
@@ -234,6 +240,7 @@ internal class RealGeneralSettingsManager(
            isShowContactPicture = storage.getBoolean("showContactPicture", true),
            isColorizeMissingContactPictures = storage.getBoolean(KEY_COLORIZE_MISSING_CONTACT_PICTURE, true),
            isChangeContactNameColor = storage.getBoolean(KEY_CHANGE_REGISTERED_NAME_COLOR, false),
            isUseBackgroundAsUnreadIndicator = storage.getBoolean(KEY_USE_BACKGROUND_AS_UNREAD_INDICATOR, false),
        )

        updateSettingsFlow(settings)
Loading