Mercurial > libervia-desktop-kivy
diff 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 |
line wrap: on
line diff
--- a/cagou/core/platform_/android.py Fri Jan 17 20:35:57 2020 +0100 +++ b/cagou/core/platform_/android.py Sat Jan 18 23:12:52 2020 +0100 @@ -32,7 +32,8 @@ log = logging.getLogger(__name__) service = autoclass('org.salutatoi.cagou.ServiceBackend') -mActivity = autoclass('org.kivy.android.PythonActivity').mActivity +PythonActivity = autoclass('org.kivy.android.PythonActivity') +mActivity = PythonActivity.mActivity Intent = autoclass('android.content.Intent') AndroidString = autoclass('java.lang.String') Uri = autoclass('android.net.Uri') @@ -103,6 +104,15 @@ self._frontend_status_socket.sendall(STATE_STOPPED) self._frontend_status_socket.close() + def on_key_back_root(self): + PythonActivity.moveTaskToBack(True) + return True + + def on_key_back_share(self, share_widget): + share_widget.close() + PythonActivity.moveTaskToBack(True) + return True + def getPathFromUri(self, uri): cursor = mActivity.getContentResolver().query(uri, None, None, None, None) if cursor is None: