Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 9627ce1b authored by Wolf-Martell Montwé's avatar Wolf-Martell Montwé Committed by GitHub
Browse files

Merge pull request #9270 from shamim-emon/fix-issue-9269

Convert AlertResponse class from Java to Kotlin
parents f2aabf7b 1bce5ae7
Loading
Loading
Loading
Loading
+0 −26
Original line number Diff line number Diff line
package com.fsck.k9.mail.store.imap;


import static com.fsck.k9.mail.store.imap.ImapResponseParser.equalsIgnoreCase;


class AlertResponse {
    private static final String ALERT_RESPONSE_CODE = "ALERT";


    private AlertResponse() {
    }

    public static String getAlertText(ImapResponse response) {
        if (response.size() < 3 || !response.isList(1)) {
            return null;
        }

        ImapList responseTextCode = response.getList(1);
        if (responseTextCode.size() != 1 || !equalsIgnoreCase(responseTextCode.get(0), ALERT_RESPONSE_CODE)) {
            return null;
        }

        return response.getString(2);
    }
}
+25 −0
Original line number Diff line number Diff line
package com.fsck.k9.mail.store.imap

import com.fsck.k9.mail.store.imap.ImapResponseParser.equalsIgnoreCase

internal object AlertResponse {
    private const val ALERT_RESPONSE_CODE = "ALERT"
    private const val MINIMUM_RESPONSE_SIZE = 3

    @JvmStatic
    fun getAlertText(response: ImapResponse): String? {
        return if (
            response.size >= MINIMUM_RESPONSE_SIZE &&
            response.isList(1)
        ) {
            val responseTextCode = response.getList(1)
            if (responseTextCode.size == 1 && equalsIgnoreCase(responseTextCode[0], ALERT_RESPONSE_CODE)) {
                response.getString(2)
            } else {
                null
            }
        } else {
            null
        }
    }
}