Repository: thunderbird/thunderbird-android
File: mail/protocols/imap/src/main/java/com/fsck/k9/mail/store/imap/ImapResponseParser.java (Java)

Code before:

import com.fsck.k9.logging.Timber;
import com.fsck.k9.mail.K9MailLib;
import com.fsck.k9.mail.filter.FixedLengthInputStream;
import com.fsck.k9.mail.filter.PeekableInputStream;
import okio.Buffer;

import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_IMAP;


class ImapResponseParser {
    private PeekableInputStream inputStream;
    private ImapResponse response;
    private Exception exception;
    private boolean utf8Accept;
    private FolderNameCodec folderNameCodec;

    public ImapResponseParser(PeekableInputStream in, FolderNameCodec c) {
        this.inputStream = in;
        this.utf8Accept = false;
        this.folderNameCodec = c;
    }

    public void setUtf8Accepted(final boolean yes) {
        utf8Accept = yes;
        folderNameCodec.setUtf8Accept(true);
    }

    public ImapResponse readResponse() throws IOException {
        return readResponse(null);
    }

    /**
     * Reads the next response available on the stream and returns an {@code ImapResponse} object that represents it.
     */
    public ImapResponse readResponse(ImapResponseCallback callback) throws IOException {
        try {
            int peek = inputStream.peek();
            if (peek == '+') {
                readContinuationRequest(callback);
            } else if (peek == '*') {
                readUntaggedResponse(callback);
            } else {
                readTaggedResponse(callback);
            }

            if (exception != null) {
                throw new ImapResponseParserException("readResponse(): Exception in callback method", exception);
            }

            return response;

Review comment (suggestion):
If you apply the property name change, and use the Kotlin Property:
```suggestion
        folderNameCodec.setAcceptUtf8Encoding(true);
```

Code after:

import net.thunderbird.core.logging.legacy.Log;
import com.fsck.k9.mail.K9MailLib;
import com.fsck.k9.mail.filter.FixedLengthInputStream;
import com.fsck.k9.mail.filter.PeekableInputStream;
import okio.Buffer;

import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_IMAP;


class ImapResponseParser {
    private PeekableInputStream inputStream;
    private ImapResponse response;
    private Exception exception;
    private boolean utf8Accept;
    private FolderNameCodec folderNameCodec;

    public ImapResponseParser(PeekableInputStream in, FolderNameCodec folderNameCodec) {
        this.inputStream = in;
        this.utf8Accept = false;
        this.folderNameCodec = folderNameCodec;
    }

    public void setUtf8Accepted(final boolean yes) {
        utf8Accept = yes;
        folderNameCodec.setAcceptUtf8Encoding(yes);
    }

    public ImapResponse readResponse() throws IOException {
        return readResponse(null);
    }

    /**
     * Reads the next response available on the stream and returns an {@code ImapResponse} object that represents it.
     */
    public ImapResponse readResponse(ImapResponseCallback callback) throws IOException {
        try {
            int peek = inputStream.peek();
            if (peek == '+') {
                readContinuationRequest(callback);
            } else if (peek == '*') {
                readUntaggedResponse(callback);
            } else {
                readTaggedResponse(callback);
            }

            if (exception != null) {
                throw new ImapResponseParserException("readResponse(): Exception in callback method", exception);
            }

            return response;