Loading core/java/android/view/inputmethod/BaseInputConnection.java +9 −0 Original line number Diff line number Diff line Loading @@ -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) Loading core/java/android/view/inputmethod/InputMethodManager.java +4 −0 Original line number Diff line number Diff line Loading @@ -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(); } } } Loading core/java/com/android/internal/widget/EditableInputConnection.java +14 −18 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -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(); Loading @@ -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); Loading Loading
core/java/android/view/inputmethod/BaseInputConnection.java +9 −0 Original line number Diff line number Diff line Loading @@ -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) Loading
core/java/android/view/inputmethod/InputMethodManager.java +4 −0 Original line number Diff line number Diff line Loading @@ -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(); } } } Loading
core/java/com/android/internal/widget/EditableInputConnection.java +14 −18 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -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(); Loading @@ -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); Loading