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

Code before:
            }

            DisplayMode.SPLIT_VIEW -> {
                val messageListFragment = checkNotNull(this.messageListFragment)

                messageListWasDisplayed = true
                messageListFragment.setFullyActive()

                messageViewContainerFragment.let { messageViewContainerFragment ->
                    if (messageViewContainerFragment == null) {
                        showMessageViewPlaceHolder()
                    } else {
                        messageViewContainerFragment.isActive = true
                    }
                }

                setDrawerLockState()
                onMessageListDisplayed()
            }
        }
    }
    private fun decodeExtras(intent: Intent): Boolean {
        val launchData = decodeExtrasToLaunchData(intent)
        if (intent.action === Intent.ACTION_SEARCH && !intent.component?.className.equals(
                "com.fsck.k9.activity.Search",
            )
        ) {
            finish()
        }
        // If Unified Inbox was disabled show default account instead
        val search = if (launchData.search.isUnifiedInbox && !K9.isShowUnifiedInbox) {
            createDefaultLocalSearch()
        } else {
            launchData.search
        }

        // If no account has been specified, keep the currently active account when opening the Unified Inbox
        val account = launchData.account
            ?: account?.takeIf { launchData.search.isUnifiedInbox }
            ?: search.firstAccount()

        if (account == null) {
            finish()
            return false
        }

        this.account = account
        this.search = search
        singleFolderMode = search.folderIds.size == 1
        noThreading = launchData.noThreading
        messageReference = launchData.messageReference

Review comment (suggestion):
I would like to suggest the following change:
```suggestion
        if (intent.action == Intent.ACTION_SEARCH && intent.component?.className != Search::class.java.name) {
```

It will be easier to track whether the name or package of the `Search` Activity changes in the future. Additionally, as we are finishing the Activity if the intent does not originate from the `Search` Activity, I recommend moving the conditional check before the `decodeExtrasToLaunchData(intent)`, as we won’t need that data at that point.

Code after:
            }

            DisplayMode.SPLIT_VIEW -> {
                val messageListFragment = checkNotNull(this.messageListFragment)

                messageListWasDisplayed = true
                messageListFragment.setFullyActive()

                messageViewContainerFragment.let { messageViewContainerFragment ->
                    if (messageViewContainerFragment == null) {
                        showMessageViewPlaceHolder()
                    } else {
                        messageViewContainerFragment.isActive = true
                    }
                }

                setDrawerLockState()
                onMessageListDisplayed()
            }
        }
    }
    private fun decodeExtras(intent: Intent): Boolean {
        if (intent.action === Intent.ACTION_SEARCH && !intent.component?.className.equals(
                Search::class.java.name,
            )
        ) {
            finish()
        }

        val launchData = decodeExtrasToLaunchData(intent)
        // If Unified Inbox was disabled show default account instead
        val search = if (launchData.search.isUnifiedInbox && !K9.isShowUnifiedInbox) {
            createDefaultLocalSearch()
        } else {
            launchData.search
        }

        // If no account has been specified, keep the currently active account when opening the Unified Inbox
        val account = launchData.account
            ?: account?.takeIf { launchData.search.isUnifiedInbox }
            ?: search.firstAccount()

        if (account == null) {
            finish()
            return false
        }

        this.account = account
        this.search = search
        singleFolderMode = search.folderIds.size == 1
        noThreading = launchData.noThreading