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

Commit 1b3d01de authored by Gilles Debunne's avatar Gilles Debunne Committed by Android (Google) Code Review
Browse files

Merge "InputConnection is warned when finished"

parents a6bae56f 9d69ecbf
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -151,6 +151,15 @@ public class BaseInputConnection implements InputConnection {
        return false;
    }

    /**
     * Called when this InputConnection is no longer used by the InputMethodManager.
     *
     * @hide
     */
    protected void reportFinish() {
        // Intentionaly empty
    }

    /**
     * Default implementation uses
     * {@link MetaKeyKeyListener#clearMetaKeyState(long, int)
+4 −0
Original line number Diff line number Diff line
@@ -708,6 +708,10 @@ public final class InputMethodManager {
    public void reportFinishInputConnection(InputConnection ic) {
        if (mServedInputConnection != ic) {
            ic.finishComposingText();
            // To avoid modifying the public InputConnection interface
            if (ic instanceof BaseInputConnection) {
                ((BaseInputConnection) ic).reportFinish();
            }
        }
    }

+14 −18
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ public class EditableInputConnection extends BaseInputConnection {
    public boolean endBatchEdit() {
        synchronized(this) {
            if (mBatchEditNesting > 0) {
                // When the connection is reset by the InputMethodManager and finishComposingText
                // When the connection is reset by the InputMethodManager and reportFinish
                // is called, some endBatchEdit calls may still be asynchronously received from the
                // IME. Do not take these into account, thus ensuring that this IC's final
                // contribution to mTextView's nested batch edit count is zero.
@@ -82,6 +82,19 @@ public class EditableInputConnection extends BaseInputConnection {
        return false;
    }

    @Override
    protected void reportFinish() {
        super.reportFinish();

        synchronized(this) {
            while (mBatchEditNesting > 0) {
                endBatchEdit();
            }
            // Will prevent any further calls to begin or endBatchEdit
            mBatchEditNesting = -1;
        }
    }

    @Override
    public boolean clearMetaKeyStates(int states) {
        final Editable content = getEditable();
@@ -98,23 +111,6 @@ public class EditableInputConnection extends BaseInputConnection {
        return true;
    }

    @Override
    public boolean finishComposingText() {
        final boolean superResult = super.finishComposingText();
        synchronized(this) {
            if (mBatchEditNesting < 0) {
                // The connection was already finished
                return false;
            }
            while (mBatchEditNesting > 0) {
                endBatchEdit();
            }
            // Will prevent any further calls to begin or endBatchEdit
            mBatchEditNesting = -1;
        }
        return superResult;
    }

    @Override
    public boolean commitCompletion(CompletionInfo text) {
        if (DEBUG) Log.v(TAG, "commitCompletion " + text);