mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 00:16:15 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user