pull/2718/head
Horis 2 years ago
parent eebdbd41ec
commit 82afa372d9
  1. 9
      app/src/main/java/io/legado/app/ui/font/FontSelectDialog.kt

@ -1,6 +1,7 @@
package io.legado.app.ui.font
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.view.MenuItem
import android.view.View
@ -9,6 +10,7 @@ import androidx.documentfile.provider.DocumentFile
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
import io.legado.app.constant.AppLog
import io.legado.app.constant.PreferKey
import io.legado.app.databinding.DialogFontSelectBinding
import io.legado.app.help.config.AppConfig
@ -113,10 +115,12 @@ class FontSelectDialog : BaseDialogFragment(R.layout.dialog_font_select),
launch(Main) {
val defaultPath = "SD${File.separator}Fonts"
selectFontDir.launch {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
otherActions = arrayListOf(SelectItem(defaultPath, -1))
}
}
}
}
private fun getLocalFonts(): ArrayList<FileDoc> {
val path = FileUtils.getPath(requireContext().externalFiles, "font")
@ -141,11 +145,12 @@ class FontSelectDialog : BaseDialogFragment(R.layout.dialog_font_select),
execute {
val fontItems = fileDoc.list {
it.name.matches(fontRegex)
}
mergeFontItems(fontItems!!, getLocalFonts())
} ?: ArrayList()
mergeFontItems(fontItems, getLocalFonts())
}.onSuccess {
adapter.setItems(it)
}.onError {
AppLog.put("加载字体文件失败\n${it.localizedMessage}", it)
toastOnUi("getFontFiles:${it.localizedMessage}")
}
}

Loading…
Cancel
Save