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

Code before:
        return when (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
            OpenPgpApi.RESULT_CODE_SUCCESS -> {
                val type = getRecipientAutocryptStatusFromIntent(result)
                val pendingIntent = IntentCompat.getParcelableExtra(
                    result,
                    OpenPgpApi.RESULT_INTENT,
                    PendingIntent::class.java,
                )
                RecipientAutocryptStatus(type, pendingIntent)
            }

            OpenPgpApi.RESULT_CODE_ERROR -> {
                val error = IntentCompat.getParcelableExtra(
                    result,
                    OpenPgpApi.RESULT_ERROR,
                    OpenPgpError::class.java,
                )
                if (error != null) {
                    w("OpenPGP API Error #%s: %s", error.getErrorId(), error.getMessage())
                } else {
                    w("OpenPGP API Unknown Error")
                }
                RecipientAutocryptStatus(RecipientAutocryptStatusType.ERROR, null)
            }

            OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED -> return RecipientAutocryptStatus(
                RecipientAutocryptStatusType.ERROR,
                null,
            )

            else -> RecipientAutocryptStatus(RecipientAutocryptStatusType.ERROR, null)
        }
    }

    private fun getRecipientAutocryptStatusFromIntent(result: Intent): RecipientAutocryptStatusType {
        val allKeysConfirmed = result.getBooleanExtra(OpenPgpApi.RESULT_KEYS_CONFIRMED, false)
        val autocryptStatus =
            result.getIntExtra(OpenPgpApi.RESULT_AUTOCRYPT_STATUS, OpenPgpApi.AUTOCRYPT_STATUS_UNAVAILABLE)

        return when (autocryptStatus) {
            OpenPgpApi.AUTOCRYPT_STATUS_UNAVAILABLE -> {
                RecipientAutocryptStatusType.UNAVAILABLE
            }

            OpenPgpApi.AUTOCRYPT_STATUS_DISCOURAGE -> {
                if (allKeysConfirmed) {
                    RecipientAutocryptStatusType.DISCOURAGE_CONFIRMED
                } else {
                    RecipientAutocryptStatusType.DISCOURAGE_UNCONFIRMED
                }
            }

Review comment (suggestion):
The return here is redundant.

```suggestion
            OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED -> RecipientAutocryptStatus(

```

Code after:
        return when (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
            OpenPgpApi.RESULT_CODE_SUCCESS -> {
                val type = getRecipientAutocryptStatusFromIntent(result)
                val pendingIntent = IntentCompat.getParcelableExtra(
                    result,
                    OpenPgpApi.RESULT_INTENT,
                    PendingIntent::class.java,
                )
                RecipientAutocryptStatus(type, pendingIntent)
            }

            OpenPgpApi.RESULT_CODE_ERROR -> {
                val error = IntentCompat.getParcelableExtra(
                    result,
                    OpenPgpApi.RESULT_ERROR,
                    OpenPgpError::class.java,
                )
                if (error != null) {
                    w("OpenPGP API Error #%s: %s", error.getErrorId(), error.getMessage())
                } else {
                    w("OpenPGP API Unknown Error")
                }
                RecipientAutocryptStatus(RecipientAutocryptStatusType.ERROR, null)
            }

            OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED -> RecipientAutocryptStatus(

                RecipientAutocryptStatusType.ERROR,
                null,
            )

            else -> RecipientAutocryptStatus(RecipientAutocryptStatusType.ERROR, null)
        }
    }

    private fun getRecipientAutocryptStatusFromIntent(result: Intent): RecipientAutocryptStatusType {
        val allKeysConfirmed = result.getBooleanExtra(OpenPgpApi.RESULT_KEYS_CONFIRMED, false)
        val autocryptStatus =
            result.getIntExtra(OpenPgpApi.RESULT_AUTOCRYPT_STATUS, OpenPgpApi.AUTOCRYPT_STATUS_UNAVAILABLE)

        return when (autocryptStatus) {
            OpenPgpApi.AUTOCRYPT_STATUS_UNAVAILABLE -> {
                RecipientAutocryptStatusType.UNAVAILABLE
            }

            OpenPgpApi.AUTOCRYPT_STATUS_DISCOURAGE -> {
                if (allKeysConfirmed) {
                    RecipientAutocryptStatusType.DISCOURAGE_CONFIRMED
                } else {
                    RecipientAutocryptStatusType.DISCOURAGE_UNCONFIRMED
                }