Skip to content

Commit df55cf7

Browse files
committed
Listen to chnages in the gloabal layout for figuring out when the
IME is activated.
1 parent b1ba8dc commit df55cf7

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,6 @@ public void run(){
11321132

11331133
public void dispatchCommand(String message){
11341134

1135-
Boolean ret = false;
11361135
int delay = 0;
11371136
while (message.length() > 50){
11381137
delayed_message(message.substring(0, 50), delay);
@@ -1146,7 +1145,7 @@ public void dispatchCommand(String message){
11461145

11471146
if (DEBUG) Log.d(TAG, String.format("dispatch :%s", message));
11481147
int keyCode = 45;
1149-
//send control sequence start \x01
1148+
//send control sequence start
11501149
nativeKey(keyCode, 1, 1);
11511150
nativeKey(keyCode, 0, 1);
11521151

@@ -1156,18 +1155,28 @@ public void dispatchCommand(String message){
11561155
nativeKey(keyCode, 0, (int) message.charAt(i));
11571156
}
11581157

1159-
//send control sequence start \x01
1158+
//send control sequence end \x02
11601159
nativeKey(keyCode, 1, 2);
11611160
nativeKey(keyCode, 0, 2);
11621161

11631162
}
11641163

11651164
@Override
11661165
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
1167-
// setting inputtype to TYPE_CLASS_TEXT is necessary for swiftkey to enable
11681166
outAttrs.inputType = inputType;
11691167
// ask IME to avoid taking full screen on landscape mode
11701168
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI;
1169+
1170+
// add a listener for the layout chnages to the IME view
1171+
final android.view.View activityRootView = mActivity.getWindow().getDecorView();
1172+
activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new android.view.ViewTreeObserver.OnGlobalLayoutListener() {
1173+
@Override
1174+
public void onGlobalLayout() {
1175+
//send control sequence start /x04 == kayboard layout changed
1176+
nativeKey(45, 1, 4);
1177+
nativeKey(45, 0, 4);
1178+
}
1179+
});
11711180
return new BaseInputConnection(this, false){
11721181

11731182
private void deleteLastText(){

0 commit comments

Comments
 (0)