Skip to content

Fixed keyboard issues for old_toolchain. #572

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

Closed
wants to merge 2 commits into from
Closed
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
21 changes: 17 additions & 4 deletions recipes/android/src/android/_android.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,27 @@ version_codes = autoclass('android.os.Build$VERSION_CODES')


python_act = autoclass('org.renpy.android.PythonActivity')
Rect = autoclass('android.graphics.Rect')
mActivity = python_act.mActivity
if mActivity:
# do not add a listener here, one is already implemented in
# SDLSurfaceView.java which sends a event to kivy which makes
# a call to `get_keyboard_height`.
class LayoutListener(PythonJavaClass):
__javainterfaces__ = ['android/view/ViewTreeObserver$OnGlobalLayoutListener']

height = 0

@java_method('()V')
def onGlobalLayout(self):
rctx = Rect()
mActivity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rctx)
# NOTE top should always be zero
rctx.top = 0
self.height = mActivity.getWindowManager().getDefaultDisplay().getHeight() - (rctx.bottom - rctx.top)

ll = LayoutListener()
python_act.mView.getViewTreeObserver().addOnGlobalLayoutListener(ll)

def get_keyboard_height():
return python_act.mView.kHeight
return ll.height
else:
def get_keyboard_height():
return 0
Expand Down