mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40:30 +05:30
remove storage permissions
This commit is contained in:
parent
9641add481
commit
93ca40cd6f
@ -5,12 +5,7 @@
|
|||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
|
||||||
<uses-permission
|
|
||||||
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
|
|
||||||
tools:ignore="ScopedStorage" />
|
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
|
@ -16,7 +16,6 @@ import com.github.libretube.databinding.DialogDownloadBinding
|
|||||||
import com.github.libretube.extensions.TAG
|
import com.github.libretube.extensions.TAG
|
||||||
import com.github.libretube.obj.Streams
|
import com.github.libretube.obj.Streams
|
||||||
import com.github.libretube.services.DownloadService
|
import com.github.libretube.services.DownloadService
|
||||||
import com.github.libretube.util.PermissionHelper
|
|
||||||
import com.github.libretube.util.ThemeHelper
|
import com.github.libretube.util.ThemeHelper
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import retrofit2.HttpException
|
import retrofit2.HttpException
|
||||||
@ -32,8 +31,6 @@ class DownloadDialog(
|
|||||||
|
|
||||||
fetchAvailableSources()
|
fetchAvailableSources()
|
||||||
|
|
||||||
PermissionHelper.requestReadWrite(requireActivity())
|
|
||||||
|
|
||||||
binding.title.text = ThemeHelper.getStyledAppName(requireContext())
|
binding.title.text = ThemeHelper.getStyledAppName(requireContext())
|
||||||
|
|
||||||
binding.audioRadio.setOnClickListener {
|
binding.audioRadio.setOnClickListener {
|
||||||
|
@ -10,7 +10,6 @@ import androidx.fragment.app.DialogFragment
|
|||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.services.UpdateService
|
import com.github.libretube.services.UpdateService
|
||||||
import com.github.libretube.update.UpdateInfo
|
import com.github.libretube.update.UpdateInfo
|
||||||
import com.github.libretube.util.PermissionHelper
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
|
||||||
class UpdateDialog(
|
class UpdateDialog(
|
||||||
@ -26,7 +25,6 @@ class UpdateDialog(
|
|||||||
val downloadUrl = getDownloadUrl(updateInfo)
|
val downloadUrl = getDownloadUrl(updateInfo)
|
||||||
Log.i("downloadUrl", downloadUrl.toString())
|
Log.i("downloadUrl", downloadUrl.toString())
|
||||||
if (downloadUrl != null) {
|
if (downloadUrl != null) {
|
||||||
PermissionHelper.requestReadWrite(requireActivity())
|
|
||||||
val intent = Intent(context, UpdateService::class.java)
|
val intent = Intent(context, UpdateService::class.java)
|
||||||
intent.putExtra("downloadUrl", downloadUrl)
|
intent.putExtra("downloadUrl", downloadUrl)
|
||||||
context?.startService(intent)
|
context?.startService(intent)
|
||||||
|
@ -23,7 +23,6 @@ import com.github.libretube.dialogs.LoginDialog
|
|||||||
import com.github.libretube.dialogs.LogoutDialog
|
import com.github.libretube.dialogs.LogoutDialog
|
||||||
import com.github.libretube.extensions.await
|
import com.github.libretube.extensions.await
|
||||||
import com.github.libretube.util.ImportHelper
|
import com.github.libretube.util.ImportHelper
|
||||||
import com.github.libretube.util.PermissionHelper
|
|
||||||
import com.github.libretube.util.PreferenceHelper
|
import com.github.libretube.util.PreferenceHelper
|
||||||
import com.github.libretube.views.MaterialPreferenceFragment
|
import com.github.libretube.views.MaterialPreferenceFragment
|
||||||
|
|
||||||
@ -147,15 +146,7 @@ class InstanceSettings : MaterialPreferenceFragment() {
|
|||||||
val importSubscriptions = findPreference<Preference>(PreferenceKeys.IMPORT_SUBS)
|
val importSubscriptions = findPreference<Preference>(PreferenceKeys.IMPORT_SUBS)
|
||||||
importSubscriptions?.setOnPreferenceClickListener {
|
importSubscriptions?.setOnPreferenceClickListener {
|
||||||
// check StorageAccess
|
// check StorageAccess
|
||||||
val accessGranted =
|
getContent.launch("*/*")
|
||||||
PermissionHelper.isStoragePermissionGranted(requireActivity())
|
|
||||||
// import subscriptions
|
|
||||||
if (accessGranted) {
|
|
||||||
getContent.launch("*/*")
|
|
||||||
} // request permissions if not granted
|
|
||||||
else {
|
|
||||||
PermissionHelper.requestReadWrite(requireActivity())
|
|
||||||
}
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user