11# Android-specific python services.
22
3- cdef extern int SDL_ANDROID_CheckPause()
4- cdef extern void SDL_ANDROID_WaitForResume() nogil
5- cdef extern void SDL_ANDROID_MapKey(int scancode, int keysym)
6-
7- def check_pause ():
8- return SDL_ANDROID_CheckPause()
9-
10- def wait_for_resume ():
11- android_accelerometer_enable(False )
12- SDL_ANDROID_WaitForResume()
13- android_accelerometer_enable(accelerometer_enabled)
14-
15- def map_key (scancode , keysym ):
16- SDL_ANDROID_MapKey(scancode, keysym)
3+ include " config.pxi"
4+
5+ IF BOOTSTRAP == ' pygame' :
6+ cdef extern int SDL_ANDROID_CheckPause()
7+ cdef extern void SDL_ANDROID_WaitForResume() nogil
8+ cdef extern void SDL_ANDROID_MapKey(int scancode, int keysym)
9+
10+ def check_pause ():
11+ return SDL_ANDROID_CheckPause()
12+
13+ def wait_for_resume ():
14+ android_accelerometer_enable(False )
15+ SDL_ANDROID_WaitForResume()
16+ android_accelerometer_enable(accelerometer_enabled)
17+
18+ def map_key (scancode , keysym ):
19+ SDL_ANDROID_MapKey(scancode, keysym)
1720
1821# Android keycodes.
1922KEYCODE_UNKNOWN = 0
@@ -109,12 +112,6 @@ KEYCODE_MEDIA_REWIND = 89
109112KEYCODE_MEDIA_FAST_FORWARD = 90
110113KEYCODE_MUTE = 91
111114
112- # Activate input - required to receive input events.
113- cdef extern void android_activate_input()
114-
115- def init ():
116- android_activate_input()
117-
118115# Vibration support.
119116cdef extern void android_vibrate(double )
120117
@@ -178,7 +175,7 @@ api_version = autoclass('android.os.Build$VERSION').SDK_INT
178175version_codes = autoclass(' android.os.Build$VERSION_CODES' )
179176
180177
181- python_act = autoclass(' org.renpy.android .PythonActivity' )
178+ python_act = autoclass(JAVA_NAMESPACE + ' .PythonActivity' )
182179Rect = autoclass(' android.graphics.Rect' )
183180mActivity = python_act.mActivity
184181if mActivity:
@@ -194,7 +191,10 @@ if mActivity:
194191 self .height = mActivity.getWindowManager().getDefaultDisplay().getHeight() - (rctx.bottom - rctx.top)
195192
196193 ll = LayoutListener()
197- python_act.mView.getViewTreeObserver().addOnGlobalLayoutListener(ll)
194+ IF BOOTSTRAP == ' sdl2' :
195+ python_act.getLayout().getViewTreeObserver().addOnGlobalLayoutListener(ll)
196+ ELSE :
197+ python_act.mView.getViewTreeObserver().addOnGlobalLayoutListener(ll)
198198
199199 def get_keyboard_height ():
200200 return ll.height
@@ -276,52 +276,59 @@ def get_buildinfo():
276276 binfo.VERSION_RELEASE = BUILD_VERSION_RELEASE
277277 return binfo
278278
279- # Action send
280- cdef extern void android_action_send(char * , char * , char * , char * , char * )
281- def action_send (mimetype , filename = None , subject = None , text = None ,
282- chooser_title = None ):
283- cdef char * j_mimetype = < bytes> mimetype
284- cdef char * j_filename = NULL
285- cdef char * j_subject = NULL
286- cdef char * j_text = NULL
287- cdef char * j_chooser_title = NULL
288- if filename is not None :
289- j_filename = < bytes> filename
290- if subject is not None :
291- j_subject = < bytes> subject
292- if text is not None :
293- j_text = < bytes> text
294- if chooser_title is not None :
295- j_chooser_title = < bytes> chooser_title
296- android_action_send(j_mimetype, j_filename, j_subject, j_text,
297- j_chooser_title)
298-
299- cdef extern int android_checkstop()
300- cdef extern void android_ackstop()
301-
302- def check_stop ():
303- return android_checkstop()
304-
305- def ack_stop ():
306- android_ackstop()
307-
308- # -------------------------------------------------------------------
309- # URL Opening.
310- cdef extern void android_open_url(char * url)
311- def open_url (url ):
312- android_open_url(url)
313-
314- # Web browser support.
315- class AndroidBrowser (object ):
316- def open (self , url , new = 0 , autoraise = True ):
317- open_url(url)
318- def open_new (self , url ):
319- open_url(url)
320- def open_new_tab (self , url ):
321- open_url(url)
322-
323- import webbrowser
324- webbrowser.register(' android' , AndroidBrowser, None , - 1 )
279+ IF IS_PYGAME:
280+ # Activate input - required to receive input events.
281+ cdef extern void android_activate_input()
282+
283+ def init ():
284+ android_activate_input()
285+
286+ # Action send
287+ cdef extern void android_action_send(char * , char * , char * , char * , char * )
288+ def action_send (mimetype , filename = None , subject = None , text = None ,
289+ chooser_title = None ):
290+ cdef char * j_mimetype = < bytes> mimetype
291+ cdef char * j_filename = NULL
292+ cdef char * j_subject = NULL
293+ cdef char * j_text = NULL
294+ cdef char * j_chooser_title = NULL
295+ if filename is not None :
296+ j_filename = < bytes> filename
297+ if subject is not None :
298+ j_subject = < bytes> subject
299+ if text is not None :
300+ j_text = < bytes> text
301+ if chooser_title is not None :
302+ j_chooser_title = < bytes> chooser_title
303+ android_action_send(j_mimetype, j_filename, j_subject, j_text,
304+ j_chooser_title)
305+
306+ cdef extern int android_checkstop()
307+ cdef extern void android_ackstop()
308+
309+ def check_stop ():
310+ return android_checkstop()
311+
312+ def ack_stop ():
313+ android_ackstop()
314+
315+ # -------------------------------------------------------------------
316+ # URL Opening.
317+ cdef extern void android_open_url(char * url)
318+ def open_url (url ):
319+ android_open_url(url)
320+
321+ # Web browser support.
322+ class AndroidBrowser (object ):
323+ def open (self , url , new = 0 , autoraise = True ):
324+ open_url(url)
325+ def open_new (self , url ):
326+ open_url(url)
327+ def open_new_tab (self , url ):
328+ open_url(url)
329+
330+ import webbrowser
331+ webbrowser.register(' android' , AndroidBrowser, None , - 1 )
325332
326333cdef extern void android_start_service(char * , char * , char * )
327334def start_service (title = None , description = None , arg = None ):
0 commit comments