Skip to content

Fix Keyboard auto-suggestion bug when dealing with multiple textinputs. #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions src/src/org/renpy/android/SDLSurfaceView.java
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ private void printConfig(EGL10 egl, EGLDisplay display,

private PowerManager.WakeLock wakeLock;

// This stores the length of the text in pridiction/swype buffer
private int mDelLen = 0;

// The width and height. (This should be set at startup time -
// these values just prevent segfaults and divide by zero, etc.)
int mWidth = 100;
Expand Down Expand Up @@ -970,6 +973,10 @@ public boolean onTouchEvent(final MotionEvent event) {
@Override
public boolean onKeyDown(int keyCode, final KeyEvent event) {
//Log.i("python", String.format("key down %d", keyCode));
if (mDelLen > 0){
mDelLen = 0;
return true;
}
if (mInputActivated && nativeKey(keyCode, 1, event.getUnicodeChar())) {
return true;
} else {
Expand All @@ -979,6 +986,10 @@ public boolean onKeyDown(int keyCode, final KeyEvent event) {

@Override
public boolean onKeyUp(int keyCode, final KeyEvent event) {
if (mDelLen > 0){
mDelLen = 0;
return true;
}
//Log.i("python", String.format("key up %d", keyCode));
if (mInputActivated && nativeKey(keyCode, 0, event.getUnicodeChar())) {
return true;
Expand All @@ -991,6 +1002,10 @@ public boolean onKeyUp(int keyCode, final KeyEvent event) {
public boolean onKeyMultiple(int keyCode, int count, KeyEvent event){
String keys = event.getCharacters();
char[] keysBuffer = new char[keys.length()];
if (mDelLen > 0){
mDelLen = 0;
return true;
}
if (keyCode == 0){
// FIXME: here is hardcoed value of "q" key
// on hacker's keyboard. It is passed to
Expand Down Expand Up @@ -1042,11 +1057,10 @@ public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI;
return new BaseInputConnection(this, false){

private int mDelLen = 0;

private void deleteLastText(){
// send back space keys
for (int i = 0; i < this.mDelLen; i++){
for (int i = 0; i < mDelLen; i++){
nativeKey(KeyEvent.KEYCODE_DEL, 1, 23);
nativeKey(KeyEvent.KEYCODE_DEL, 0, 23);
}
Expand All @@ -1065,7 +1079,7 @@ public boolean setComposingText(CharSequence text,
nativeKey(45, 0, (int) c);
}
// store len to be deleted for next time
this.mDelLen = text.length();
mDelLen = text.length();
return super.setComposingText(text, newCursorPosition);
}

Expand All @@ -1074,7 +1088,7 @@ public boolean commitText(CharSequence text, int newCursorPosition) {
// some code which takes the input and manipulates it and calls editText.getText().replace() afterwards
//Log.i("Python:", String.format("Commit Text %s", text));
this.deleteLastText();
this.mDelLen = 0;
mDelLen = 0;
return super.commitText(text, newCursorPosition);
}
};
Expand Down