diff --git a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt index 47d4ac1a1..a129ae47c 100644 --- a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt @@ -123,10 +123,11 @@ class FontSelectDialog : DialogFragment(), private fun getFontFiles(uri: Uri) { launch(IO) { FileUtils.deleteFile(fontCacheFolder) - DocumentFile.fromTreeUri(App.INSTANCE, uri)?.listFiles()?.forEach { file -> - if (file.name?.toLowerCase()?.matches(".*\\.[ot]tf".toRegex()) == true) { - DocumentUtils.readBytes(App.INSTANCE, file.uri)?.let { - FileUtils.createFileIfNotExist(fontCacheFolder + file.name).writeBytes(it) + DocumentUtils.listFiles(App.INSTANCE, uri).forEach { item -> + if (item.name.toLowerCase().matches(".*\\.[ot]tf".toRegex())) { + DocumentUtils.readBytes(App.INSTANCE, item.uri)?.let { byteArray -> + FileUtils.createFileIfNotExist(fontCacheFolder + item.name) + .writeBytes(byteArray) } } }