From 587b763675e63a6442acdcffef0b4aa1f4d8a71f Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 27 Oct 2020 15:08:54 +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/help/ReadBookConfig.kt | 1 + .../legado/app/lib/dialogs/AndroidDialogs.kt | 4 +-- .../io/legado/app/ui/about/AboutFragment.kt | 2 +- .../ui/book/read/config/BgTextConfigDialog.kt | 24 +++++++++++--- .../ui/book/read/config/ReadStyleDialog.kt | 2 +- .../ui/main/bookshelf/BookshelfFragment.kt | 21 ++++++------ .../app/ui/replace/ReplaceRuleActivity.kt | 15 +++++---- .../ui/rss/source/manage/RssSourceActivity.kt | 15 +++++---- .../app/ui/widget/font/FontSelectDialog.kt | 2 +- .../main/res/layout/dialog_read_bg_text.xml | 32 +++++++++++++++++++ app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values-zh/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 14 files changed, 90 insertions(+), 32 deletions(-) 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 18b865f5a..faa36e9c0 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -359,6 +359,7 @@ object ReadBookConfig { @Keep @Parcelize class Config( + var name: String = "", var bgStr: String = "#EEEEEE",//白天背景 var bgStrNight: String = "#000000",//夜间背景 var bgStrEInk: String = "#FFFFFF", diff --git a/app/src/main/java/io/legado/app/lib/dialogs/AndroidDialogs.kt b/app/src/main/java/io/legado/app/lib/dialogs/AndroidDialogs.kt index 0d40174f4..037807dff 100644 --- a/app/src/main/java/io/legado/app/lib/dialogs/AndroidDialogs.kt +++ b/app/src/main/java/io/legado/app/lib/dialogs/AndroidDialogs.kt @@ -48,10 +48,10 @@ fun Context.alert( } inline fun Fragment.alert( - title: Int? = null, + titleResource: Int? = null, message: Int? = null, noinline init: (AlertBuilder.() -> Unit)? = null -) = requireActivity().alert(title, message, init) +) = requireActivity().alert(titleResource, message, init) fun Context.alert( titleResource: Int? = null, diff --git a/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt b/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt index d6c7df52a..da1b22d60 100644 --- a/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt +++ b/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt @@ -73,7 +73,7 @@ class AboutFragment : PreferenceFragmentCompat() { } private fun showQqGroups() { - alert(title = R.string.join_qq_group) { + alert(titleResource = R.string.join_qq_group) { val names = arrayListOf() qqGroups.forEach { names.add(it.key) 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 02f7a87c7..805bec4a3 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 @@ -17,10 +17,7 @@ import io.legado.app.help.ReadBookConfig import io.legado.app.help.http.HttpHelper import io.legado.app.help.permission.Permissions import io.legado.app.help.permission.PermissionsCompat -import io.legado.app.lib.dialogs.alert -import io.legado.app.lib.dialogs.customView -import io.legado.app.lib.dialogs.noButton -import io.legado.app.lib.dialogs.okButton +import io.legado.app.lib.dialogs.* import io.legado.app.lib.theme.bottomBackground import io.legado.app.lib.theme.getPrimaryTextColor import io.legado.app.lib.theme.getSecondaryTextColor @@ -99,6 +96,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FileChooserDialog.CallBack { @SuppressLint("InflateParams") private fun initData() = with(ReadBookConfig.durConfig) { + tv_name.text = name.ifBlank { "文字" } sw_dark_status_icon.isChecked = curStatusIconDark() adapter = BgAdapter(requireContext(), secondaryTextColor) recycler_view.adapter = adapter @@ -115,7 +113,25 @@ class BgTextConfigDialog : BaseDialogFragment(), FileChooserDialog.CallBack { } } + @SuppressLint("InflateParams") private fun initEvent() = with(ReadBookConfig.durConfig) { + iv_edit.onClick { + alert(R.string.style_name) { + var editText: AutoCompleteTextView? = null + customView { + layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { + editText = edit_view + } + } + okButton { + editText?.text?.toString()?.let { + tv_name.text = it + ReadBookConfig.durConfig.name = it + } + } + cancelButton() + } + } sw_dark_status_icon.onCheckedChange { buttonView, isChecked -> if (buttonView?.isPressed == true) { setCurStatusIconDark(isChecked) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index ef5d6d000..99e4a30f1 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -165,7 +165,7 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack { @SuppressLint("InflateParams") private fun showTitleConfig() = ReadBookConfig.apply { - requireContext().alert(R.string.title) { + alert(R.string.title) { val rootView = LayoutInflater.from(requireContext()) .inflate(R.layout.dialog_title_config, null).apply { rg_title_mode.checkByIndex(titleMode) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index 79f1a24a1..e1b37f31e 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -176,18 +176,17 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b @SuppressLint("InflateParams") private fun addBookByUrl() { - requireContext() - .alert(titleResource = R.string.add_book_url) { - var editText: AutoCompleteTextView? = null - customView { - layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { - editText = edit_view - } + alert(titleResource = R.string.add_book_url) { + var editText: AutoCompleteTextView? = null + customView { + layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { + editText = edit_view + } + } + okButton { + editText?.text?.toString()?.let { + viewModel.addBookByUrl(it) } - okButton { - editText?.text?.toString()?.let { - viewModel.addBookByUrl(it) - } } noButton { } }.show().applyTint() diff --git a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt index 87fa9de07..a88189f8d 100644 --- a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt +++ b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt @@ -125,16 +125,19 @@ class ReplaceRuleActivity : } override fun onClickMainAction() { - this@ReplaceRuleActivity - .alert(titleResource = R.string.draw, messageResource = R.string.sure_del) { - okButton { viewModel.delSelection(adapter.getSelection()) } - noButton { } - } - .show().applyTint() + delSourceDialog() } }) } + private fun delSourceDialog() { + alert(titleResource = R.string.draw, messageResource = R.string.sure_del) { + okButton { viewModel.delSelection(adapter.getSelection()) } + noButton { } + } + .show().applyTint() + } + private fun observeReplaceRuleData(key: String? = null) { dataInit = false replaceRuleLiveData?.removeObservers(this) diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt index eae5f3457..bf4613239 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt @@ -171,16 +171,19 @@ class RssSourceActivity : VMBaseActivity(R.layout.activity_r } override fun onClickMainAction() { - this@RssSourceActivity - .alert(titleResource = R.string.draw, messageResource = R.string.sure_del) { - okButton { viewModel.delSelection(adapter.getSelection()) } - noButton { } - } - .show().applyTint() + delSourceDialog() } }) } + private fun delSourceDialog() { + alert(titleResource = R.string.draw, messageResource = R.string.sure_del) { + okButton { viewModel.delSelection(adapter.getSelection()) } + noButton { } + } + .show().applyTint() + } + private fun upGroupMenu() { groupMenu?.removeGroup(R.id.source_group) groups.sortedWith(Collator.getInstance(Locale.CHINESE)) 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 ca932932a..22de0c8e5 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 @@ -87,7 +87,7 @@ class FontSelectDialog : BaseDialogFragment(), when (item?.itemId) { R.id.menu_default -> { val requireContext = requireContext() - requireContext.alert(titleResource = R.string.system_typeface) { + alert(titleResource = R.string.system_typeface) { items( requireContext.resources.getStringArray(R.array.system_typefaces).toList() ) { _, i -> 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 cbf9c4c02..553f893b4 100644 --- a/app/src/main/res/layout/dialog_read_bg_text.xml +++ b/app/src/main/res/layout/dialog_read_bg_text.xml @@ -9,6 +9,38 @@ android:orientation="vertical" android:padding="10dp"> + + + + + + + + + + 自动清除过期搜索数据 超过一天的搜索数据 重新分段 + 样式名称: diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 33ebcf483..3a9aa7edf 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -774,5 +774,6 @@ 自动清除过期搜索数据 超过一天的搜索数据 重新分段 + 样式名称: diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index f9d6236aa..970b3379d 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -777,5 +777,6 @@ 自动清除过期搜索数据 超过一天的搜索数据 重新分段 + 样式名称: diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5ab11e2a6..74a809c16 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -780,5 +780,6 @@ 自动清除过期搜索数据 超过一天的搜索数据 重新分段 + 样式名称: