提交 4d1f1f6d 编写于 作者: J Jason Simmons 提交者: GitHub

Do not call restartInput twice when setting a new text input client. (#3808)

If restartInput is called twice in quick succession, then the IME may output
warnings related to usage of the obsolete connection resulting from the first
call.

Fixes https://github.com/flutter/flutter/issues/10730
上级 fa2726cd
......@@ -38,6 +38,7 @@ public class TextInputPlugin implements MethodCallHandler {
private int mClient = 0;
private JSONObject mConfiguration;
private Editable mEditable;
private boolean mRestartInputPending;
public TextInputPlugin(FlutterView view) {
mView = view;
......@@ -128,7 +129,9 @@ public class TextInputPlugin implements MethodCallHandler {
mConfiguration = configuration;
mEditable = Editable.Factory.getInstance().newEditable("");
mImm.restartInput(view);
// setTextInputClient will be followed by a call to setTextInputEditingState.
// Do a restartInput at that time.
mRestartInputPending = true;
}
private void applyStateToSelection(JSONObject state) throws JSONException {
......@@ -143,7 +146,8 @@ public class TextInputPlugin implements MethodCallHandler {
private void setTextInputEditingState(FlutterView view, JSONObject state)
throws JSONException {
if (state.getString("text").equals(mEditable.toString())) {
if (!mRestartInputPending &&
state.getString("text").equals(mEditable.toString())) {
applyStateToSelection(state);
mImm.updateSelection(
mView,
......@@ -155,6 +159,7 @@ public class TextInputPlugin implements MethodCallHandler {
mEditable.replace(0, mEditable.length(), state.getString("text"));
applyStateToSelection(state);
mImm.restartInput(view);
mRestartInputPending = false;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册