Loading core/java/android/view/inputmethod/InputMethodManager.java +26 −18 Original line number Diff line number Diff line Loading @@ -651,25 +651,31 @@ public final class InputMethodManager { } } if (mServedInputConnection != null) { notifyInputConnectionFinished(); mServedView = null; mCompletions = null; mServedConnecting = false; clearConnectionLocked(); } } /** * Notifies the served view that the current InputConnection will no longer be used. */ private void notifyInputConnectionFinished() { if (mServedView != null && mServedInputConnection != null) { // We need to tell the previously served view that it is no // longer the input target, so it can reset its state. Schedule // this call on its window's Handler so it will be on the correct // thread and outside of our lock. Handler vh = mServedView.getHandler(); if (vh != null) { // This will result in a call to reportFinishInputConnection() // below. // This will result in a call to reportFinishInputConnection() below. vh.sendMessage(vh.obtainMessage(ViewRootImpl.FINISH_INPUT_CONNECTION, mServedInputConnection)); } } mServedView = null; mCompletions = null; mServedConnecting = false; clearConnectionLocked(); } } /** Loading Loading @@ -1012,6 +1018,8 @@ public final class InputMethodManager { // Hook 'em up and let 'er rip. mCurrentTextBoxAttribute = tba; mServedConnecting = false; // Notify the served view that its previous input connection is finished notifyInputConnectionFinished(); mServedInputConnection = ic; IInputContext servedContext; if (ic != null) { Loading Loading @@ -1115,7 +1123,7 @@ public final class InputMethodManager { } } void scheduleCheckFocusLocked(View view) { static void scheduleCheckFocusLocked(View view) { Handler vh = view.getHandler(); if (vh != null && !vh.hasMessages(ViewRootImpl.CHECK_FOCUS)) { // This will result in a call to checkFocus() below. Loading core/java/com/android/internal/widget/EditableInputConnection.java +46 −8 Original line number Diff line number Diff line Loading @@ -35,6 +35,11 @@ public class EditableInputConnection extends BaseInputConnection { private final TextView mTextView; // Keeps track of nested begin/end batch edit to ensure this connection always has a // balanced impact on its associated TextView. // A negative value means that this connection has been finished by the InputMethodManager. private int mBatchEditNesting; public EditableInputConnection(TextView textview) { super(textview, true); mTextView = textview; Loading @@ -51,15 +56,31 @@ public class EditableInputConnection extends BaseInputConnection { @Override public boolean beginBatchEdit() { synchronized(this) { if (mBatchEditNesting >= 0) { mTextView.beginBatchEdit(); mBatchEditNesting++; return true; } } return false; } @Override public boolean endBatchEdit() { synchronized(this) { if (mBatchEditNesting > 0) { // When the connection is reset by the InputMethodManager and finishComposingText // 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. mTextView.endBatchEdit(); mBatchEditNesting--; return true; } } return false; } @Override public boolean clearMetaKeyStates(int states) { Loading @@ -77,6 +98,23 @@ 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/InputMethodManager.java +26 −18 Original line number Diff line number Diff line Loading @@ -651,25 +651,31 @@ public final class InputMethodManager { } } if (mServedInputConnection != null) { notifyInputConnectionFinished(); mServedView = null; mCompletions = null; mServedConnecting = false; clearConnectionLocked(); } } /** * Notifies the served view that the current InputConnection will no longer be used. */ private void notifyInputConnectionFinished() { if (mServedView != null && mServedInputConnection != null) { // We need to tell the previously served view that it is no // longer the input target, so it can reset its state. Schedule // this call on its window's Handler so it will be on the correct // thread and outside of our lock. Handler vh = mServedView.getHandler(); if (vh != null) { // This will result in a call to reportFinishInputConnection() // below. // This will result in a call to reportFinishInputConnection() below. vh.sendMessage(vh.obtainMessage(ViewRootImpl.FINISH_INPUT_CONNECTION, mServedInputConnection)); } } mServedView = null; mCompletions = null; mServedConnecting = false; clearConnectionLocked(); } } /** Loading Loading @@ -1012,6 +1018,8 @@ public final class InputMethodManager { // Hook 'em up and let 'er rip. mCurrentTextBoxAttribute = tba; mServedConnecting = false; // Notify the served view that its previous input connection is finished notifyInputConnectionFinished(); mServedInputConnection = ic; IInputContext servedContext; if (ic != null) { Loading Loading @@ -1115,7 +1123,7 @@ public final class InputMethodManager { } } void scheduleCheckFocusLocked(View view) { static void scheduleCheckFocusLocked(View view) { Handler vh = view.getHandler(); if (vh != null && !vh.hasMessages(ViewRootImpl.CHECK_FOCUS)) { // This will result in a call to checkFocus() below. Loading
core/java/com/android/internal/widget/EditableInputConnection.java +46 −8 Original line number Diff line number Diff line Loading @@ -35,6 +35,11 @@ public class EditableInputConnection extends BaseInputConnection { private final TextView mTextView; // Keeps track of nested begin/end batch edit to ensure this connection always has a // balanced impact on its associated TextView. // A negative value means that this connection has been finished by the InputMethodManager. private int mBatchEditNesting; public EditableInputConnection(TextView textview) { super(textview, true); mTextView = textview; Loading @@ -51,15 +56,31 @@ public class EditableInputConnection extends BaseInputConnection { @Override public boolean beginBatchEdit() { synchronized(this) { if (mBatchEditNesting >= 0) { mTextView.beginBatchEdit(); mBatchEditNesting++; return true; } } return false; } @Override public boolean endBatchEdit() { synchronized(this) { if (mBatchEditNesting > 0) { // When the connection is reset by the InputMethodManager and finishComposingText // 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. mTextView.endBatchEdit(); mBatchEditNesting--; return true; } } return false; } @Override public boolean clearMetaKeyStates(int states) { Loading @@ -77,6 +98,23 @@ 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