pull/2718/head
kunfei 2 years ago
parent 2f7774cb67
commit 11712836b7
  1. 3
      app/src/main/java/io/legado/app/lib/permission/PermissionActivity.kt
  2. 6
      app/src/main/java/io/legado/app/lib/permission/Permissions.kt
  3. 2
      app/src/main/java/io/legado/app/lib/permission/Request.kt
  4. 6
      app/src/main/java/io/legado/app/ui/document/HandleFileActivity.kt
  5. 6
      app/src/main/java/io/legado/app/ui/font/FontAdapter.kt

@ -2,7 +2,6 @@ package io.legado.app.lib.permission
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import android.view.KeyEvent
@ -46,7 +45,7 @@ class PermissionActivity : AppCompatActivity() {
}
//所有文件的管理权限
Request.TYPE_MANAGE_ALL_FILES_ACCESS_PERMISSION -> try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (Permissions.isManageExternalStorage()) {
val settingIntent = Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION)
settingActivityResult.launch(settingIntent)
} else {

@ -42,7 +42,7 @@ object Permissions {
const val ACCESS_MEDIA_LOCATION = "android.permission.ACCESS_MEDIA_LOCATION"
object Group {
val STORAGE = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val STORAGE = if (isManageExternalStorage()) {
arrayOf(MANAGE_EXTERNAL_STORAGE)
} else {
arrayOf(READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE)
@ -78,4 +78,8 @@ object Permissions {
RECEIVE_MMS
)
}
fun isManageExternalStorage(): Boolean {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
}
}

@ -119,7 +119,7 @@ internal class Request : OnRequestPermissionsResultCallback {
val deniedPermissionList = ArrayList<String>()
for (permission in permissions) {
if (permission == Permissions.MANAGE_EXTERNAL_STORAGE) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (Permissions.isManageExternalStorage()) {
if (!Environment.isExternalStorageManager()) {
deniedPermissionList.add(permission)
}

@ -2,7 +2,6 @@ package io.legado.app.ui.document
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.webkit.MimeTypeMap
import androidx.activity.result.contract.ActivityResultContracts
@ -162,8 +161,7 @@ class HandleFileActivity :
private fun getDirActions(onlySys: Boolean = false): ArrayList<SelectItem<Int>> {
return if (
onlySys ||
(Build.VERSION.SDK_INT > Build.VERSION_CODES.Q && AppConfig.isGooglePlay)
onlySys || (Permissions.isManageExternalStorage() && AppConfig.isGooglePlay)
) {
arrayListOf(SelectItem(getString(R.string.sys_folder_picker), HandleFileContract.DIR))
} else {
@ -175,7 +173,7 @@ class HandleFileActivity :
}
private fun getFileActions(): ArrayList<SelectItem<Int>> {
return if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q && AppConfig.isGooglePlay) {
return if (Permissions.isManageExternalStorage() && AppConfig.isGooglePlay) {
arrayListOf(SelectItem(getString(R.string.sys_file_picker), HandleFileContract.FILE))
} else {
arrayListOf(

@ -8,7 +8,6 @@ import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.RecyclerAdapter
import io.legado.app.databinding.ItemFontBinding
import io.legado.app.utils.*
import java.io.File
import java.net.URLDecoder
@ -34,9 +33,8 @@ class FontAdapter(context: Context, curFilePath: String, val callBack: CallBack)
val typeface: Typeface? = if (item.isContentScheme) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.contentResolver
.openFileDescriptor(item.uri, "r")
?.fileDescriptor?.let {
Typeface.Builder(it).build()
.openFileDescriptor(item.uri, "r")?.use {
Typeface.Builder(it.fileDescriptor).build()
}
} else {
Typeface.createFromFile(RealPathUtil.getPath(context, item.uri))

Loading…
Cancel
Save