diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index 50ab1c873..6be087f05 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -38,4 +38,5 @@ object PreferKey { const val bodyIndent = "textIndent" const val shareLayout = "shareLayout" const val readStyleSelect = "readStyleSelect" + const val systemTypefaces = "system_typefaces" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index 1f4302fdc..f71652c23 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -86,4 +86,10 @@ object AppConfig { set(value) { App.INSTANCE.putPrefInt(PreferKey.chineseConverterType, value) } + + var systemTypefaces: Int + get() = App.INSTANCE.getPrefInt(PreferKey.systemTypefaces) + set(value) { + App.INSTANCE.putPrefInt(PreferKey.systemTypefaces, value) + } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index 7618ddc51..4b133a001 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -8,6 +8,7 @@ import android.text.TextUtils import io.legado.app.App import io.legado.app.constant.PreferKey import io.legado.app.data.entities.BookChapter +import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp import io.legado.app.help.ReadBookConfig import io.legado.app.ui.book.read.page.entities.TextChapter @@ -308,7 +309,11 @@ object ChapterProvider { if (!TextUtils.isEmpty(fontPath)) { Typeface.createFromFile(fontPath) } else { - Typeface.SANS_SERIF + when (AppConfig.systemTypefaces) { + 1 -> Typeface.SERIF + 2 -> Typeface.MONOSPACE + else -> Typeface.SANS_SERIF + } } } catch (e: Exception) { App.INSTANCE.removePref(PreferKey.readBookFont) 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 be5523b58..128415769 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 @@ -16,7 +16,9 @@ import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseDialogFragment +import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey +import io.legado.app.help.AppConfig import io.legado.app.help.permission.Permissions import io.legado.app.help.permission.PermissionsCompat import io.legado.app.lib.dialogs.alert @@ -89,9 +91,13 @@ class FontSelectDialog : BaseDialogFragment(), R.id.menu_default -> { val cb = (parentFragment as? CallBack) ?: (activity as? CallBack) cb?.let { - if (it.curFontPath != "") { - it.selectFile("") - } + val requireContext = requireContext() + requireContext.alert(titleResource = R.string.system_typeface) { + items(requireContext.resources.getStringArray(R.array.system_typefaces).toList()) { _, i -> + AppConfig.systemTypefaces = i + onDefaultFontChange(it) + } + }.show() } dismiss() } @@ -255,6 +261,14 @@ class FontSelectDialog : BaseDialogFragment(), } } + private fun onDefaultFontChange(callBack: CallBack){ + if (curFilePath() == "") { + postEvent(EventBus.UP_CONFIG, true) + } else { + callBack.selectFile("") + } + } + interface CallBack { fun selectFile(path: String) val curFontPath: String diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 87fd0d8e0..ff1fc875c 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -152,4 +152,9 @@ 简体转繁体 + + 系统默认字体 + 系统衬线字体 + 系统等宽等宽 + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f64f60c5a..8da65e500 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -627,4 +627,5 @@ 其它朗读设置 + 系统内置字体样式