@@ -1021,7 +1021,44 @@ public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
1021
1021
outAttrs .inputType = EditorInfo .TYPE_CLASS_TEXT ;
1022
1022
// ask IME to avoid taking full screen on landscape mode
1023
1023
outAttrs .imeOptions = EditorInfo .IME_FLAG_NO_EXTRACT_UI ;
1024
- return new BaseInputConnection (this , false );
1024
+ return new BaseInputConnection (this , false ){
1025
+
1026
+ private int mDelLen = 0 ;
1027
+
1028
+ private void deleteLastText (){
1029
+ // send back space keys
1030
+ for (int i = 0 ; i < this .mDelLen ; i ++){
1031
+ nativeKey (KeyEvent .KEYCODE_DEL , 1 , 23 );
1032
+ nativeKey (KeyEvent .KEYCODE_DEL , 0 , 23 );
1033
+ }
1034
+ }
1035
+
1036
+ @ Override
1037
+ public boolean setComposingText (CharSequence text ,
1038
+ int newCursorPosition ){
1039
+ //Log.i("Python:", String.format("set Composing Text %s", text));
1040
+ this .deleteLastText ();
1041
+ // send text
1042
+ for (int i = 0 ; i < text .length (); i ++){
1043
+ // Calls both up/down events to emulate key pressing
1044
+ char c = text .charAt (i );
1045
+ nativeKey (45 , 1 , (int ) c );
1046
+ nativeKey (45 , 0 , (int ) c );
1047
+ }
1048
+ // store len to be deleted for next time
1049
+ this .mDelLen = text .length ();
1050
+ return super .setComposingText (text , newCursorPosition );
1051
+ }
1052
+
1053
+ @ Override
1054
+ public boolean commitText (CharSequence text , int newCursorPosition ) {
1055
+ // some code which takes the input and manipulates it and calls editText.getText().replace() afterwards
1056
+ //Log.i("Python:", String.format("Commit Text %s", text));
1057
+ this .deleteLastText ();
1058
+ this .mDelLen = 0 ;
1059
+ return super .commitText (text , newCursorPosition );
1060
+ }
1061
+ };
1025
1062
}
1026
1063
1027
1064
static void activateInput () {
0 commit comments