app, io: [wasm, android] add support for numeric/email keyboard mode

Previously, the on-screen keyboard always displays the text keyboard,
(QWERTY or equivalent).

For optimal user experience, it's possible to specify the keyboard type
using `InputHint`. The on-screen keyboard will provide shortcuts or
restrict what the user can input.

Due to some limitations (gio#116), only numeric and text keyboards are
supported on Android.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
This commit is contained in:
Inkeliz
2021-04-30 13:03:17 +01:00
committed by Elias Naur
parent e68ee35c86
commit 9b4b91fec0
14 changed files with 128 additions and 5 deletions
+13 -1
View File
@@ -36,6 +36,7 @@ import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.EditorInfo;
import android.text.InputType;
import java.io.UnsupportedEncodingException;
@@ -47,6 +48,7 @@ public final class GioView extends SurfaceView implements Choreographer.FrameCal
private final InputMethodManager imm;
private final float scrollXScale;
private final float scrollYScale;
private int keyboardHint;
private long nhandle;
@@ -247,10 +249,20 @@ public final class GioView extends SurfaceView implements Choreographer.FrameCal
}
}
@Override public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
@Override public InputConnection onCreateInputConnection(EditorInfo editor) {
editor.inputType = this.keyboardHint;
editor.imeOptions = EditorInfo.IME_FLAG_NO_FULLSCREEN | EditorInfo.IME_FLAG_NO_EXTRACT_UI;
return new InputConnection(this);
}
void setInputHint(int hint) {
if (hint == this.keyboardHint) {
return;
}
this.keyboardHint = hint;
imm.restartInput(this);
}
void showTextInput() {
GioView.this.requestFocus();
imm.showSoftInput(GioView.this, 0);