Repository: thunderbird/thunderbird-android
File: legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/MessageTopView.kt (Kotlin)

Code before:
    private var showAccountIndicator = false

    private var messageCryptoPresenter: MessageCryptoPresenter? = null

    public override fun onFinishInflate() {
        super.onFinishInflate()

        messageHeaderView = findViewById(R.id.header_container)
        layoutInflater = LayoutInflater.from(context)

        viewAnimator = findViewById(R.id.message_layout_animator)
        progressBar = findViewById(R.id.message_progress)
        progressText = findViewById(R.id.message_progress_text)

        downloadRemainderButton = findViewById(R.id.download_remainder)
        downloadRemainderButton.visibility = GONE

        extraHeaderContainer = findViewById(R.id.extra_header_container)
        showPicturesButton = findViewById(R.id.show_pictures)
        setShowPicturesButtonListener()

        containerView = findViewById(R.id.message_container)

        renderPlainFormat =
            (generalSettingsManager.getConfig().display.visualSettings.bodyContentType == BodyContentType.TEXT_PLAIN)

        hideHeaderView()
    }

    fun setShowAccountIndicator(showAccountIndicator: Boolean) {
        this.showAccountIndicator = showAccountIndicator
    }

    private fun setShowPicturesButtonListener() {
        showPicturesButton.setOnClickListener {
            showPicturesInAllContainerViews()
            showPicturesButtonClicked = true
        }
    }

    private fun showPicturesInAllContainerViews() {
        val messageContainerViewCandidate = containerView.getChildAt(0)
        if (messageContainerViewCandidate is MessageContainerView) {
            messageContainerViewCandidate.showPictures()
        }
        hideShowPicturesButton()
    }

    private fun resetAndPrepareMessageView(messageViewInfo: MessageViewInfo) {
        downloadRemainderButton.visibility = GONE
        containerView.removeAllViews()

Review comment (security):
In case you choose to go with the injection of `DisplayVisualSettingsPreferenceManager` instead, you could simplify to:

```suggestion
        renderPlainFormat =
            visualSettingsPrefManager.getConfig().bodyContentType == BodyContentType.TEXT_PLAIN
```

Code after:
    private var showAccountIndicator = false

    private var messageCryptoPresenter: MessageCryptoPresenter? = null

    public override fun onFinishInflate() {
        super.onFinishInflate()

        messageHeaderView = findViewById(R.id.header_container)
        layoutInflater = LayoutInflater.from(context)

        viewAnimator = findViewById(R.id.message_layout_animator)
        progressBar = findViewById(R.id.message_progress)
        progressText = findViewById(R.id.message_progress_text)

        downloadRemainderButton = findViewById(R.id.download_remainder)
        downloadRemainderButton.visibility = GONE

        extraHeaderContainer = findViewById(R.id.extra_header_container)
        showPicturesButton = findViewById(R.id.show_pictures)
        setShowPicturesButtonListener()

        containerView = findViewById(R.id.message_container)

        renderPlainFormat = visualSettingsPrefManager.getConfig().bodyContentType == BodyContentType.TEXT_PLAIN

        hideHeaderView()
    }

    fun setShowAccountIndicator(showAccountIndicator: Boolean) {
        this.showAccountIndicator = showAccountIndicator
    }

    private fun setShowPicturesButtonListener() {
        showPicturesButton.setOnClickListener {
            showPicturesInAllContainerViews()
            showPicturesButtonClicked = true
        }
    }

    private fun showPicturesInAllContainerViews() {
        val messageContainerViewCandidate = containerView.getChildAt(0)
        if (messageContainerViewCandidate is MessageContainerView) {
            messageContainerViewCandidate.showPictures()
        }
        hideShowPicturesButton()
    }

    private fun resetAndPrepareMessageView(messageViewInfo: MessageViewInfo) {
        downloadRemainderButton.visibility = GONE
        containerView.removeAllViews()
        setShowDownloadButton(messageViewInfo)