From 82afa372d994e24e6646429addec441f110acdf0 Mon Sep 17 00:00:00 2001 From: Horis <821938089@qq.com> Date: Tue, 17 Jan 2023 15:34:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/font/FontSelectDialog.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/font/FontSelectDialog.kt b/app/src/main/java/io/legado/app/ui/font/FontSelectDialog.kt index 09b887f06..6ce5bdbbb 100644 --- a/app/src/main/java/io/legado/app/ui/font/FontSelectDialog.kt +++ b/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,7 +115,9 @@ class FontSelectDialog : BaseDialogFragment(R.layout.dialog_font_select), launch(Main) { val defaultPath = "SD${File.separator}Fonts" selectFontDir.launch { - otherActions = arrayListOf(SelectItem(defaultPath, -1)) + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) { + otherActions = arrayListOf(SelectItem(defaultPath, -1)) + } } } } @@ -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}") } }