Skip to content

Commit 3345c66

Browse files
committed
move parts of get_keyboard_height to global
1 parent ce41723 commit 3345c66

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

recipes/android/src/android/_android.pyx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,16 @@ def get_dpi():
170170
cdef extern void android_show_keyboard(int)
171171
cdef extern void android_hide_keyboard()
172172

173+
174+
from jnius import autoclass
175+
python_act = autoclass('org.renpy.android.PythonActivity')
176+
rctx = autoclass('android.graphics.Rect')()
177+
mActivity = python_act.mActivity
178+
decor_view = mActivity.getWindow().getDecorView()
179+
height = mActivity.getWindowManager().getDefaultDisplay().getHeight()
173180
# get keyboard height
174181
def get_keyboard_height():
175-
from jnius import autoclass
176-
python_act = autoclass('org.renpy.android.PythonActivity')
177-
rctx = autoclass('android.graphics.Rect')()
178-
mActivity = python_act.mActivity
179-
mActivity.getWindow().getDecorView().\
180-
getWindowVisibleDisplayFrame(rctx)
181-
height = mActivity.getWindowManager().getDefaultDisplay().getHeight()
182+
decor_view.getWindowVisibleDisplayFrame(rctx)
182183
return height - rctx.bottom
183184

184185

0 commit comments

Comments
 (0)