@@ -323,6 +323,9 @@ private void printConfig(EGL10 egl, EGLDisplay display,
323
323
324
324
private PowerManager .WakeLock wakeLock ;
325
325
326
+ // This stores the length of the text in pridiction/swype buffer
327
+ private int mDelLen = 0 ;
328
+
326
329
// The width and height. (This should be set at startup time -
327
330
// these values just prevent segfaults and divide by zero, etc.)
328
331
int mWidth = 100 ;
@@ -970,6 +973,10 @@ public boolean onTouchEvent(final MotionEvent event) {
970
973
@ Override
971
974
public boolean onKeyDown (int keyCode , final KeyEvent event ) {
972
975
//Log.i("python", String.format("key down %d", keyCode));
976
+ if (mDelLen > 0 ){
977
+ mDelLen = 0 ;
978
+ return true ;
979
+ }
973
980
if (mInputActivated && nativeKey (keyCode , 1 , event .getUnicodeChar ())) {
974
981
return true ;
975
982
} else {
@@ -979,6 +986,10 @@ public boolean onKeyDown(int keyCode, final KeyEvent event) {
979
986
980
987
@ Override
981
988
public boolean onKeyUp (int keyCode , final KeyEvent event ) {
989
+ if (mDelLen > 0 ){
990
+ mDelLen = 0 ;
991
+ return true ;
992
+ }
982
993
//Log.i("python", String.format("key up %d", keyCode));
983
994
if (mInputActivated && nativeKey (keyCode , 0 , event .getUnicodeChar ())) {
984
995
return true ;
@@ -991,6 +1002,10 @@ public boolean onKeyUp(int keyCode, final KeyEvent event) {
991
1002
public boolean onKeyMultiple (int keyCode , int count , KeyEvent event ){
992
1003
String keys = event .getCharacters ();
993
1004
char [] keysBuffer = new char [keys .length ()];
1005
+ if (mDelLen > 0 ){
1006
+ mDelLen = 0 ;
1007
+ return true ;
1008
+ }
994
1009
if (keyCode == 0 ){
995
1010
// FIXME: here is hardcoed value of "q" key
996
1011
// on hacker's keyboard. It is passed to
@@ -1042,11 +1057,10 @@ public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
1042
1057
outAttrs .imeOptions = EditorInfo .IME_FLAG_NO_EXTRACT_UI ;
1043
1058
return new BaseInputConnection (this , false ){
1044
1059
1045
- private int mDelLen = 0 ;
1046
1060
1047
1061
private void deleteLastText (){
1048
1062
// send back space keys
1049
- for (int i = 0 ; i < this . mDelLen ; i ++){
1063
+ for (int i = 0 ; i < mDelLen ; i ++){
1050
1064
nativeKey (KeyEvent .KEYCODE_DEL , 1 , 23 );
1051
1065
nativeKey (KeyEvent .KEYCODE_DEL , 0 , 23 );
1052
1066
}
@@ -1065,7 +1079,7 @@ public boolean setComposingText(CharSequence text,
1065
1079
nativeKey (45 , 0 , (int ) c );
1066
1080
}
1067
1081
// store len to be deleted for next time
1068
- this . mDelLen = text .length ();
1082
+ mDelLen = text .length ();
1069
1083
return super .setComposingText (text , newCursorPosition );
1070
1084
}
1071
1085
@@ -1074,7 +1088,7 @@ public boolean commitText(CharSequence text, int newCursorPosition) {
1074
1088
// some code which takes the input and manipulates it and calls editText.getText().replace() afterwards
1075
1089
//Log.i("Python:", String.format("Commit Text %s", text));
1076
1090
this .deleteLastText ();
1077
- this . mDelLen = 0 ;
1091
+ mDelLen = 0 ;
1078
1092
return super .commitText (text , newCursorPosition );
1079
1093
}
1080
1094
};
0 commit comments