|
|
|
@ -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}") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|