| Index: services/keyboard/src/org/chromium/mojo/keyboard/KeyboardServiceState.java
|
| diff --git a/services/keyboard/src/org/chromium/mojo/keyboard/KeyboardServiceState.java b/services/keyboard/src/org/chromium/mojo/keyboard/KeyboardServiceState.java
|
| index 7196b24f89bebc68894b3ef2e31313be84d014d2..4b025f19849153975c65ec6bf5724663fdf8f91b 100644
|
| --- a/services/keyboard/src/org/chromium/mojo/keyboard/KeyboardServiceState.java
|
| +++ b/services/keyboard/src/org/chromium/mojo/keyboard/KeyboardServiceState.java
|
| @@ -4,7 +4,10 @@
|
|
|
| package org.chromium.mojo.keyboard;
|
|
|
| +import android.text.Editable;
|
| import android.text.InputType;
|
| +import android.text.Selection;
|
| +import android.text.SpannableStringBuilder;
|
| import android.view.View;
|
| import android.view.inputmethod.EditorInfo;
|
| import android.view.inputmethod.InputConnection;
|
| @@ -18,23 +21,26 @@ public class KeyboardServiceState {
|
| private View mView;
|
| private KeyboardClient mActiveClient;
|
| private int mRequestedInputType;
|
| + private Editable mActiveEditable;
|
|
|
| public KeyboardServiceState(View view) {
|
| mView = view;
|
| mActiveClient = null;
|
| mRequestedInputType = InputType.TYPE_CLASS_TEXT;
|
| + mActiveEditable = null;
|
| }
|
|
|
| public InputConnection createInputConnection(EditorInfo outAttrs) {
|
| if (mActiveClient == null) return null;
|
| outAttrs.inputType = mRequestedInputType;
|
| - return new InputConnectionAdaptor(mView, mActiveClient, outAttrs);
|
| + return new InputConnectionAdaptor(mView, mActiveClient, mActiveEditable, outAttrs);
|
| }
|
|
|
| public void setClient(KeyboardClient client, int inputType) {
|
| if (mActiveClient != null) mActiveClient.close();
|
| mActiveClient = client;
|
| mRequestedInputType = inputType;
|
| + mActiveEditable = new SpannableStringBuilder();
|
| }
|
|
|
| public View getView() {
|
| @@ -45,5 +51,14 @@ public class KeyboardServiceState {
|
| if (mActiveClient == null) return;
|
| mActiveClient.close();
|
| mActiveClient = null;
|
| + mActiveEditable = null;
|
| + }
|
| +
|
| + public void setText(String text) {
|
| + mActiveEditable.replace(0, mActiveEditable.length(), text);
|
| + }
|
| +
|
| + public void setSelection(int start, int end) {
|
| + Selection.setSelection(mActiveEditable, start, end);
|
| }
|
| }
|
|
|