Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions recipes/android/src/android/_android.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,18 @@ def get_dpi():
cdef extern void android_show_keyboard(int)
cdef extern void android_hide_keyboard()

# get keyboard height
def get_keyboard_height():
from jnius import autoclass
python_act = autoclass('org.renpy.android.PythonActivity')
rctx = autoclass('android.graphics.Rect')()
mActivity = python_act.mActivity
mActivity.getWindow().getDecorView().\
getWindowVisibleDisplayFrame(rctx)
height = mActivity.getWindowManager().getDefaultDisplay().getHeight()
return height - rctx.bottom


# Flags for input_type, for requesting a particular type of keyboard
#android FLAGS
TYPE_CLASS_DATETIME = 4
Expand Down
17 changes: 13 additions & 4 deletions src/src/org/renpy/android/SDLSurfaceView.java
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,6 @@ public void run(){

public void dispatchCommand(String message){

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

if (DEBUG) Log.d(TAG, String.format("dispatch :%s", message));
int keyCode = 45;
//send control sequence start \x01
//send control sequence start
nativeKey(keyCode, 1, 1);
nativeKey(keyCode, 0, 1);

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

//send control sequence start \x01
//send control sequence end \x02
nativeKey(keyCode, 1, 2);
nativeKey(keyCode, 0, 2);

}

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
// setting inputtype to TYPE_CLASS_TEXT is necessary for swiftkey to enable
outAttrs.inputType = inputType;
// ask IME to avoid taking full screen on landscape mode
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI;

// add a listener for the layout chnages to the IME view
final android.view.View activityRootView = mActivity.getWindow().getDecorView();
activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new android.view.ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
//send control sequence start /x04 == kayboard layout changed
nativeKey(45, 1, 4);
nativeKey(45, 0, 4);
}
});
return new BaseInputConnection(this, false){

private void deleteLastText(){
Expand Down