From ac77fe9e1ec5c289becb18c9e03aa0712e205bd3 Mon Sep 17 00:00:00 2001 From: lufebe16 Date: Tue, 28 Feb 2023 19:56:36 +0100 Subject: [PATCH] Android build updates --- .gitignore | 4 ++-- buildozer/buildozer.spec | 6 ++++-- buildozer/pipreq.txt | 28 ++++++++++++++++------------ pysollib/kivy/androidperms.py | 10 ++++++++++ pysollib/kivy/tkwidget.py | 2 +- 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 09a2718f..d200c745 100644 --- a/.gitignore +++ b/.gitignore @@ -24,11 +24,11 @@ PySolFC-Cardsets-2.0/ android/*.apk android/*.zip android/bin/keystore -buildozer/.buildozer +buildozer/.buildozer* buildozer/PySolFC-Cardsets* buildozer/bin buildozer/tmp buildozer/support* buildozer/ENV buildozer/VENV -venv* \ No newline at end of file +venv* diff --git a/buildozer/buildozer.spec b/buildozer/buildozer.spec index c96cd2d3..19e488c1 100644 --- a/buildozer/buildozer.spec +++ b/buildozer/buildozer.spec @@ -52,7 +52,7 @@ presplash.filename = %(source.dir)s/data/images/logo-with-margin-1024.png icon.filename = %(source.dir)s/data/images/icons/48x48/pysol.png # (str) Supported orientation (one of landscape, sensorLandscape, portrait or all) -orientation = all +orientation = portrait, landscape # (list) List of service to declare #services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY @@ -96,6 +96,7 @@ fullscreen = 1 # (list) Permissions #android.permissions = INTERNET +android.permissions = INTERNET, WRITE_EXTERNAL_STORAGE # (list) features (adds uses-feature -tags to manifest) #android.features = android.hardware.usb.host @@ -312,6 +313,7 @@ android.debug_artifact = apk # (str) python-for-android specific commit to use, defaults to HEAD, must be within p4a.branch #p4a.commit = HEAD +p4a.commit = v2023.02.10 # (str) python-for-android git clone directory (if empty, it will be automatically cloned from github) #p4a.source_dir = @@ -388,7 +390,7 @@ ios.codesign.allowed = false [buildozer] # (int) Log level (0 = error only, 1 = info, 2 = debug (with command output)) -log_level = 1 +log_level = 2 # (int) Display warning if buildozer is run as root (0 = False, 1 = True) warn_on_root = 1 diff --git a/buildozer/pipreq.txt b/buildozer/pipreq.txt index 3c36f26d..c3223363 100644 --- a/buildozer/pipreq.txt +++ b/buildozer/pipreq.txt @@ -1,12 +1,16 @@ -attrs -buildozer -configobj -Cython -Kivy -pep8 -permutation -pip -pysol-cards -python-for-android -setuptools -wheel +appdirs==1.4.4 +attrs==22.2.0 +-e git+https://github.com/kivy/buildozer.git@3ebc09e885457db4747e67a1250c2aea1ca7a046#egg=buildozer +colorama==0.4.6 +configobj==5.0.8 +Cython==0.29.33 +Jinja2==3.1.2 +Kivy==2.1.0 +pep517==0.13.0 +pep8==1.7.1 +permutation==0.4.0 +pip==23.0.1 +pysol-cards==0.14.3 +setuptools==67.0.0 +toml==0.10.2 +wheel==0.38.4 diff --git a/pysollib/kivy/androidperms.py b/pysollib/kivy/androidperms.py index 2cc78d74..5c621627 100644 --- a/pysollib/kivy/androidperms.py +++ b/pysollib/kivy/androidperms.py @@ -27,6 +27,9 @@ class AndroidPerms(object): 'androidx.core.content.ContextCompat') self.currentActivity = jnius.cast( 'android.app.Activity', self.PythonActivity.mActivity) + self.build = jnius.autoclass("android.os.Build") + self.version = jnius.autoclass("android.os.Build$VERSION") + self.vcodes = jnius.autoclass("android.os.Build$VERSION_CODES") def getPerm(self, permission): if jnius is None: @@ -54,12 +57,19 @@ class AndroidPerms(object): def getStoragePerm(): ap = AndroidPerms() + # print('Android API version: ', ap.version.SDK_INT) + logging.info("androidperms: API version %d" % (ap.version.SDK_INT)) + if ap.version.SDK_INT > 29: + return False return ap.getPerms( ["android.permission.WRITE_EXTERNAL_STORAGE"]) def requestStoragePerm(): ap = AndroidPerms() + logging.info("androidperms: API version %d" % (ap.version.SDK_INT)) + if ap.version.SDK_INT > 29: + return # ap.requestPerms( # ["android.permission.READ_EXTERNAL_STORAGE","android.permission.WRITE_EXTERNAL_STORAGE"]) ap.requestPerms( diff --git a/pysollib/kivy/tkwidget.py b/pysollib/kivy/tkwidget.py index 65402ea1..94504ac4 100644 --- a/pysollib/kivy/tkwidget.py +++ b/pysollib/kivy/tkwidget.py @@ -221,7 +221,7 @@ class PysolAboutDialog(object): logging.info('PysolAboutDialog: txt=%s' % text) text = text + '\n\n' + 'Adaptation to Kivy/Android\n' + \ - ' Copyright (C) (2016-19) LB' + ' Copyright (C) (2016-23) LB' self.parent = parent self.app = app