Mercurial > libervia-desktop-kivy
comparison src/cagou/core/cagou_main.py @ 61:0b7f10de416e
android: android build first draft:
- added buildozer.spec
- added src/sat.conf which is the configuration used on android (FIXME: need to rename/move it)
- small hack to change loading paths on android
- sys.platform is set to android when kivy_utils.platform is set to android
- softinput_mode is set to "below_target", so field are not hidden when virtual keyboard appears
Note: using org.goffi.cagou instead of org.salut-a-toi.cagou for package domain because the dash ("-") is causing trouble to buildozer. This need to be fixed.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 04 Dec 2016 18:21:23 +0100 |
parents | 35abe494e6c7 |
children | af4f986d86f0 |
comparison
equal
deleted
inserted
replaced
60:35abe494e6c7 | 61:0b7f10de416e |
---|---|
59 import os.path | 59 import os.path |
60 import glob | 60 import glob |
61 import cagou.plugins | 61 import cagou.plugins |
62 import cagou.kv | 62 import cagou.kv |
63 from sat.core import sat_main | 63 from sat.core import sat_main |
64 from kivy import utils as kivy_utils | |
64 import sys | 65 import sys |
66 if kivy_utils.platform == "android": | |
67 # FIXME: move to separate android module | |
68 kivy.support.install_android() | |
69 # sys.platform is "linux" on android by default | |
70 # so we change it to allow backend to detect android | |
71 sys.platform = "android" | |
65 | 72 |
66 | 73 |
67 class NotifsIcon(IconButton): | 74 class NotifsIcon(IconButton): |
68 notifs = properties.ListProperty() | 75 notifs = properties.ListProperty() |
69 | 76 |
264 def onBackendReady(self): | 271 def onBackendReady(self): |
265 self.app.showWidget() | 272 self.app.showWidget() |
266 self.postInit() | 273 self.postInit() |
267 | 274 |
268 def postInit(self, dummy=None): | 275 def postInit(self, dummy=None): |
276 # FIXME: resize seem to bug on android, so we use below_target for now | |
277 self.app.root_window.softinput_mode = "below_target" | |
269 profile_manager = self.app._profile_manager | 278 profile_manager = self.app._profile_manager |
270 del self.app._profile_manager | 279 del self.app._profile_manager |
271 super(Cagou, self).postInit(profile_manager) | 280 super(Cagou, self).postInit(profile_manager) |
272 | 281 |
273 def _defaultFactory(self, plugin_info, target, profiles): | 282 def _defaultFactory(self, plugin_info, target, profiles): |
285 log.debug(u"kv file {} loaded".format(kv_path)) | 294 log.debug(u"kv file {} loaded".format(kv_path)) |
286 | 295 |
287 def _import_plugins(self): | 296 def _import_plugins(self): |
288 """import all plugins""" | 297 """import all plugins""" |
289 self.default_wid = None | 298 self.default_wid = None |
290 plugins_path = os.path.dirname(cagou.plugins.__file__) | 299 if sys.platform == "android": |
291 plug_lst = [os.path.splitext(p)[0] for p in map(os.path.basename, glob.glob(os.path.join(plugins_path, "plugin*.py")))] | 300 # FIXME: android hack, need to be moved to separate file |
301 plugins_path = "/data/data/org.goffi.cagou.cagou/files/cagou/plugins" | |
302 plugin_glob = "plugin*.pyo" | |
303 else: | |
304 plugins_path = os.path.dirname(cagou.plugins.__file__) | |
305 plugin_glob = "plugin*.py" | |
306 plug_lst = [os.path.splitext(p)[0] for p in map(os.path.basename, glob.glob(os.path.join(plugins_path, plugin_glob)))] | |
307 | |
292 imported_names = set() # use to avoid loading 2 times plugin with same import name | 308 imported_names = set() # use to avoid loading 2 times plugin with same import name |
293 for plug in plug_lst: | 309 for plug in plug_lst: |
294 plugin_path = 'cagou.plugins.' + plug | 310 plugin_path = 'cagou.plugins.' + plug |
295 mod = import_module(plugin_path) | 311 mod = import_module(plugin_path) |
296 try: | 312 try: |
490 def closeUI(self): | 506 def closeUI(self): |
491 self.app.root.show() | 507 self.app.root.show() |
492 | 508 |
493 def getDefaultAvatar(self, entity=None): | 509 def getDefaultAvatar(self, entity=None): |
494 return self.app.default_avatar | 510 return self.app.default_avatar |
511 | |
512 def showDialog(self, message, title, type="info", answer_cb=None, answer_data=None): | |
513 # TODO | |
514 log.info(u"FIXME: showDialog not implemented") | |
515 log.info(u"message: {} -- {}".format(title, message)) |