Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: services/keyboard/src/org/chromium/mojo/keyboard/InputConnectionAdaptor.java

Issue 1382943003: Add a Submit method to the keyboard interface (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: services/keyboard/src/org/chromium/mojo/keyboard/InputConnectionAdaptor.java
diff --git a/services/keyboard/src/org/chromium/mojo/keyboard/InputConnectionAdaptor.java b/services/keyboard/src/org/chromium/mojo/keyboard/InputConnectionAdaptor.java
index 42bdd57f1805cfb9a76778bf1562dbe143b7e950..2efbce6e6ce5f55583a8fb8cb410ad32e6dae4c0 100644
--- a/services/keyboard/src/org/chromium/mojo/keyboard/InputConnectionAdaptor.java
+++ b/services/keyboard/src/org/chromium/mojo/keyboard/InputConnectionAdaptor.java
@@ -4,6 +4,8 @@
package org.chromium.mojo.keyboard;
+import android.text.Editable;
+import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.CompletionInfo;
@@ -13,19 +15,29 @@ import android.view.inputmethod.EditorInfo;
import org.chromium.mojom.keyboard.CompletionData;
import org.chromium.mojom.keyboard.CorrectionData;
import org.chromium.mojom.keyboard.KeyboardClient;
+import org.chromium.mojom.keyboard.SubmitAction;
/**
* An adaptor between InputConnection and KeyboardClient.
*/
public class InputConnectionAdaptor extends BaseInputConnection {
private KeyboardClient mClient;
+ private Editable mEditable;
- public InputConnectionAdaptor(View view, KeyboardClient client, EditorInfo outAttrs) {
+ public InputConnectionAdaptor(View view, KeyboardClient client, Editable editable,
+ EditorInfo outAttrs) {
super(view, true);
assert client != null;
mClient = client;
+ mEditable = editable;
outAttrs.initialSelStart = -1;
outAttrs.initialSelEnd = -1;
+ outAttrs.imeOptions = EditorInfo.IME_ACTION_DONE;
+ }
+
+ @Override
+ public Editable getEditable() {
+ return mEditable;
}
@Override
@@ -71,4 +83,20 @@ public class InputConnectionAdaptor extends BaseInputConnection {
mClient.setSelection(start, end);
return super.setSelection(start, end);
}
+
+ // Number keys come through as key events instead of commitText!?
jamesr 2015/10/07 01:04:42 who's the intended user of this comment?
jsimmons1 2015/10/07 01:14:14 I'm not sure - this was pre-existing code copied o
+ @Override
+ public boolean sendKeyEvent(KeyEvent event) {
+ if (event.getAction() == KeyEvent.ACTION_UP) {
+ // 1 appears to always be the value for newCursorPosition?
+ mClient.commitText(String.valueOf(event.getNumber()), 1);
+ }
+ return super.sendKeyEvent(event);
+ }
+
+ @Override
+ public boolean performEditorAction(int actionCode) {
+ mClient.submit(SubmitAction.DONE);
+ return true;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698