forked from LBRYCommunity/lbry-sdk
added Android platform detection and androidhelpers module which will be used to determine base paths
This commit is contained in:
parent
e204a3b9a5
commit
70881dab6e
3 changed files with 41 additions and 4 deletions
1
lbrynet/androidhelpers/__init__.py
Normal file
1
lbrynet/androidhelpers/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
import paths
|
26
lbrynet/androidhelpers/paths.py
Normal file
26
lbrynet/androidhelpers/paths.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
# App root files dir
|
||||
# https://developer.android.com/reference/android/content/ContextWrapper.html#getFilesDir%28%29
|
||||
def android_files_dir():
|
||||
return None
|
||||
|
||||
|
||||
# Base internal storage path
|
||||
def android_internal_storage_dir():
|
||||
return None
|
||||
|
||||
|
||||
# Base external (SD card, if present) storage path
|
||||
def android_external_storage_dir():
|
||||
return None
|
||||
|
||||
|
||||
# Internal device storage (private app folder)
|
||||
# https://developer.android.com/reference/android/content/ContextWrapper.html#getExternalFilesDirs(java.lang.String)
|
||||
def android_app_internal_storage_dir():
|
||||
return None
|
||||
|
||||
|
||||
# External (app folder on SD card, if present) storage
|
||||
# https://developer.android.com/reference/android/content/ContextWrapper.html#getExternalFilesDirs(java.lang.String)
|
||||
def android_app_external_storage_dir():
|
||||
return None
|
|
@ -9,10 +9,12 @@ import envparse
|
|||
from appdirs import user_data_dir, user_config_dir
|
||||
from lbrynet.core import utils
|
||||
from lbrynet.core.Error import InvalidCurrencyError
|
||||
from lbrynet.androidhelpers.paths import android_internal_storage_dir, android_app_internal_storage_dir
|
||||
|
||||
try:
|
||||
from lbrynet.winhelpers.knownpaths import get_path, FOLDERID, UserHandle
|
||||
except (ImportError, ValueError):
|
||||
except (ImportError, ValueError, NameError):
|
||||
# Android platform: NameError: name 'c_wchar' is not defined
|
||||
pass
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -31,6 +33,7 @@ APP_NAME = 'LBRY'
|
|||
LINUX = 1
|
||||
DARWIN = 2
|
||||
WINDOWS = 3
|
||||
ANDROID = 4
|
||||
KB = 2 ** 10
|
||||
MB = 2 ** 20
|
||||
|
||||
|
@ -89,7 +92,11 @@ def _get_old_directories(platform):
|
|||
|
||||
def _get_new_directories(platform):
|
||||
dirs = {}
|
||||
if platform == WINDOWS:
|
||||
if platform == ANDROID:
|
||||
dirs['data'] = '%s/lbrynet' % android_app_internal_storage_dir()
|
||||
dirs['lbryum'] = '%s/lbryum' % android_app_internal_storage_dir()
|
||||
dirs['download'] = '%s/Download' % android_internal_storage_dir()
|
||||
elif platform == WINDOWS:
|
||||
dirs['data'] = user_data_dir('lbrynet', 'lbry')
|
||||
dirs['lbryum'] = user_data_dir('lbryum', 'lbry')
|
||||
dirs['download'] = get_path(FOLDERID.Downloads, UserHandle.current)
|
||||
|
@ -113,7 +120,11 @@ def _get_new_directories(platform):
|
|||
return dirs
|
||||
|
||||
|
||||
if 'darwin' in sys.platform:
|
||||
if 'ANDROID_ARGUMENT' in os.environ:
|
||||
# https://github.com/kivy/kivy/blob/master/kivy/utils.py#L417-L421
|
||||
platform = ANDROID
|
||||
dirs = _get_new_directories(ANDROID)
|
||||
elif 'darwin' in sys.platform:
|
||||
platform = DARWIN
|
||||
dirs = _get_old_directories(DARWIN)
|
||||
elif 'win' in sys.platform:
|
||||
|
@ -521,7 +532,6 @@ class Config(object):
|
|||
# type: Config
|
||||
settings = None
|
||||
|
||||
|
||||
def get_default_env():
|
||||
env_defaults = {}
|
||||
for k, v in ADJUSTABLE_SETTINGS.iteritems():
|
||||
|
|
Loading…
Reference in a new issue