Skip to content

Commit bda532d

Browse files
committed
swype input: simplify IME management, allow text predictionto work
and ensure IME doesn't take up entire screen in landscape mode Tested with:: - Stock JellyBean keyboard with swiping and text prediction - SwiftKey with flow and text prediction - Swype Keyboard with swiping and text prediction
1 parent 2da7d84 commit bda532d

File tree

1 file changed

+5
-34
lines changed

1 file changed

+5
-34
lines changed

src/src/org/renpy/android/SDLSurfaceView.java

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,6 @@ private void printConfig(EGL10 egl, EGLDisplay display,
276276
// Is Python ready to receive input events?
277277
static boolean mInputActivated = false;
278278

279-
// Is Composing text being repeated?
280-
static boolean mComposingText = false;
281-
282279
// The number of times we should clear the screen after swap.
283280
private int mClears = 2;
284281

@@ -475,7 +472,6 @@ public void onDestroy() {
475472
InputMethodManager inputMethodManager = (InputMethodManager)getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
476473
inputMethodManager.hideSoftInputFromInputMethod(this.getWindowToken(), 0);
477474

478-
479475
// application didn't leave, give 10s before closing.
480476
// hopefully, this could be enough for launching the on_stop() trigger within the app.
481477
mPause = PAUSE_STOP_REQUEST;
@@ -877,7 +873,6 @@ public int swapBuffers() {
877873

878874
private static final int INVALID_POINTER_ID = -1;
879875
private int mActivePointerId = INVALID_POINTER_ID;
880-
private static String mCompText = "";
881876

882877
@Override
883878
public boolean onTouchEvent(final MotionEvent event) {
@@ -987,14 +982,6 @@ public boolean onKeyMultiple(int keyCode, int count, KeyEvent event){
987982
}
988983
if (mInputActivated && event.getAction() == KeyEvent.ACTION_MULTIPLE){
989984
keys.getChars(0, keys.length(), keysBuffer, 0);
990-
if (mComposingText == true){
991-
mComposingText = false;
992-
this.mCompText = keys;
993-
}else if (this.mCompText.equals(keys)){
994-
// skip on composing text
995-
this.mCompText = "";
996-
return true;
997-
}
998985

999986
for(char c: keysBuffer){
1000987
//Log.i("python", "Char from multiply " + (int) c);
@@ -1030,31 +1017,15 @@ public boolean onKeyPreIme(int keyCode, final KeyEvent event){
10301017

10311018
@Override
10321019
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
1033-
outAttrs.inputType = EditorInfo.TYPE_NULL;
1034-
return new BaseInputConnection(this, false) {
1035-
1036-
@Override
1037-
public boolean setComposingText(CharSequence text,
1038-
int newCursorPosition) {
1039-
commitText(text, 0);
1040-
mComposingText = true;
1041-
sendKeyEvent(
1042-
new KeyEvent(
1043-
KeyEvent.ACTION_DOWN,
1044-
KeyEvent.KEYCODE_SPACE));
1045-
sendKeyEvent(
1046-
new KeyEvent(
1047-
KeyEvent.ACTION_UP,
1048-
KeyEvent.KEYCODE_SPACE));
1049-
//Log.i("Python:", String.format("set Composing Text %s", mComposingText));
1050-
return true;
1051-
}
1052-
};
1020+
// setting inputtype to TYPE_CLASS_TEXT is necessary for swiftkey to enable
1021+
outAttrs.inputType = EditorInfo.TYPE_CLASS_TEXT;
1022+
// ask IME to avoid taking full screen on landscape mode
1023+
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI;
1024+
return new BaseInputConnection(this, false);
10531025
}
10541026

10551027
static void activateInput() {
10561028
mInputActivated = true;
1057-
mComposingText = false;
10581029
}
10591030

10601031
static void openUrl(String url) {

0 commit comments

Comments
 (0)