[Android] AndroidTv: fix askStoragePermission

Duncan McNamara git at videolan.org
Tue Jan 24 12:33:36 UTC 2023


vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Thu Jan 19 16:00:20 2023 +0100| [0cd68422d6b2bc148d18dd43039f0d095e25e9b6] | committer: Nicolas Pomepuy

AndroidTv: fix askStoragePermission

AskStoragePermission checks if the onboarding is done before updating
the ui after giving permission. Though onboarding on tv is based on a
different SharedPreference key KEY_TV_ONBOARDING_DONE instead of
ONBOARDING_DONE_KEY. This checks the correct onboarding key for tv

> https://code.videolan.org/videolan/vlc-android/commit/0cd68422d6b2bc148d18dd43039f0d095e25e9b6
---

 .../vlc/gui/helpers/hf/StoragePermissionsDelegate.kt       | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/hf/StoragePermissionsDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/hf/StoragePermissionsDelegate.kt
index 1b4f8b0c91..7bbf590cc0 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/hf/StoragePermissionsDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/hf/StoragePermissionsDelegate.kt
@@ -46,10 +46,7 @@ import org.videolan.resources.EXTRA_UPGRADE
 import org.videolan.resources.SCHEME_PACKAGE
 import org.videolan.resources.util.isExternalStorageManager
 import org.videolan.resources.util.startMedialibrary
-import org.videolan.tools.INITIAL_PERMISSION_ASKED
-import org.videolan.tools.Settings
-import org.videolan.tools.isCallable
-import org.videolan.tools.putSingle
+import org.videolan.tools.*
 import org.videolan.vlc.gui.onboarding.ONBOARDING_DONE_KEY
 import org.videolan.vlc.util.FileUtils
 import org.videolan.vlc.util.Permissions
@@ -173,8 +170,15 @@ class StoragePermissionsDelegate : BaseHeadlessFragment() {
                 val granted = getStoragePermission(write)
                 val model : PermissionViewmodel by viewModels()
                 if (model.permissionPending) model.deferredGrant.complete(granted)
-                if (granted && withContext(Dispatchers.IO) { settings.getBoolean(ONBOARDING_DONE_KEY, false) })
+                val onboardingDone = withContext(Dispatchers.IO) {
+                    if (AndroidDevices.isTv)
+                        settings.getBoolean(KEY_TV_ONBOARDING_DONE, false)
+                    else
+                        settings.getBoolean(ONBOARDING_DONE_KEY, false)
+                }
+                if (granted && onboardingDone) {
                     (cb ?: getAction(this at askStoragePermission, firstRun, upgrade)).run()
+                }
             }
         }
 



More information about the Android mailing list