# HG changeset patch # User Goffi # Date 1527238319 -7200 # Node ID 86e57108bd50f4b686bce6084518d7eefa9eba49 # Parent bd9d92bc0d6c1f38817f90a5c576a39cf31cf1f8 core (constants): new downloads_dir config option (default path where files can be downloaded): use Android API to find downloads_dir on this platform diff -r bd9d92bc0d6c -r 86e57108bd50 sat/core/constants.py --- a/sat/core/constants.py Tue May 22 10:07:33 2018 +0200 +++ b/sat/core/constants.py Fri May 25 10:51:59 2018 +0200 @@ -173,10 +173,18 @@ if "org.goffi.cagou.cagou" in BaseDirectory.__file__: # FIXME: hack to make config read from the right location on Android # TODO: fix it in a more proper way + + # we need to use Android API to get downloads directory + import os.path + from jnius import autoclass + Environment = autoclass("android.os.Environment") + BaseDirectory = None DEFAULT_CONFIG = { 'local_dir': '/data/data/org.goffi.cagou.cagou/app', 'media_dir': '/data/data/org.goffi.cagou.cagou/files/app/media', + # FIXME: temporary location for downloads, need to call API properly + 'downloads_dir': os.path.join(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath(), APP_NAME_FILE), 'pid_dir': '%(local_dir)s', 'log_dir': '%(local_dir)s', } @@ -187,6 +195,7 @@ DEFAULT_CONFIG = { 'media_dir': '/usr/share/' + APP_NAME_FILE + '/media', 'local_dir': BaseDirectory.save_data_path(APP_NAME_FILE), + 'downloads_dir': '~/Downloads/' + APP_NAME_FILE, 'pid_dir': '%(local_dir)s', 'log_dir': '%(local_dir)s', }