Repository: thunderbird/thunderbird-android
File: legacy/core/src/main/java/com/fsck/k9/preferences/RealGeneralSettingsManager.kt (Kotlin)

Code before:
    }

    override fun setIsShowContactPicture(isShowContactPicture: Boolean) {
        getSettings().copy(isShowContactPicture = isShowContactPicture).persist()
    }

    override fun setIsChangeContactNameColor(isChangeContactNameColor: Boolean) {
        getSettings().copy(isChangeContactNameColor = isChangeContactNameColor).persist()
    }

    private fun writeSettings(editor: StorageEditor, settings: GeneralSettings) {
        editor.putBoolean("showRecentChanges", settings.showRecentChanges)
        editor.putEnum("theme", settings.appTheme)
        editor.putEnum("messageViewTheme", settings.messageViewTheme)
        editor.putEnum("messageComposeTheme", settings.messageComposeTheme)
        editor.putBoolean("fixedMessageViewTheme", settings.fixedMessageViewTheme)
        editor.putBoolean("showUnifiedInbox", settings.isShowUnifiedInbox)
        editor.putBoolean("showStarredCount", settings.isShowStarredCount)
        editor.putBoolean("messageListStars", settings.isShowMessageListStars)
        editor.putBoolean("animations", settings.isShowAnimations)
        editor.putBoolean("showCorrespondentNames", settings.isShowCorrespondentNames)
        editor.putBoolean(KEY_SHOULD_SHOW_SETUP_ARCHIVE_FOLDER_DIALOG, settings.shouldShowSetupArchiveFolderDialog)
        editor.putBoolean("messageListSenderAboveSubject", settings.isMessageListSenderAboveSubject)
        editor.putBoolean("showContactName", settings.isShowContactName)
        editor.putBoolean("showContactPicture", settings.isShowContactPicture)
        editor.putBoolean("changeRegisteredNameColor", settings.isChangeContactNameColor)
    }

    private fun loadGeneralSettings(): GeneralSettings {
        val storage = preferences.storage

        val settings = GeneralSettings(
            backgroundSync = K9.backgroundOps.toBackgroundSync(),
            showRecentChanges = storage.getBoolean("showRecentChanges", true),
            appTheme = storage.getEnum("theme", AppTheme.FOLLOW_SYSTEM),
            messageViewTheme = storage.getEnum(
                "messageViewTheme",
                SubTheme.USE_GLOBAL,
            ),
            messageComposeTheme = storage.getEnum(
                "messageComposeTheme",
                SubTheme.USE_GLOBAL,
            ),
            fixedMessageViewTheme = storage.getBoolean("fixedMessageViewTheme", true),
            isShowUnifiedInbox = storage.getBoolean("showUnifiedInbox", false),
            isShowStarredCount = storage.getBoolean("showStarredCount", false),
            isShowMessageListStars = storage.getBoolean("messageListStars", true),
            isShowAnimations = storage.getBoolean("animations", true),
            isShowCorrespondentNames = storage.getBoolean("showCorrespondentNames", true),
            shouldShowSetupArchiveFolderDialog = storage.getBoolean(
                key = KEY_SHOULD_SHOW_SETUP_ARCHIVE_FOLDER_DIALOG,

Review comment (suggestion):
The `"changeRegisteredNameColor"` is used in multiple places. Please move it to a constant. You can take `KEY_SHOULD_SHOW_SETUP_ARCHIVE_FOLDER_DIALOG` as an example.

Code after:
        getSettings().copy(isShowContactName = isShowContactName).persist()
    }

    override fun setIsShowContactPicture(isShowContactPicture: Boolean) {
        getSettings().copy(isShowContactPicture = isShowContactPicture).persist()
    }

    override fun setIsChangeContactNameColor(isChangeContactNameColor: Boolean) {
        getSettings().copy(isChangeContactNameColor = isChangeContactNameColor).persist()
    }

    private fun writeSettings(editor: StorageEditor, settings: GeneralSettings) {
        editor.putBoolean("showRecentChanges", settings.showRecentChanges)
        editor.putEnum("theme", settings.appTheme)
        editor.putEnum("messageViewTheme", settings.messageViewTheme)
        editor.putEnum("messageComposeTheme", settings.messageComposeTheme)
        editor.putBoolean("fixedMessageViewTheme", settings.fixedMessageViewTheme)
        editor.putBoolean("showUnifiedInbox", settings.isShowUnifiedInbox)
        editor.putBoolean("showStarredCount", settings.isShowStarredCount)
        editor.putBoolean("messageListStars", settings.isShowMessageListStars)
        editor.putBoolean("animations", settings.isShowAnimations)
        editor.putBoolean("showCorrespondentNames", settings.isShowCorrespondentNames)
        editor.putBoolean(KEY_SHOULD_SHOW_SETUP_ARCHIVE_FOLDER_DIALOG, settings.shouldShowSetupArchiveFolderDialog)
        editor.putBoolean("messageListSenderAboveSubject", settings.isMessageListSenderAboveSubject)
        editor.putBoolean("showContactName", settings.isShowContactName)
        editor.putBoolean("showContactPicture", settings.isShowContactPicture)
        editor.putBoolean(KEY_CHANGE_REGISTERED_NAME_COLOR, settings.isChangeContactNameColor)
    }

    private fun loadGeneralSettings(): GeneralSettings {
        val storage = preferences.storage

        val settings = GeneralSettings(
            backgroundSync = K9.backgroundOps.toBackgroundSync(),
            showRecentChanges = storage.getBoolean("showRecentChanges", true),
            appTheme = storage.getEnum("theme", AppTheme.FOLLOW_SYSTEM),
            messageViewTheme = storage.getEnum(
                "messageViewTheme",
                SubTheme.USE_GLOBAL,
            ),
            messageComposeTheme = storage.getEnum(
                "messageComposeTheme",
                SubTheme.USE_GLOBAL,
            ),
            fixedMessageViewTheme = storage.getBoolean("fixedMessageViewTheme", true),
            isShowUnifiedInbox = storage.getBoolean("showUnifiedInbox", false),
            isShowStarredCount = storage.getBoolean("showStarredCount", false),
            isShowMessageListStars = storage.getBoolean("messageListStars", true),
            isShowAnimations = storage.getBoolean("animations", true),
            isShowCorrespondentNames = storage.getBoolean("showCorrespondentNames", true),
            shouldShowSetupArchiveFolderDialog = storage.getBoolean(