From 93ca40cd6f8c7fcec9b9a204178ab65d1472d26e Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 9 Sep 2022 17:04:49 +0200 Subject: [PATCH] remove storage permissions --- app/src/main/AndroidManifest.xml | 5 -- .../libretube/dialogs/DownloadDialog.kt | 3 - .../github/libretube/dialogs/UpdateDialog.kt | 2 - .../libretube/preferences/InstanceSettings.kt | 11 +-- .../github/libretube/util/PermissionHelper.kt | 70 ------------------- 5 files changed, 1 insertion(+), 90 deletions(-) delete mode 100644 app/src/main/java/com/github/libretube/util/PermissionHelper.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2375541e1..77fd1d9b4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -5,12 +5,7 @@ - - - (PreferenceKeys.IMPORT_SUBS) importSubscriptions?.setOnPreferenceClickListener { // check StorageAccess - val accessGranted = - PermissionHelper.isStoragePermissionGranted(requireActivity()) - // import subscriptions - if (accessGranted) { - getContent.launch("*/*") - } // request permissions if not granted - else { - PermissionHelper.requestReadWrite(requireActivity()) - } + getContent.launch("*/*") true } diff --git a/app/src/main/java/com/github/libretube/util/PermissionHelper.kt b/app/src/main/java/com/github/libretube/util/PermissionHelper.kt deleted file mode 100644 index 1df60a152..000000000 --- a/app/src/main/java/com/github/libretube/util/PermissionHelper.kt +++ /dev/null @@ -1,70 +0,0 @@ -package com.github.libretube.util - -import android.Manifest -import android.app.Activity -import android.content.pm.PackageManager -import android.os.Build -import android.os.Environment -import androidx.core.app.ActivityCompat - -object PermissionHelper { - /** - * request storage permissions if not granted yet - */ - fun requestReadWrite(activity: Activity): Boolean { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - if (!Environment.isExternalStorageManager()) { - ActivityCompat.requestPermissions( - activity, - arrayOf( - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.MANAGE_EXTERNAL_STORAGE - ), - 1 - ) // permission request code is just an int - return false - } - } else { - if (ActivityCompat.checkSelfPermission( - activity, - Manifest.permission.READ_EXTERNAL_STORAGE - ) != PackageManager.PERMISSION_GRANTED || - ActivityCompat.checkSelfPermission( - activity, - Manifest.permission.WRITE_EXTERNAL_STORAGE - ) != PackageManager.PERMISSION_GRANTED - ) { - ActivityCompat.requestPermissions( - activity, - arrayOf( - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.WRITE_EXTERNAL_STORAGE - ), - 1 - ) - return false - } - } - return true - } - - fun isStoragePermissionGranted(activity: Activity): Boolean { - return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) - == PackageManager.PERMISSION_GRANTED - ) { - true - } else { - ActivityCompat.requestPermissions( - activity, - arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), - 1 - ) - false - } - } else { - // permission is automatically granted on sdk < 23 upon installation - true - } - } -}