pull/66/head
kunfei 5 years ago
parent fbd2e4573d
commit d1e25c9772
  1. 26
      app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt

@ -70,6 +70,23 @@ class FontSelectDialog : DialogFragment(),
val fontPath = getPrefString(PreferKey.fontFolder)
if (fontPath.isNullOrEmpty()) {
openFolder()
} else {
val uri = Uri.parse(fontPath)
if (DocumentFile.fromTreeUri(requireContext(), uri)?.canRead() == true) {
getFontFiles(uri)
} else {
openFolder()
}
}
}
override fun onDestroy() {
super.onDestroy()
job.cancel()
}
private fun openFolder() {
try {
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
@ -81,15 +98,6 @@ class FontSelectDialog : DialogFragment(),
.onGranted { getFontFilesOld() }
.request()
}
} else {
val uri = Uri.parse(fontPath)
getFontFiles(uri)
}
}
override fun onDestroy() {
super.onDestroy()
job.cancel()
}
@SuppressLint("DefaultLocale")

Loading…
Cancel
Save