Repository: thunderbird/thunderbird-android (language: kotlin)

Issue:
Replace all direct usage of K9.isShowCorrespondentNames with PreferenceDataStore
Goal of this issue is to replace all direct usage of` K9.isShowCorrespondentNames` withPreferenceDataStore's implementation of `GeneralSettingsDataStore`


Discussion hints:
nan

Pull request: Replace all direct usage of K9.isShowCorrespondentNames with PreferenceDataStore
 - Fixes #9267 

Test command: ./gradlew :legacy:core:testDebugUnitTest --tests "com.fsck.k9.notification.NotificationContentCreatorTest" --tests "com.fsck.k9.helper.MessageHelperTest"

Fix patch:
diff --git a/core/preferences/src/commonMain/kotlin/net/thunderbird/core/preferences/GeneralSettings.kt b/core/preferences/src/commonMain/kotlin/net/thunderbird/core/preferences/GeneralSettings.kt
index db52ec02e0a..f06fd6ca5e5 100644
--- a/core/preferences/src/commonMain/kotlin/net/thunderbird/core/preferences/GeneralSettings.kt
+++ b/core/preferences/src/commonMain/kotlin/net/thunderbird/core/preferences/GeneralSettings.kt
@@ -21,6 +21,7 @@ data class GeneralSettings(
     val isShowStarredCount: Boolean,
     val isShowMessageListStars: Boolean,
     val isShowAnimations: Boolean,
+    val isShowCorrespondentNames: Boolean,
 )
 
 enum class BackgroundSync {
diff --git a/core/preferences/src/commonMain/kotlin/net/thunderbird/core/preferences/GeneralSettingsManager.kt b/core/preferences/src/commonMain/kotlin/net/thunderbird/core/preferences/GeneralSettingsManager.kt
index 2f40c21b761..5f1b665b87f 100644
--- a/core/preferences/src/commonMain/kotlin/net/thunderbird/core/preferences/GeneralSettingsManager.kt
+++ b/core/preferences/src/commonMain/kotlin/net/thunderbird/core/preferences/GeneralSettingsManager.kt
@@ -20,4 +20,5 @@ interface GeneralSettingsManager {
     fun setIsShowStarredCount(isShowStarredCount: Boolean)
     fun setIsShowMessageListStars(isShowMessageListStars: Boolean)
     fun setIsShowAnimations(isShowAnimations: Boolean)
+    fun setIsShowCorrespondentNames(isShowCorrespondentNames: Boolean)
 }
diff --git a/feature/widget/message-list-glance/src/main/kotlin/net/thunderbird/feature/widget/message/list/KoinModule.kt b/feature/widget/message-list-glance/src/main/kotlin/net/thunderbird/feature/widget/message/list/KoinModule.kt
index 70605941e4b..f7a061c8066 100644
--- a/feature/widget/message-list-glance/src/main/kotlin/net/thunderbird/feature/widget/message/list/KoinModule.kt
+++ b/feature/widget/message-list-glance/src/main/kotlin/net/thunderbird/feature/widget/message/list/KoinModule.kt
@@ -3,5 +3,12 @@ package net.thunderbird.feature.widget.message.list
 import org.koin.dsl.module
 
 val featureWidgetMessageListModule = module {
-    factory { MessageListLoader(preferences = get(), messageListRepository = get(), messageHelper = get()) }
+    factory {
+        MessageListLoader(
+            preferences = get(),
+            messageListRepository = get(),
+            messageHelper = get(),
+            generalSettingsManager = get(),
+        )
+    }
 }
diff --git a/feature/widget/message-list-glance/src/main/kotlin/net/thunderbird/feature/widget/message/list/MessageListItemMapper.kt b/feature/widget/message-list-glance/src/main/kotlin/net/thunderbird/feature/widget/message/list/MessageListItemMapper.kt
index 730feb3cb46..11536f9c557 100644
--- a/feature/widget/message-list-glance/src/main/kotlin/net/thunderbird/feature/widget/message/list/MessageListItemMapper.kt
+++ b/feature/widget/message-list-glance/src/main/kotlin/net/thunderbird/feature/widget/message/list/MessageListItemMapper.kt
@@ -8,10 +8,12 @@ import com.fsck.k9.ui.helper.DisplayAddressHelper
 import java.util.Calendar
 import java.util.Locale
 import net.thunderbird.core.android.account.LegacyAccount
+import net.thunderbird.core.preferences.GeneralSettingsManager
 
 internal class MessageListItemMapper(
     private val messageHelper: MessageHelper,
     private val account: LegacyAccount,
+    private val generalSettingsManager: GeneralSettingsManager,
 ) : MessageMapper<MessageListItem> {
     private val calendar: Calendar = Calendar.getInstance()
 
@@ -24,7 +26,10 @@ internal class MessageListItemMapper(
         val showRecipients = DisplayAddressHelper.shouldShowRecipients(account, message.folderId)
         val displayAddress = if (showRecipients) toAddresses.firstOrNull() else fromAddresses.firstOrNull()
         val displayName = if (showRecipients) {
-            messageHelper.getRecipientDisplayNames(toAddresses.toTypedArray()).toString()
+            messageHelper.getRecipientDisplayNames(
+                toAddresses.toTypedArray(),
+                generalSettingsManager.getSettings().isShowCorrespondentNames,
+            ).toString()
         } else {
             messageHelper.getSenderDisplayName(displayAddress).toString()
         }
diff --git a/feature/widget/message-list-glance/src/main/kotlin/net/thunderbird/feature/widget/message/list/MessageListLoader.kt b/feature/widget/message-list-glance/src/main/kotlin/net/thunderbird/feature/widget/message/list/MessageListLoader.kt
index 9e3affb49e8..cf03cea3c41 100644
--- a/feature/widget/message-list-glance/src/main/kotlin/net/thunderbird/feature/widget/message/list/MessageListLoader.kt
+++ b/feature/widget/message-list-glance/src/main/kotlin/net/thunderbird/feature/widget/message/list/MessageListLoader.kt
@@ -9,11 +9,13 @@ import com.fsck.k9.search.getAccounts
 import net.thunderbird.core.android.account.LegacyAccount
 import net.thunderbird.core.android.account.SortType
 import net.thunderbird.core.logging.legacy.Log
+import net.thunderbird.core.preferences.GeneralSettingsManager
 
 internal class MessageListLoader(
     private val preferences: Preferences,
     private val messageListRepository: MessageListRepository,
     private val messageHelper: MessageHelper,
+    private val generalSettingsManager: GeneralSettingsManager,
 ) {
 
     @Suppress("TooGenericExceptionCaught")
@@ -42,7 +44,7 @@ internal class MessageListLoader(
     private fun loadMessageListForAccount(account: LegacyAccount, config: MessageListConfig): List<MessageListItem> {
         val accountUuid = account.uuid
         val sortOrder = buildSortOrder(config)
-        val mapper = MessageListItemMapper(messageHelper, account)
+        val mapper = MessageListItemMapper(messageHelper, account, generalSettingsManager)
 
         return if (config.showingThreadedList) {
             val (selection, selectionArgs) = buildSelection(config)
diff --git a/feature/widget/message-list/src/main/kotlin/app/k9mail/feature/widget/message/list/KoinModule.kt b/feature/widget/message-list/src/main/kotlin/app/k9mail/feature/widget/message/list/KoinModule.kt
index d70caa03713..bebab0517fb 100644
--- a/feature/widget/message-list/src/main/kotlin/app/k9mail/feature/widget/message/list/KoinModule.kt
+++ b/feature/widget/message-list/src/main/kotlin/app/k9mail/feature/widget/message/list/KoinModule.kt
@@ -4,5 +4,12 @@ import org.koin.dsl.module
 
 val messageListWidgetModule = module {
     single { MessageListWidgetManager(context = get(), messageListRepository = get(), config = get()) }
-    factory { MessageListLoader(preferences = get(), messageListRepository = get(), messageHelper = get()) }
+    factory {
+        MessageListLoader(
+            preferences = get(),
+            messageListRepository = get(),
+            messageHelper = get(),
+            generalSettingsManager = get(),
+        )
+    }
 }
diff --git a/feature/widget/message-list/src/main/kotlin/app/k9mail/feature/widget/message/list/MessageListItemMapper.kt b/feature/widget/message-list/src/main/kotlin/app/k9mail/feature/widget/message/list/MessageListItemMapper.kt
index 7aa00a6e1eb..691920ecadd 100644
--- a/feature/widget/message-list/src/main/kotlin/app/k9mail/feature/widget/message/list/MessageListItemMapper.kt
+++ b/feature/widget/message-list/src/main/kotlin/app/k9mail/feature/widget/message/list/MessageListItemMapper.kt
@@ -8,10 +8,12 @@ import com.fsck.k9.ui.helper.DisplayAddressHelper
 import java.util.Calendar
 import java.util.Locale
 import net.thunderbird.core.android.account.LegacyAccount
+import net.thunderbird.core.preferences.GeneralSettingsManager
 
 internal class MessageListItemMapper(
     private val messageHelper: MessageHelper,
     private val account: LegacyAccount,
+    private val generalSettingsManager: GeneralSettingsManager,
 ) : MessageMapper<MessageListItem> {
     private val calendar: Calendar = Calendar.getInstance()
 
@@ -24,7 +26,10 @@ internal class MessageListItemMapper(
         val showRecipients = DisplayAddressHelper.shouldShowRecipients(account, message.folderId)
         val displayAddress = if (showRecipients) toAddresses.firstOrNull() else fromAddresses.firstOrNull()
         val displayName = if (showRecipients) {
-            messageHelper.getRecipientDisplayNames(toAddresses.toTypedArray()).toString()
+            messageHelper.getRecipientDisplayNames(
+                toAddresses.toTypedArray(),
+                generalSettingsManager.getSettings().isShowCorrespondentNames,
+            ).toString()
         } else {
             messageHelper.getSenderDisplayName(displayAddress).toString()
         }
diff --git a/feature/widget/message-list/src/main/kotlin/app/k9mail/feature/widget/message/list/MessageListLoader.kt b/feature/widget/message-list/src/main/kotlin/app/k9mail/feature/widget/message/list/MessageListLoader.kt
index d73a2118d63..264513f7e4c 100644
--- a/feature/widget/message-list/src/main/kotlin/app/k9mail/feature/widget/message/list/MessageListLoader.kt
+++ b/feature/widget/message-list/src/main/kotlin/app/k9mail/feature/widget/message/list/MessageListLoader.kt
@@ -9,11 +9,13 @@ import com.fsck.k9.search.getAccounts
 import net.thunderbird.core.android.account.LegacyAccount
 import net.thunderbird.core.android.account.SortType
 import net.thunderbird.core.logging.legacy.Log
+import net.thunderbird.core.preferences.GeneralSettingsManager
 
 internal class MessageListLoader(
     private val preferences: Preferences,
     private val messageListRepository: MessageListRepository,
     private val messageHelper: MessageHelper,
+    private val generalSettingsManager: GeneralSettingsManager,
 ) {
 
     @Suppress("TooGenericExceptionCaught")
@@ -42,7 +44,7 @@ internal class MessageListLoader(
     private fun loadMessageListForAccount(account: LegacyAccount, config: MessageListConfig): List<MessageListItem> {
         val accountUuid = account.uuid
         val sortOrder = buildSortOrder(config)
-        val mapper = MessageListItemMapper(messageHelper, account)
+        val mapper = MessageListItemMapper(messageHelper, account, generalSettingsManager)
 
         return if (config.showingThreadedList) {
             val (selection, selectionArgs) = buildSelection(config)
diff --git a/legacy/core/src/main/java/com/fsck/k9/K9.kt b/legacy/core/src/main/java/com/fsck/k9/K9.kt
index e1c1700bc65..a9a1c45dafd 100644
--- a/legacy/core/src/main/java/com/fsck/k9/K9.kt
+++ b/legacy/core/src/main/java/com/fsck/k9/K9.kt
@@ -174,9 +174,6 @@ object K9 : KoinComponent {
     @JvmStatic
     var messageListPreviewLines = 2
 
-    @JvmStatic
-    var isShowCorrespondentNames = true
-
     @JvmStatic
     var isMessageListSenderAboveSubject = false
 
@@ -341,7 +338,6 @@ object K9 : KoinComponent {
         quietTimeEnds = storage.getStringOrDefault("quietTimeEnds", "7:00")
 
         messageListDensity = storage.getEnum("messageListDensity", UiDensity.Default)
-        isShowCorrespondentNames = storage.getBoolean("showCorrespondentNames", true)
         isShowContactName = storage.getBoolean("showContactName", false)
         isShowContactPicture = storage.getBoolean("showContactPicture", true)
         isChangeContactNameColor = storage.getBoolean("changeRegisteredNameColor", false)
@@ -428,7 +424,6 @@ object K9 : KoinComponent {
         editor.putBoolean("messageListSenderAboveSubject", isMessageListSenderAboveSubject)
         editor.putBoolean("showAccountSelector", isShowAccountSelector)
         editor.putInt("messageListPreviewLines", messageListPreviewLines)
-        editor.putBoolean("showCorrespondentNames", isShowCorrespondentNames)
         editor.putBoolean("showContactName", isShowContactName)
         editor.putBoolean("showContactPicture", isShowContactPicture)
         editor.putBoolean("changeRegisteredNameColor", isChangeContactNameColor)
diff --git a/legacy/core/src/main/java/com/fsck/k9/helper/KoinModule.kt b/legacy/core/src/main/java/com/fsck/k9/helper/KoinModule.kt
index 906215c2232..a9c5af6cb14 100644
--- a/legacy/core/src/main/java/com/fsck/k9/helper/KoinModule.kt
+++ b/legacy/core/src/main/java/com/fsck/k9/helper/KoinModule.kt
@@ -7,7 +7,7 @@ import org.koin.dsl.module
 
 val helperModule = module {
     single { ClipboardManager(get()) }
-    single { MessageHelper(resourceProvider = get(), contactRepository = get()) }
+    single { MessageHelper(resourceProvider = get(), contactRepository = get(), generalSettingsManager = get()) }
     factory<KeyStoreDirectoryProvider> { AndroidKeyStoreDirectoryProvider(context = get()) }
     factory { get<Context>().getSystemService(Context.ALARM_SERVICE) as AlarmManager }
     factory<ContactNameProvider> { RealContactNameProvider(contactRepository = get()) }
diff --git a/legacy/core/src/main/java/com/fsck/k9/helper/MessageHelper.kt b/legacy/core/src/main/java/com/fsck/k9/helper/MessageHelper.kt
index 8236282d2d9..d73da55d158 100644
--- a/legacy/core/src/main/java/com/fsck/k9/helper/MessageHelper.kt
+++ b/legacy/core/src/main/java/com/fsck/k9/helper/MessageHelper.kt
@@ -10,14 +10,15 @@ import com.fsck.k9.CoreResourceProvider
 import com.fsck.k9.K9.contactNameColor
 import com.fsck.k9.K9.isChangeContactNameColor
 import com.fsck.k9.K9.isShowContactName
-import com.fsck.k9.K9.isShowCorrespondentNames
 import com.fsck.k9.mail.Address
 import java.util.regex.Pattern
 import net.thunderbird.core.common.mail.toEmailAddressOrNull
+import net.thunderbird.core.preferences.GeneralSettingsManager
 
 class MessageHelper(
     private val resourceProvider: CoreResourceProvider,
     private val contactRepository: ContactRepository,
+    private val generalSettingsManager: GeneralSettingsManager,
 ) {
 
     fun getSenderDisplayName(address: Address?): CharSequence {
@@ -25,15 +26,15 @@ class MessageHelper(
             return resourceProvider.contactUnknownSender()
         }
         val repository = if (isShowContactName) contactRepository else null
-        return toFriendly(address, repository)
+        return toFriendly(address, generalSettingsManager.getSettings().isShowCorrespondentNames, repository)
     }
 
-    fun getRecipientDisplayNames(addresses: Array<Address>?): CharSequence {
+    fun getRecipientDisplayNames(addresses: Array<Address>?, isShowCorrespondentNames: Boolean): CharSequence {
         if (addresses == null || addresses.isEmpty()) {
             return resourceProvider.contactUnknownRecipient()
         }
         val repository = if (isShowContactName) contactRepository else null
-        val recipients = toFriendly(addresses, repository)
+        val recipients = toFriendly(addresses, isShowCorrespondentNames, repository)
         return SpannableStringBuilder(resourceProvider.contactDisplayNamePrefix()).append(' ').append(recipients)
     }
 
@@ -60,7 +61,11 @@ class MessageHelper(
          * @param contacts A [Contacts] instance or `null`.
          * @return A "friendly" name for this [Address].
          */
-        fun toFriendly(address: Address, contactRepository: ContactRepository?): CharSequence {
+        fun toFriendly(
+            address: Address,
+            isShowCorrespondentNames: Boolean,
+            contactRepository: ContactRepository?,
+        ): CharSequence {
             return toFriendly(
                 address,
                 contactRepository,
@@ -70,7 +75,11 @@ class MessageHelper(
             )
         }
 
-        fun toFriendly(addresses: Array<Address>?, contactRepository: ContactRepository?): CharSequence? {
+        fun toFriendly(
+            addresses: Array<Address>?,
+            isShowCorrespondentNames: Boolean,
+            contactRepository: ContactRepository?,
+        ): CharSequence? {
             var repository = contactRepository
             if (addresses == null) {
                 return null
@@ -81,7 +90,7 @@ class MessageHelper(
             }
             val stringBuilder = SpannableStringBuilder()
             for (i in addresses.indices) {
-                stringBuilder.append(toFriendly(addresses[i], repository))
+                stringBuilder.append(toFriendly(addresses[i], isShowCorrespondentNames, repository))
                 if (i < addresses.size - 1) {
                     stringBuilder.append(',')
                 }
diff --git a/legacy/core/src/main/java/com/fsck/k9/notification/CoreKoinModule.kt b/legacy/core/src/main/java/com/fsck/k9/notification/CoreKoinModule.kt
index fe709af7607..2e3844e0f1d 100644
--- a/legacy/core/src/main/java/com/fsck/k9/notification/CoreKoinModule.kt
+++ b/legacy/core/src/main/java/com/fsck/k9/notification/CoreKoinModule.kt
@@ -78,7 +78,13 @@ val coreNotificationModule = module {
             clock = get(),
         )
     }
-    factory { NotificationContentCreator(resourceProvider = get(), contactRepository = get()) }
+    factory {
+        NotificationContentCreator(
+            resourceProvider = get(),
+            contactRepository = get(),
+            generalSettingsManager = get(),
+        )
+    }
     factory { BaseNotificationDataCreator() }
     factory { SingleMessageNotificationDataCreator() }
     factory { SummaryNotificationDataCreator(singleMessageNotificationDataCreator = get()) }
diff --git a/legacy/core/src/main/java/com/fsck/k9/notification/NotificationContentCreator.kt b/legacy/core/src/main/java/com/fsck/k9/notification/NotificationContentCreator.kt
index 7ec02e69c4d..57f73e40a6b 100644
--- a/legacy/core/src/main/java/com/fsck/k9/notification/NotificationContentCreator.kt
+++ b/legacy/core/src/main/java/com/fsck/k9/notification/NotificationContentCreator.kt
@@ -8,10 +8,12 @@ import com.fsck.k9.helper.MessageHelper
 import com.fsck.k9.mail.Message
 import com.fsck.k9.mailstore.LocalMessage
 import net.thunderbird.core.android.account.LegacyAccount
+import net.thunderbird.core.preferences.GeneralSettingsManager
 
 internal class NotificationContentCreator(
     private val resourceProvider: NotificationResourceProvider,
     private val contactRepository: ContactRepository,
+    private val generalSettingsManager: GeneralSettingsManager,
 ) {
     fun createFromMessage(account: LegacyAccount, message: LocalMessage): NotificationContent {
         val sender = getMessageSender(account, message)
@@ -77,7 +79,11 @@ internal class NotificationContentCreator(
         if (!fromAddresses.isNullOrEmpty()) {
             isSelf = account.isAnIdentity(fromAddresses)
             if (!isSelf) {
-                return MessageHelper.toFriendly(fromAddresses.first(), localContactRepository).toString()
+                return MessageHelper.toFriendly(
+                    fromAddresses.first(),
+                    generalSettingsManager.getSettings().isShowCorrespondentNames,
+                    localContactRepository,
+                ).toString()
             }
         }
 
@@ -87,6 +93,7 @@ internal class NotificationContentCreator(
             if (!recipients.isNullOrEmpty()) {
                 val recipientDisplayName = MessageHelper.toFriendly(
                     address = recipients.first(),
+                    isShowCorrespondentNames = generalSettingsManager.getSettings().isShowCorrespondentNames,
                     contactRepository = localContactRepository,
                 ).toString()
                 return resourceProvider.recipientDisplayName(recipientDisplayName)
diff --git a/legacy/core/src/main/java/com/fsck/k9/preferences/RealGeneralSettingsManager.kt b/legacy/core/src/main/java/com/fsck/k9/preferences/RealGeneralSettingsManager.kt
index 995d78122b9..29d1e05c615 100644
--- a/legacy/core/src/main/java/com/fsck/k9/preferences/RealGeneralSettingsManager.kt
+++ b/legacy/core/src/main/java/com/fsck/k9/preferences/RealGeneralSettingsManager.kt
@@ -150,6 +150,10 @@ internal class RealGeneralSettingsManager(
         getSettings().copy(isShowAnimations = isShowAnimations).persist()
     }
 
+    override fun setIsShowCorrespondentNames(isShowCorrespondentNames: Boolean) {
+        getSettings().copy(isShowCorrespondentNames = isShowCorrespondentNames).persist()
+    }
+
     private fun writeSettings(editor: StorageEditor, settings: GeneralSettings) {
         editor.putBoolean("showRecentChanges", settings.showRecentChanges)
         editor.putEnum("theme", settings.appTheme)
@@ -160,6 +164,7 @@ internal class RealGeneralSettingsManager(
         editor.putBoolean("showStarredCount", settings.isShowStarredCount)
         editor.putBoolean("messageListStars", settings.isShowMessageListStars)
         editor.putBoolean("animations", settings.isShowAnimations)
+        editor.putBoolean("showCorrespondentNames", settings.isShowCorrespondentNames)
     }
 
     private fun loadGeneralSettings(): GeneralSettings {
@@ -182,6 +187,7 @@ internal class RealGeneralSettingsManager(
             isShowStarredCount = storage.getBoolean("showStarredCount", false),
             isShowMessageListStars = storage.getBoolean("messageListStars", true),
             isShowAnimations = storage.getBoolean("animations", true),
+            isShowCorrespondentNames = storage.getBoolean("showCorrespondentNames", true),
         )
 
         updateSettingsFlow(settings)
diff --git a/legacy/ui/legacy/src/main/java/com/fsck/k9/activity/MessageListActivityConfig.kt b/legacy/ui/legacy/src/main/java/com/fsck/k9/activity/MessageListActivityConfig.kt
index 5ed6549f32e..36a3d396e03 100644
--- a/legacy/ui/legacy/src/main/java/com/fsck/k9/activity/MessageListActivityConfig.kt
+++ b/legacy/ui/legacy/src/main/java/com/fsck/k9/activity/MessageListActivityConfig.kt
@@ -47,7 +47,7 @@ data class MessageListActivityConfig(
                 appTheme = settings.appTheme,
                 isShowUnifiedInbox = generalSettingsManager.getSettings().isShowUnifiedInbox,
                 isShowMessageListStars = generalSettingsManager.getSettings().isShowMessageListStars,
-                isShowCorrespondentNames = K9.isShowCorrespondentNames,
+                isShowCorrespondentNames = generalSettingsManager.getSettings().isShowCorrespondentNames,
                 isMessageListSenderAboveSubject = K9.isMessageListSenderAboveSubject,
                 isShowContactName = K9.isShowContactName,
                 isChangeContactNameColor = K9.isChangeContactNameColor,
diff --git a/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/KoinModule.kt b/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/KoinModule.kt
index c4ffedef71f..69936a62c54 100644
--- a/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/KoinModule.kt
+++ b/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/KoinModule.kt
@@ -16,6 +16,7 @@ val messageListUiModule = module {
             localStoreProvider = get(),
             messageListRepository = get(),
             messageHelper = get(),
+            generalSettingsManager = get(),
         )
     }
     factory {
diff --git a/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListItemMapper.kt b/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListItemMapper.kt
index ead93a2e3c7..ec024931df8 100644
--- a/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListItemMapper.kt
+++ b/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListItemMapper.kt
@@ -6,10 +6,12 @@ import app.k9mail.legacy.message.extractors.PreviewResult.PreviewType
 import com.fsck.k9.helper.MessageHelper
 import com.fsck.k9.ui.helper.DisplayAddressHelper
 import net.thunderbird.core.android.account.LegacyAccount
+import net.thunderbird.core.preferences.GeneralSettingsManager
 
 class MessageListItemMapper(
     private val messageHelper: MessageHelper,
     private val account: LegacyAccount,
+    private val generalSettingsManager: GeneralSettingsManager,
 ) : MessageMapper<MessageListItem> {
 
     override fun map(message: MessageDetailsAccessor): MessageListItem {
@@ -22,7 +24,10 @@ class MessageListItemMapper(
         val showRecipients = DisplayAddressHelper.shouldShowRecipients(account, message.folderId)
         val displayAddress = if (showRecipients) toAddresses.firstOrNull() else fromAddresses.firstOrNull()
         val displayName = if (showRecipients) {
-            messageHelper.getRecipientDisplayNames(toAddresses.toTypedArray())
+            messageHelper.getRecipientDisplayNames(
+                toAddresses.toTypedArray(),
+                generalSettingsManager.getSettings().isShowCorrespondentNames,
+            )
         } else {
             messageHelper.getSenderDisplayName(displayAddress)
         }
diff --git a/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListLoader.kt b/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListLoader.kt
index 9201d0b27b8..a8816ab9613 100644
--- a/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListLoader.kt
+++ b/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListLoader.kt
@@ -10,6 +10,7 @@ import com.fsck.k9.search.getAccounts
 import net.thunderbird.core.android.account.LegacyAccount
 import net.thunderbird.core.android.account.SortType
 import net.thunderbird.core.logging.legacy.Log
+import net.thunderbird.core.preferences.GeneralSettingsManager
 import net.thunderbird.feature.search.LocalSearch
 import net.thunderbird.feature.search.api.SearchField
 
@@ -18,6 +19,7 @@ class MessageListLoader(
     private val localStoreProvider: LocalStoreProvider,
     private val messageListRepository: MessageListRepository,
     private val messageHelper: MessageHelper,
+    private val generalSettingsManager: GeneralSettingsManager,
 ) {
 
     fun getMessageList(config: MessageListConfig): MessageListInfo {
@@ -48,16 +50,18 @@ class MessageListLoader(
         val accountUuid = account.uuid
         val threadId = getThreadId(config.search)
         val sortOrder = buildSortOrder(config)
-        val mapper = MessageListItemMapper(messageHelper, account)
+        val mapper = MessageListItemMapper(messageHelper, account, generalSettingsManager)
 
         return when {
             threadId != null -> {
                 messageListRepository.getThread(accountUuid, threadId, sortOrder, mapper)
             }
+
             config.showingThreadedList -> {
                 val (selection, selectionArgs) = buildSelection(account, config)
                 messageListRepository.getThreadedMessages(accountUuid, selection, selectionArgs, sortOrder, mapper)
             }
+
             else -> {
                 val (selection, selectionArgs) = buildSelection(account, config)
                 messageListRepository.getMessages(accountUuid, selection, selectionArgs, sortOrder, mapper)
@@ -126,27 +130,33 @@ class MessageListLoader(
             SortType.SORT_DATE -> {
                 compareBy(config.sortAscending) { it.messageDate }
             }
+
             SortType.SORT_ARRIVAL -> {
                 compareBy(config.sortAscending) { it.internalDate }
             }
+
             SortType.SORT_SUBJECT -> {
                 compareStringBy<MessageListItem>(config.sortAscending) { it.subject.orEmpty() }
                     .thenByDate(config)
             }
+
             SortType.SORT_SENDER -> {
                 compareStringBy<MessageListItem>(config.sortAscending) { it.displayName.toString() }
                     .thenByDate(config)
             }
+
             SortType.SORT_UNREAD -> {
                 compareBy<MessageListItem>(config.sortAscending) {
                     config.sortOverrides[it.messageReference]?.isRead ?: it.isRead
                 }.thenByDate(config)
             }
+
             SortType.SORT_FLAGGED -> {
                 compareBy<MessageListItem>(!config.sortAscending) {
                     config.sortOverrides[it.messageReference]?.isStarred ?: it.isStarred
                 }.thenByDate(config)
             }
+
             SortType.SORT_ATTACHMENT -> {
                 compareBy<MessageListItem>(!config.sortAscending) { it.hasAttachments }
                     .thenByDate(config)
diff --git a/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/KoinModule.kt b/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/KoinModule.kt
index c898e5fa6c9..a6a2078d1a9 100644
--- a/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/KoinModule.kt
+++ b/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/KoinModule.kt
@@ -3,5 +3,11 @@ package com.fsck.k9.ui.messageview
 import org.koin.dsl.module
 
 val messageViewUiModule = module {
-    factory { createMessageViewRecipientFormatter(contactNameProvider = get(), resources = get()) }
+    factory {
+        createMessageViewRecipientFormatter(
+            contactNameProvider = get(),
+            resources = get(),
+            generalSettingsManager = get(),
+        )
+    }
 }
diff --git a/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/MessageViewRecipientFormatter.kt b/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/MessageViewRecipientFormatter.kt
index 274aeb97004..b5fed2d7990 100644
--- a/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/MessageViewRecipientFormatter.kt
+++ b/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/MessageViewRecipientFormatter.kt
@@ -10,6 +10,7 @@ import com.fsck.k9.mail.Address
 import com.fsck.k9.ui.R
 import net.thunderbird.core.android.account.Identity
 import net.thunderbird.core.android.account.LegacyAccount
+import net.thunderbird.core.preferences.GeneralSettingsManager
 
 /**
  * Get the display name for a recipient to be shown in the message view screen.
@@ -79,10 +80,11 @@ internal class RealMessageViewRecipientFormatter(
 internal fun createMessageViewRecipientFormatter(
     contactNameProvider: ContactNameProvider,
     resources: Resources,
+    generalSettingsManager: GeneralSettingsManager,
 ): MessageViewRecipientFormatter {
     return RealMessageViewRecipientFormatter(
         contactNameProvider = contactNameProvider,
-        showCorrespondentNames = K9.isShowCorrespondentNames,
+        showCorrespondentNames = generalSettingsManager.getSettings().isShowCorrespondentNames,
         showContactNames = K9.isShowContactName,
         contactNameColor = if (K9.isChangeContactNameColor) K9.contactNameColor else null,
         meText = resources.getString(R.string.message_view_me_text),
diff --git a/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/settings/general/GeneralSettingsDataStore.kt b/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/settings/general/GeneralSettingsDataStore.kt
index d118310870e..7a9d98cbda3 100644
--- a/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/settings/general/GeneralSettingsDataStore.kt
+++ b/legacy/ui/legacy/src/main/java/com/fsck/k9/ui/settings/general/GeneralSettingsDataStore.kt
@@ -29,7 +29,7 @@ class GeneralSettingsDataStore(
             "show_unified_inbox" -> generalSettingsManager.getSettings().isShowUnifiedInbox
             "show_starred_count" -> generalSettingsManager.getSettings().isShowStarredCount
             "messagelist_stars" -> generalSettingsManager.getSettings().isShowMessageListStars
-            "messagelist_show_correspondent_names" -> K9.isShowCorrespondentNames
+            "messagelist_show_correspondent_names" -> generalSettingsManager.getSettings().isShowCorrespondentNames
             "messagelist_sender_above_subject" -> K9.isMessageListSenderAboveSubject
             "messagelist_show_contact_name" -> K9.isShowContactName
             "messagelist_change_contact_name_color" -> K9.isChangeContactNameColor
@@ -60,7 +60,7 @@ class GeneralSettingsDataStore(
             "show_unified_inbox" -> setIsShowUnifiedInbox(value)
             "show_starred_count" -> setIsShowStarredCount(isShowStarredCount = value)
             "messagelist_stars" -> setIsShowMessageListStars(isShowMessageListStars = value)
-            "messagelist_show_correspondent_names" -> K9.isShowCorrespondentNames = value
+            "messagelist_show_correspondent_names" -> setIsShowCorrespondentNames(isShowCorrespondentNames = value)
             "messagelist_sender_above_subject" -> K9.isMessageListSenderAboveSubject = value
             "messagelist_show_contact_name" -> K9.isShowContactName = value
             "messagelist_change_contact_name_color" -> K9.isChangeContactNameColor = value
@@ -282,6 +282,11 @@ class GeneralSettingsDataStore(
         generalSettingsManager.setIsShowAnimations(isShowAnimations)
     }
 
+    private fun setIsShowCorrespondentNames(isShowCorrespondentNames: Boolean) {
+        skipSaveSettings = true
+        generalSettingsManager.setIsShowCorrespondentNames(isShowCorrespondentNames)
+    }
+
     private fun appThemeToString(theme: AppTheme) = when (theme) {
         AppTheme.LIGHT -> "light"
         AppTheme.DARK -> "dark"
diff --git a/legacy/ui/legacy/src/main/java/com/fsck/k9/view/RecipientSelectView.java b/legacy/ui/legacy/src/main/java/com/fsck/k9/view/RecipientSelectView.java
index 9105f31b5cd..3a51b23f2d2 100644
--- a/legacy/ui/legacy/src/main/java/com/fsck/k9/view/RecipientSelectView.java
+++ b/legacy/ui/legacy/src/main/java/com/fsck/k9/view/RecipientSelectView.java
@@ -47,13 +47,14 @@
 import com.google.android.material.textview.MaterialTextView;
 import com.tokenautocomplete.TokenCompleteTextView;
 import de.hdodenhof.circleimageview.CircleImageView;
+import net.thunderbird.core.preferences.GeneralSettingsManager;
 import net.thunderbird.core.logging.legacy.Log;
 
 import static com.fsck.k9.FontSizes.FONT_DEFAULT;
 
 
 public class RecipientSelectView extends TokenCompleteTextView<Recipient> implements LoaderCallbacks<List<Recipient>>,
-        AlternateRecipientListener {
+    AlternateRecipientListener {
 
     private static final int MINIMUM_LENGTH_FOR_FILTERING = 2;
 
@@ -65,6 +66,8 @@ public class RecipientSelectView extends TokenCompleteTextView<Recipient> implem
 
     private final UserInputEmailAddressParser emailAddressParser = DI.get(UserInputEmailAddressParser.class);
 
+    private final GeneralSettingsManager generalSettingsManager = DI.get(GeneralSettingsManager.class);
+
     private RecipientAdapter adapter;
     @Nullable
     private String cryptoProvider;
@@ -149,7 +152,9 @@ private View inflateLayout() {
     private void bindObjectView(Recipient recipient, View view) {
         RecipientTokenViewHolder holder = (RecipientTokenViewHolder) view.getTag();
 
-        holder.vName.setText(recipient.getDisplayNameOrAddress());
+        holder.vName.setText(recipient.getDisplayNameOrAddress(
+            generalSettingsManager.getSettings().isShowCorrespondentNames()
+        ));
         if (tokenTextSize != FONT_DEFAULT) {
             holder.vName.setTextSize(TypedValue.COMPLEX_UNIT_SP, tokenTextSize);
         }
@@ -163,7 +168,7 @@ private void bindObjectView(Recipient recipient, View view) {
         }
 
         boolean isAvailable = recipient.cryptoStatus == RecipientCryptoStatus.AVAILABLE_TRUSTED ||
-                recipient.cryptoStatus == RecipientCryptoStatus.AVAILABLE_UNTRUSTED;
+            recipient.cryptoStatus == RecipientCryptoStatus.AVAILABLE_UNTRUSTED;
 
         holder.showCryptoState(isAvailable, showCryptoEnabled);
     }
@@ -224,16 +229,15 @@ public void onFocusChanged(boolean hasFocus, int direction, Rect previous) {
     }
 
     /**
-     * TokenCompleteTextView removes composing strings, and etc, but leaves internal composition
-     * predictions partially constructed. Changing either/or the Selection or Candidate start/end
-     * positions, forces the IMM to reset cleaner.
+     * TokenCompleteTextView removes composing strings, and etc, but leaves internal composition predictions partially
+     * constructed. Changing either/or the Selection or Candidate start/end positions, forces the IMM to reset cleaner.
      */
     @Override
     protected void replaceText(CharSequence text) {
         super.replaceText(text);
 
         InputMethodManager imm = (InputMethodManager) getContext().getSystemService(
-                Context.INPUT_METHOD_SERVICE);
+            Context.INPUT_METHOD_SERVICE);
         imm.updateSelection(this, getSelectionStart(), getSelectionEnd(), -1, -1);
     }
 
@@ -506,8 +510,8 @@ public void onRecipientAddressCopy(Recipient currentRecipient) {
     }
 
     /**
-     * Changing the size of our RecipientTokenSpan doesn't seem to redraw the cursor in the new position. This will
-     * make sure the cursor position is recalculated.
+     * Changing the size of our RecipientTokenSpan doesn't seem to redraw the cursor in the new position. This will make
+     * sure the cursor position is recalculated.
      */
     private void invalidateCursorPositionHack() {
         int oldStart = getSelectionStart();
@@ -522,9 +526,8 @@ private void invalidateCursorPositionHack() {
     }
 
     /**
-     * This method builds the span given a recipient object. We override it with identical
-     * functionality, but using the custom RecipientTokenSpan class which allows us to
-     * retrieve the view for redrawing at a later point.
+     * This method builds the span given a recipient object. We override it with identical functionality, but using the
+     * custom RecipientTokenSpan class which allows us to retrieve the view for redrawing at a later point.
      */
     @Override
     protected TokenImageSpan buildSpanForObject(Recipient obj) {
@@ -537,8 +540,8 @@ protected TokenImageSpan buildSpanForObject(Recipient obj) {
     }
 
     /**
-     * Find the token view tied to a given recipient. This method relies on spans to
-     * be of the RecipientTokenSpan class, as created by the buildSpanForObject method.
+     * Find the token view tied to a given recipient. This method relies on spans to be of the RecipientTokenSpan class,
+     * as created by the buildSpanForObject method.
      */
     private View getTokenViewForRecipient(Recipient currentRecipient) {
         Editable text = getText();
@@ -557,8 +560,8 @@ private View getTokenViewForRecipient(Recipient currentRecipient) {
     }
 
     /**
-     * We use a specialized version of TokenCompleteTextView.TokenListener as well,
-     * adding a callback for onTokenChanged.
+     * We use a specialized version of TokenCompleteTextView.TokenListener as well, adding a callback for
+     * onTokenChanged.
      */
     public void setTokenListener(TokenListener<Recipient> listener) {
         super.setTokenListener(listener);
@@ -592,7 +595,7 @@ public void onClick() {
 
         @Override
         public void draw(@NonNull Canvas canvas, CharSequence text, int start, int end, float x, int top, int y,
-                int bottom, @NonNull Paint paint) {
+            int bottom, @NonNull Paint paint) {
             super.draw(canvas, text, start, end, x, top, y, bottom, paint);
 
             // Dispatch onPreDraw event so image loading using Glide will work properly.
@@ -660,7 +663,7 @@ public Recipient(@NonNull Address address) {
         }
 
         public Recipient(String name, String email, String addressLabel, long contactId, String lookupKey,
-                int timesContacted, String sortKey, boolean starred) {
+            int timesContacted, String sortKey, boolean starred) {
             this.address = new Address(email, name);
             this.contactId = contactId;
             this.addressLabel = addressLabel;
@@ -671,8 +674,8 @@ public Recipient(String name, String email, String addressLabel, long contactId,
             this.starred = starred;
         }
 
-        public String getDisplayNameOrAddress() {
-            final String displayName = K9.isShowCorrespondentNames() ? getDisplayName() : null;
+        public String getDisplayNameOrAddress(Boolean showCorrespondentNames) {
+            final String displayName = showCorrespondentNames ? getDisplayName() : null;
 
             if (displayName != null) {
                 return displayName;


Test patch:
diff --git a/legacy/core/src/test/java/com/fsck/k9/helper/MessageHelperTest.kt b/legacy/core/src/test/java/com/fsck/k9/helper/MessageHelperTest.kt
index 24fb41e7083..a29c84c4e33 100644
--- a/legacy/core/src/test/java/com/fsck/k9/helper/MessageHelperTest.kt
+++ b/legacy/core/src/test/java/com/fsck/k9/helper/MessageHelperTest.kt
@@ -14,27 +14,67 @@ import com.fsck.k9.mail.Address
 import net.thunderbird.core.android.testing.RobolectricTest
 import net.thunderbird.core.common.mail.EmailAddress
 import net.thunderbird.core.common.mail.toEmailAddressOrThrow
+import net.thunderbird.core.preferences.AppTheme
+import net.thunderbird.core.preferences.BackgroundSync
+import net.thunderbird.core.preferences.GeneralSettings
+import net.thunderbird.core.preferences.GeneralSettingsManager
+import net.thunderbird.core.preferences.SubTheme
+import org.junit.Before
 import org.junit.Test
 import org.mockito.kotlin.doReturn
 import org.mockito.kotlin.mock
 import org.mockito.kotlin.stub
+import org.mockito.kotlin.whenever
 
 class MessageHelperTest : RobolectricTest() {
 
     private val contactRepository: ContactRepository = mock()
+    private val generalSettingsManager: GeneralSettingsManager = mock()
     private val resourceProvider: CoreResourceProvider = TestCoreResourceProvider()
-    private val messageHelper: MessageHelper = MessageHelper(resourceProvider, contactRepository)
+    private val messageHelper: MessageHelper =
+        MessageHelper(resourceProvider, contactRepository, generalSettingsManager)
+
+    @Before
+    fun setUp() {
+        whenever(generalSettingsManager.getSettings()).doReturn(
+            GeneralSettings(
+                backgroundSync = BackgroundSync.ALWAYS,
+                showRecentChanges = true,
+                appTheme = AppTheme.DARK,
+                messageComposeTheme = SubTheme.DARK,
+                isShowCorrespondentNames = true,
+                fixedMessageViewTheme = true,
+                messageViewTheme = SubTheme.DARK,
+                isShowUnifiedInbox = false,
+                isShowStarredCount = false,
+                isShowMessageListStars = false,
+                isShowAnimations = false,
+            ),
+        )
+    }
 
     @Test
     fun testToFriendlyShowsPersonalPartIfItExists() {
         val address = Address("test@testor.com", "Tim Testor")
-        assertThat(toFriendly(address, contactRepository)).isEqualTo("Tim Testor")
+        assertThat(
+            toFriendly(
+                address,
+                generalSettingsManager.getSettings().isShowCorrespondentNames,
+                contactRepository,
+            ),
+        ).isEqualTo("Tim Testor")
     }
 
     @Test
     fun testToFriendlyShowsEmailPartIfNoPersonalPartExists() {
         val address = Address("test@testor.com")
-        assertThat(toFriendly(address, contactRepository)).isEqualTo("test@testor.com")
+        assertThat(
+            toFriendly(
+                address,
+                generalSettingsManager.getSettings().isShowCorrespondentNames,
+                contactRepository,
+            ),
+        ).isEqualTo("test@testor.com")
     }
 
     @Test
@@ -42,7 +82,13 @@ class MessageHelperTest : RobolectricTest() {
         val address1 = Address("test@testor.com", "Tim Testor")
         val address2 = Address("foo@bar.com", "Foo Bar")
         val addresses = arrayOf(address1, address2)
-        assertThat(toFriendly(addresses, contactRepository).toString()).isEqualTo("Tim Testor,Foo Bar")
+        assertThat(
+            toFriendly(
+                addresses,
+                generalSettingsManager.getSettings().isShowCorrespondentNames,
+                contactRepository,
+            ).toString(),
+        ).isEqualTo("Tim Testor,Foo Bar")
     }
 
     @Test
@@ -50,7 +96,13 @@ class MessageHelperTest : RobolectricTest() {
         val address = Address(EMAIL_ADDRESS.address)
         setupContactRepositoryWithFakeContact(EMAIL_ADDRESS)
 
-        assertThat(toFriendly(address, contactRepository)).isEqualTo("Tim Testor")
+        assertThat(
+            toFriendly(
+                address,
+                generalSettingsManager.getSettings().isShowCorrespondentNames,
+                contactRepository,
+            ),
+        ).isEqualTo("Tim Testor")
     }
 
     @Test
@@ -87,21 +139,24 @@ class MessageHelperTest : RobolectricTest() {
     @Test
     fun toFriendly_spoofPreventionOverridesPersonal() {
         val address = Address("test@testor.com", "potus@whitehouse.gov")
-        val friendly = toFriendly(address, contactRepository)
+        val friendly =
+            toFriendly(address, generalSettingsManager.getSettings().isShowCorrespondentNames, contactRepository)
         assertThat(friendly).isEqualTo("test@testor.com")
     }
 
     @Test
     fun toFriendly_atPrecededByOpeningParenthesisShouldNotTriggerSpoofPrevention() {
         val address = Address("gitlab@gitlab.example", "username (@username)")
-        val friendly = toFriendly(address, contactRepository)
+        val friendly =
+            toFriendly(address, generalSettingsManager.getSettings().isShowCorrespondentNames, contactRepository)
         assertThat(friendly).isEqualTo("username (@username)")
     }
 
     @Test
     fun toFriendly_nameStartingWithAtShouldNotTriggerSpoofPrevention() {
         val address = Address("address@domain.example", "@username")
-        val friendly = toFriendly(address, contactRepository)
+        val friendly =
+            toFriendly(address, generalSettingsManager.getSettings().isShowCorrespondentNames, contactRepository)
         assertThat(friendly).isEqualTo("@username")
     }
 
@@ -126,7 +181,10 @@ class MessageHelperTest : RobolectricTest() {
         val address2 = Address("foo@bar.com", "Foo Bar")
         val addresses = arrayOf(address1, address2)
         setupContactRepositoryWithFakeContact(EMAIL_ADDRESS)
-        val displayName = messageHelper.getRecipientDisplayNames(addresses)
+        val displayName = messageHelper.getRecipientDisplayNames(
+            addresses,
+            generalSettingsManager.getSettings().isShowCorrespondentNames,
+        )
         assertThat(displayName.toString()).isEqualTo("To: Tim Testor,Foo Bar")
     }
 
@@ -136,13 +194,17 @@ class MessageHelperTest : RobolectricTest() {
         val address2 = Address("foo@bar.com")
         val addresses = arrayOf(address1, address2)
 
-        val displayName = messageHelper.getRecipientDisplayNames(addresses)
+        val displayName = messageHelper.getRecipientDisplayNames(
+            addresses,
+            generalSettingsManager.getSettings().isShowCorrespondentNames,
+        )
         assertThat(displayName.toString()).isEqualTo("To: test@testor.com,foo@bar.com")
     }
 
     @Test
     fun testGetSenderDisplayNameWithoutInputReturnCorrectOutput() {
-        val displayName = messageHelper.getRecipientDisplayNames(null)
+        val displayName =
+            messageHelper.getRecipientDisplayNames(null, generalSettingsManager.getSettings().isShowCorrespondentNames)
         assertThat(displayName.toString()).isEqualTo(resourceProvider.contactUnknownRecipient())
     }
 
diff --git a/legacy/core/src/test/java/com/fsck/k9/notification/NotificationContentCreatorTest.kt b/legacy/core/src/test/java/com/fsck/k9/notification/NotificationContentCreatorTest.kt
index 71777caa26f..e6e040308a4 100644
--- a/legacy/core/src/test/java/com/fsck/k9/notification/NotificationContentCreatorTest.kt
+++ b/legacy/core/src/test/java/com/fsck/k9/notification/NotificationContentCreatorTest.kt
@@ -10,6 +10,10 @@ import com.fsck.k9.mail.Message.RecipientType
 import com.fsck.k9.mailstore.LocalMessage
 import net.thunderbird.core.android.account.LegacyAccount
 import net.thunderbird.core.android.testing.RobolectricTest
+import net.thunderbird.core.preferences.AppTheme
+import net.thunderbird.core.preferences.BackgroundSync
+import net.thunderbird.core.preferences.GeneralSettings
+import net.thunderbird.core.preferences.SubTheme
 import org.junit.Test
 import org.mockito.kotlin.any
 import org.mockito.kotlin.doReturn
@@ -142,6 +146,21 @@ class NotificationContentCreatorTest : RobolectricTest() {
         return NotificationContentCreator(
             resourceProvider,
             contactRepository,
+            mock {
+                on { getSettings() } doReturn GeneralSettings(
+                    backgroundSync = BackgroundSync.ALWAYS,
+                    showRecentChanges = true,
+                    appTheme = AppTheme.DARK,
+                    messageComposeTheme = SubTheme.DARK,
+                    isShowCorrespondentNames = true,
+                    fixedMessageViewTheme = true,
+                    messageViewTheme = SubTheme.DARK,
+                    isShowStarredCount = false,
+                    isShowUnifiedInbox = false,
+                    isShowMessageListStars = false,
+                    isShowAnimations = false,
+                )
+            },
         )
     }