|
9 | 9 | from kivy.uix.label import Label
|
10 | 10 | from kivy.uix.popup import Popup
|
11 | 11 | from kivy.factory import Factory
|
12 |
| -from kivy.utils import platform |
13 | 12 |
|
14 | 13 | import functools
|
15 | 14 | import os
|
|
22 | 21 | J_FileOutputStream = autoclass("java.io.FileOutputStream")
|
23 | 22 | J_FileUtils = autoclass("android.os.FileUtils")
|
24 | 23 | J_Intent = autoclass("android.content.Intent")
|
25 |
| - J_PythonActivity = autoclass('org.kivy.android.PythonActivity') |
26 |
| - J_Environment = autoclass("android.os.Environment") |
27 |
| - J_Settings = autoclass("android.provider.Settings") |
28 |
| - J_Uri = autoclass("android.net.Uri") |
29 | 24 | OPERATING_SYSTEM = "Android"
|
30 | 25 | except:
|
31 | 26 | OPERATING_SYSTEM = None
|
|
34 | 29 | from shared.storage import Rawlog
|
35 | 30 | from shared.utils import Paths
|
36 | 31 | from shared.ui.mobile_about_dialog import MobileAboutDialog
|
| 32 | +import shared.utils.mobileHelpers as helpers |
37 | 33 |
|
38 | 34 | import logging
|
39 | 35 | logger = logging.getLogger(__name__)
|
@@ -104,7 +100,7 @@ def on_start(self, *args):
|
104 | 100 | # Use if the os is Android to avoid Android peculiarities
|
105 | 101 | if OPERATING_SYSTEM == "Android":
|
106 | 102 | logger.info("Asking for permission for external storage")
|
107 |
| - self.permissions_external_storage() |
| 103 | + helpers.permissions_external_storage() |
108 | 104 |
|
109 | 105 | context = cast('android.content.Context', mActivity.getApplicationContext())
|
110 | 106 | logger.info(f"Startup application context: {context}")
|
@@ -165,19 +161,6 @@ def on_new_intent(self, intent):
|
165 | 161 | self.openFile(cacheFile)
|
166 | 162 | os.remove(cacheFile)
|
167 | 163 | """
|
168 |
| - # See: https://stackoverflow.com/questions/64849485/why-is-filemanager-not-working-on-android-kivymd |
169 |
| - def permissions_external_storage(self, *args): |
170 |
| - if not J_Environment.isExternalStorageManager(): |
171 |
| - try: |
172 |
| - logger.debug("Ask for ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION") |
173 |
| - context = mActivity.getApplicationContext() |
174 |
| - uri = J_Uri.parse("package:" + context.getPackageName()) |
175 |
| - intent = J_Intent(J_Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, uri) |
176 |
| - except Exception as e: |
177 |
| - logger.debug("ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION Failed! Open ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION") |
178 |
| - intent = J_Intent(J_Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION) |
179 |
| - currentActivity = cast("android.app.Activity", J_PythonActivity.mActivity) |
180 |
| - currentActivity.startActivityForResult(intent, 101) |
181 | 164 |
|
182 | 165 | def selectFile(self, *args):
|
183 | 166 | # Create popup window to select file
|
|
0 commit comments