core (constants): new downloads_dir config option (default path where files can be downloaded):

use Android API to find downloads_dir on this platform
This commit is contained in:
Goffi 2018-05-25 10:51:59 +02:00
commit 37c73105e0

View file

@ -173,10 +173,18 @@ class Const(object):
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 @@ class Const(object):
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',
}