File tree 1 file changed +7
-14
lines changed
recipes/android/src/android
1 file changed +7
-14
lines changed Original file line number Diff line number Diff line change @@ -182,22 +182,15 @@ python_act = autoclass('org.renpy.android.PythonActivity')
182
182
Rect = autoclass(' android.graphics.Rect' )
183
183
mActivity = python_act.mActivity
184
184
if mActivity:
185
- class LayoutListener (PythonJavaClass ):
186
- __javainterfaces__ = [' android/view/ViewTreeObserver$OnGlobalLayoutListener' ]
187
-
188
- height = 0
189
-
190
- @ java_method (' ()V' )
191
- def onGlobalLayout (self ):
192
- rctx = Rect()
193
- mActivity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rctx)
194
- self .height = mActivity.getWindowManager().getDefaultDisplay().getHeight() - (rctx.bottom - rctx.top)
195
-
196
- ll = LayoutListener()
197
- python_act.mView.getViewTreeObserver().addOnGlobalLayoutListener(ll)
185
+ # do not add a listener here, one is already implemented in the Hardware.java
186
+ # that sends a event to kivy which makes a call to `get_keyboard_height`.
187
+ decorview = mActivity.getWindow().getDecorView()
188
+ default_display = mActivity.getWindowManager().getDefaultDisplay()
198
189
199
190
def get_keyboard_height ():
200
- return ll.height
191
+ rctx = Rect()
192
+ decorview.getWindowVisibleDisplayFrame(rctx)
193
+ return default_display.getHeight() - (rctx.bottom - rctx.top)
201
194
else :
202
195
def get_keyboard_height ():
203
196
return 0
You can’t perform that action at this time.
0 commit comments