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

Code before:

import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

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);
            }


Review comment (suggestion):
Please, avoid using single-letter variable names as they are not descriptive enough.

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

Code after:

import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

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);
            }