From 66b1f5e08a47bd4f11361ab3d7de50a524397700 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 28 Apr 2021 10:25:24 +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 --- .../ui/book/read/config/BgTextConfigDialog.kt | 25 ++++++++++++++----- .../main/res/layout/dialog_read_bg_text.xml | 12 +++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) 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 1a89cd4b1..9bd8049ff 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 @@ -15,8 +15,10 @@ import io.legado.app.constant.EventBus import io.legado.app.databinding.DialogEditTextBinding import io.legado.app.databinding.DialogReadBgTextBinding import io.legado.app.databinding.ItemBgImageBinding +import io.legado.app.help.DefaultData import io.legado.app.help.ReadBookConfig import io.legado.app.lib.dialogs.alert +import io.legado.app.lib.dialogs.selector import io.legado.app.lib.permission.Permissions import io.legado.app.lib.permission.PermissionsCompat import io.legado.app.lib.theme.bottomBackground @@ -107,12 +109,6 @@ class BgTextConfigDialog : BaseDialogFragment() { binding.ivExport.setColorFilter(primaryTextColor) binding.ivDelete.setColorFilter(primaryTextColor) binding.tvBgImage.setTextColor(primaryTextColor) - } - - @SuppressLint("InflateParams") - private fun initData() = with(ReadBookConfig.durConfig) { - binding.tvName.text = name.ifBlank { "文字" } - binding.swDarkStatusIcon.isChecked = curStatusIconDark() adapter = BgAdapter(requireContext(), secondaryTextColor) binding.recyclerView.adapter = adapter adapter.addHeaderView { @@ -131,6 +127,12 @@ class BgTextConfigDialog : BaseDialogFragment() { } } + @SuppressLint("InflateParams") + private fun initData() = with(ReadBookConfig.durConfig) { + binding.tvName.text = name.ifBlank { "文字" } + binding.swDarkStatusIcon.isChecked = curStatusIconDark() + } + @SuppressLint("InflateParams") private fun initEvent() = with(ReadBookConfig.durConfig) { binding.ivEdit.setOnClickListener { @@ -148,6 +150,17 @@ class BgTextConfigDialog : BaseDialogFragment() { cancelButton() }.show() } + binding.tvRestore.setOnClickListener { + val defaultConfigs = DefaultData.readConfigs + val layoutNames = defaultConfigs.map { it.name } + selector("选择预设布局", layoutNames) { _, i -> + if (i >= 0) { + ReadBookConfig.durConfig = defaultConfigs[i] + initData() + postEvent(EventBus.UP_CONFIG, true) + } + } + } binding.swDarkStatusIcon.setOnCheckedChangeListener { _, isChecked -> setCurStatusIconDark(isChecked) (activity as? ReadBookActivity)?.upSystemUiVisibility() 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 553f893b4..310c62bc8 100644 --- a/app/src/main/res/layout/dialog_read_bg_text.xml +++ b/app/src/main/res/layout/dialog_read_bg_text.xml @@ -39,6 +39,18 @@ app:tint="@color/secondaryText" android:contentDescription="@string/edit" /> + + + +