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

Commit c8bde75c authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka Committed by Android (Google) Code Review
Browse files

Merge "Optimize InputConnection.getCursorCapsMode calling" into jb-dev

parents d5cd7e64 03ca17c8
Loading
Loading
Loading
Loading
+18 −6
Original line number Diff line number Diff line
@@ -1026,13 +1026,25 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
    }

    public boolean getCurrentAutoCapsState() {
        if (!mSettingsValues.mAutoCap) return false;

        final EditorInfo ei = getCurrentInputEditorInfo();
        if (ei == null) return false;

        final int inputType = ei.inputType;
        if ((inputType & InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS) != 0) return true;

        final boolean noNeedToCheckCapsMode = (inputType & (InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
                | InputType.TYPE_TEXT_FLAG_CAP_WORDS)) == 0;
        if (noNeedToCheckCapsMode) return false;

        final InputConnection ic = getCurrentInputConnection();
        EditorInfo ei = getCurrentInputEditorInfo();
        if (mSettingsValues.mAutoCap && ic != null && ei != null
                && ei.inputType != InputType.TYPE_NULL) {
            return ic.getCursorCapsMode(ei.inputType) != 0;
        }
        return false;
        if (ic == null) return false;
        // TODO: This blocking IPC call is heavy. Consider doing this without using IPC calls.
        // Note: getCursorCapsMode() returns the current capitalization mode that is any
        // combination of CAP_MODE_CHARACTERS, CAP_MODE_WORDS, and CAP_MODE_SENTENCES. 0 means none
        // of them.
        return ic.getCursorCapsMode(inputType) != 0;
    }

    // "ic" may be null