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

Code before:
    public override fun onNewIntent(intent: Intent) {
        super.onNewIntent(intent)

        if (isFinishing) {
            return
        }

        if (intent.action == Intent.ACTION_MAIN && intent.hasCategory(Intent.CATEGORY_LAUNCHER)) {
            // There's nothing to do if the default launcher Intent was used.
            // This only brings the existing screen to the foreground.
            return
        }

        setIntent(intent)

        // Start with a fresh fragment back stack
        supportFragmentManager.popBackStackImmediate(
            FIRST_FRAGMENT_TRANSACTION,
            FragmentManager.POP_BACK_STACK_INCLUSIVE,
        )

        removeMessageListFragment()
        removeMessageViewContainerFragment()

        messageReference = null
        search = null

        if (!decodeExtras(intent)) {
            return
        }

        if (isDrawerEnabled) {
            configureDrawer()
        }

        initializeDisplayMode(null)
        initializeFragments()
        displayViews()
    }

    private fun deleteIncompleteAccounts(accounts: List<LegacyAccount>) {
        accounts.filter { !it.isFinishedSetup }.forEach {
            accountRemover.removeAccountAsync(it.uuid)
        }
    }

    private fun findFragments() {
        val fragmentManager = supportFragmentManager
        messageListFragment = fragmentManager.findFragmentById(R.id.message_list_container) as MessageListFragment?
        messageViewContainerFragment =
            fragmentManager.findFragmentByTag(FRAGMENT_TAG_MESSAGE_VIEW_CONTAINER) as MessageViewContainerFragment?

Review comment (bug):
You still need to include the `insets.bottom` in the `MessageList` container, otherwise, this will cause regression on two bugs we fixed before: #9338, #9165 

| (Before) Download button hidden | (After) Download button |
| --- | --- |
| <img width="579" height="1321" alt="Image" src="https://github.com/user-attachments/assets/d2001ba0-efef-4ad8-8036-e812e0fd5b2e" /> | <img width="580" height="1321" alt="Image" src="https://github.com/user-attachments/assets/4588f8ab-2ee5-4113-8967-b264fa8128e8" /> |
| (Before) Navigation bar | (After) Navigation bar |
| <img width="577" height="1322" alt="Image" src="https://github.com/user-attachments/assets/fc3fcaef-9827-424a-a8b2-f9631f8ccee0" /> | <img width="578" height="1321" alt="Image" src="https://github.com/user-attachments/assets/4d1b684d-c07e-4b81-9e5a-390c0f09d5b7" /> |

Code after:

        ViewCompat.setOnApplyWindowInsetsListener(container) { v, windowsInsets ->
            val insets = windowsInsets.getInsets(displayCutout() or navigationBars())
            v.setPadding(insets.left, 0, insets.right, insets.bottom)

            windowsInsets
        }
    }

    private fun initializeFunding() {
        fundingManager.addFundingReminder(this) {
            FeatureLauncherActivity.launch(
                context = this,
                target = FeatureLauncherTarget.Funding,
            )
        }
    }

    public override fun onNewIntent(intent: Intent) {
        super.onNewIntent(intent)

        if (isFinishing) {
            return
        }

        if (intent.action == Intent.ACTION_MAIN && intent.hasCategory(Intent.CATEGORY_LAUNCHER)) {
            // There's nothing to do if the default launcher Intent was used.
            // This only brings the existing screen to the foreground.
            return
        }

        setIntent(intent)

        // Start with a fresh fragment back stack
        supportFragmentManager.popBackStackImmediate(
            FIRST_FRAGMENT_TRANSACTION,
            FragmentManager.POP_BACK_STACK_INCLUSIVE,
        )

        removeMessageListFragment()
        removeMessageViewContainerFragment()

        messageReference = null
        search = null

        if (!decodeExtras(intent)) {
            return
        }

        if (isDrawerEnabled) {
            configureDrawer()