diff --git a/app/src/app/AndroidManifest.xml b/app/src/app/AndroidManifest.xml
deleted file mode 100644
index 3f719a2e9..000000000
--- a/app/src/app/AndroidManifest.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/app/src/google/AndroidManifest.xml b/app/src/google/AndroidManifest.xml
new file mode 100644
index 000000000..115df8b4e
--- /dev/null
+++ b/app/src/google/AndroidManifest.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 344e35512..2fc642579 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -12,10 +12,12 @@
-
+
+
+
{
+ //权限请求
+ Request.TYPE_REQUEST_PERMISSION -> {
val requestCode = intent.getIntExtra(KEY_INPUT_PERMISSIONS_CODE, 1000)
val permissions = intent.getStringArrayExtra(KEY_INPUT_PERMISSIONS)
if (permissions != null) {
@@ -33,8 +35,8 @@ class PermissionActivity : AppCompatActivity() {
finish()
}
}
- Request.TYPE_REQUEST_SETTING//跳转到设置界面
- -> try {
+ //跳转到设置界面
+ Request.TYPE_REQUEST_SETTING -> try {
val settingIntent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
settingIntent.data = Uri.fromParts("package", packageName, null)
settingActivityResult.launch(settingIntent)
@@ -42,7 +44,19 @@ class PermissionActivity : AppCompatActivity() {
toastOnUi(R.string.tip_cannot_jump_setting_page)
finish()
}
-
+ //所有文件所有文件的管理权限
+ Request.TYPE_MANAGE_ALL_FILES_ACCESS_PERMISSION -> try {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ val settingIntent = Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION)
+ settingIntent.data = Uri.parse("package:$packageName")
+ settingActivityResult.launch(settingIntent)
+ } else {
+ throw NoStackTraceException("no MANAGE_ALL_FILES_ACCESS_PERMISSION")
+ }
+ } catch (e: Exception) {
+ toastOnUi(R.string.tip_cannot_jump_setting_page)
+ finish()
+ }
}
}
@@ -59,6 +73,7 @@ class PermissionActivity : AppCompatActivity() {
finish()
}
+
override fun startActivity(intent: Intent) {
super.startActivity(intent)
overridePendingTransition(0, 0)
diff --git a/app/src/main/java/io/legado/app/lib/permission/Permissions.kt b/app/src/main/java/io/legado/app/lib/permission/Permissions.kt
index 5dee84603..b4d22b914 100644
--- a/app/src/main/java/io/legado/app/lib/permission/Permissions.kt
+++ b/app/src/main/java/io/legado/app/lib/permission/Permissions.kt
@@ -35,11 +35,13 @@ object Permissions {
const val READ_EXTERNAL_STORAGE = "android.permission.READ_EXTERNAL_STORAGE"
const val WRITE_EXTERNAL_STORAGE = "android.permission.WRITE_EXTERNAL_STORAGE"
+ const val MANAGE_EXTERNAL_STORAGE = "android.permission.MANAGE_EXTERNAL_STORAGE"
const val ACCESS_MEDIA_LOCATION = "android.permission.ACCESS_MEDIA_LOCATION"
object Group {
- val STORAGE = arrayOf(READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE)
+ val STORAGE =
+ arrayOf(READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE, MANAGE_EXTERNAL_STORAGE)
val CAMERA = arrayOf(Permissions.CAMERA)
diff --git a/app/src/main/java/io/legado/app/lib/permission/Request.kt b/app/src/main/java/io/legado/app/lib/permission/Request.kt
index 605f49da0..8d0aceb59 100644
--- a/app/src/main/java/io/legado/app/lib/permission/Request.kt
+++ b/app/src/main/java/io/legado/app/lib/permission/Request.kt
@@ -84,10 +84,23 @@ internal class Request : OnRequestPermissionsResultCallback {
}
} else {
if (deniedPermissions != null) {
- source?.context?.startActivity {
- putExtra(PermissionActivity.KEY_INPUT_REQUEST_TYPE, TYPE_REQUEST_PERMISSION)
- putExtra(PermissionActivity.KEY_INPUT_PERMISSIONS_CODE, requestCode)
- putExtra(PermissionActivity.KEY_INPUT_PERMISSIONS, deniedPermissions)
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
+ && deniedPermissions.contains(Permissions.MANAGE_EXTERNAL_STORAGE)
+ ) {
+ source?.context?.startActivity {
+ putExtra(
+ PermissionActivity.KEY_INPUT_REQUEST_TYPE,
+ TYPE_MANAGE_ALL_FILES_ACCESS_PERMISSION
+ )
+ putExtra(PermissionActivity.KEY_INPUT_PERMISSIONS_CODE, requestCode)
+ putExtra(PermissionActivity.KEY_INPUT_PERMISSIONS, deniedPermissions)
+ }
+ } else if (!deniedPermissions.contains(Permissions.MANAGE_EXTERNAL_STORAGE)) {
+ source?.context?.startActivity {
+ putExtra(PermissionActivity.KEY_INPUT_REQUEST_TYPE, TYPE_REQUEST_PERMISSION)
+ putExtra(PermissionActivity.KEY_INPUT_PERMISSIONS_CODE, requestCode)
+ putExtra(PermissionActivity.KEY_INPUT_PERMISSIONS, deniedPermissions)
+ }
}
} else {
onPermissionsGranted()
@@ -191,5 +204,6 @@ internal class Request : OnRequestPermissionsResultCallback {
companion object {
const val TYPE_REQUEST_PERMISSION = 1
const val TYPE_REQUEST_SETTING = 2
+ const val TYPE_MANAGE_ALL_FILES_ACCESS_PERMISSION = 3
}
}
\ No newline at end of file
diff --git a/app/src/main/java/io/legado/app/ui/book/import/BaseImportBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/import/BaseImportBookActivity.kt
index ebdbaae43..e871fcef3 100644
--- a/app/src/main/java/io/legado/app/ui/book/import/BaseImportBookActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/book/import/BaseImportBookActivity.kt
@@ -40,7 +40,6 @@ abstract class BaseImportBookActivity : VMBase
yesButton {
localBookTreeSelect.launch {
title = hint
- mode = HandleFileContract.DIR_SYS
}
}
noButton {
diff --git a/app/src/main/java/io/legado/app/ui/document/HandleFileActivity.kt b/app/src/main/java/io/legado/app/ui/document/HandleFileActivity.kt
index 3a7097045..e3672779b 100644
--- a/app/src/main/java/io/legado/app/ui/document/HandleFileActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/document/HandleFileActivity.kt
@@ -13,6 +13,7 @@ import io.legado.app.constant.AppLog
import io.legado.app.constant.Theme
import io.legado.app.databinding.ActivityTranslucenceBinding
import io.legado.app.help.IntentData
+import io.legado.app.help.config.AppConfig
import io.legado.app.lib.dialogs.SelectItem
import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.permission.Permissions
@@ -160,7 +161,10 @@ class HandleFileActivity :
}
private fun getDirActions(onlySys: Boolean = false): ArrayList> {
- return if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q || onlySys) {
+ return if (
+ onlySys ||
+ (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q && AppConfig.isGooglePlay)
+ ) {
arrayListOf(SelectItem(getString(R.string.sys_folder_picker), HandleFileContract.DIR))
} else {
arrayListOf(