diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index d6c89a647..4353e2fe1 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -118,13 +118,16 @@ object ReadBookConfig { } } - fun resetDur() { - defaultConfigs[styleSelect].let { - durConfig.setBg(it.bgType(), it.bgStr()) - durConfig.setTextColor(it.textColor()) + fun deleteDur(): Boolean { + if (configList.size > 5) { + configList.removeAt(styleSelect) + if (styleSelect > 0) { + styleSelect -= 1 + } upBg() - save() + return true } + return false } private fun resetAll() { diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt index 46e5dbd0f..841a5b9a9 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt @@ -102,6 +102,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FileChooserDialog.CallBack { sw_dark_status_icon.setTextColor(primaryTextColor) iv_import.setColorFilter(primaryTextColor) iv_export.setColorFilter(primaryTextColor) + iv_delete.setColorFilter(primaryTextColor) tv_bg_image.setTextColor(primaryTextColor) } @@ -149,10 +150,6 @@ class BgTextConfigDialog : BaseDialogFragment(), FileChooserDialog.CallBack { .setDialogId(BG_COLOR) .show(requireActivity()) } - tv_default.onClick { - ReadBookConfig.resetDur() - postEvent(EventBus.UP_CONFIG, false) - } iv_import.onClick { val importFormNet = "网络导入" val otherActions = arrayListOf(importFormNet) @@ -175,6 +172,14 @@ class BgTextConfigDialog : BaseDialogFragment(), FileChooserDialog.CallBack { title = getString(R.string.export_str) ) } + iv_delete.onClick { + if (ReadBookConfig.deleteDur()) { + postEvent(EventBus.UP_CONFIG, true) + dismiss() + } else { + toast("数量以是最少,不能删除.") + } + } } private fun selectImage() { diff --git a/app/src/main/res/layout/dialog_read_bg_text.xml b/app/src/main/res/layout/dialog_read_bg_text.xml index 0be5daf57..cbf9c4c02 100644 --- a/app/src/main/res/layout/dialog_read_bg_text.xml +++ b/app/src/main/res/layout/dialog_read_bg_text.xml @@ -57,23 +57,6 @@ app:isBottomBackground="true" tools:ignore="HardcodedText" /> - - + +