comparison cagou/core/platform_/android.py @ 357:4d3a0c4f2430

core: better back key (ESC) management: - back key (which is mapped to esc keycode by SDL2 backend) is now handler with a platform specific method when on root widget (i.e. a default widget is selected, or nothing is selected). Default behaviour is to do nothing, while on Android the app is put to background - CagouWidget now has a default key_input method which go back to default widget.
author Goffi <goffi@goffi.org>
date Sat, 18 Jan 2020 23:12:52 +0100
parents a3cefa7158dc
children 1a12bbd80943
comparison
equal deleted inserted replaced
356:307c2501d8b2 357:4d3a0c4f2430
30 30
31 31
32 log = logging.getLogger(__name__) 32 log = logging.getLogger(__name__)
33 33
34 service = autoclass('org.salutatoi.cagou.ServiceBackend') 34 service = autoclass('org.salutatoi.cagou.ServiceBackend')
35 mActivity = autoclass('org.kivy.android.PythonActivity').mActivity 35 PythonActivity = autoclass('org.kivy.android.PythonActivity')
36 mActivity = PythonActivity.mActivity
36 Intent = autoclass('android.content.Intent') 37 Intent = autoclass('android.content.Intent')
37 AndroidString = autoclass('java.lang.String') 38 AndroidString = autoclass('java.lang.String')
38 Uri = autoclass('android.net.Uri') 39 Uri = autoclass('android.net.Uri')
39 ImagesMedia = autoclass('android.provider.MediaStore$Images$Media') 40 ImagesMedia = autoclass('android.provider.MediaStore$Images$Media')
40 AudioMedia = autoclass('android.provider.MediaStore$Audio$Media') 41 AudioMedia = autoclass('android.provider.MediaStore$Audio$Media')
101 102
102 def on_stop(self): 103 def on_stop(self):
103 self._frontend_status_socket.sendall(STATE_STOPPED) 104 self._frontend_status_socket.sendall(STATE_STOPPED)
104 self._frontend_status_socket.close() 105 self._frontend_status_socket.close()
105 106
107 def on_key_back_root(self):
108 PythonActivity.moveTaskToBack(True)
109 return True
110
111 def on_key_back_share(self, share_widget):
112 share_widget.close()
113 PythonActivity.moveTaskToBack(True)
114 return True
115
106 def getPathFromUri(self, uri): 116 def getPathFromUri(self, uri):
107 cursor = mActivity.getContentResolver().query(uri, None, None, None, None) 117 cursor = mActivity.getContentResolver().query(uri, None, None, None, None)
108 if cursor is None: 118 if cursor is None:
109 return uri.getPath() 119 return uri.getPath()
110 else: 120 else: